/* ============================================================================
 * 心镜 · V2 视觉体系（M0）
 * 来源：team/dsh-web-v2-1608/UI.md §1 token / §2 玻璃规范 / §3–§7 组件
 * 移动优先 375px；桌面内容区 max-width:560px；零外链、无外部字体
 * ==========================================================================*/

/* ---------------------------------------------------------------- 1. token */
:root {
  /* 1.1 莫兰迪蓝主色阶（10 档） */
  --blue-50: #F1F6FA;
  --blue-100: #E3EDF4;
  --blue-200: #C8DBE7;
  --blue-300: #A8C2D4;
  --blue-400: #8DA9BE;
  --blue-500: #7D9BB0;
  --blue-600: #5E7F96;
  --blue-700: #47647A;
  --blue-800: #34495C;
  --blue-900: #24333F;

  --primary-ink: #3F5F75;
  --primary-soft: #E6EEF3;
  --primary-btn-a: #52738A;
  --primary-btn-b: #425F73;

  /* 1.2 文字三级 + 状态色 */
  --text-1: #22303A;
  --text-2: #41546A;
  --text-3: #5A6C7B;
  --text-inv: #FFFFFF;
  --danger: #C05A62;
  --danger-ink: #8E3239;
  --danger-bg: #FDF0F1;
  --danger-border: #E3A9AE;
  --warning: #B5813C;
  --warning-ink: #7A5518;
  --warning-bg: #FBF3E4;
  --success: #4E7D63;
  --success-ink: #3F6B52;
  --success-bg: #EAF4EE;

  /* 3-Agent 色 */
  --agent-assess: #5E9B7C;
  --agent-assess-ink: #38664F;
  --agent-assess-bg: #E9F3ED;
  --agent-consult: #5B87A8;
  --agent-consult-ink: #3D6280;
  --agent-consult-bg: #E8F0F6;
  --agent-guard: #C09A45;
  --agent-guard-ink: #6B5214;
  --agent-guard-bg: #FBF2DE;
  --agent-risk: #C0464E;
  --agent-risk-ink: #8E2F36;
  --agent-risk-bg: #FBE9EA;

  /* 1.3 玻璃层与边框 */
  --glass-bg: rgba(255, 255, 255, 0.58);
  --glass-bg-strong: rgba(255, 255, 255, 0.74);
  --glass-bg-dim: rgba(238, 244, 248, 0.42);
  --glass-border: rgba(255, 255, 255, 0.66);
  --glass-stroke: rgba(122, 156, 180, 0.22);
  --glass-hi: inset 0 1px 0 rgba(255, 255, 255, 0.72), inset 0 0 0 1px rgba(255, 255, 255, 0.30);
  --glass-fallback: rgba(244, 248, 251, 0.96);
  --border: #E2E9EE;

  /* 1.4 圆角 */
  --r-8: 8px;
  --r-12: 12px;
  --r-16: 16px;
  --r-22: 22px;
  --r-28: 28px;
  --r-pill: 999px;

  /* 1.5 间距 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* 1.6 字号 */
  --fs-12: 12px;
  --fs-14: 14px;
  --fs-16: 16px;
  --fs-20: 20px;
  --fs-24: 24px;
  --fs-28: 28px;

  /* 1.7 阴影 */
  --sh-1: 0 1px 2px rgba(52, 73, 92, 0.06), 0 2px 8px rgba(52, 73, 92, 0.06);
  --sh-2: 0 2px 4px rgba(52, 73, 92, 0.06), 0 8px 24px rgba(52, 73, 92, 0.10);
  --sh-3: 0 4px 8px rgba(52, 73, 92, 0.08), 0 18px 48px rgba(52, 73, 92, 0.16);

  /* 1.8 模糊 */
  --blur-8: 8px;
  --blur-14: 14px;
  --blur-18: 18px;
  --blur-22: 22px;
  --blur-32: 32px;

  /* 1.9 渐变 */
  --grad-bg: radial-gradient(120% 80% at 50% -10%, #F4F8FB 0%, #E7EFF5 46%, #D8E4EC 100%);
  --grad-glass: linear-gradient(160deg, rgba(255, 255, 255, 0.78) 0%, rgba(255, 255, 255, 0.46) 42%, rgba(233, 241, 247, 0.52) 100%);
  --grad-sheen: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.55) 18%, transparent 38%);
  --grad-primary: linear-gradient(135deg, #52738A 0%, #425F73 100%);

  /* 1.10 动效 */
  --dur-150: 150ms;
  --dur-250: 250ms;
  --dur-400: 400ms;
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-inout: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

/* ---------------------------------------------------------------- 2. 基础 */
*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  font-family: var(--font);
  font-size: var(--fs-16);
  line-height: 1.5;
  color: var(--text-1);
  background: var(--grad-bg);
  -webkit-font-smoothing: antialiased;
}

img, svg, canvas { max-width: 100%; }

p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }

a { color: var(--primary-ink); }

button { font-family: inherit; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 300;
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  background: var(--glass-bg-strong);
  color: var(--primary-ink);
  font-size: var(--fs-14);
  font-weight: 500;
  text-decoration: none;
  box-shadow: var(--sh-2);
  transition: top var(--dur-150) var(--ease-out);
}
.skip-link:focus { top: 12px; }

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--primary-ink);
  outline-offset: 2px;
  border-radius: inherit;
  box-shadow: 0 0 0 4px rgba(125, 155, 176, 0.30);
}

