/* 芝麻智能 · 家长端小程序原型
   数值全部来自 brand-tokens.css（品牌 Token v2.2）；这里只做别名与组件，不写色值。 */
@import url('brand-tokens.css');
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@500&display=swap');

:root {
  --bg: var(--zhima-color-surface-page);
  --surface: var(--zhima-color-surface-paper);
  --fg: var(--zhima-color-text-primary);
  --muted: var(--zhima-color-text-secondary);
  --border: var(--zhima-color-border-divider);
  --accent: var(--zhima-color-brand-primary);

  --accent-pressed: var(--zhima-color-brand-pressed);
  --pressed: var(--zhima-color-surface-pressed);
  --selected: var(--zhima-color-surface-selected);
  --control: var(--zhima-color-border-control);
  --context: var(--zhima-color-chart-context);
  --range: var(--zhima-color-chart-range);
  --ink: var(--zhima-color-surface-inverse);
  --error: var(--zhima-color-status-error);
  --error-bg: var(--zhima-color-status-error-surface);
  --backdrop: var(--zhima-color-surface-backdrop);

  --font-title: var(--zhima-font-family-title);
  --font-ui: var(--zhima-font-family-ui);
  --font-hand: "Kaiti SC", "STKaiti", "KaiTi", var(--zhima-font-family-title);

  --m: var(--zhima-layout-miniprogram-page-margin);   /* 20 */
  --r: var(--zhima-radius-control);                   /* 8 */
  --gap-sec: 40px;   /* 区块之间 = space.10 */
  --gap-stack: 16px; /* 区块标题 → 内容 */
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font-family: var(--font-ui);
  font-size: var(--zhima-typography-miniprogram-body-font-size);
  line-height: var(--zhima-typography-miniprogram-body-line-height);
  line-break: strict; overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
p, h1, h2, h3, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.icon { width: 24px; height: 24px; flex: none; }
.icon.sm { width: 20px; height: 20px; }

/* ---------- 设备框（桌面预览用；窄屏直接全屏） ---------- */
.stage { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.device {
  width: 390px; height: 844px; position: relative; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border); border-radius: 48px;
  display: flex; flex-direction: column;
  outline: 10px solid var(--ink); outline-offset: 0;
}
.statusbar { height: 47px; flex: none; display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 28px 8px 34px; font-size: 15px; font-weight: 500; }
.statusbar .dots { display: flex; gap: 6px; align-items: center; }
.statusbar .dots i { display: block; width: 17px; height: 10px; border: 1.5px solid var(--fg); border-radius: 3px; }
.statusbar .dots b { display: block; width: 16px; height: 10px; background: var(--fg); border-radius: 2px; }

.wxnav { height: 44px; flex: none; display: grid; grid-template-columns: 96px 1fr 96px; align-items: center;
  padding: 0 7px 0 6px; background: var(--bg); position: relative; z-index: 100; }
.wxnav .back { width: 44px; height: 44px; display: grid; place-items: center; color: var(--fg); border-radius: var(--r); }
.wxnav .back:active { background: var(--pressed); }
.wxnav .t { text-align: center; font-size: 17px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.capsule { justify-self: end; width: 87px; height: 32px; border: 1px solid var(--border); border-radius: 16px;
  display: grid; grid-template-columns: 1fr 1px 1fr; align-items: center; background: var(--surface); }
.capsule span { display: grid; place-items: center; }
.capsule .sep { height: 18px; background: var(--border); }
.capsule .more { display: flex; gap: 3px; justify-content: center; }
.capsule .more i { width: 4px; height: 4px; border-radius: 2px; background: var(--fg); }
.capsule .ring { width: 16px; height: 16px; border: 1.5px solid var(--fg); border-radius: 50%; position: relative; }
.capsule .ring::after { content: ''; position: absolute; inset: 3.5px; background: var(--fg); border-radius: 50%; }

.screen { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; position: relative; }
.screen::-webkit-scrollbar { display: none; }
.homebar { height: 34px; flex: none; display: grid; place-items: center; background: var(--bg); }
.homebar::after { content: ''; width: 134px; height: 5px; border-radius: 3px; background: var(--fg); }

@media (max-width: 480px) {
  .stage { padding: 0; display: block; }
  .device { width: 100%; height: 100vh; height: 100dvh; border: 0; border-radius: 0; outline: 0; }
  .statusbar { display: none; }
  .homebar { height: env(safe-area-inset-bottom); }
  .homebar::after { display: none; }
}

/* ---------- 版式 ---------- */
.page { padding: 8px var(--m) 48px; }
.head { padding: 12px 0 28px; }
.kicker { font-size: 14px; line-height: 22px; color: var(--muted); }
.title { font-family: var(--font-title); font-weight: 500;
  font-size: var(--zhima-typography-miniprogram-page-title-font-size);
  line-height: var(--zhima-typography-miniprogram-page-title-line-height); margin-top: 4px; }
.caption { font-size: 14px; line-height: 22px; color: var(--muted); }
.sec { padding-top: var(--gap-sec); }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding-bottom: 12px; border-bottom: 1px solid var(--fg); margin-bottom: 4px; }
.sec-h h2 { font-size: 18px; line-height: 28px; font-weight: 500; }
.sec-h .caption { flex: none; }
.sec-note { padding: 10px 0 4px; }
.hot { color: var(--accent); }
.strong { font-weight: 500; }

/* 关键数字 */
.key { display: flex; align-items: flex-end; gap: 6px; }
.key .n { font-size: 56px; line-height: 1; font-weight: 400; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.key .of { font-size: 16px; color: var(--muted); padding-bottom: 6px; }
.facts { margin-top: 16px; display: grid; gap: 0; border-top: 1px solid var(--border); }
.facts li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.facts li .v { font-variant-numeric: tabular-nums; text-align: right; }

/* 列表行 */
.rows > li + li, .rows > a + a { border-top: 1px solid var(--border); }
.row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 0; width: 100%; text-align: left;
  transition: background var(--zhima-motion-press-restore); }
a.row:active, button.row:active { background: var(--pressed); transition: none; }
a.row:active .caption, button.row:active .caption { color: var(--zhima-color-text-secondary-pressed); }
.row .body { flex: 1; min-width: 0; }
.row .lt { font-size: 16px; line-height: 24px; font-weight: 500; }
.row .end { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.row .chev { color: var(--accent); flex: none; }
.row .chev.off { visibility: hidden; }
.rows.bleed .row { margin: 0 calc(var(--m) * -1); padding-left: var(--m); padding-right: var(--m); width: calc(100% + var(--m) * 2); }

/* 比例条 */
.meter { position: relative; height: 6px; background: var(--border); margin-top: 8px; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--context); }
.meter > i.focus { background: var(--accent); }
.meter > b { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--fg); }
.meter > u { position: absolute; top: -3px; bottom: -3px; border-left: 1px dashed var(--accent); }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 96px; height: 44px; padding: 0 20px;
  border-radius: var(--r); font-size: 16px; line-height: 24px; font-weight: 500; white-space: nowrap;
  transition: background var(--zhima-motion-press-restore), color var(--zhima-motion-press-restore); }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--zhima-color-text-on-brand); }
