:root {
  --bg-primary: #0a0d14;
  --bg-card: rgba(22, 27, 34, 0.75);
  --bg-card-hover: rgba(30, 38, 48, 0.85);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --accent-color: #7c3aed;
  --accent-glow: rgba(124, 58, 237, 0.4);
  --emotion-color: #38bdf8;
  --user-bubble: #1e293b;
  --robot-bubble: #2e1065;
  --success: #10b981;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--bg-primary);
}

body {
  background: radial-gradient(circle at top center, #1e1b4b 0%, var(--bg-primary) 70%);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Header Bar
   ========================================================================== */
header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: rgba(10, 13, 20, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: relative;
  z-index: 50;
  transition: all 0.2s ease;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon-svg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.4), rgba(56, 189, 248, 0.4));
  border: 1px solid rgba(167, 139, 250, 0.4);
  border-radius: 10px;
  color: #c4b5fd;
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.3);
  flex-shrink: 0;
}

.logo-title {
  display: flex;
  flex-direction: column;
}

.logo-title h1 {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
  white-space: nowrap;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.2;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
  flex-shrink: 0;
}

.status-dot.offline {
  background-color: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.84rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: translateY(0);
}

.icon-btn.highlight-config {
  background: rgba(124, 58, 237, 0.25);
  border-color: rgba(167, 139, 250, 0.5);
  color: #ede9fe;
}

.icon-btn.highlight-config:hover {
  background: rgba(124, 58, 237, 0.45);
}

.icon-btn.highlight-config.unconfigured {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fde68a;
  animation: pulse-border 2.5s infinite;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 rgba(245, 158, 11, 0); }
  50% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }
}

/* Family Dynamics Switcher */
.family-switcher-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 27, 75, 0.65);
  border: 1px solid rgba(167, 139, 250, 0.35);
  padding: 4px 12px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
}

.family-icon-svg {
  color: #a78bfa;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.family-pill-label {
  font-size: 0.8rem;
  color: #c4b5fd;
  white-space: nowrap;
}

.family-select {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f1f5f9;
  font-size: 0.82rem;
  border-radius: 8px;
  padding: 3px 8px;
  cursor: pointer;
  outline: none;
}

.add-member-mini-btn {
  background: var(--accent-color);
  border: none;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.add-member-mini-btn:hover {
  transform: scale(1.1);
}

/* ==========================================================================
   Desktop Grid Layout
   ========================================================================== */
.app-container {
  flex: 1 1 0;
  min-height: 0;
  height: calc(100vh - 60px);
  height: calc(100dvh - 60px);
  display: grid;
  grid-template-columns: 320px 1fr 340px;
  gap: 16px;
  padding: 16px 20px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
}

/* Glass Panels */
.card-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  height: 100%;
  min-height: 0;
}

.status-panel {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(167, 139, 250, 0.2) transparent;
}

.status-panel::-webkit-scrollbar {
  width: 5px;
}
.status-panel::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.2);
  border-radius: 3px;
}

.panel-header {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 14px;
  flex-shrink: 0;
}

.status-subtag {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}

/* ==========================================================================
   Left Panel: Emotion & Growth Avatar
   ========================================================================== */
.avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  flex-shrink: 0;
}

.avatar-orb-container {
  width: 130px;
  height: 130px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.avatar-orb {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c084fc, #6366f1 60%, #312e81 100%);
  box-shadow: 0 0 35px var(--accent-glow), inset 0 0 20px rgba(255, 255, 255, 0.3);
  animation: orb-breathe 4s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.orb-inner-core {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, rgba(216, 180, 254, 0.4) 60%, transparent 100%);
  filter: blur(2px);
  animation: core-shimmer 3s ease-in-out infinite alternate;
}

@keyframes orb-breathe {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.06); filter: brightness(1.2); }
}

@keyframes core-shimmer {
  0% { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.15); opacity: 0.95; }
}

.avatar-halo {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 1px dashed rgba(167, 139, 250, 0.35);
  animation: halo-spin 20s linear infinite;
}

@keyframes halo-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.robot-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 4px;
}