/* --------------------------------------------------- 3. L0 水面 / 关键帧 */
.bg-water {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: var(--grad-bg);
}

.bg-water::before {
  content: '';
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(60% 45% at 22% 18%, rgba(255, 255, 255, 0.55), transparent 70%),
    radial-gradient(50% 40% at 82% 30%, rgba(200, 219, 231, 0.45), transparent 72%),
    radial-gradient(70% 50% at 50% 100%, rgba(141, 169, 190, 0.30), transparent 70%);
  animation: hm-drift 28s var(--ease-inout) infinite;
  will-change: transform;
}

.rip {
  position: absolute;
  left: 50%;
  bottom: -18vh;
  width: 76vw;
  height: 76vw;
  margin-left: -38vw;
  border-radius: 50%;
  border: 1px solid rgba(125, 155, 176, 0.55);
  transform-origin: 50% 50%;
  animation: hm-ripple 6.4s var(--ease-inout) infinite;
}
.rip--2 { margin-left: -48vw; width: 96vw; height: 96vw; animation-delay: 2.1s; opacity: 0.7; }
.rip--3 { margin-left: -28vw; width: 56vw; height: 56vw; animation-delay: 4.2s; opacity: 0.5; }

.sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 34%, rgba(255, 255, 255, 0.34) 44%, transparent 54%);
  mix-blend-mode: screen;
  opacity: 0.7;
  animation: hm-sheen-bg 18s var(--ease-inout) infinite;
}

@keyframes hm-ripple {
  0%   { transform: scale(0.55); opacity: 0.38; }
  70%  { opacity: 0.10; }
  100% { transform: scale(1.65); opacity: 0; }
}

@keyframes hm-drift {
  0%   { transform: translate3d(-2%, 1%, 0) scale(1.04); }
  50%  { transform: translate3d(2%, -1%, 0) scale(1.07); }
  100% { transform: translate3d(-2%, 1%, 0) scale(1.04); }
}

@keyframes hm-sheen {
  0%   { transform: translateX(-140%) skewX(-14deg); opacity: 0; }
  12%  { opacity: 0.55; }
  38%  { opacity: 0; }
  100% { transform: translateX(160%) skewX(-14deg); opacity: 0; }
}

@keyframes hm-sheen-bg {
  0%, 100% { opacity: 0.45; transform: translateX(-6%); }
  50%      { opacity: 0.75; transform: translateX(6%); }
}

@keyframes hm-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168, 194, 212, 0.34), var(--sh-3); }
  50%      { box-shadow: 0 0 0 12px rgba(168, 194, 212, 0.00), var(--sh-3); }
}

@keyframes hm-agent-pulse {
  0%   { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(2.2); opacity: 0; }
}

@keyframes hm-wave {
  0%   { transform: scaleY(0.35); }
  100% { transform: scaleY(1); }
}

@keyframes hm-badge-pop {
  0%   { transform: scale(0.6) rotate(-8deg); }
  60%  { transform: scale(1.12) rotate(0deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ------------------------------------------------------ 4. 玻璃拟态基础 */
.glass {
  position: relative;
  border-radius: var(--r-16);
  background: var(--glass-bg);
  background-image: var(--grad-glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--sh-2), var(--glass-hi);
  -webkit-backdrop-filter: blur(var(--blur-18)) saturate(1.35);
  backdrop-filter: blur(var(--blur-18)) saturate(1.35);
}
.glass--strong {
  background: var(--glass-bg-strong);
  background-image: var(--grad-glass);
  --blur-18: var(--blur-22);
}
.glass--dim { background: var(--glass-bg-dim); }

.glass--sheen::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--grad-sheen);
  pointer-events: none;
  overflow: hidden;
  animation: hm-sheen 7.2s var(--ease-inout) infinite;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: var(--glass-fallback);
    background-image: none;
    border-color: rgba(122, 156, 180, 0.30);
  }
  .glass--strong { background: rgba(249, 252, 254, 0.98); }
  .bg-water, .bg-water::before, .rip, .sheen { display: none; }
  body { background: var(--grad-bg); }
  .glass--sheen::after { display: none; }
}

