:root{
  --bg: #fbfbfe;
  --card: rgba(255,255,255,.75);
  --stroke: rgba(15,23,42,.12);
  --text: #0f172a;
  --muted: rgba(15,23,42,.65);
  --shadow: 0 10px 30px rgba(15,23,42,.08);
  --radius: 18px;
  --radius2: 14px;
  --space-xs: 8px;
  --space-sm: 10px;
  --space-md: 12px;
  --space-lg: 14px;
  --space-xl: 20px;
  --space-2xl: 28px;
  --accent1: #a7f3d0;
  --accent2: #c4b5fd;
  --accent3: #fbcfe8;
  --accent4: #bae6fd;
  --user: rgba(255,255,255,.85);
  --bot: rgba(255,255,255,.65);
  --focus: rgba(59,130,246,.35);
  --font: 21px;
}

body[data-theme="mint"]{ --accent1:#a7f3d0; --accent2:#c4b5fd; --accent3:#fbcfe8; --accent4:#bae6fd; }
body[data-theme="lavender"]{ --accent1:#ddd6fe; --accent2:#c7d2fe; --accent3:#f5d0fe; --accent4:#bae6fd; }
body[data-theme="peach"]{ --accent1:#fed7aa; --accent2:#fbcfe8; --accent3:#fde68a; --accent4:#bfdbfe; }
body[data-theme="sky"]{ --accent1:#bae6fd; --accent2:#c7d2fe; --accent3:#fbcfe8; --accent4:#a7f3d0; }

body[data-contrast="high"]{
  --stroke: rgba(15,23,42,.22);
  --muted: rgba(15,23,42,.78);
  --card: rgba(255,255,255,.92);
  --bot: rgba(255,255,255,.92);
  --user: rgba(255,255,255,.98);
}

body[data-text="large"]{ --font: 24px; }
body[data-mode="elder"]{ --font: 23px; }

*{ box-sizing:border-box; }
html,body{ height:100%; }
[hidden]{ display:none !important; }
body{
  margin:0;
  font-size:var(--font);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color:var(--text);
  background:
    radial-gradient(1000px 600px at 20% 0%, var(--accent4), transparent 55%),
    radial-gradient(900px 600px at 80% 10%, var(--accent3), transparent 55%),
    radial-gradient(900px 700px at 35% 100%, var(--accent1), transparent 58%),
    radial-gradient(900px 700px at 95% 90%, var(--accent2), transparent 60%),
    var(--bg);
}

.app{
  height:100vh;
  height:100dvh;
  display:flex;
  flex-direction:column;
  max-width:1400px;
  margin:0 auto;
  padding:var(--space-lg);
  gap:var(--space-md);
}

/* ---------- 新增三栏布局样式 ---------- */
.hub-container {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: var(--space-md);
}

.hub-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.hub-left, .hub-right {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  overflow-y: auto;
}

/* 面板样式 */
.panel {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.bot-character-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-md) 0;
  transition: all 0.3s ease;
  position: relative;
  z-index: 5;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.bot-character {
  width: 220px;
  height: 220px;
  object-fit: contain;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.bot-character:hover {
  transform: scale(1.05);
}
.panel-title {
  font-size: 1.05em;
  font-weight: 800;
  margin: 0 0 16px 0;
  color: var(--text);
}

/* 硬件状态区 */
.hw-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.6);
  border-radius: 12px;
  border: 1px solid var(--stroke);
}
.hw-icon { font-size: 1.5em; }
.hw-info { flex: 1; }
.hw-label { font-size: 0.8em; color: var(--muted); font-weight: 700; }
.hw-val { font-size: 1.1em; font-weight: 800; color: var(--text); margin-top: 2px; }
.hw-btn { width: 100%; margin-top: 8px; padding: 12px; border-radius: 12px; }

/* 陪伴档案记忆卡片 */
.memo-card {
  padding: 10px;
  background: rgba(255,255,255,0.6);
  border-left: 4px solid var(--accent2);
  border-radius: 8px;
  margin-bottom: 10px;
}
.memo-card.alert { border-left-color: #fca5a5; background: rgba(254,202,202,0.2); }
.memo-time { font-size: 0.75em; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.memo-content { font-size: 0.9em; line-height: 1.4; }

/* 情绪折线图模拟 */
.chart-mock {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 120px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--stroke);
  margin-bottom: 8px;
}
.chart-bar {
  width: 24px;
  border-radius: 4px 4px 0 0;
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
  transition: height 0.3s ease;
}
.chart-labels {
  display: flex;
  justify-content: space-around;
  font-size: 0.75em;
  font-weight: 700;
  color: var(--muted);
}

/* 感知融合雷达 */
.radar-stat {
  margin-bottom: 8px;
}
.radar-label {
  font-size: 0.85em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 4px;
}
.radar-bar {
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  height: 20px;
  overflow: hidden;
}
.radar-fill {
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  height: 100%;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-size: 0.75em;
  color: var(--text);
  font-weight: bold;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.radar-desc {
  font-size: 0.75em;
  color: var(--muted);
  font-weight: 700;
  margin-top: 12px;
  text-align: center;
}

/* 健康关怀指数 */
.r-value-wrap {
  display: flex;
  justify-content: center;
  padding: 0;
  margin-top: 4px;
}
.r-value-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 5px solid var(--accent1);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--text);
  transition: border-color 0.8s ease;
  background: rgba(255,255,255,0.5);
}
.r-value-circle span {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}
.r-value-circle small {
  font-size: 0.8em;
  font-weight: 700;
  color: var(--muted);
  margin-top: 4px;
}
.r-value-desc {
  font-size: 0.85em;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  padding: 0 10px;
  margin-top: 8px;
}
/* ------------------------------------ */

/* ---------- 顶栏：汉堡 + 品牌 + 播报开关 ---------- */
.topbar{
  display:flex;
  align-items:center;
  gap:12px;
  padding:8px 10px;
  min-height:64px;
  background:var(--card);
  border:1px solid var(--stroke);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  backdrop-filter: blur(10px);
}
.brandText{ flex:1; text-align:center; min-width:0; }
.brandText .title{ font-size:1.12em; font-weight:750; letter-spacing:.2px; }
.brandText .subtitle{ font-size:.9em; color:var(--muted); }
.logo{
  width:44px;
  height:44px;
  border-radius:12px;
  object-fit:cover;
  border:1px solid rgba(255,255,255,.55);
  box-shadow: 0 6px 16px rgba(15,23,42,.08);
}

.iconBtn{
  border:1px solid var(--stroke);
  background: linear-gradient(135deg, var(--accent4), var(--accent3));
  border-radius:14px;
  padding:10px 14px;
  min-width:52px;
  min-height:52px;
  cursor:pointer;
  color:var(--text);
  font-weight:800;
  font-size:1.02em;
}
.menuBtn{ font-size:1.2em; }
.speakBtn{ font-size:.9em; white-space:nowrap; }

/* ---------- 主区：空状态 / 聊天流 ---------- */
.main{
  flex:1;
  display:flex;
  flex-direction:column;
  min-height:0;
  width:100%;
}

.emptyState{
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  gap:var(--space-md);
  padding:var(--space-xl);
  text-align:center;
  overflow:auto;
}
.emptyGreeting{ font-size:1.3em; font-weight:750; text-wrap:balance; }

.chips{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:var(--space-sm);
  width:100%;
  max-width:560px;
  margin-top:var(--space-xl);
}
.chip{
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.72);
  padding:11px 20px;
  border-radius:999px;
  cursor:pointer;
  font-weight:650;
  font-size:.94em;
  color:var(--text);
  min-height:52px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.chip:hover{ filter:brightness(1.02); }

.chat{
  flex:1;
  min-height:0;
  overflow:auto;
  padding:var(--space-lg) var(--space-lg) var(--space-xl);
  background:var(--card);
  border:1px solid var(--stroke);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  backdrop-filter: blur(10px);
}

.rowMsg{
  display:flex;
  align-items:flex-end;
  gap:var(--space-sm);
}
.rowMsg + .rowMsg{ margin-top:var(--space-xs); }
/* A speaker change is a new conversational beat; give it more air than
   consecutive messages from the same side. */
.rowMsg.user + .rowMsg.bot,
.rowMsg.bot + .rowMsg.user{ margin-top:var(--space-xl); }
.rowMsg.user{ justify-content:flex-end; }
.rowMsg.bot{ justify-content:flex-start; }

.msgAvatar{
  width:48px;
  height:48px;
  border-radius:14px;
  object-fit:contain;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.9);
}
.rowMsg.bot .msgAvatar {
  border: none;
  background: transparent;
}
/* Within a run of messages from one speaker, only the first row shows the
   avatar; visibility (not display) keeps the bubbles column-aligned. */
.rowMsg.user + .rowMsg.user .msgAvatar,
.rowMsg.bot + .rowMsg.bot .msgAvatar{ visibility:hidden; }
.rowMsg.user .msgAvatar{ order:2; }
.rowMsg.user .bubble{ order:1; }

.bubble{
  max-width:min(600px, 86%);
  padding:14px 16px;
  border-radius:20px;
  border:1px solid var(--stroke);
  white-space:pre-wrap;
  line-height:1.5;
}
.rowMsg.user .bubble{
  background: linear-gradient(135deg, rgba(255,255,255,.95), var(--accent3));
  border-top-right-radius:10px;
}
.rowMsg.bot .bubble{
  background: linear-gradient(135deg, rgba(255,255,255,.95), var(--accent4));
  border-top-left-radius:10px;
}
.meta{
  margin-top:6px;
  font-size:.82em;
  color:var(--muted);
}

/* ---------- 底部：单行胶囊输入 ---------- */
.composer{
  position:relative;
  width:100%;
}
.voiceStatus{
  position:absolute;
  bottom:100%;
  left:12px;
  right:12px;
  margin-bottom:8px;
  padding:10px 14px;
  background:rgba(255,255,255,.94);
  border:1px solid var(--stroke);
  border-radius:14px;
  box-shadow:var(--shadow);
  color:var(--text);
  font-size:.9em;
  font-weight:700;
  cursor:pointer;
}
.voiceStatus:empty{ display:none; }
.voiceDiag{ display:none; }

.pill{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--stroke);
  border-radius:999px;
  background:rgba(255,255,255,.9);
  box-shadow:var(--shadow);
  padding:6px 6px 6px 18px;
  transition: background .18s ease, border-color .18s ease;
}
.pill:focus-within{ box-shadow:0 0 0 4px var(--focus); }
.pillInput{
  flex:1;
  min-width:0;
  border:0;
  outline:none;
  background:transparent;
  font-size:1em;
  font-family:inherit;
  color:var(--text);
  padding:12px 0;
}
.pillBtn{
  flex:0 0 auto;
  width:52px;
  height:52px;
  border-radius:999px;
  border:0;
  cursor:pointer;
  font-size:1.15em;
  font-weight:800;
  color:var(--text);
  display:flex;
  align-items:center;
  justify-content:center;
}
.pillBtn[disabled]{ opacity:.55; cursor:default; filter:saturate(.6); }
.micBtn{ background: linear-gradient(135deg, var(--accent1), var(--accent4)); }
.sendBtn{
  background: linear-gradient(135deg, var(--accent4), var(--accent3));
  box-shadow: 0 6px 14px rgba(15,23,42,.10);
}
.pill[data-recording="true"]{
  background: linear-gradient(135deg, #fca5a5, #fecaca);
  border-color: rgba(220,38,38,.35);
}
.pill[data-recording="true"] .micBtn{ background:rgba(255,255,255,.88); }
.pill[data-recording="true"] .pillInput::placeholder{ color:var(--text); font-weight:700; }

/* ---------- 左侧抽屉 ---------- */
.drawerOverlay{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.35);
  z-index:50;
}
.drawer{
  position:fixed;
  top:0;
  bottom:0;
  left:0;
  width:min(320px, 85vw);
  z-index:60;
  background:rgba(255,255,255,.96);
  border-right:1px solid var(--stroke);
  box-shadow:var(--shadow);
  padding:var(--space-xl) var(--space-lg);
  display:flex;
  flex-direction:column;
  gap:var(--space-2xl);
  overflow:auto;
  transform:translateX(-105%);
  transition:transform .2s ease-out;
}
.drawer[data-open="true"]{ transform:translateX(0); }
.drawerBrand{ display:flex; align-items:center; gap:10px; }
.drawerBrand .title{ font-size:1.08em; font-weight:750; }
.drawerLabel{ font-size:.9em; font-weight:700; color:var(--muted); margin-bottom:var(--space-sm); }
.drawerActions{ margin-top:auto; display:flex; flex-direction:column; gap:var(--space-sm); }
.drawerBtn{
  width:100%;
  text-align:left;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.85);
  border-radius:14px;
  padding:14px 16px;
  min-height:52px;
  font-weight:750;
  font-size:1em;
  cursor:pointer;
  color:var(--text);
}