.emotion-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid rgba(167, 139, 250, 0.4);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  margin-top: 8px;
  color: #ddd6fe;
}

.emotion-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--emotion-color);
  box-shadow: 0 0 6px var(--emotion-color);
}

.growth-card {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  padding: 12px;
  margin-top: 14px;
  flex-shrink: 0;
}

.growth-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.stage-badge {
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #38bdf8);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.member-personality-hint {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 6px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* PAD Meters */
.pad-meters {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.pad-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.meter-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.meter-val {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ==========================================================================
   Center Panel: Conversation Workspace
   ========================================================================== */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Unconfigured Alert Banner */
.llm-alert-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.15));
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.llm-alert-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-icon-svg {
  color: #fbbf24;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.alert-text {
  font-size: 0.8rem;
  color: #fef3c7;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.alert-text strong {
  font-size: 0.85rem;
  color: #fde68a;
}

.banner-action-btn {
  background: #d97706;
  border: none;
  color: white;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.banner-action-btn:hover {
  background: #b45309;
}

/* Mobile Companion Mini Strip (Hidden on Desktop) */
.mobile-companion-strip {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: rgba(30, 27, 75, 0.5);
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: 14px;
  padding: 8px 12px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.strip-left {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.mini-avatar-orb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c084fc, #6366f1 60%, #312e81 100%);
  box-shadow: 0 0 14px var(--accent-glow);
  animation: orb-breathe 4s ease-in-out infinite;
  flex-shrink: 0;
}

.strip-info {
  display: flex;
  flex-direction: column;
}

.strip-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.strip-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #f1f5f9;
}

.strip-emotion {
  font-size: 0.72rem;
  background: rgba(124, 58, 237, 0.25);
  color: #ddd6fe;
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.strip-status-sub {
  font-size: 0.7rem;
  color: #94a3b8;
}

.mobile-bond-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: #c4b5fd;
  background: rgba(124, 58, 237, 0.2);
  border: 1px solid rgba(167, 139, 250, 0.3);
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.active-member-tag {
  font-size: 0.75rem;
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid rgba(124, 58, 237, 0.4);
  color: #ddd6fe;
  padding: 2px 8px;
  border-radius: 12px;
}

.messages-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(167, 139, 250, 0.3) transparent;
}

.messages-list::-webkit-scrollbar {
  width: 6px;
}
.messages-list::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.25);
  border-radius: 4px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row.robot {
  align-self: flex-start;
}

.msg-row.user {
  align-self: flex-end;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-row.robot .msg-bubble {
  background: var(--robot-bubble);
  border: 1px solid rgba(167, 139, 250, 0.25);
  color: #f3e8ff;
  border-bottom-left-radius: 4px;
}

.msg-row.robot .msg-bubble.proactive-bubble {
  border-left: 3px solid #ec4899;
  box-shadow: 0 0 14px rgba(236, 72, 153, 0.15);
}

.proactive-badge-tag {
  color: #f472b6;
  font-weight: 500;
}

.msg-row.user .msg-bubble {
  background: var(--user-bubble);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

.msg-meta {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 4px;
  padding: 0 4px;
}

.msg-row.user .msg-meta {
  text-align: right;
}

/* Chat Input Bar */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(10, 13, 20, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  margin-top: 8px;
  flex-shrink: 0;
}

.voice-mic-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #c4b5fd;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.voice-mic-btn:hover {
  background: rgba(124, 58, 237, 0.3);
  color: white;
}

.voice-mic-btn:active {
  transform: scale(0.95);
}

.voice-mic-btn.recording {
  background: #ef4444;
  color: white;
  animation: pulse-red 1.2s infinite;
  border-color: #f87171;
}

@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.92rem;
  padding: 6px 4px;
}

.chat-input::placeholder {
  color: #64748b;
}

.send-btn {
  background: var(--accent-color);
  border: none;
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-btn:hover {
  background: #6d28d9;
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

/* ==========================================================================
   Right Panel: Stream of Consciousness & Long-term Memory
   ========================================================================== */
.thought-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.urge-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.urge-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #ec4899);
  border-radius: 4px;
  transition: width 0.6s ease;
}

.thought-feed {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(167, 139, 250, 0.3) transparent;
}

.thought-feed::-webkit-scrollbar {
  width: 5px;
}
.thought-feed::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.2);
  border-radius: 3px;
}