/* --------------------------------------------- 5. L2：顶栏 + Agent 状态栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(560px, 100%);
  margin: 0 auto;
  height: 52px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
}

.brand__mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-8);
  background: var(--grad-primary);
  color: #fff;
  font-size: 16px;
  box-shadow: var(--sh-1);
}

.brand__name {
  font-size: var(--fs-16);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-1);
}

.topbar #settings-btn { margin-left: auto; }

.agent-bar {
  position: sticky;
  top: 52px;
  z-index: 120;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  width: min(560px, 100%);
  height: 44px;
  margin: 0 auto;
  padding: 0 8px;
  border-radius: 0 0 var(--r-12) var(--r-12);
  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 12px rgba(52, 73, 92, 0.08);
  -webkit-backdrop-filter: blur(var(--blur-22)) saturate(1.4);
  backdrop-filter: blur(var(--blur-22)) saturate(1.4);
}

.agent-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 32px;
  margin: auto 0;
  padding: 0 6px;
  border-radius: var(--r-8);
  opacity: 0.62;
  transition: background-color var(--dur-150) ease, box-shadow var(--dur-150) ease,
              opacity var(--dur-150) ease;
}

.agent-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--blue-400);
}

.agent-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.agent-name {
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-state {
  font-size: var(--fs-12);
  font-weight: 400;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-cell[data-agent="assess"] .agent-dot { background: var(--agent-assess); }
.agent-cell[data-agent="consult"] .agent-dot { background: var(--agent-consult); }
.agent-cell[data-agent="supervisor"] .agent-dot { background: var(--agent-guard); }

.agent-cell[data-agent="supervisor"] { opacity: 1; }

.agent-cell.is-active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(125, 155, 176, 0.55);
}
.agent-cell.is-active .agent-state { color: var(--text-1); }

.agent-cell.is-active .agent-dot { position: relative; }
.agent-cell.is-active .agent-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid currentColor;
  animation: hm-agent-pulse 2s infinite;
}

.agent-cell[data-agent="assess"].is-active .agent-dot { color: var(--agent-assess); }
.agent-cell[data-agent="consult"].is-active .agent-dot { color: var(--agent-consult); }

.agent-cell.is-done { opacity: 1; }

.agent-cell.is-alert {
  opacity: 1;
  background: var(--agent-risk-bg);
  box-shadow: inset 0 0 0 1px var(--danger-border);
}
.agent-cell.is-alert .agent-dot {
  background: var(--agent-risk);
  position: relative;
}
.agent-cell.is-alert .agent-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--agent-risk);
  animation: hm-agent-pulse 1.2s infinite;
}
.agent-cell.is-alert .agent-name,
.agent-cell.is-alert .agent-state { color: var(--danger-ink); }

.agent-cell[data-agent="supervisor"].is-guard { opacity: 1; }

/* ---------------------------------------------------------- 6. 页面布局 */
.app {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 16px 16px 24px;
}

.page {
  min-height: calc(100dvh - 44px);
  animation: hm-page-in var(--dur-250) var(--ease-out) both;
}

@keyframes hm-page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page__head { margin: 4px 0 20px; }

.page__kicker {
  margin: 0 0 2px;
  font-size: var(--fs-12);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.page__head h1 {
  margin: 0 0 4px;
  font-size: var(--fs-24);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: var(--text-1);
}

.page__sub {
  margin: 0;
  font-size: var(--fs-14);
  color: var(--text-2);
  line-height: 1.5;
}

/* --------------------------------------------------------------- 7. 卡片 */
.card {
  margin-bottom: 12px;
  padding: 16px;
  border-radius: var(--r-16);
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.card__title {
  margin: 0;
  font-size: var(--fs-16);
  font-weight: 600;
  color: var(--text-1);
}

.card__hint,
.field__hint {
  margin: 0;
  font-size: var(--fs-12);
  color: var(--text-3);
  line-height: 1.45;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 20px 0 8px;
  font-size: var(--fs-20);
  font-weight: 600;
  color: var(--text-1);
}

.section-title__hint {
  font-size: var(--fs-12);
  font-weight: 400;
  color: var(--text-3);
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.row--between { justify-content: space-between; }

.feedback {
  margin: 12px 2px 0;
  min-height: 1.4em;
  font-size: var(--fs-12);
  color: var(--text-3);
  text-align: center;
}

.empty {
  margin: 4px 0;
  color: var(--text-3);
  font-size: var(--fs-14);
  text-align: center;
}

/* --------------------------------------------------------------- 8. 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-size: var(--fs-16);
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-150) ease, border-color var(--dur-150) ease,
              color var(--dur-150) ease, transform var(--dur-150) ease,
              box-shadow var(--dur-150) ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled,
.btn[disabled] {
  background: var(--blue-100);
  border-color: transparent;
  color: var(--text-3);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn--primary {
  min-height: 48px;
  background: var(--grad-primary);
  color: var(--text-inv);
  box-shadow: var(--sh-2);
}
.btn--primary:hover { filter: brightness(1.04); }

.btn--secondary {
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.btn--secondary:hover { background: var(--blue-100); }

.btn--ghost {
  background: transparent;
  color: var(--primary-ink);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.5); }

.btn--danger {
  background: var(--danger);
  color: var(--text-inv);
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn--icon {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
}

.btn--sm {
  min-height: 44px;
  padding: 8px 14px;
  font-size: var(--fs-14);
}

/* --------------------------------------------------------------- 9. 表单 */
textarea,
input[type="text"] {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--glass-stroke);
  border-radius: var(--r-12);
  background: rgba(255, 255, 255, 0.66);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-16);
  line-height: 1.5;
  resize: vertical;
}

textarea { min-height: 72px; }

textarea::placeholder { color: var(--text-3); }

textarea:focus,
input[type="text"]:focus {
  border-color: var(--blue-500);
  background: rgba(255, 255, 255, 0.86);
  outline: none;
  box-shadow: 0 0 0 3px rgba(125, 155, 176, 0.22);
}

.field { margin-top: 16px; }

.field__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.field__label {
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--text-1);
}

/* --------------------------------------------------------------- 10. 滑块 */
.slider {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 2px;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
  --slider-pct: 50%;
}

.slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: linear-gradient(
    90deg,
    var(--primary-btn-a) 0 var(--slider-pct),
    var(--blue-200) var(--slider-pct) 100%
  );
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -11px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--blue-600);
  box-shadow: var(--sh-1);
}

.slider::-moz-range-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--blue-200);
}
.slider::-moz-range-progress {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--primary-btn-a);
}
.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--blue-600);
  box-shadow: var(--sh-1);
}

.mood-scale {
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
  font-size: var(--fs-12);
  color: var(--text-3);
}

