/* steady · style.css — elder-first UI: huge type, high contrast, one thing per screen. */

:root {
  --bg: #FFFDF6;
  --ink: #1C1B19;
  --muted: #5C5850;
  --primary: #0E6B4A;
  --primary-dark: #0A523A;
  --primary-soft: #E3F2EB;
  --accent: #1D5FA8;
  --warn-bg: #FFF4DE;
  --warn-ink: #7A4E00;
  --danger: #B3261E;
  --card: #FFFFFF;
  --line: #D8D3C8;
  --shadow: 0 2px 10px rgba(40, 35, 20, 0.08);
  --radius: 18px;
  --skeleton: #34d399;
}

/* base text size ≥22px; user-adjustable in settings */
html { font-size: 22px; }
html.fs-large { font-size: 25px; }
html.fs-xl { font-size: 28px; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 0.95rem; }

h2 { font-size: 1.5rem; margin: 0.4em 0; }
h3 { font-size: 1.15rem; margin: 1em 0 0.4em; }
p { margin: 0.5em 0; }
a { color: var(--accent); }

/* ---------- file:// guard ---------- */
#file-warning {
  max-width: 640px;
  margin: 6vh auto;
  padding: 0 22px;
  text-align: center;
}

/* ---------- topbar ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 2px solid var(--line);
}
#topbar h1 { font-size: 1.2rem; margin: 0; font-weight: 700; }
.btn-icon {
  min-width: 64px;
  min-height: 56px;
  font-size: 1.5rem;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.btn-icon:active { transform: scale(0.97); }

/* ---------- screens ---------- */
#app { max-width: 780px; margin: 0 auto; padding: 18px 18px 56px; }
.screen { display: none; }
.screen.active { display: block; animation: fadein 0.18s ease-out; }
@keyframes fadein { from { opacity: 0.4; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 72px;
  padding: 12px 26px;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: var(--primary);
  border: 3px solid var(--primary);
  border-radius: var(--radius);
  cursor: pointer;
  width: 100%;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-big { min-height: 84px; font-size: 1.3rem; }
.btn-secondary { background: var(--card); color: var(--primary-dark); }
.btn-ghost {
  background: transparent;
  color: var(--primary-dark);
  border-color: transparent;
  text-decoration: underline;
  min-height: 60px;
  font-weight: 600;
}
.btn-danger { background: var(--card); color: var(--danger); border-color: var(--danger); }
.btn-card {
  background: var(--card);
  color: var(--ink);
  border: 3px solid var(--line);
  justify-content: flex-start;
  text-align: left;
  font-size: 1.2rem;
}
.btn-card:hover, .stance-card:hover { border-color: var(--primary); }
:focus-visible { outline: 4px solid var(--accent); outline-offset: 2px; }

.stack { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.stack-row { display: flex; gap: 14px; margin: 18px 0; }
.stack-row .btn { flex: 1; }

/* ---------- chips ---------- */
.chip-grid { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 4px; }
.chip {
  min-height: 64px;
  padding: 8px 22px;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.chip.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.chip-streak {
  display: inline-flex;
  align-items: center;
  border-color: transparent;
  background: var(--primary-soft);
  color: var(--primary-dark);
  margin: 6px 0 2px;
  cursor: default;
}

/* ---------- cards & banners ---------- */
.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
.card-note { border-left: 8px solid var(--primary); }
.banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin: 12px 0;
  font-weight: 600;
}
.banner-safety { background: var(--primary-soft); color: var(--primary-dark); }
.banner-warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner-privacy { background: #EAF1FA; color: #143D6B; }

/* ---------- home ---------- */
.home-head { margin-top: 8px; }
.home-title { font-size: 2rem; font-weight: 800; }
.home-latin { color: var(--primary); font-size: 1.2rem; font-weight: 700; }
.tile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 16px 0;
}
@media (min-width: 640px) { .tile-grid { grid-template-columns: 1fr 1fr; } }
.tile {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 110px;
  padding: 18px 22px;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: inherit;
  text-align: left;
  color: var(--ink);
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.tile:hover { border-color: var(--primary); }
.tile:active { transform: scale(0.985); }
.tile-icon { font-size: 2.4rem; }
.home-links { display: flex; gap: 10px; flex-wrap: wrap; }
.home-links .btn { width: auto; flex: 1; }
.privacy-foot { color: var(--muted); font-size: 0.9rem; text-align: center; margin-top: 18px; }

.hero-mark {
  width: 120px;
  height: 120px;
  margin: 24px auto 8px;
  border-radius: 30px;
  background: var(--primary);
  color: #fff;
  font-size: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

/* ---------- steps list ---------- */
.steps { padding-left: 0; list-style: none; counter-reset: step; margin: 14px 0; }
.steps li {
  counter-increment: step;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 10px 0;
  font-size: 1.1rem;
  font-weight: 600;
}
.steps li::before {
  content: counter(step);
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

/* ---------- camera stage ---------- */
.stage-slot { margin: 10px 0; }
#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 52vh;
  background: #10231C;
  border-radius: var(--radius);
  overflow: hidden;
}
#cam, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#cam { transform: scaleX(-1); }
#stage.demo #cam { display: none; }
#stage-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
}
.status-line {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 8px;
}
.status-line.ok { color: var(--primary-dark); }

/* ---------- run screens ---------- */
.screen-run .stage-slot { margin-top: 0; }
.run-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 130px;
}
.big-count {
  font-size: clamp(72px, 18vmin, 150px);
  font-weight: 800;
  line-height: 1;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}
.big-count.pop { animation: pop 0.35s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.18); } 100% { transform: scale(1); } }
.ring { width: 130px; height: 130px; flex: 0 0 auto; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 10; }
.ring-fg {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
}
.ring-text { font-size: 38px; font-weight: 800; fill: var(--ink); }
.countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(120px, 40vmin, 320px);
  font-weight: 800;
  color: #fff;
  background: rgba(10, 40, 30, 0.82);
}

