﻿@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,560;9..144,650&family=Noto+Sans+SC:wght@400;500;600&display=swap");

:root {
  --paper: #f4efe6;
  --ink: #2a221c;
  --muted: #7a6e63;
  --line: #e4d8c8;
  --accent: #c45c32;
  --sage: #5f7a63;
  --coach: #fffdf8;
  --you: #ead9c4;
  --side: rgba(255, 252, 247, 0.78);
  --shadow: 0 22px 60px rgba(42, 34, 28, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  position: relative;
  overflow-x: hidden;
  font-family: "Noto Sans SC", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}
body.admin-body,
body.gate-body {
  height: auto;
  min-height: 100%;
}
body.watch-page {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 20px 28px 20px;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(244, 239, 230, 0.72), rgba(244, 239, 230, 0.88)),
    url("/static/img/wash.jpg") center / cover no-repeat;
}
body.need-login .app { visibility: hidden; }

h1, h2, .auth-panel h2 {
  font-family: "Fraunces", "Songti SC", "Noto Serif SC", serif;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.mark {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 6px 18px rgba(42, 34, 28, 0.16);
}
.mark.sm { width: 44px; height: 44px; }

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100%;
  min-height: 0;
}

.side {
  background: var(--side);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--line);
  padding: 28px 24px;
  overflow: auto;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
}