/* --------------------------------------------------------------- 11. chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  background: var(--glass-bg);
  box-shadow: var(--sh-1);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-14);
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-250) var(--ease-out),
              border-color var(--dur-250) var(--ease-out),
              color var(--dur-250) var(--ease-out), transform 100ms ease;
}
.chip::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
}
.chip:active { transform: scale(0.96); }

.chip[aria-pressed="true"],
.chip.is-selected {
  background: var(--primary-soft);
  border-color: var(--blue-500);
  box-shadow: inset 0 0 0 1px var(--blue-500);
  color: var(--primary-ink);
}

.chip[aria-pressed="true"]::before,
.chip.is-selected::before {
  content: '✓';
  font-size: var(--fs-12);
  line-height: 1;
}

.chip--static {
  cursor: default;
  min-height: 28px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--primary-soft);
  border-color: transparent;
  box-shadow: none;
  font-size: var(--fs-12);
  color: var(--primary-ink);
}
.chip--static::after { display: none; }

.chip--cloud { font-size: var(--fs-14); }
.chip--cloud[data-emotion="焦虑"],
.chip--cloud[data-emotion="内耗"],
.chip--cloud[data-emotion="自我否定"] { font-size: var(--fs-16); font-weight: 500; }

.cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 4px 0 8px;
}

/* --------------------------------------------------------------- 12. 欢迎页 */
.page--welcome { min-height: calc(100dvh - 96px); }

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8vh 0 0;
  text-align: center;
  animation: hm-page-in var(--dur-400) var(--ease-out) both;
}

.welcome__mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: var(--r-28);
  font-size: 34px;
  color: var(--primary-ink);
  animation: hm-breathe 3.6s var(--ease-inout) infinite;
}

.welcome__title {
  margin: 2px 0 0;
  font-size: var(--fs-28);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.25;
  color: var(--text-1);
}

.welcome__sub {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 340px;
}

.welcome__main {
  margin: 0;
  font-size: var(--fs-20);
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-1);
}

.welcome__text {
  margin: 0;
  font-size: var(--fs-14);
  line-height: 1.6;
  color: var(--text-2);
}

.welcome__subtext {
  margin: 0;
  font-size: var(--fs-12);
  color: var(--text-3);
}

.welcome__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.welcome__return {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 64px;
  margin: 0;
  padding: 12px 16px;
  text-align: left;
}

.welcome__return-label { font-size: var(--fs-14); font-weight: 500; color: var(--text-1); }
.welcome__return-hint { font-size: var(--fs-12); color: var(--text-3); }

.welcome__foot {
  margin: 2px 0 0;
  font-size: var(--fs-12);
  color: var(--text-3);
}

.welcome > .btn { width: min(343px, 100%); }

/* --------------------------------------------------------------- 13. 签到 */
.mood-readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 2px 0 4px;
}

.mood-readout__num {
  font-size: var(--fs-28);
  font-weight: 600;
  line-height: 1.2;
  color: var(--blue-700);
  font-variant-numeric: tabular-nums;
}

.mood-readout__unit { font-size: var(--fs-14); color: var(--text-3); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-12);
  line-height: 1.4;
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.badge--streak { background: var(--warning-bg); color: var(--warning-ink); }
.badge--warning { background: var(--warning-bg); color: var(--warning-ink); }
.badge--success { background: var(--success-bg); color: var(--success-ink); }

#checkin-latest-summary { margin: 4px 2px 0; text-align: center; }

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline__item {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 10px 0 10px 18px;
  border-left: 2px solid var(--blue-200);
  margin-left: 6px;
}
.timeline__item::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue-600);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--blue-200);
}
.timeline__item.is-missing::before {
  background: #fff;
  border-color: var(--blue-300);
}
.timeline__date { flex: 0 0 auto; font-size: var(--fs-12); color: var(--text-3); }
.timeline__body { min-width: 0; }
.timeline__score { font-size: var(--fs-14); font-weight: 600; color: var(--text-1); }
.timeline__tags { font-size: 11px; color: var(--text-3); }
.timeline__note {
  margin: 2px 0 0;
  font-size: var(--fs-12);
  color: var(--text-3);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------- 14. 评估 */
.stepbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.stepbar__seg {
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--blue-200);
  transition: background-color var(--dur-250) ease;
}
.stepbar__seg.is-done { background: var(--blue-600); }
.stepbar__seg.is-current { background: var(--blue-400); }

.hintbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--r-12);
  background: var(--warning-bg);
  color: var(--warning-ink);
  font-size: var(--fs-12);
}

.phq4 { display: flex; flex-direction: column; gap: 12px; }

.phq4__item {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--glass-stroke);
  border-radius: var(--r-12);
  background: rgba(255, 255, 255, 0.42);
}

.phq4__item legend {
  padding: 0 4px;
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--text-1);
}

.phq4__options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.phq4__options .chip {
  min-height: 44px;
  padding: 0 10px;
  font-size: var(--fs-14);
}

.assess__nav {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.assess__nav .btn { flex: 1; }

.dual { margin-top: 12px; }

.dual__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 10px 0 2px;
}

.dual__label { font-size: var(--fs-14); font-weight: 500; color: var(--text-1); }

.dual__value {
  font-size: var(--fs-20);
  font-weight: 600;
  color: var(--blue-700);
  font-variant-numeric: tabular-nums;
}