.btn.primary:active { background: var(--accent-pressed); transition: none; }
.btn.secondary { border: 1px solid var(--accent); color: var(--accent); }
.btn.secondary:active { background: var(--pressed); color: var(--accent-pressed); transition: none; }
.btn.text { min-width: 0; padding: 0 8px; color: var(--accent); }
.btn.text:active { background: var(--pressed); }
.btn[disabled] { background: var(--zhima-color-border-disabled); color: var(--zhima-color-text-disabled); border-color: var(--zhima-color-border-disabled); cursor: not-allowed; }
.link { color: var(--accent); display: inline-flex; align-items: center; gap: 4px; min-height: 44px; }
.link:active { color: var(--accent-pressed); }

/* 标签 */
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: var(--zhima-radius-pill);
  border: 1px solid var(--border); font-size: 13px; line-height: 1; color: var(--muted); white-space: nowrap; }
.tag.auto { border-style: dashed; border-color: var(--control); }
.tag.hot { border-color: var(--accent); color: var(--accent); }

/* 摘要与建议 */
.summary { padding: 16px 0 0; }
.summary p { font-size: 16px; line-height: 28px; margin-top: 10px; }
.src { font-size: 13px; line-height: 20px; color: var(--muted); margin-top: 10px; }
.src b { color: var(--fg); font-weight: 500; margin-right: 4px; }
.advice { counter-reset: adv; }
.advice li { display: grid; grid-template-columns: 28px 1fr; gap: 4px 8px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.advice li::before { counter-increment: adv; content: counter(adv, decimal-leading-zero); font-family: var(--font-title);
  font-weight: 500; font-size: 15px; line-height: 26px; color: var(--muted); letter-spacing: 0.05em; }
.advice li p { grid-column: 2; }
.advice li .src { grid-column: 2; margin-top: 4px; }

/* 手写作答 */
.paper { background: var(--surface); border: 1px solid var(--border); padding: 14px 16px 16px;
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--bg) 31px 32px); background-position: 0 14px; }
.paper .hand { font-family: var(--font-hand); font-size: 18px; line-height: 32px; color: var(--fg); }
.paper .mark { font-size: 14px; line-height: 22px; color: var(--accent); margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--accent); }
.qtext { font-size: 16px; line-height: 28px; }
.blank { font-size: 15px; line-height: 24px; color: var(--muted); padding: 14px 0; }