.thought-card {
  background: rgba(15, 23, 42, 0.6);
  border-left: 3px solid #8b5cf6;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.84rem;
  line-height: 1.5;
  color: #f1f5f9;
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-left-width: 3px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}

.thought-card:hover {
  transform: translateX(2px);
  background: rgba(30, 27, 75, 0.6);
}

.thought-body {
  font-size: 0.88rem;
  color: #f8fafc;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

.thought-time {
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
}

.facts-section {
  margin-top: 14px;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  flex-shrink: 0;
}

.fact-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-height: 120px;
  overflow-y: auto;
}

.fact-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #bae6fd;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 12px;
}

.fact-chip b {
  color: #f0f9ff;
  font-weight: 600;
}

.chip-delete-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s ease;
}

.chip-delete-btn:hover {
  color: #ef4444;
  transform: scale(1.15);
}

/* ==========================================================================
   Mobile Bottom Navigation Bar (Hidden on Desktop)
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
  flex-shrink: 0;
  position: relative; /* 处于标准文档流中，严禁 fixed 遮挡上方输入框 */
  width: 100%;
  height: calc(52px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 50;
  justify-content: space-around;
  align-items: center;
}

.mobile-nav-btn {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.72rem;
  user-select: none;
}

.mobile-nav-btn .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.mobile-nav-btn.active {
  color: #c4b5fd;
  font-weight: 600;
}

.mobile-nav-btn.active .nav-icon {
  transform: translateY(-2px);
  color: #a78bfa;
  filter: drop-shadow(0 0 8px rgba(167, 139, 250, 0.6));
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #1e1b4b;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  animation: modalScale 0.2s ease;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 9px 12px;
  color: white;
  font-size: 0.88rem;
  outline: none;
  box-sizing: border-box;
}

.form-input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 8px rgba(124, 58, 237, 0.4);
}

.preset-box {
  background: rgba(124, 58, 237, 0.12);
  border: 1px dashed rgba(167, 139, 250, 0.4);
  padding: 10px 12px;
  border-radius: 8px;
}