.hintcard {
  display: flex;
  align-items: center;
  min-height: 56px;
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--blue-500);
  border-radius: var(--r-12);
  background: var(--glass-bg-dim);
  font-size: var(--fs-14);
  color: var(--text-2);
}

.beliefcard {
  padding: 16px;
  border-radius: var(--r-22);
  border-color: var(--blue-300);
}

.beliefcard__kicker {
  margin: 0 0 6px;
  font-size: var(--fs-12);
  color: var(--text-3);
}

.beliefcard__text {
  min-height: 72px;
  font-size: var(--fs-16);
  line-height: 1.6;
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.55);
}

.beliefcard__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

/* 信念候选卡（app-assessment 动态生成；勾选必须有明显视觉反馈） */
.belief-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 12px;
}

.beliefcard__option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  min-height: 44px;
  padding: 12px 14px 12px 42px;
  border: 1px solid var(--glass-stroke);
  border-radius: var(--r-12);
  background: rgba(255, 255, 255, 0.42);
  color: var(--text-1);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-150) ease, border-color var(--dur-150) ease,
              box-shadow var(--dur-150) ease, opacity var(--dur-150) ease;
}

.beliefcard__option::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border: 1.5px solid var(--blue-400);
  border-radius: 50%;
  background: #fff;
  color: transparent;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
}

.beliefcard__option-title {
  font-size: var(--fs-14);
  font-weight: 500;
}

.beliefcard__option-item {
  font-size: var(--fs-12);
  line-height: 1.45;
  color: var(--text-3);
}

.beliefcard__option:hover {
  background: rgba(255, 255, 255, 0.66);
  border-color: var(--blue-400);
}

.beliefcard__option[data-selected="1"],
.beliefcard__option.is-selected {
  border-color: var(--blue-600);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--blue-600);
}

.beliefcard__option[data-selected="1"]::before,
.beliefcard__option.is-selected::before {
  content: '✓';
  border-color: var(--blue-600);
  background: var(--blue-600);
  color: #fff;
}

.beliefcard__option[data-selected="1"] .beliefcard__option-title,
.beliefcard__option.is-selected .beliefcard__option-title {
  font-weight: 600;
  color: var(--primary-ink);
}

.beliefcard__option[data-rejected="1"] {
  opacity: 0.55;
}

.beliefcard__option[data-rejected="1"] .beliefcard__option-title,
.beliefcard__option[data-rejected="1"] .beliefcard__option-item {
  text-decoration: line-through;
}

.beliefcard .btn { margin-top: 8px; }

/* --------------------------------------------------------------- 15. 对话 */
.agentstrip {
  display: flex;
  align-items: center;
  min-height: 36px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  background: var(--agent-consult-bg);
  color: var(--agent-consult-ink);
  font-size: var(--fs-12);
  line-height: 1.4;
}

.chatlog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 44vh;
  min-height: 160px;
  margin-bottom: 8px;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border-radius: var(--r-22);
}

.msg { display: flex; }
.msg--user { justify-content: flex-end; }

.msg__bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 4px var(--r-22) var(--r-22) var(--r-22);
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--sh-1);
  font-size: var(--fs-16);
  line-height: 1.5;
  color: var(--text-1);
  overflow-wrap: anywhere;
  animation: hm-page-in var(--dur-250) var(--ease-out) both;
}
.msg--user .msg__bubble {
  border-radius: var(--r-22) 4px var(--r-22) var(--r-22);
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: var(--text-inv);
}

.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  width: max-content;
  margin: 2px 0 10px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}
.typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue-400);
  animation: hm-typing 1.2s infinite ease-in-out;
}
.typing__dot:nth-child(2) { animation-delay: 0.15s; }
.typing__dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes hm-typing {
  0%, 100% { transform: translateY(0); opacity: 0.45; }
  50% { transform: translateY(-3px); opacity: 1; }
}

.quickactions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.homework {
  margin-top: 16px;
  scroll-margin-top: 16px;
  padding: 14px;
  border-style: dashed;
  border-color: var(--blue-300);
  border-radius: var(--r-16);
}

.homework__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.homework__kicker { font-size: var(--fs-12); color: var(--text-3); }
.homework__body { font-size: var(--fs-16); line-height: 1.5; color: var(--text-1); }
.homework .btn { margin-top: 10px; }

.chatinput {
  margin-top: 10px;
  padding: 12px;
  border-radius: var(--r-22);
}
.chatinput textarea { min-height: 64px; background: rgba(255, 255, 255, 0.55); }
.chatinput__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.chatinput__send {
  margin-left: auto;
  min-width: 88px;
  min-height: 44px;
}

.recordband {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--r-pill);
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--sh-1);
}
.recordband__icon { font-size: 18px; }
.recordband__timer {
  font-size: var(--fs-12);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.wave {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
  height: 32px;
  overflow: hidden;
}
.wave span {
  flex: 1 1 3px;
  max-width: 3px;
  height: 32px;
  border-radius: var(--r-pill);
  background: var(--blue-500);
  transform-origin: 50% 50%;
  animation: hm-wave 900ms var(--ease-inout) infinite alternate;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.wave span[data-bar="1"] { --i: 0; }
.wave span[data-bar="2"] { --i: 1; }
.wave span[data-bar="3"] { --i: 2; }
.wave span[data-bar="4"] { --i: 3; }
.wave span[data-bar="5"] { --i: 4; }
.wave span[data-bar="6"] { --i: 5; }
.wave span[data-bar="7"] { --i: 6; }
.wave span[data-bar="8"] { --i: 7; }
.wave span[data-bar="9"] { --i: 8; }
.wave span[data-bar="10"] { --i: 9; }
.wave span[data-bar="11"] { --i: 10; }

#cbt-restart { margin-top: 10px; }

/* --------------------------------------------------------------- 16. 看板 */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  padding: 12px 8px;
  border-radius: var(--r-16);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--sh-1);
  -webkit-backdrop-filter: blur(var(--blur-18)) saturate(1.35);
  backdrop-filter: blur(var(--blur-18)) saturate(1.35);
  text-align: center;
}