/* ---------- results ---------- */
.result-num {
  text-align: center;
  font-size: clamp(88px, 24vmin, 180px);
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.result-band { font-size: 1.2rem; font-weight: 700; text-align: center; }
.note-item {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 8px 0;
  font-weight: 600;
}

/* ---------- training ---------- */
.ex-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.ex-card:hover { border-color: var(--primary); }
.ex-card .ex-emoji { font-size: 2rem; }
.ex-card .ex-meta { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.ex-card.locked { opacity: 0.55; }
.ex-card.done-today { border-color: var(--primary); background: var(--primary-soft); }
.ex-check { margin-left: auto; font-size: 1.6rem; color: var(--primary-dark); }
.level-badge {
  font-size: 0.75rem;
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 700;
}
.ex-icon { font-size: 96px; text-align: center; margin: 10px 0; }
.ex-icon-run { font-size: 140px; margin: 0; }
.howto { font-size: 1.2rem; font-weight: 600; }
.safety-chip {
  display: inline-block;
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: 999px;
  padding: 6px 16px;
  margin: 4px 6px 4px 0;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------- captions & toast ---------- */
#caption-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(92vw, 760px);
  background: rgba(20, 20, 18, 0.88);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 14px 26px;
  border-radius: 16px;
  text-align: center;
}
#toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--primary-dark);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 14px;
}

/* ---------- dialog ---------- */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 24px;
  max-width: min(92vw, 520px);
  font-size: 1.1rem;
  font-family: inherit;
  color: var(--ink);
}
dialog::backdrop { background: rgba(20, 20, 18, 0.5); }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; }
.chart-grid { stroke: var(--line); stroke-width: 1.5; }
.chart-band { fill: var(--primary-soft); }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 5; stroke-linejoin: round; }
.chart-dot { fill: var(--primary-dark); }
.chart-bar { fill: var(--primary); }
.chart-tick { font-size: 22px; fill: var(--muted); font-weight: 600; }
.chart-val { font-size: 24px; fill: var(--ink); font-weight: 800; }

/* ---------- print report ---------- */
.print-only { display: none; }
@media print {
  body * { visibility: hidden; }
  #report, #report * { visibility: visible; }
  .print-only { display: block; }
  #report {
    position: absolute;
    inset: 0;
    padding: 24px;
    font-size: 14px;
    color: #000;
    background: #fff;
  }
  #report h1 { font-size: 22px; margin: 0 0 4px; }
  #report table { width: 100%; border-collapse: collapse; margin: 12px 0; }
  #report th, #report td { border: 1px solid #888; padding: 6px 10px; text-align: left; font-size: 13px; }
  #report .rpt-note { font-size: 11px; color: #444; }
}