.status-badge-inline {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge-inline.offline {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ==========================================================================
   Responsive Breakpoints: Mobile Screen Support (<= 860px)
   ========================================================================== */
@media (max-width: 860px) {
  /* Header Adaptation */
  header {
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    gap: 8px;
  }

  .logo-group {
    gap: 6px;
    min-width: 0;
    flex-shrink: 1;
  }

  .logo-icon-svg {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }

  .logo-icon-svg svg {
    width: 18px;
    height: 18px;
  }

  .logo-title h1 {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .logo-text-sub {
    display: none; /* Hide subtitle to avoid awkward word wraps */
  }

  .status-indicator {
    font-size: 0.68rem;
  }

  .family-switcher-bar {
    padding: 2px 6px;
    gap: 4px;
    background: rgba(30, 27, 75, 0.5);
  }

  .family-pill-label {
    display: none; /* Hide '对话成员：' label on mobile */
  }

  .family-select {
    font-size: 0.78rem;
    padding: 2px 4px;
    max-width: 80px;
  }

  .add-member-mini-btn {
    width: 20px;
    height: 20px;
  }

  .header-actions {
    gap: 6px;
  }

  .hide-on-mobile {
    display: none !important;
  }

  .btn-text-desktop {
    display: none !important;
  }

  .icon-btn {
    padding: 6px 8px;
    border-radius: 8px;
  }

  /* Main Container Layout for Mobile Tabs */
  .app-container {
    display: flex;
    flex-direction: column;
    padding: 6px 8px 4px 8px;
    gap: 0;
    flex: 1 1 0;
    min-height: 0;
    height: auto; /* 由 flex 自动撑满剩余空间，杜绝魔鬼高度计算导致的遮挡 */
    width: 100%;
    margin: 0;
    max-width: 100%;
    overflow: hidden;
  }

  /* Control Panels: Only active tab is shown */
  .card-panel {
    display: none !important;
    padding: 10px 12px;
    border-radius: 12px;
    height: 100%;
    width: 100%;
    overflow: hidden;
  }

  .card-panel.mobile-active {
    display: flex !important;
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
  }

  .desktop-only-header {
    display: none !important;
  }

  .mobile-companion-strip {
    display: flex;
  }

  /* Mobile Bottom Navigation in normal flex flow */
  .mobile-bottom-nav {
    display: flex !important;
    flex-shrink: 0;
    position: relative; /* 严禁 fixed */
    height: calc(52px + env(safe-area-inset-bottom, 0px));
  }

  /* Mobile Chat Adjustments */
  .chat-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  .messages-list {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 2px;
    gap: 10px;
  }

  .msg-row {
    max-width: 88%;
  }

  .msg-bubble {
    font-size: 0.9rem;
    padding: 9px 12px;
    border-radius: 12px;
  }

  .chat-input-bar {
    padding: 6px 8px;
    gap: 6px;
    border-radius: 24px;
    margin-top: 6px;
    margin-bottom: 2px;
    background: rgba(15, 23, 42, 0.9);
    flex-shrink: 0;
  }

  .voice-mic-btn {
    width: 40px;
    height: 40px;
  }

  .chat-input {
    font-size: 16px; /* Prevents auto-zoom on iOS safari / chrome */
    padding: 6px 8px;
  }

  .send-btn {
    width: 40px;
    height: 40px;
  }

  /* Mobile Status Panel Scrollability */
  .status-panel {
    overflow-y: auto;
    padding-bottom: 20px;
  }

  .avatar-section {
    padding: 16px 0 8px 0;
  }

  .avatar-orb-container {
    width: 120px;
    height: 120px;
  }

  .avatar-orb {
    width: 84px;
    height: 84px;
  }

  .avatar-halo {
    width: 110px;
    height: 110px;
  }

  /* Mobile Thought Panel Scrollability */
  .thought-panel {
    overflow-y: auto;
    padding-bottom: 20px;
  }

  .thought-feed {
    max-height: 240px;
  }

  .facts-section {
    margin-top: 10px;
  }
}

/* ==========================================================================
   Authentication & Security Modal
   ========================================================================== */
.auth-overlay {
  z-index: 99999 !important;
  background: rgba(10, 13, 20, 0.88) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
}

.auth-modal-card {
  max-width: 420px;
  padding: 32px 28px;
  background: linear-gradient(145deg, #1e1b4b 0%, #111425 100%);
  border: 1px solid rgba(124, 58, 237, 0.35);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8), 0 0 32px rgba(124, 58, 237, 0.2);
  border-radius: 20px;
  text-align: center;
}

.auth-header {
  margin-bottom: 24px;
}

.auth-orb-glow {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px auto;
  border-radius: 50%;
  background: radial-gradient(circle, #7c3aed 0%, #4338ca 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(124, 58, 237, 0.6);
  animation: authPulse 3s infinite ease-in-out;
}

@keyframes authPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 24px rgba(124, 58, 237, 0.6);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 36px rgba(124, 58, 237, 0.9);
  }
}

.auth-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 0.86rem;
  color: #94a3b8;
  line-height: 1.4;
}

.auth-form {
  text-align: left;
}

.pwd-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pwd-field {
  padding-right: 42px !important;
}

.pwd-toggle-btn {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: #8b949e;
  cursor: pointer;
  padding: 4px;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.pwd-toggle-btn:hover {
  opacity: 1;
}

.auth-options-row {
  margin: 12px 0 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #cbd5e1;
  cursor: pointer;
}

.remember-label input[type="checkbox"] {
  accent-color: var(--accent-color);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.auth-error-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  text-align: center;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.auth-submit-btn {
  width: 100%;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
  cursor: pointer;
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.auth-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.6);
}

.auth-submit-btn:active {
  transform: translateY(1px);
}