.seg{
  display:flex;
  padding:4px;
  border-radius:999px;
  background:rgba(255,255,255,.55);
  border:1px solid var(--stroke);
}
.segBtn{
  flex:1;
  border:0;
  background:rgba(255,255,255,.55);
  padding:13px 18px;
  min-height:48px;
  border-radius:999px;
  font-weight:750;
  font-size:1.02em;
  color:var(--muted);
  cursor:pointer;
  transition: all .18s ease;
}
.segBtn[aria-pressed="true"]{
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color:var(--text);
  box-shadow: 0 6px 18px rgba(15,23,42,.08);
}

.avatarPicker{
  display:flex;
  gap:10px;
  overflow:auto;
  padding:8px;
  border-radius:var(--radius2);
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.7);
}
.avatarBtn{
  flex:0 0 auto;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.92);
  border-radius:16px;
  padding:8px;
  width:86px;
  cursor:pointer;
}
.avatarBtn[aria-pressed="true"]{
  border-color: rgba(99,102,241,.45);
  box-shadow: 0 0 0 4px rgba(99,102,241,.15);
}
.avatarImg{
  width:100%;
  height:auto;
  aspect-ratio:1/1;
  object-fit:cover;
  border-radius:12px;
}
.avatarName{
  display:block;
  margin-top:7px;
  font-size:.72em;
  font-weight:700;
  text-align:center;
}

