:root {
  --brand: #d7263d;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0f17; --card: #151b26; --ink: #f3f4f6; --muted: #9ca3af; --line: #273042; }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; max-width: 760px; margin: 0 auto;
}
.brand { font-weight: 700; display: flex; gap: 8px; align-items: center; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); }
.tag { color: var(--muted); font-size: 14px; }
main { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.hidden { display: none !important; }
.grid { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 15px; }
input, select, textarea {
  font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); width: 100%;
}
.consent { display: flex; gap: 10px; font-weight: 400; font-size: 13px; color: var(--muted); align-items: flex-start; }
.consent input { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 14px 18px; font: 600 16px system-ui, sans-serif;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  flex: 1 1 auto; min-height: 50px;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--ink); color: var(--card); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.file { font-weight: 600; }
.privacy { font-size: 13px; color: var(--muted); margin: 0; }
.howto { background: var(--bg); border-radius: 12px; padding: 12px 14px; }
.howto summary { font-weight: 700; cursor: pointer; }
.howto ol { margin: 8px 0 0; padding-left: 20px; }
.howto li { margin: 4px 0; }

/* capture */
.stage { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage.mirror video, .stage.mirror canvas { transform: scaleX(-1); }
.hud { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; pointer-events: none; }
.pill { background: rgba(0,0,0,.65); color: #fff; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 15px; }
.pill.big { font-size: 18px; background: var(--brand); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 600; background: rgba(0,0,0,.6); }
.checks { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 14px; }
.checks li { padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.checks li::before { content: "○ "; }
.checks li.ok { color: var(--ok); } .checks li.ok::before { content: "✓ "; }
.checks li.bad { color: var(--warn); } .checks li.bad::before { content: "! "; }

/* results */
.result-hero { display: flex; gap: 20px; align-items: center; }
.ring {
  --p: 0; flex: none; width: 128px; height: 128px; border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--line) 0);
  display: grid; place-content: center; text-align: center; position: relative;
}
.ring::before { content: ""; position: absolute; inset: 12px; background: var(--card); border-radius: 50%; }
.ring span, .ring small { position: relative; }
.ring span { font-size: 32px; font-weight: 800; line-height: 1; }
.ring small { color: var(--muted); font-size: 12px; }
.status { font-weight: 800; font-size: 20px; }
.kid { font-size: 17px; margin: 6px 0; }
.metric { margin: 14px 0; }
.metric .head { display: flex; justify-content: space-between; font-weight: 600; }
.metric .val.ok { color: var(--ok); } .metric .val.no { color: var(--warn); }
.bar { position: relative; height: 14px; border-radius: 7px; background: var(--line); margin-top: 6px; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; background: var(--warn); }
.bar > i.ok { background: var(--ok); }
.bar > b { position: absolute; top: -4px; bottom: -4px; width: 3px; background: var(--ink); border-radius: 2px; }
.delta { font-size: 13px; color: var(--muted); margin-left: 6px; }
.kicks summary { cursor: pointer; color: var(--muted); margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.tip { border-left: 4px solid var(--brand); padding: 4px 0 4px 12px; margin: 14px 0; }
.tip h3 { margin: 0 0 4px; font-size: 16px; }
.tip p { margin: 4px 0; }
.week { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 10px 0; }
.week h3 { margin: 0; font-size: 16px; }
.week .dates { color: var(--muted); font-size: 13px; }
.week ul { margin: 8px 0 0; padding-left: 0; list-style: none; }
.week li { margin: 6px 0; display: flex; gap: 8px; align-items: flex-start; }
.week li input { width: 18px; height: 18px; flex: none; margin-top: 3px; }
.week .cp { color: var(--brand); font-weight: 600; font-size: 14px; }
.card-img { width: 100%; max-width: 360px; display: block; margin: 0 auto 14px; border-radius: 12px; }
#sendStatus.ok { color: var(--ok); } #sendStatus.err { color: var(--bad); }

@media (max-width: 520px) {
  h1 { font-size: 24px; }
  .result-hero { flex-direction: column; text-align: center; }
  .checks { grid-template-columns: 1fr; }
  .stage { aspect-ratio: 3 / 4; }
}
.ok { color: var(--ok); }
.welcome { display: grid; gap: 4px; }
.welcome h2 { margin: 0; }
.welcome .btn { margin-top: 8px; }
.linkbox { margin-top: 16px; padding: 14px; border-radius: 12px; background: var(--bg); display: grid; gap: 8px; }
.linkbox p { margin: 0; }
.linkbox a { word-break: break-all; color: var(--brand); }
/* progress page */
.milestones { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.ms { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 2px; background: var(--bg); }
.ms-label { font-weight: 700; font-size: 14px; color: var(--muted); }
.ms b { font-size: 24px; }
.ms span, .ms a { font-size: 13px; }
.ms a { color: var(--brand); font-weight: 600; }
.ms small { color: var(--muted); font-size: 12px; }
.ms.done { border-color: var(--ok); }
.ms.due { border-color: var(--brand); border-width: 2px; }
.ms.missed, .ms.upcoming { opacity: .7; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); }
.chart .lbl { fill: var(--muted); font-size: 13px; }
.chart .ln { fill: none; stroke: var(--brand); stroke-width: 3; }
.chart .pt { fill: var(--brand); }
.cmp { display: grid; grid-template-columns: 1fr auto 60px; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.cmp.total { font-weight: 700; border-bottom: 0; }
.cmp .d { text-align: right; font-weight: 700; }
.cmp .d.up { color: var(--ok); } .cmp .d.down { color: var(--warn); }
/* app (PWA) */
.install { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; }
.install img { border-radius: 14px; }
.install h2 { margin: 0 0 2px; }
.install p { margin: 0; }
.install .btn { grid-column: 1 / -1; }
.install.pulse { box-shadow: 0 0 0 3px var(--brand); }
.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet-wrap.open { display: flex; }
.sheet { background: var(--card); color: var(--ink); width: 100%; max-width: 520px; border-radius: 20px 20px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.sheet h2 { margin: 0; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.steps .ico { display: inline-flex; vertical-align: middle; color: #0a84ff; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 40; }
.tabbar a { flex: 1; display: grid; justify-items: center; padding: 8px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabbar a span { font-size: 22px; line-height: 1.1; }
.tabbar a.on { color: var(--brand); }
html.standalone main { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
html.standalone .top { padding-top: calc(14px + env(safe-area-inset-top)); }
