:root {
  --bg: #eceff2; --surface: #fafbfc; --ink: #14181d; --muted: #566270; --line: #d3d9df; --track: #e1e6eb;
  --accent: #1d5fc2; --accent-ink: #fff; --good: #1b7a44; --warn: #a85f0a; --bad: #b3261e;
  --display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', system-ui, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1317; --surface: #171c22; --ink: #e8ecf0; --muted: #93a0ac; --line: #2a323b; --track: #232a32;
    --accent: #5b9bff; --accent-ink: #08121f; --good: #4cc482; --warn: #e3a24a; --bad: #ff7a70;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.45 var(--body);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
#app { max-width: 680px; margin: 0 auto; padding-bottom: 150px; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1 { margin: 4px 0 12px; font: 700 40px/1 var(--display); letter-spacing: .02em; text-transform: uppercase; }
h2 { margin: 0 0 8px; font: 600 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h3 { margin: 0; font: 600 18px/1.2 var(--body); }
.sub { margin: -6px 0 14px; color: var(--muted); font-size: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card.next { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.row2 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; min-width: 0; }
.tag { font: 500 12px var(--mono); color: var(--muted); margin-top: 3px; }
.tag.warn { color: var(--warn); }
.badge { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.btn { min-height: 46px; padding: 8px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.small { min-height: 38px; padding: 4px 12px; font-size: 14px; }
.icon { width: 40px; height: 40px; flex: none; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; font-size: 16px; line-height: 1; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.chip { flex: none; min-height: 40px; padding: 6px 14px; border: 1px solid var(--line); background: var(--surface); border-radius: 20px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
input, textarea, select { font: 500 18px var(--mono); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; min-width: 0; }
textarea { font: 400 16px/1.4 var(--body); resize: vertical; min-height: 72px; }
select { font-family: var(--body); font-size: 16px; }
.exhead { display: flex; gap: 8px; align-items: flex-start; }
.last { font: 500 12px var(--mono); color: var(--muted); }
.hint { font: 500 12px var(--mono); color: var(--good); }
.sets { display: flex; flex-direction: column; gap: 6px; }
.setrow { display: grid; grid-template-columns: 26px 1fr 1fr 52px; gap: 8px; align-items: center; }
.setrow.head { font: 500 11px var(--mono); color: var(--muted); text-transform: uppercase; }
.setrow .n { font: 500 14px var(--mono); color: var(--muted); text-align: center; }
.setrow input { text-align: center; padding: 10px 4px; }
.done { height: 46px; border: 2px solid var(--line); background: var(--bg); border-radius: 8px; font-size: 20px; }
.done[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: #fff; }
.setrow.isdone input { opacity: .6; }
.btnrow { display: flex; gap: 8px; }
.btnrow .btn { flex: 1; }
.slot { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--bg); display: flex; flex-direction: column; gap: 8px; }
.slothead { display: flex; gap: 6px; align-items: flex-start; }
.sname { font-weight: 600; }
.slotbody { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: end; }
.slotbody label { font: 500 11px var(--mono); color: var(--muted); display: flex; flex-direction: column; gap: 3px; text-transform: uppercase; }
.slotbody input { padding: 8px 4px; text-align: center; }
.rows { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 8px 12px; background: var(--bg); border: 0; border-bottom: 1px solid var(--line); text-align: left; }
.row:last-child { border-bottom: 0; }
.row .box { flex: none; width: 24px; height: 24px; border: 2px solid var(--muted); border-radius: 6px; position: relative; }
.row[aria-pressed="true"] { background: var(--surface); }
.row[aria-pressed="true"] .box { background: var(--accent); border-color: var(--accent); }
.row[aria-pressed="true"] .box::after { content: ""; position: absolute; left: 6px; top: 1px; width: 6px; height: 12px; border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.row .lbl { flex: 1; font-weight: 500; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.stats div { display: flex; flex-direction: column; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font: 500 22px var(--mono); }
.stats dd small { font-size: 12px; color: var(--muted); }
.empty { text-align: center; padding: 24px 12px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { min-height: 46px; background: var(--bg); border: 0; border-right: 1px solid var(--line); font-weight: 600; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
details.sess { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 10px 12px; }
details.sess summary { cursor: pointer; font-weight: 600; }
details.sess .ln { font: 400 13px/1.5 var(--mono); color: var(--muted); margin-top: 4px; }
svg.chart { display: block; width: 100%; height: auto; }
svg .t { fill: var(--muted); font: 500 11px var(--mono); }
svg .grid { stroke: var(--line); stroke-width: 1; }
svg .ln { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
svg .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.cap { margin: 0; font: 500 13px var(--mono); color: var(--muted); }
.note { font-size: 14px; color: var(--muted); margin: 0; }

nav#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
nav#tabs button { min-height: 56px; border: 0; background: transparent; font: 600 13px var(--body); color: var(--muted); }
nav#tabs button[aria-current="page"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

#restbar { position: fixed; left: 12px; right: 12px; bottom: calc(66px + env(safe-area-inset-bottom)); max-width: 656px; margin: 0 auto; background: var(--ink); color: var(--bg); border-radius: 10px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; z-index: 30; }
#restbar #resttxt { flex: 1; font: 600 20px var(--mono); }
#restbar button { min-height: 38px; padding: 4px 12px; border: 1px solid currentColor; background: transparent; border-radius: 8px; color: inherit; font-weight: 600; }
#restbar.over { background: var(--good); color: #fff; }

.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 680px; max-height: 88vh; background: var(--surface); border-radius: 14px 14px 0 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.sheet header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sheet header h3 { flex: 1; }
.sheet .body { overflow-y: auto; padding: 12px 14px 20px; display: flex; flex-direction: column; gap: 10px; }
.pick { display: flex; flex-direction: column; gap: 2px; text-align: left; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.pick.off { opacity: .6; }
.pick .nm { font-weight: 600; }
#toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }
@media (max-width: 420px) { h1 { font-size: 34px; } .slotbody { grid-template-columns: 1fr 1fr 1fr; } .slotbody .btn { grid-column: 1 / -1; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.btnrow { margin-bottom: 12px; }
.card .btnrow, .sheet .btnrow { margin-bottom: 0; }
h2.gh { margin-top: 16px; }
.cap { margin-bottom: 6px; }