/* ---------- Modal（设置 / 清空确认） ---------- */
.modal{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:rgba(15,23,42,.35);
  z-index:70;
}
.modal[data-open="true"]{ display:flex; }
.modalCard{
  width:min(560px, 96vw);
  background:rgba(255,255,255,.92);
  border:1px solid var(--stroke);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
}
.modalHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 14px;
  border-bottom:1px solid var(--stroke);
}
.modalTitle{ font-weight:850; }
.form{ padding:var(--space-xl) var(--space-lg); display:flex; flex-direction:column; gap:var(--space-xl); }
.field .label{ font-weight:750; margin-bottom:6px; }
.help{ margin-top:6px; color:var(--muted); font-size:.9em; }
.confirmText{ font-weight:750; font-size:1.05em; padding:6px 0; }
.input{
  width:100%;
  border:1px solid var(--stroke);
  border-radius:14px;
  padding:14px 14px;
  background:rgba(255,255,255,.9);
  outline:none;
  font-size:1em;
}
.input:focus{ box-shadow:0 0 0 4px var(--focus); }
.select{
  width:100%;
  border:1px solid var(--stroke);
  border-radius:14px;
  padding:14px 14px;
  background:rgba(255,255,255,.95);
  outline:none;
  font-size:1em;
}
.row{ display:flex; gap:18px; flex-wrap:wrap; }
.toggle{ display:flex; align-items:center; gap:10px; color:var(--text); font-weight:700; }
.toggle input{ width:18px; height:18px; }
.modalFooter{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding:14px;
  border-top:1px solid var(--stroke);
}
.primaryBtn{
  border:0;
  cursor:pointer;
  border-radius:16px;
  padding:14px 18px;
  font-weight:850;
  color:var(--text);
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  box-shadow: 0 10px 22px rgba(15,23,42,.10);
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    transition-duration:.01ms !important;
    animation-duration:.01ms !important;
    animation-iteration-count:1 !important;
  }
}