h1 { margin: 4px 0 0; font-size: 26px; }
.lead, .summary, .meta { color: var(--muted); font-size: 13px; line-height: 1.65; }
.watch-binding {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 24px 18px;
  padding: 10px 12px;
  border: 1px solid rgba(168, 77, 44, 0.2);
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.72);
}
.watch-binding[hidden] { display: none; }
.watch-binding-label {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.watch-binding strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.watch-binding .meta {
  overflow: hidden;
  margin: 0;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
h2 { margin: 0; font-size: 15px; }

.panel { margin-top: 28px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.chats { list-style: none; margin: 0; padding: 0; }
.chats li {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(42, 34, 28, 0.04);
}
.chats li.on { border-color: var(--accent); background: #fff8f2; }
.chat-summary {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chat-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chat-actions button {
  height: 32px;
  width: 100%;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}
.chat-actions button:hover { background: #f7f1ea; color: var(--ink); }
.chats .empty { color: var(--muted); border: 0; background: transparent; padding: 0; box-shadow: none; cursor: default; }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.7);
  backdrop-filter: blur(12px);
  color: var(--muted);
  font-size: 13px;
}

.log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bubble {
  max-width: 68%;
  padding: 13px 16px;
  border-radius: 18px;
  line-height: 1.6;
  font-size: 15px;
  box-shadow: 0 10px 24px rgba(42, 34, 28, 0.05);
}
.bubble.you {
  align-self: flex-end;
  background: var(--you);
  border-bottom-right-radius: 6px;
}
.bubble.coach {
  align-self: flex-start;
  background: var(--coach);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  margin-left: 46px;
  position: relative;
}
.bubble.coach::before {
  content: "";
  position: absolute;
  left: -46px;
  top: 2px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: url("/static/img/avatar.jpg") center / cover;
  box-shadow: 0 4px 10px rgba(42, 34, 28, 0.12);
}
.thinking-bubble {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 124px;
  color: var(--muted);
}
.thinking-label {
  font-size: 14px;
}
.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 16px;
}
.thinking-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9c7453;
  animation: thinking-bounce 1.2s infinite ease-in-out;
}
.thinking-dots i:nth-child(2) { animation-delay: 0.16s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes thinking-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}
.bubble strong { font-weight: 600; }
.bubble.coach {
  min-width: 180px;
  padding-right: 76px;
}

.reply-text[hidden],
.reply-voice[hidden] {
  display: none;
}

.reply-mode-switch {
  position: absolute;
  top: 8px;
  right: 9px;
  display: flex;
}

.reply-mode-switch button {
  min-width: 48px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--muted);
  font-size: 10px;
  line-height: 22px;
}

.reply-mode-switch button:hover {
  background: #f7f1e9;
  color: var(--accent);
}

.reply-voice {
  margin-top: 3px;
}

.reply-voice.generating {
  color: var(--muted);
  font-size: 12px;
}

.voice-clip {
  display: flex;
  flex-wrap: wrap;
  width: min(360px, 100%);
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid rgba(72, 58, 46, 0.12);
  border-radius: 14px;
  background: rgba(247, 241, 233, 0.92);
}

.voice-play {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  background: var(--ink);
}

.voice-play svg {
  width: 16px;
  height: 16px;
}

.voice-play svg path {
  fill: #fff;
  stroke: none;
}

.voice-play.playing {
  background: var(--accent);
}

.voice-wave {
  display: flex;
  min-width: 80px;
  height: 24px;
  flex: 1;
  align-items: center;
  gap: 2px;
}

.voice-wave i {
  width: 2px;
  height: var(--h);
  min-height: 4px;
  border-radius: 999px;
  background: rgba(122, 110, 99, 0.55);
}

.voice-play.playing + .voice-wave i {
  background: var(--accent);
  animation: voice-wave 650ms ease-in-out infinite alternate;
}

.voice-wave i:nth-child(3n) { animation-delay: 120ms; }
.voice-wave i:nth-child(4n) { animation-delay: 240ms; }

@keyframes voice-wave {
  from { transform: scaleY(0.55); opacity: 0.55; }
  to { transform: scaleY(1); opacity: 1; }
}

.voice-time {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.voice-transcribe {
  padding: 2px 6px;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-size: 10px;
}

.voice-transcribe:hover {
  background: rgba(196, 92, 50, 0.08);
}

.voice-transcript {
  width: 100%;
  margin: 2px 2px 0;
  padding-top: 7px;
  border-top: 1px solid rgba(72, 58, 46, 0.1);
  color: var(--ink);
  font-size: 10px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.chat-mode-panel {
  margin-top: 18px;
}

.chat-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.82);
}

.chat-mode-switch button {
  height: 32px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.chat-mode-switch button:hover {
  background: #f7f1e9;
  color: var(--ink);
}

.chat-mode-switch button.on,
.chat-mode-switch button.on:hover {
  background: var(--ink);
  color: #fffdf8;
}

.speech-preferences {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.speech-preferences label {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.speech-preferences select {
  min-width: 0;
  height: 31px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
}

.speech-preferences p {
  margin: 0;
  color: #9b8f82;
  font-size: 10px;
  line-height: 1.45;
}

.composer {
  padding: 12px 24px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.82);
}

.composer-shell {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(72, 58, 46, 0.16);
  border-radius: 22px;
  background: rgba(255, 254, 250, 0.98);
  box-shadow:
    0 14px 34px rgba(42, 34, 28, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer-shell:focus-within {
  border-color: rgba(196, 92, 50, 0.45);
  box-shadow:
    0 16px 38px rgba(42, 34, 28, 0.1),
    0 0 0 4px rgba(196, 92, 50, 0.08);
}

.image-pick,
.voice-pick {
  display: inline-flex;
  height: 34px;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 0 12px;
  border: 1px solid rgba(196, 92, 50, 0.2);
  border-radius: 11px;
  background: rgba(196, 92, 50, 0.07);
  color: #a64e2d;
  font-size: 12px;
  font-weight: 500;
}

.voice-pick[hidden] {
  display: none;
}

.image-pick:hover,
.voice-pick:hover {
  background: rgba(196, 92, 50, 0.12);
  color: #8f3e21;
}

.image-pick svg,
.voice-pick svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.voice-pick.recording {
  border-color: rgba(169, 55, 45, 0.38);
  background: rgba(169, 55, 45, 0.1);
  color: #a3372d;
}

.voice-pick.recording svg {
  color: #b53a30;
  animation: voice-pulse 1.2s ease-in-out infinite;
}

.voice-status {
  flex: 1;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.voice-status[hidden] {
  display: none;
}

.voice-status:not([hidden]) + .composer-hint {
  display: none;
}

@keyframes voice-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.composer-toolbar {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 6px 9px 8px 12px;
}

.composer-hint {
  flex: 1;
  color: #988b7e;
  font-size: 11px;
  text-align: right;
}

.send-button {
  height: 36px;
  flex: none;
  padding: 0 20px;
  border-radius: 11px;
  background: var(--ink);
  font-size: 13px;
}

.image-preview {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 12px 10px;
  border-bottom: 1px solid rgba(72, 58, 46, 0.1);
  scrollbar-width: thin;
}

.image-preview[hidden] {
  display: none;
}

.image-chip {
  position: relative;
  width: 92px;
  height: 72px;
  flex: 0 0 92px;
  overflow: hidden;
  border: 1px solid rgba(72, 58, 46, 0.12);
  border-radius: 14px;
  background: #f1e8dc;
  box-shadow: 0 5px 16px rgba(42, 34, 28, 0.1);
}

.image-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  background: rgba(34, 28, 23, 0.66);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  backdrop-filter: blur(6px);
}

.image-remove:hover {
  background: var(--accent);
}

.bubble-copy {
  margin: 0;
  white-space: pre-wrap;
}

.bubble.you.with-images {
  width: min(520px, 76%);
  padding: 10px;
}

.bubble.you.with-images .bubble-copy {
  padding: 4px 6px 9px;
}

.bubble-images {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.bubble-images img {
  width: min(250px, 100%);
  max-height: 260px;
  border: 1px solid rgba(72, 58, 46, 0.1);
  border-radius: 14px;
  object-fit: contain;
  background: #f4ece1;
  box-shadow: 0 6px 16px rgba(42, 34, 28, 0.1);
}

textarea {
  resize: none;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
}

.composer textarea {
  min-height: 72px;
  padding: 16px 18px 8px;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  line-height: 1.55;
}

button {
  border: 0;
  background: var(--ink);
  color: #fff;
  border-radius: 14px;
  padding: 0 18px;
  cursor: pointer;
  font: inherit;
}
button:hover { background: #3a3129; }
button:disabled { opacity: 0.5; cursor: default; }
@media (prefers-reduced-motion: reduce) {
  .thinking-dots i {
    animation: none;
    opacity: 0.65;
  }
}
.auth-panel button[type="submit"]:hover { background: #a94c28; }
.text-btn, #reset {
  background: transparent;
  color: var(--accent);
  padding: 0;
  border-radius: 0;
}
.ghost-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  height: 36px;
  padding: 0 14px;
}

.toolbar-actions { display: flex; align-items: center; gap: 16px; }
.toolbar-actions a { color: var(--accent); text-decoration: none; font-weight: 500; }

.gate-body {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 36px 20px;
}

.auth {
  width: min(920px, 100%);
  min-height: 560px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.auth-brand {
  position: relative;
  min-height: 280px;
  color: #fff;
}
.auth-hero {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.auth-brand-copy {
  position: relative;
  z-index: 1;
  height: 100%;
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(180deg, rgba(42, 34, 28, 0.05) 20%, rgba(42, 34, 28, 0.72) 100%);
}
.auth-brand .eyebrow { color: #f3d2c0; }
.auth-brand h1 { font-size: 40px; color: #fff; margin: 8px 0 10px; }
.auth-brand .lead { color: rgba(255, 255, 255, 0.86); font-size: 15px; max-width: 18em; }
.auth-brand .mark { margin-bottom: 18px; border: 2px solid rgba(255,255,255,0.7); }

.auth-panel { padding: 44px 40px; display: flex; flex-direction: column; justify-content: center; }
.auth-panel h2 { font-size: 28px; margin-bottom: 6px; }
.auth-panel .meta { margin: 0 0 24px; }

.auth-panel form { display: grid; gap: 14px; }
.auth-panel form[hidden],
.auth-panel [hidden] { display: none !important; }

.auth-panel label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.auth-panel input,
.inline-form input,
.inline-form select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.auth-panel input:focus,
.inline-form input:focus,
textarea:focus {
  outline: 2px solid rgba(196, 92, 50, 0.22);
  border-color: var(--accent);
}

.composer textarea:focus {
  outline: 0;
  border-color: transparent;
}

.auth-panel button[type="submit"] {
  height: 46px;
  margin-top: 6px;
  background: var(--accent);
}

.auth-switch {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.error { color: var(--accent); font-size: 13px; margin: 0; }

.admin-body { padding: 32px 40px 56px; }
.admin-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}
.admin-title { display: flex; align-items: center; gap: 14px; }
.admin-bar nav { display: flex; gap: 16px; align-items: center; }
.admin-bar a { color: var(--accent); text-decoration: none; font-weight: 500; }
.admin-card {
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.autofill-trap {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}
.watch-page .admin-bar { margin-bottom: 12px; flex: none; }
.watch-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  padding: 16px 18px 14px;
}
.watch-card .panel-head { margin-bottom: 8px; flex: none; }
.watch-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex: none;
}
.watch-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.watch-filters select,
.watch-filters input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  background: #fffdf8;
}
.watch-filters select { min-width: 150px; }
.watch-filters input { min-width: 220px; flex: 1; }
.table-wrap { flex: 1; min-height: 0; overflow: auto; }
.table.compact th, .table.compact td { padding: 6px 8px; font-size: 13px; }
.table.compact thead th {
  position: sticky;
  top: 0;
  background: #fffdf8;
}
.id-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.id-text { font-variant-numeric: tabular-nums; }
.copy-id {
  height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
  font-size: 12px;
}
.copy-id:hover { background: #f7f1ea; }
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex: none;
}
.pager-status { margin: 0; color: var(--ink); font-size: 14px; font-weight: 500; }
.jump { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.jump input {
  width: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
}
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; position: relative; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table-wrap { overflow-x: auto; }
.admin-table-wrap .table { min-width: 1320px; }
.admin-table-wrap .table th,
.admin-table-wrap .table td { white-space: nowrap; }

/* ---------- 数据页 ---------- */
.data-main {
  max-width: 1160px;
  margin: 0 auto;
}
.data-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.data-tab {
  height: 40px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}
.data-tab:hover { background: #f7f1ea; color: var(--ink); }
.data-tab.on,
.data-tab.on:hover { background: var(--ink); border-color: var(--ink); color: #fffdf8; }
.day-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.day-now {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 210px;
  text-align: center;
}
.day-now strong { font-size: 16px; font-weight: 600; }
.day-now .meta { margin: 0; }
.day-picker-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.day-picker-field .meta {
  margin: 0;
  text-align: left;
}
.day-picker {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  color-scheme: light;
}
.day-picker:focus {
  outline: 2px solid rgba(177, 77, 45, 0.18);
  border-color: rgba(177, 77, 45, 0.45);
}
.day-picker::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.65;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.metric-card {
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(42, 34, 28, 0.06);
}
.metric-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.metric-value {
  margin: 6px 0 2px;
  font-family: "Fraunces", "Songti SC", serif;
  font-size: 26px;
  font-weight: 650;
  line-height: 1.1;
}
.metric-value span {
  margin-left: 4px;
  font-family: "Noto Sans SC", "PingFang SC", sans-serif;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}
.metric-hint {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}
.data-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin: 4px 0 14px;
}
.data-head h2 { margin: 0; }
.range-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.range-label select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fffdf8;
  font: inherit;
  color: var(--ink);
}
.exercise-list { display: grid; gap: 10px; }
.exercise-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  align-items: stretch;
  width: 100%;
  height: auto;
  padding: 14px 16px;
  text-align: left;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(42, 34, 28, 0.06);
}
.exercise-card:hover { background: #fbf5ec; }
.exercise-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
}
.exercise-route-preview {
  position: relative;
  min-height: 112px;
  overflow: hidden;
  border: 1px solid #dfd2c0;
  border-radius: 12px;
  background:
    linear-gradient(rgba(126, 108, 87, 0.08) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(126, 108, 87, 0.08) 1px, transparent 1px) 0 0 / 24px 24px,
    #f6f0e7;
}
.exercise-route-preview svg {
  display: block;
  width: 100%;
  height: 100%;
}
.exercise-route-preview.empty {
  display: grid;
  place-items: center;
  background: #f8f3eb;
}
.route-preview-label {
  position: absolute;
  top: 8px;
  left: 9px;
  z-index: 1;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.84);
  color: var(--muted);
  font-size: 9px;
  pointer-events: none;
}
.exercise-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}
.exercise-head strong { color: var(--ink); font-size: 15px; }
.exercise-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.exercise-stats em {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}
@media (max-width: 700px) {
  .exercise-card { grid-template-columns: 1fr; }
  .exercise-route-preview { min-height: 150px; }
}
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.chart-card {
  min-width: 0;
  padding: 14px 16px 8px;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(42, 34, 28, 0.06);
}
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
}
.chart-card .unit {
  margin-left: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}
.chart { width: 100%; min-height: 200px; }
.chart-empty {
  margin: 0;
  padding: 56px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
@media (max-width: 820px) {
  .chart-grid { grid-template-columns: 1fr; }
  .data-head { flex-direction: column; align-items: flex-start; }
}

.combined-card { padding-bottom: 14px; }
.combined-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.combined-head h3 { margin: 0; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 12px;
}
.legend-item:hover { background: #f7f1ea; }
.legend-item.off { opacity: 0.45; text-decoration: line-through; }
.legend-item.empty {
  color: var(--muted);
  border-style: dashed;
}
.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.sleep-stage-legend {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.sleep-stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}
.sleep-stage-chip i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.health-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.health-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.health-stats .metric-card {
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: none;
}
.health-stats .metric-label { font-size: 11px; }
.health-stats .metric-value {
  margin: 2px 0 1px;
  font-size: 22px;
}
.health-stats .metric-hint {
  font-size: 10px;
  line-height: 1.35;
}
.combined-chart { min-height: 390px; }
@media (max-width: 900px) {
  .health-layout { grid-template-columns: 1fr; }
  .health-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .health-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 横屏下给接口字段更多空间 */
.data-main { max-width: 1720px; }
.data-body { padding: 14px 18px 18px; }
.health-layout {
  grid-template-columns: 260px minmax(0, 1fr) 380px;
}
.schema-panel {
  padding: 14px;
}
.schema-panel-head {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.schema-panel-head h3 { font-size: 14px; }
.schema-panel .schema-body { padding-top: 8px; }
.schema-panel .schema-table {
  font-size: 11px;
}
.schema-panel .schema-table th,
.schema-panel .schema-table td {
  padding: 6px 7px;
}
.schema-panel .schema-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fffdf8;
}
.schema-panel .schema-table td:nth-child(2) {
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 10px;
  letter-spacing: -0.01em;
}
.schema-panel .schema-table td:nth-child(3) { color: var(--sage); }
.schema-panel .schema-table td:nth-child(4) {
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}
.schema-panel .schema-table td:nth-child(5) {
  min-width: 180px;
  line-height: 1.45;
}
.schema-panel .schema-row:hover { background: #faf4ec; }
.schema-panel .schema-detail td { padding: 0 7px 8px 36px; }

@media (max-width: 1400px) and (min-width: 1201px) {
  .health-layout { grid-template-columns: 240px minmax(0, 1fr) 340px; }
}
@media (max-width: 1200px) and (min-width: 1101px) {
  .health-layout { grid-template-columns: 230px minmax(0, 1fr) 300px; }
}

/* 独立图表卡片 */
.health-layout {
  height: auto;
  min-height: 0;
  align-items: stretch;
}
.combined-card {
  min-height: 0;
  overflow: visible;
}
.combined-chart {
  flex: none;
  min-height: 0;
}
#health-combined {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chart-panel {
  padding: 10px 12px 4px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.mini-chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.mini-chart-head h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
}
.mini-chart-head span {
  color: var(--muted);
  font-size: 10px;
}
.mini-chart-body {
  min-height: 0;
}

/* 中间图表独立滚动 */
.health-layout {
  height: calc(100vh - 290px);
  min-height: 560px;
  align-items: stretch;
}
.health-stats,
.schema-panel,
.combined-card {
  height: 100%;
  min-height: 0;
}
.combined-card {
  overflow: hidden;
}
.combined-chart {
  flex: 1 1 auto;
  min-height: 0;
}
#health-combined {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 8px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #c9bcaa transparent;
}
#health-combined::-webkit-scrollbar {
  width: 8px;
}
#health-combined::-webkit-scrollbar-track {
  background: transparent;
}
#health-combined::-webkit-scrollbar-thumb {
  background: #c9bcaa;
  border-radius: 4px;
}

.schema-card {
  margin-top: 16px;
}
.schema-card summary {
  cursor: pointer;
  font-weight: 600;
}
.schema-card h3 {
  margin: 14px 0 8px;
  font-size: 14px;
}
.schema-body {
  margin-top: 12px;
  overflow: auto;
}
.schema-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.schema-table th,
.schema-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.schema-table th {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.schema-table td:first-child {
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
}
.schema-table td:last-child {
  color: var(--muted);
  word-break: break-word;
}
.schema-fields-table th:first-child,
.schema-fields-table td:first-child {
  width: 30px;
  padding-left: 4px;
  padding-right: 4px;
  text-align: center;
}
.schema-row { cursor: pointer; }
.schema-row:hover { background: #faf4ec; }
.schema-toggle {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}
.schema-toggle:hover { background: #f7f1ea; }
.schema-detail td {
  padding: 0 8px 8px 34px;
  background: #fbf7f1;
}
.schema-detail pre {
  margin: 0;
  padding: 10px 12px;
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--muted);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 健康数据三栏工作台 */
.data-main { max-width: 1720px; }
.data-body { padding: 14px 18px 18px; }
.data-body .admin-bar { margin-bottom: 16px; }
.data-body .data-tabs { margin-bottom: 12px; }
.data-body .day-bar { margin-bottom: 12px; }
.health-layout {
  grid-template-columns: 260px minmax(0, 1fr) 380px;
  gap: 14px;
  height: 800px;
  min-height: 0;
  align-items: stretch;
}
.health-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
  overflow: auto;
  padding-right: 2px;
}
.health-stats .metric-card {
  padding: 8px 10px;
  border-radius: 10px;
}
.health-stats .metric-label { font-size: 10px; }
.health-stats .metric-value {
  margin: 1px 0;
  font-size: 18px;
}
.health-stats .metric-value span { font-size: 10px; }
.health-stats .metric-hint {
  display: -webkit-box;
  overflow: hidden;
  font-size: 9px;
  line-height: 1.3;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.combined-card {
  display: flex;
  flex-direction: column;
  min-height: 760px;
  overflow: visible;
}
.combined-chart {
  flex: 1;
  min-height: 0;
}
.schema-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(42, 34, 28, 0.06);
}
.schema-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.schema-panel-head h3 {
  margin: 0;
  font-size: 14px;
}
.schema-panel-head .meta { font-size: 10px; }
.schema-panel .schema-body {
  flex: 1;
  min-height: 0;
  margin-top: 0;
  overflow: auto;
}
.schema-panel .schema-table { font-size: 11px; }
.schema-panel .schema-table th,
.schema-panel .schema-table td { padding: 6px 7px; }
.schema-panel .schema-table td:nth-child(5) { min-width: 180px; }
.schema-panel .schema-detail td { padding: 0 7px 8px 36px; }
.schema-panel .schema-detail pre {
  max-height: 220px;
  padding: 6px 8px;
  font-size: 11px;
}

@media (max-width: 1200px) {
  .health-layout { grid-template-columns: 230px minmax(0, 1fr) 300px; }
}
@media (max-width: 1100px) {
  .health-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .health-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }
  .schema-panel { max-height: 420px; }
}
@media (max-width: 560px) {
  .health-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.table th { color: var(--muted); font-weight: 500; }
.table th, .table td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); }
.table .actions button {
  background: transparent;
  color: var(--accent);
  padding: 0 8px 0 0;
}

.memory-mask {
  position: fixed;
  inset: 0;
  background: rgba(42, 34, 28, 0.35);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
}
.memory-mask[hidden] { display: none; }
.memory-panel {
  width: min(760px, 100%);
  max-height: min(82vh, 820px);
  overflow: auto;
  background: #fffdf8;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 20px 24px 28px;
}
.memory-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.memory-panel h2 { font-size: 22px; margin: 0; }
.memory-panel h3 { font-size: 15px; margin: 18px 0 8px; }
.memory-panel h4 { margin: 0 0 4px; font-size: 15px; }
.memory-panel h5 { margin: 12px 0 5px; font-size: 13px; color: var(--accent); }
.memory-notes { margin: 0; padding-left: 18px; }
.memory-chat {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #fff;
}
.memory-summary { color: var(--muted); font-size: 13px; line-height: 1.55; }
.memory-log p { margin: 8px 0; font-size: 14px; line-height: 1.55; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side {
    display: block;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 38vh;
  }
  .auth { grid-template-columns: 1fr; min-height: 0; }
  .auth-brand { min-height: 220px; }
  .auth-panel { padding: 28px 22px; }
  .admin-body { padding: 20px; }
  .composer { padding: 10px 14px 16px; }
  .composer-hint { display: none; }
  .image-pick { padding: 0 10px; }
  .send-button { padding: 0 16px; }
  .bubble.you.with-images { width: min(520px, 88%); }
}

/* 最终覆盖：中间图表区独立纵向滚动 */
.health-layout {
  height: calc(100vh - 290px);
  min-height: 560px;
}
.combined-card {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.combined-head {
  flex: 0 0 auto;
}
.combined-chart {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
#health-combined {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 8px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #c9bcaa transparent;
}

/* 接口字段固定在卡片宽度内换行，仅保留纵向滚动 */
.schema-panel .schema-body {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.schema-panel .schema-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  font-size: 10px;
}
.schema-panel .schema-table th,
.schema-panel .schema-table td {
  padding: 5px 4px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.schema-panel .schema-table th:nth-child(1),
.schema-panel .schema-table td:nth-child(1) {
  width: 24px;
  padding-right: 2px;
  padding-left: 2px;
}
.schema-panel .schema-table th:nth-child(2),
.schema-panel .schema-table td:nth-child(2) {
  width: 31%;
}
.schema-panel .schema-table th:nth-child(3),
.schema-panel .schema-table td:nth-child(3) {
  width: 40px;
}
.schema-panel .schema-table th:nth-child(4),
.schema-panel .schema-table td:nth-child(4) {
  width: 34px;
}
.schema-panel .schema-table td:nth-child(2) {
  font-size: 9px;
  line-height: 1.35;
}
.schema-panel .schema-table td:nth-child(4) {
  padding-right: 2px;
  padding-left: 2px;
  text-align: center;
}
.schema-panel .schema-table td:nth-child(5) {
  min-width: 0;
  font-size: 9px;
  line-height: 1.4;
}

.schema-panel .schema-detail pre {
  max-height: min(420px, 55vh);
  padding: 10px 12px;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 10px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  tab-size: 2;
  background:
    linear-gradient(90deg, rgba(110, 91, 71, 0.08) 1px, transparent 1px) 0 0 / 18px 100%,
    #fffdf8;
}