.stat__num {
  display: block;
  font-size: var(--fs-24);
  font-weight: 600;
  line-height: 1.25;
  color: var(--blue-700);
  font-variant-numeric: tabular-nums;
}
.stat__label {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-12);
  color: var(--text-3);
  line-height: 1.35;
}

.mean {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 8px;
}
.mean__num {
  font-size: var(--fs-28);
  font-weight: 600;
  line-height: 1.2;
  color: var(--blue-700);
  font-variant-numeric: tabular-nums;
}
.mean__caption { font-size: var(--fs-12); color: var(--text-3); }

.chart {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 200px;
  padding: 12px;
  border: 1px dashed var(--blue-200);
  border-radius: var(--r-12);
  background: var(--glass-bg-dim);
}
.chart:empty::after {
  content: attr(data-placeholder);
  padding: 0 12px;
  font-size: var(--fs-12);
  color: var(--text-3);
  text-align: center;
}
.chart:not(:empty) {
  display: block;
  padding: 0;
  border-style: solid;
  border-color: transparent;
  background: transparent;
}
.chart canvas,
.chart svg { display: block; width: 100%; height: auto; }

.chart-fallback {
  margin-top: 10px;
  padding: 12px;
  border-radius: var(--r-12);
  background: var(--glass-bg-dim);
  font-size: var(--fs-12);
  color: var(--text-3);
  line-height: 1.5;
}

.noded {
  padding: 14px 16px;
  border-left: 3px solid var(--blue-800);
  background: var(--glass-bg-dim);
  border-radius: var(--r-16);
}
.noded__kicker { margin: 0 0 4px; font-size: var(--fs-12); color: var(--text-3); }
.noded__text {
  margin: 0;
  font-size: var(--fs-14);
  line-height: 1.7;
  color: var(--text-1);
}

.badges {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: var(--r-16);
  background: var(--blue-100);
  opacity: 0.55;
}
.badge-item__icon { font-size: 26px; line-height: 1; }
.badge-item__label { font-size: 11px; color: var(--text-3); }
.badge-item[data-unlocked="1"] {
  background: var(--glass-bg-strong);
  box-shadow: var(--sh-2), var(--glass-hi);
  opacity: 1;
  animation: hm-badge-pop var(--dur-400) var(--ease-spring) both;
}
.badge-item[data-unlocked="1"] .badge-item__label { color: var(--text-1); }

.entrycards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.entrycard {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 96px;
  margin: 0;
  padding: 14px;
  text-align: left;
  cursor: pointer;
}
.entrycard__icon { font-size: 20px; color: var(--blue-500); }
.entrycard__title { font-size: var(--fs-16); font-weight: 600; color: var(--text-1); }
.entrycard__sub { font-size: var(--fs-12); color: var(--text-3); }

/* --------------------------------------------------------------- 17. 沙盒 */
.sandbox-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 0;
  color: var(--text-3);
  font-size: var(--fs-14);
}
.sandbox-empty__mark {
  display: grid;
  place-items: center;
  width: 120px;
  height: 120px;
  border-radius: var(--r-22);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--sh-1);
  font-size: 48px;
  color: var(--blue-300);
}
.sandbox-empty p { margin: 0; }

.branchlist { display: flex; flex-direction: column; gap: 12px; }

.branchcard {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  grid-template-areas:
    "letter title"
    "letter desc"
    "letter meta";
  gap: 2px 12px;
  min-height: 96px;
  margin: 0;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-150) ease, transform var(--dur-150) ease;
}
.branchcard:hover { background: var(--glass-bg-strong); }
.branchcard:active { transform: translateY(-1px); }
.branchcard__letter {
  grid-area: letter;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--agent-consult);
  color: #fff;
  font-size: var(--fs-14);
  font-weight: 600;
}
.branchcard[data-branch="a"] .branchcard__letter { background: var(--agent-assess); }
.branchcard[data-branch="b"] .branchcard__letter { background: var(--agent-consult); }
.branchcard[data-branch="c"] .branchcard__letter { background: var(--agent-guard); }
.branchcard__title { grid-area: title; font-size: var(--fs-16); font-weight: 600; color: var(--text-1); }
.branchcard__desc { grid-area: desc; font-size: var(--fs-14); color: var(--text-2); line-height: 1.45; }
.branchcard__meta { grid-area: meta; font-size: var(--fs-12); color: var(--text-3); }
.branchcard[data-selected="1"] { box-shadow: inset 0 0 0 2px var(--blue-600), var(--sh-2); }

.deduction { padding: 16px; }
.deduction__title { margin: 0 0 10px; font-size: var(--fs-16); font-weight: 600; }
.deduction__text { font-size: var(--fs-14); color: var(--text-2); line-height: 1.6; }
.deduction__text ol { margin: 0 0 8px; padding-left: 1.2em; }
.deduction__text li { margin-bottom: 6px; }