/* 5-inch kiosk tuning (typical 800x480 / 854x480) */
.mobile-only { display: none !important; }

@media (max-width: 950px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .app { max-width: 820px; }
  /* 在手机端，我们要把大猫咪放回中间聊天区 */
  .bot-character-wrap {
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-md) 0;
  }
  .bot-character {
    width: 150px;
    height: 150px;
  }
}

@media (max-height: 600px), (max-width: 900px) {
  :root { --font: 18px; }
  body[data-text="large"] { --font: 20px; }
  body[data-mode="elder"] { --font: 19px; }

  /* Weak kiosk GPUs drop frames compositing blur over 4 radial gradients. */
  .topbar, .chat, .drawer {
    backdrop-filter: none;
    background: rgba(255,255,255,.92);
  }
  .pill { background: rgba(255,255,255,.94); }

  .app { padding: 8px; gap: 8px; }

  .topbar {
    padding: 4px 6px;
    min-height: 56px;
    border-radius: 14px;
  }
  .brandText .title { font-size: 1em; }
  .brandText .subtitle { font-size: .85em; }
  .iconBtn { min-width: 48px; min-height: 48px; padding: 8px 10px; border-radius: 12px; font-size: .9em; }

  .chat { padding: 8px 8px 12px; border-radius: 14px; }
  .rowMsg { gap: 8px; }
  .rowMsg + .rowMsg { margin-top: 6px; }
  .rowMsg.user + .rowMsg.bot,
  .rowMsg.bot + .rowMsg.user { margin-top: 14px; }
  .msgAvatar { width: 38px; height: 38px; border-radius: 10px; object-fit: contain; }
  .rowMsg.bot .msgAvatar { border: none; background: transparent; }
  .bubble { padding: 10px 12px; border-radius: 14px; line-height: 1.4; }

  .emptyState { gap: 8px; padding: 8px; }
  .bot-character { width: 80px; height: 80px; }
  .bot-character-wrap { padding: 4px 0; }
  .chips { gap: 8px; margin-top: 12px; }
  .chip { min-height: 48px; padding: 8px 12px; font-size: .9em; }

  .pillBtn { width: 48px; height: 48px; }
  .pillInput { padding: 10px 0; }
  .voiceStatus { font-size: .8em; padding: 8px 12px; }
}
