/* 在场 · 样式
 * 不引任何外部字体 / CSS / 图片：整个界面零网络依赖。
 */
:root {
  --bg: #0d1117;
  --bg2: #131a23;
  --line: #232c38;
  --fg: #e6edf3;
  --dim: #8b98a9;
  --ok: #3fb950;
  --warn: #d29922;
  --hot: #f85149;
  --idle: #39414d;
  --accent: #58a6ff;
  --r: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC",
        "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
}
body { display: flex; }
b { color: #fff; font-weight: 600; }

/* ── 屏幕切换 ─────────────────────────────────── */
.screen { display: none; flex: 1; min-width: 0; }
.screen.is-on { display: flex; animation: in .35s ease both; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } }

.wrap {
  margin: auto; width: 100%; max-width: 460px;
  padding: 28px 22px calc(28px + env(safe-area-inset-bottom));
  text-align: center;
}
.wrap.wide { max-width: 560px; }

.brand {
  font-size: 46px; font-weight: 300; letter-spacing: .34em;
  margin: 0 0 6px; text-indent: .34em;
  background: linear-gradient(100deg, #fff, #7ee0a0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { color: var(--dim); margin: 0 0 26px; font-size: 14.5px; }

/* ── 开始页 ───────────────────────────────────── */
.promises { list-style: none; padding: 0; margin: 0 0 26px; text-align: left; }
.promises li {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 15px; margin-bottom: 9px; font-size: 13.5px; color: var(--dim);
}
.promises .k { display: block; color: var(--fg); font-size: 14.5px; font-weight: 600; margin-bottom: 2px; }

.setup { display: flex; gap: 10px; margin-bottom: 18px; }
.setup label { flex: 1; font-size: 12.5px; color: var(--dim); }
.setup select {
  width: 100%; margin-top: 5px; padding: 10px; font-size: 15px;
  background: var(--bg2); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px;
}

.btn-primary, .btn-ghost, .btn-stop {
  width: 100%; padding: 15px; font-size: 16px; font-weight: 600;
  border: 0; border-radius: 13px; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--ok); color: #06210d; }
.btn-primary:disabled { background: var(--idle); color: #8b98a9; cursor: default; }
.btn-ghost { background: transparent; color: var(--dim); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--fg); }
.fine { color: #5c6874; font-size: 12px; margin: 14px 0 0; }
.fine.err { color: var(--hot); }

/* ── 校准页 ───────────────────────────────────── */
.calib-ring {
  width: 128px; height: 128px; margin: 34px auto 22px; border-radius: 50%;
  border: 2px solid var(--line); display: flex;
  align-items: baseline; justify-content: center;
}
.calib-n { font-size: 52px; font-weight: 300; line-height: 128px; }
.calib-d { color: var(--dim); font-size: 15px; }
.calib-bar { height: 5px; background: var(--bg2); border-radius: 3px; margin: 26px 0 22px; overflow: hidden; }
.calib-bar i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .4s; }
#s-calib h2 { font-size: 19px; font-weight: 500; margin: 0 0 8px; }

/* ── 进行中 ───────────────────────────────────── */
.live { margin: auto; width: 100%; max-width: 520px; padding: 22px 20px; display: flex; flex-direction: column; }
.live-top { text-align: center; margin-bottom: 26px; }
.clock { font-size: 46px; font-weight: 200; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.live-sub { color: var(--dim); font-size: 13px; margin-top: 2px; }
.live-sub.warn { color: var(--warn); }

.lamps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }
.lamp {
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px 8px 16px; text-align: center; transition: border-color .3s, background .3s;
}
.lamp-t { font-size: 12.5px; color: var(--dim); margin-top: 13px; }
.lamp-s { font-size: 13px; margin-top: 3px; font-variant-numeric: tabular-nums; min-height: 20px; }
.bulb {
  width: 34px; height: 34px; margin: 0 auto; border-radius: 50%;
  background: var(--idle); transition: all .35s;
}
.lamp[data-state="ok"]   { border-color: #1c3a24; }
.lamp[data-state="ok"]   .bulb { background: var(--ok); box-shadow: 0 0 22px #3fb95077; }
.lamp[data-state="ok"]   .lamp-s { color: #7ee0a0; }
.lamp[data-state="warn"] { border-color: #3d3316; }
.lamp[data-state="warn"] .bulb { background: var(--warn); box-shadow: 0 0 22px #d2992277; }
.lamp[data-state="warn"] .lamp-s { color: #e3b341; }
.lamp[data-state="hot"]  { border-color: #4a2320; background: #1c1315; }
.lamp[data-state="hot"]  .bulb { background: var(--hot); box-shadow: 0 0 26px #f8514988; animation: pulse 1.6s infinite; }
.lamp[data-state="hot"]  .lamp-s { color: #ff7b72; }
@keyframes pulse { 50% { opacity: .55; } }

.focus { text-align: center; margin: 30px 0; }
.focus-l { color: var(--dim); font-size: 12.5px; }
.focus-v { font-size: 34px; font-weight: 200; font-variant-numeric: tabular-nums; }

.live-foot { margin-top: auto; padding-top: 20px; }
.privacy {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  color: var(--dim); font-size: 12px; margin-bottom: 12px;
}
.privacy .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.privacy.bad .dot { background: var(--hot); }
.privacy.bad { color: var(--hot); }
.btn-stop { background: var(--bg2); color: var(--dim); border: 1px solid var(--line); }
.btn-stop:hover { color: var(--fg); border-color: #3d4653; }

/* ── 提示条 ───────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 14%; transform: translate(-50%, 20px);
  background: #1c2128; border: 1px solid var(--line); border-left: 3px solid var(--warn);
  padding: 13px 20px; border-radius: 11px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: all .3s; z-index: 50;
  max-width: 84vw; text-align: left;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── 报告页 ───────────────────────────────────── */
.rep-title { font-size: 21px; font-weight: 500; margin: 8px 0 4px; line-height: 1.5; }
.rep-when { color: var(--dim); font-size: 13px; margin: 0 0 30px; }
.rep-hero {
  background: linear-gradient(160deg, #16211a, var(--bg2));
  border: 1px solid #1e3325; border-radius: var(--r);
  padding: 28px 20px; margin-bottom: 14px;
}
.hero-n { font-size: 62px; font-weight: 200; line-height: 1; color: #7ee0a0; font-variant-numeric: tabular-nums; }
.hero-l { color: var(--dim); font-size: 13px; margin-top: 8px; }
.rep-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.cell { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 15px; }
.cell b { display: block; font-size: 21px; font-weight: 400; font-variant-numeric: tabular-nums; }
.cell span { font-size: 12.5px; color: var(--dim); }
.rep-advice { list-style: none; padding: 0; margin: 0 0 26px; text-align: left; }
.rep-advice li {
  font-size: 13.5px; color: var(--dim); padding: 11px 0 11px 16px;
  border-left: 2px solid var(--line); margin-bottom: 8px; position: relative;
}
.rep-advice li::before { content: "·"; position: absolute; left: 5px; color: var(--ok); font-weight: 700; }
.rep-actions { display: flex; gap: 10px; }
.rep-actions .btn-ghost { flex: 0 0 40%; }

@media (max-width: 360px) {
  .lamps { gap: 7px; }
  .lamp { padding: 15px 4px 12px; }
  .lamp-t { font-size: 11.5px; }
  .clock { font-size: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── 构图检查（家长主动开启的 5 秒预览）─────────────────
   整个自习过程中没有预览窗口；这里是唯一的例外，
   因为架歪了会静默失灵，必须让人先看见画面。 */
.framing {
  position: fixed; inset: 0; z-index: 100;
  background: #000; display: none; flex-direction: column;
}
.framing.on { display: flex; }
#cam-frame {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1);   /* 镜像，跟照镜子一样 */
}
#frame-ov { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame-top {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 12px;
  padding: calc(18px + env(safe-area-inset-top)) 20px 18px;
  background: linear-gradient(#000c, #0000); font-size: 14px; color: #fff;
}
.frame-timer {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  background: #fff; color: #000; font-weight: 700; font-size: 17px;
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.frame-result {
  position: relative; z-index: 2; margin: auto 18px 0; padding: 15px 18px;
  background: #0d1117ee; border: 1px solid var(--line); border-radius: 13px;
  font-size: 14.5px; line-height: 1.6; text-align: left; min-height: 62px;
}
.frame-result.good { border-color: #1e3325; }
.frame-result.bad  { border-color: #4a2320; }
.frame-result b { display: block; font-size: 16px; margin-bottom: 3px; }
.frame-note {
  position: relative; z-index: 2; text-align: center;
  padding: 14px 20px calc(20px + env(safe-area-inset-bottom));
  font-size: 12px; color: #7d8894;
}


/* ══ 静默模式 ══════════════════════════════════════════
   孩子写的是纸质作业，大部分时间没在看屏幕。
   所以"一切正常"的时候，屏幕应该安静到几乎不存在；
   越安静，出事那一下才越有冲击力。 */
.live.all-ok .lamp { background: transparent; border-color: transparent; }
.live.all-ok .lamp-t { color: #39414d; }
.live.all-ok .lamp-s { color: #39414d; }
.live.all-ok .bulb { width: 22px; height: 22px; opacity: .5; box-shadow: none; }
.live.all-ok .focus { opacity: .45; }
.live.all-ok .clock { opacity: .55; }

/* ══ 提醒 ══════════════════════════════════════════════
   孩子不看屏幕也能感觉到：颜色从余光里就能捕捉到，
   声音是不看也知道在说什么，大字是留给"真看见了"的人。 */
#flash {
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
}
#flash.on { display: flex; animation: flashIn .28s ease both; }
#flash.fade { animation: flashOut .5s ease both; }
@keyframes flashIn  { from { opacity: 0; } }
@keyframes flashOut { to   { opacity: 0; } }
#flash .f-ico   { font-size: 60px; line-height: 1; }
#flash .f-words {
  font-size: 30px; font-weight: 600; letter-spacing: .02em;
  padding: 0 28px; text-align: center; line-height: 1.35;
}
#flash.f-headLow { background: #3d1f1f; }  #flash.f-headLow .f-words { color: #ffc9c4; }
#flash.f-slouch  { background: #1f2f3d; }  #flash.f-slouch  .f-words { color: #bcd9ff; }
#flash.f-away   { background: #3d3316; }  #flash.f-away   .f-words { color: #ffe6a8; }
#flash.f-done   { background: #16301f; }  #flash.f-done   .f-words { color: #b6f0c4; }

@media (prefers-reduced-motion: reduce) {
  #flash.on, #flash.fade { animation: none; }
  #flash.fade { display: none; }
}

/* ══ 正向信号 ══════════════════════════════════════════
   刻意做成"不动、不闪、不出声"：孩子没抬头就完全感知不到，
   一抬头就看见自己攒下了几颗。打断专注的反馈在这里是负分。 */
.pips { display: flex; justify-content: center; gap: 9px; margin-top: 16px; height: 10px; }
.pips i {
  width: 9px; height: 9px; border-radius: 50%;
  background: #1c2430; transition: background .6s, box-shadow .6s, transform .6s;
}
.pips i.on {
  background: #3fb950; box-shadow: 0 0 10px #3fb95066; transform: scale(1.12);
}
/* 里程碑：一圈很淡的绿，缓缓淡出。不是闪烁，是"刚才那段是好的" */
.live .calm { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.live.milestone::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  box-shadow: inset 0 0 120px 20px #1d4d2b; animation: calmGlow 9s ease-out both;
}
@keyframes calmGlow {
  0%   { opacity: 0; }
  18%  { opacity: .85; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .live.milestone::after { animation: none; opacity: .5; }
}

/* ══ 报告：先说好的 ══════════════════════════════════════
   原来四项指标同权重并排，视觉上等于在骂人。
   现在：安静学习占屏幕最大一块，低头驼背退成时间轴上的细色块。 */
.rep-hero { position: relative; }
.hero-span { color: #7d8894; font-size: 13px; margin-top: 10px; }

.tl { margin: 0 0 20px; }
.tl-bar {
  display: flex; height: 26px; border-radius: 7px; overflow: hidden;
  background: #131a23; border: 1px solid var(--line);
}
.tl-bar span { display: block; min-width: 1px; }
.tl-bar .s-focus  { background: #2ea043; }
.tl-bar .s-dip    { background: #6b5a2a; }
.tl-bar .s-slouch { background: #8a5a24; }
.tl-bar .s-deepLow{ background: #8a3a34; }
.tl-bar .s-away   { background: #2b3038; }
.tl-axis {
  display: flex; justify-content: space-between;
  color: #5c6874; font-size: 11px; margin-top: 5px;
  font-variant-numeric: tabular-nums;
}
.tl-key { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.tl-key span { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: #6b7684; }
.tl-key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.tl-key .k-focus{ background: #2ea043; }
.tl-key .k-dip  { background: #6b5a2a; }
.tl-key .k-slouch{ background: #8a5a24; }
.tl-key .k-away { background: #2b3038; }

.rep-good { text-align: left; margin: 0 0 18px; }
.rep-good div {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 0 11px 14px;
  border-left: 2px solid #1e3325; margin-bottom: 7px;
  font-size: 13.5px; color: #b8c2cc; line-height: 1.6;
}
.rep-good div::before { content: "✓"; color: #3fb950; font-weight: 700; flex: 0 0 auto; }
.rep-good b { color: #7ee0a0; font-weight: 600; }

.rep-more { margin: 0 0 20px; }
.rep-more summary {
  cursor: pointer; color: #6b7684; font-size: 13px; padding: 9px 0;
  list-style: none; user-select: none;
}
.rep-more summary::-webkit-details-marker { display: none; }
.rep-more summary::before { content: "＋ "; }
.rep-more[open] summary::before { content: "－ "; }
.rep-more[open] summary { color: #8b98a9; }
.rep-more .rep-grid { margin-top: 6px; }

/* ══ 久坐记录 ══════════════════════════════════════════ */
.trend { margin: 0 0 22px; text-align: left; }
.trend-h { font-size: 12.5px; color: var(--dim); margin-bottom: 9px; }
.trend-bars { display: flex; align-items: flex-end; gap: 6px; height: 72px; }
.trend-bars i {
  flex: 1; background: #1e3325; border-radius: 4px 4px 2px 2px;
  min-height: 3px; position: relative; transition: height .4s;
}
.trend-bars i.today { background: #3fb950; }
.trend-bars i span {
  position: absolute; bottom: -17px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: #5c6874; font-style: normal;
}
.trend-delta { font-size: 13.5px; margin-bottom: 10px; }
.trend-delta.up { color: #7ee0a0; }
.trend-delta.down { color: #ff9d94; }
.trend-delta.flat { color: var(--dim); }