/* 开关 */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--range); transition: background 150ms; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border); transition: transform 150ms; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); border-color: var(--accent); }

/* 趋势柱 */
.bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; align-items: end; height: 168px; padding-top: 24px; position: relative; }
.bars .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.bars .v { font-size: 15px; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.bars .bar { width: 100%; max-width: 44px; background: var(--context); position: relative; }
.bars .bar.focus { background: var(--accent); }
.bars .avg { position: absolute; left: -6px; right: -6px; height: 0; border-top: 2px solid var(--fg); }
.bars-x { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; border-top: 1px solid var(--fg); padding-top: 8px; }
.bars-x span { text-align: center; font-size: 13px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; line-height: 20px; color: var(--muted); padding-top: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; vertical-align: -1px; margin-right: 6px; background: var(--context); }
.legend i.focus { background: var(--accent); }
.legend i.line { height: 0; border-top: 2px solid var(--fg); width: 14px; vertical-align: 3px; background: none; }
.legend i.dash { height: 10px; width: 0; border-left: 1px dashed var(--accent); background: none; margin-left: 4px; margin-right: 9px; }
.legend i.range { background: var(--range); }

/* 堆叠条 */
.stack { display: flex; height: 28px; gap: 2px; margin-top: 16px; }
.stack > i { display: block; background: var(--context); }
.stack > i.focus { background: var(--accent); }
.stack > i.range { background: var(--range); }

/* 状态 */
.state { display: grid; justify-items: center; text-align: center; padding: 96px 12px 48px; gap: 12px; }
.state .big { width: 64px; height: 64px; color: var(--muted); }
.state .big.err { color: var(--error); }
.state h2 { font-family: var(--font-title); font-weight: 500; font-size: 21px; line-height: 30px; margin-top: 8px; }
.state p { color: var(--muted); max-width: 18em; }
.state .btn { margin-top: 12px; }
.spin { animation: spin 900ms linear infinite; color: var(--zhima-color-loading-indicator); }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { background: var(--border); height: 14px; margin: 10px 0; opacity: .7; }
.errbar { display: flex; gap: 10px; align-items: flex-start; background: var(--error-bg); padding: 12px 14px; border-radius: var(--r); }
.errbar .icon { color: var(--error); }
.errbar b { color: var(--error); font-weight: 500; display: block; }

/* Toast */
.toast { position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%); max-width: calc(100% - 40px);
  background: var(--ink); color: var(--zhima-color-text-on-inverse); border-radius: var(--r); padding: 11px 16px;
  font-size: 15px; line-height: 22px; display: flex; gap: 8px; align-items: center; z-index: 500;
  opacity: 0; pointer-events: none; transition: opacity var(--zhima-motion-fade); }
.toast.on { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .spin { animation-duration: 2400ms; }
}