/* ------------------------------------------------------------- 18. 微课堂 */
.progressblock { margin-bottom: 14px; }
.progressblock__head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: var(--fs-12);
  color: var(--text-3);
}
.progressblock__num { font-variant-numeric: tabular-nums; }

.progressbar {
  height: 6px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: var(--blue-200);
}
.progressbar__fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--grad-primary);
  transition: width var(--dur-250) var(--ease-out);
}

.chapterlist { display: flex; flex-direction: column; gap: 12px; }

.chaptercard {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  margin: 0;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
}
.chaptercard__num {
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: var(--fs-14);
  font-weight: 600;
}
.chaptercard__body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.chaptercard__title {
  font-size: var(--fs-16);
  font-weight: 500;
  color: var(--text-1);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chaptercard__meta { font-size: var(--fs-12); color: var(--text-3); }
.chaptercard__arrow { font-size: 20px; color: var(--blue-400); }
.chaptercard[data-read="1"] { opacity: 0.82; }
.chaptercard[data-read="1"] .chaptercard__title { color: var(--text-2); }
.chaptercard[data-read="1"] .chaptercard__arrow { color: var(--success-ink); }

.reader__body {
  margin-bottom: 14px;
  font-size: var(--fs-16);
  line-height: 1.7;
  color: var(--text-2);
}
.reader__body h3 { margin: 0 0 8px; font-size: var(--fs-20); color: var(--text-1); }
.reader__body p { margin-bottom: 12px; }

/* ---------------------------------------------------------- 19. 弹层 / sheet */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet__mask {
  position: absolute;
  inset: 0;
  background: rgba(35, 49, 60, 0.28);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.sheet__panel {
  position: relative;
  width: min(560px, 100%);
  max-height: 82dvh;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  border-radius: var(--r-28) var(--r-28) 0 0;
  box-shadow: var(--sh-3);
  animation: hm-sheet-in var(--dur-250) var(--ease-out) both;
}

@keyframes hm-sheet-in {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet__handle {
  display: block;
  width: 22px;
  height: 4px;
  margin: 4px auto 12px;
  border-radius: var(--r-pill);
  background: var(--blue-300);
}

.sheet__title { margin: 0 0 8px; font-size: var(--fs-20); font-weight: 600; }
.sheet__meta { margin: 0 0 14px; font-size: var(--fs-12); color: var(--text-3); }
.sheet__panel .btn { margin-bottom: 8px; }

.switchrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  font-size: var(--fs-14);
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--blue-200);
  cursor: pointer;
  transition: background-color var(--dur-150) ease;
}
.switch[aria-checked="true"] { background: var(--blue-600); }
.switch__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-1);
  transition: transform var(--dur-150) var(--ease-out);
}
.switch[aria-checked="true"] .switch__knob { transform: translateX(20px); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal__mask {
  position: absolute;
  inset: 0;
  background: rgba(35, 49, 60, 0.28);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.modal__card {
  position: relative;
  width: min(360px, calc(100% - 32px));
  max-height: 70vh;
  padding: 20px;
  overflow-y: auto;
  border-radius: var(--r-22);
  box-shadow: var(--sh-3);
  animation: hm-modal-in var(--dur-250) var(--ease-out) both;
}

@keyframes hm-modal-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.modal__title { margin: 0 0 10px; font-size: var(--fs-20); font-weight: 600; }
.modal__body {
  margin-bottom: 16px;
  font-size: var(--fs-14);
  line-height: 1.6;
  color: var(--text-2);
}
.modal__body p { margin-bottom: 8px; }
.modal__actions { display: flex; gap: 8px; }
.modal__actions .btn { flex: 1; }
.modal__card > .btn { margin-top: 4px; }

/* ------------------------------------------------------------- 20. 导航/提示 */
.nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 140;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  width: min(560px, 100%);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--glass-border);
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: var(--r-12) var(--r-12) 0 0;
  box-shadow: 0 -6px 24px rgba(52, 73, 92, 0.10);
  -webkit-backdrop-filter: blur(var(--blur-22)) saturate(1.35);
  backdrop-filter: blur(var(--blur-22)) saturate(1.35);
  transform: translateX(-50%);
}

.nav__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 4px;
  border: 0;
  border-radius: var(--r-12);
  background: transparent;
  color: var(--text-3);
  font: inherit;
  font-size: 11px;
  line-height: 1.3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--dur-150) ease, background-color var(--dur-150) ease;
}
.nav__btn:hover { background: rgba(255, 255, 255, 0.55); color: var(--primary-ink); }
.nav__btn.is-active,
.nav__btn[aria-current="page"] {
  color: var(--primary-ink);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.62);
}
.nav__icon { font-size: 18px; line-height: 1; }

.toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 260;
  width: min(420px, calc(100% - 32px));
  padding: 10px 16px;
  border-radius: var(--r-12);
  background: rgba(35, 51, 63, 0.92);
  color: #fff;
  font-size: var(--fs-14);
  line-height: 1.45;
  text-align: center;
  box-shadow: var(--sh-2);
  transform: translateX(-50%);
}

/* ------------------------------------------------------------- 21. 危机横幅 */
.crisis {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--danger-border);
  border-radius: var(--r-16);
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: var(--fs-14);
  line-height: 1.55;
}
.crisis strong { display: block; margin-bottom: 6px; font-size: var(--fs-16); }
.crisis a { color: var(--danger-ink); font-weight: 600; }
.crisis__note { margin-top: 6px; font-size: 11px; }
.crisis__actions { display: flex; gap: 8px; margin-top: 10px; }
.crisis__actions .btn { flex: 1; }

/* ------------------------------------------------------------- 22. 无障碍/降级 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .rip, .sheen, .bg-water::before { display: none !important; }
  .bg-water { background: var(--grad-bg); }
  .glass--sheen::after { display: none; }
  .welcome__mark { animation: none; }
  .wave span { animation: none; transform: scaleY(0.55); }
}

html[data-reduced-motion="on"] *,
html[data-reduced-motion="on"] *::before,
html[data-reduced-motion="on"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
html[data-reduced-motion="on"] .rip,
html[data-reduced-motion="on"] .sheen,
html[data-reduced-motion="on"] .bg-water::before,
html[data-reduced-motion="on"] .glass--sheen::after { display: none !important; }
html[data-reduced-motion="on"] .welcome__mark { animation: none; }
html[data-reduced-motion="on"] .wave span { animation: none; transform: scaleY(0.55); }

/* 窄屏：卡片 blur 降级到 14px（性能） */
@media (max-width: 379px) {
  .glass { -webkit-backdrop-filter: blur(var(--blur-14)) saturate(1.3); backdrop-filter: blur(var(--blur-14)) saturate(1.3); }
  .agent-bar, .nav { -webkit-backdrop-filter: blur(var(--blur-18)) saturate(1.35); backdrop-filter: blur(var(--blur-18)) saturate(1.35); }
}

/* Agent 栏窄屏降级（UI §4.4） */
@media (max-width: 359px) {
  .agent-state { display: none; }
  .agent-cell { justify-content: center; }
}
@media (max-width: 343px) {
  .agent-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: 68px;
    padding-bottom: 2px;
  }
  .agent-cell { height: 30px; }
  #agent-cell-supervisor { grid-column: 1 / -1; justify-content: center; }
  .agent-state { display: inline; font-size: 11px; }
}

/* 桌面：内容区 560 居中，Agent 栏 48px */
@media (min-width: 768px) {
  .agent-bar { height: 48px; }
  .agent-cell { height: 36px; }
  .agent-dot { flex-basis: 10px; width: 10px; height: 10px; }
}

@media (prefers-reduced-transparency: reduce) {
  .glass, .agent-bar, .nav, .stat {
    background: rgba(255, 255, 255, 0.90);
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* --------------------------------------------- 23. Agent 文案行 / 知识贴士 */
.agent-bar__line {
  /* #agent-bar：三 Agent 文案行（aria 语义文本，视觉由三格承载） */
  pointer-events: none;
}

.tips {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(560px, 100%);
  min-height: 52px;
  margin: 10px auto 0;
  padding: 10px 14px;
  border-radius: var(--r-16);
}

.tips__icon { flex: 0 0 auto; font-size: 18px; }

.tips__text {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--fs-14);
  line-height: 1.45;
  color: var(--text-2);
}

.tips__dots {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.tips__dot {
  width: 8px;
  min-width: 8px;
  height: 8px;
  min-height: 8px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--blue-300);
  cursor: pointer;
  transition: width var(--dur-150) ease, background-color var(--dur-150) ease;
}
.tips__dot.is-active { width: 16px; background: var(--blue-600); }

/* 图表兜底表格 */
.fallback-table {
  width: 100%;
  margin: 8px 0;
  border-collapse: collapse;
  font-size: var(--fs-12);
  color: var(--text-2);
}
.fallback-table th,
.fallback-table td {
  padding: 4px 6px;
  border-bottom: 1px dashed var(--blue-200);
  text-align: left;
}
.fallback-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* 无 JS 降级：七页容器不 hidden（契约 §4），app-core 启动后移除 .no-js */
html.no-js .page[hidden] { display: block !important; }
html.no-js .agent-bar,
html.no-js #page-nav { display: none; }
html.no-js .page + .page { margin-top: 24px; padding-top: 20px; border-top: 1px dashed var(--blue-200); }

/* --------------------------------------------- 24. V3 登录弹层 / 流式对话 / 安全卡 */
.authhint { margin: 0 0 12px; font-size: var(--fs-12); color: var(--text-3); }

.authinput {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--glass-stroke);
  border-radius: var(--r-12);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-16);
}
.authinput:focus {
  border-color: var(--blue-500);
  outline: none;
  box-shadow: 0 0 0 3px rgba(125, 155, 176, 0.22);
}

.auth-error {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: var(--r-8);
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: var(--fs-12);
  line-height: 1.45;
}

.settings-account-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

/* SSE 流式光标（逐字追加时显示） */
.msg__bubble.is-streaming::after {
  content: '▍';
  margin-left: 1px;
  color: var(--blue-500);
  animation: hm-cursor 900ms steps(2 end) infinite;
}
@keyframes hm-cursor {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* API done.suggestions：复用快捷话术 chips */
#chat-quick-actions .chip[data-quick] { border-color: var(--glass-stroke); }
.quickactions:not(:empty) { margin-top: 2px; }

/* 安全阻断卡（block 事件）：复用 crisis 视觉，追加资源列表 */
.crisis__resources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.crisis__resources a,
.crisis__resources span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--danger-border);
  color: var(--danger-ink);
  font-size: var(--fs-12);
  text-decoration: none;
}
