/* Micro Load. Native-app layout: bottom tab bar on phones, sidebar on desktop. */
/* Direction: iron and chalk. Graphite neutrals, one cobalt accent (the 20 kg plate), figures set like a logbook. */
:root {
  --bg: #F4F4F5; --surface: #FFFFFF; --surface-2: #FAFAFA; --fill: #EDEDEF; --fill-2: #E2E2E5;
  --ink: #171717; --muted: #525252; --faint: #737373; --line: rgba(23, 23, 23, .08);
  --accent: #1D4ED8; --accent-ink: #FFFFFF; --accent-soft: rgba(29, 78, 216, .09);
  --good: #16A34A; --good-ink: #15803D; --good-soft: rgba(22, 163, 74, .09); --warn: #B45309; --warn-soft: rgba(180, 83, 9, .09);
  --bad: #DC2626; --bad-soft: rgba(220, 38, 38, .08); --gold: #A16207; --gold-soft: rgba(202, 138, 4, .13);
  --primary-btn: #171717; --primary-btn-ink: #FFFFFF; --accent-fill: #1D4ED8; --accent-tint: rgba(29, 78, 216, .07);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --r: 14px; --r-sm: 10px; --ease: cubic-bezier(.22, 1, .36, 1);
  --tabbar: 56px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141415; --surface: #19191B; --surface-2: #1E1E20; --fill: #232325; --fill-2: #2C2C2F;
    --ink: #EDEDED; --muted: #A1A1A6; --faint: #85858B; --line: rgba(237, 237, 237, .08);
    --accent: #7AA2F7; --accent-ink: #0F0F10; --accent-soft: rgba(122, 162, 247, .13);
    --good: #4CC38A; --good-ink: #4CC38A; --good-soft: rgba(76, 195, 138, .1); --warn: #E0A24A; --warn-soft: rgba(224, 162, 74, .1);
    --bad: #E5484D; --bad-soft: rgba(229, 72, 77, .1); --gold: #E9C46A; --gold-soft: rgba(233, 196, 106, .12);
    --primary-btn: #EDEDED; --primary-btn-ink: #141415; --accent-fill: #3366E0; --accent-tint: rgba(122, 162, 247, .09);
    --shadow-float: 0 8px 24px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141415; --surface: #19191B; --surface-2: #1E1E20; --fill: #232325; --fill-2: #2C2C2F;
  --ink: #EDEDED; --muted: #A1A1A6; --faint: #85858B; --line: rgba(237, 237, 237, .08);
  --accent: #7AA2F7; --accent-ink: #0F0F10; --accent-soft: rgba(122, 162, 247, .13);
  --good: #4CC38A; --good-ink: #4CC38A; --good-soft: rgba(76, 195, 138, .1); --warn: #E0A24A; --warn-soft: rgba(224, 162, 74, .1);
  --bad: #E5484D; --bad-soft: rgba(229, 72, 77, .1); --gold: #E9C46A; --gold-soft: rgba(233, 196, 106, .12);
  --primary-btn: #EDEDED; --primary-btn-ink: #141415; --accent-fill: #3366E0; --accent-tint: rgba(122, 162, 247, .09);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
input, select, textarea { -webkit-appearance: none; appearance: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 16px; height: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.app { min-height: 100vh; }
main { padding: calc(var(--safe-t) + 8px) 16px calc(var(--tabbar) + var(--safe-b) + 96px); max-width: 760px; margin: 0 auto; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 86%, transparent); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--line);
}
.tabbar .brand { display: none; }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .01em; }
.tabbar button[aria-selected="true"] { color: var(--accent); }
.tabbar button svg.i { width: 24px; height: 24px; }

/* screen header */
.nav { display: flex; align-items: flex-end; gap: 12px; padding: 14px 0 12px; }
.nav h1 { font-size: 30px; line-height: 1.1; font-weight: 600; letter-spacing: -.01em; margin: 0; flex: 1; min-width: 0; }
.nav .sub { display: block; font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; margin-top: 2px; }
.nav .acts { display: flex; gap: 8px; align-items: center; padding-bottom: 4px; }
.backlink { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-size: 16px; font-weight: 500; margin: 6px 0 -4px -6px; }

/* section labels and groups */
.sec { font-size: 13px; font-weight: 600; color: var(--muted); margin: 24px 4px 8px; display: flex; justify-content: space-between; align-items: center; }
.sec button { color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 600; }
.group { background: var(--surface); border-radius: var(--r); overflow: hidden; }
.group + .note { margin-top: 6px; }
.note { font-size: 13px; color: var(--muted); padding: 0 6px; margin: 6px 0 0; }
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 12px 16px; position: relative; width: 100%; text-align: left; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--line); }
.row .body { flex: 1; min-width: 0; }
.row .t { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .d { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.row .end { color: var(--muted); font-size: 15px; display: flex; align-items: center; gap: 6px; flex: none; }
.row .chev { color: var(--faint); }
button.row:active, .row.tap:active { background: var(--fill); }
.row.danger { color: var(--bad); font-weight: 500; justify-content: center; }
.row.accent { color: var(--accent); font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 2px 8px; background: var(--fill); color: var(--muted); white-space: nowrap; }
.badge.up, .badge.easier { background: var(--good-soft); color: var(--good); }
.badge.hold, .badge.first, .badge.shift { background: var(--warn-soft); color: var(--warn); }
.badge.down { background: var(--bad-soft); color: var(--bad); }
.badge.pr { background: var(--gold-soft); color: var(--gold); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 600; font-size: 16px; background: var(--fill); color: var(--ink); }
.btn:active { opacity: .7; }
.btn.primary { background: var(--primary-btn); color: var(--primary-btn-ink); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.tint { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 12px; border-radius: 9px; font-size: 14px; }
.btn.pill { border-radius: 999px; }
.btn:disabled { opacity: .4; cursor: default; }
.txtbtn { color: var(--accent); font-weight: 600; font-size: 15px; padding: 6px 2px; }
.txtbtn.muted { color: var(--muted); font-weight: 500; }
.txtbtn.danger { color: var(--bad); }
.iconbtn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; color: var(--muted); }
.iconbtn:active { background: var(--fill); }
.iconbtn:disabled { opacity: .3; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btnrow.end { justify-content: flex-end; }
.btnrow.spread > * { flex: 1; }

/* inputs */
.field, .search { width: 100%; border: 0; background: var(--fill); border-radius: var(--r-sm); padding: 12px; font-size: 16px; }
.search { padding-left: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 10px 50%; background-size: 18px; }
textarea.field { resize: vertical; min-height: 44px; line-height: 1.4; }
select.field { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; padding-right: 34px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form label.wide { grid-column: 1 / -1; }
.form .field { color: var(--ink); font-weight: 400; }
.seg { display: inline-flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { min-width: 44px; padding: 6px 10px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
.seg.wrap { flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border-radius: 999px; padding: 8px 12px; font-size: 14px; font-weight: 600; background: var(--fill); color: var(--ink); white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }

/* ---------- train ---------- */
.train { display: block; }
.rack { display: none; }
.tips { background: var(--surface); border-radius: var(--r); padding: 16px; margin-bottom: 12px; font-size: 14px; }
.tips b.h { display: block; font-size: 16px; margin-bottom: 6px; }
.tips ul { margin: 0 0 10px; padding-left: 18px; color: var(--muted); }
.tips li { margin: 3px 0; }
.tips li b { color: var(--ink); font-weight: 600; }
.session-title { width: 100%; border: 0; background: none; font-size: 30px; font-weight: 600; letter-spacing: -.01em; padding: 0; line-height: 1.1; }
.session-title::placeholder { color: var(--faint); }
.slots { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.slots > li.lib-ghost, .slots > li[data-ex] { list-style: none; background: var(--accent-soft); color: var(--accent); border-radius: var(--r); padding: 14px; font-weight: 600; }
.slots .sortable-ghost { opacity: .35; }
.empty-card { background: var(--surface); border-radius: var(--r); padding: 28px 18px; text-align: center; color: var(--muted); }
.empty-card b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

.insert { list-style: none; display: flex; justify-content: center; margin: -4px 0; }
.insert button { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 999px; }
.insert button svg { width: 15px; height: 15px; }
.insert button:active, .insert button:focus-visible { color: var(--accent); background: var(--accent-soft); }
.addrow { list-style: none; }

.card { background: var(--surface); border-radius: var(--r); overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 8px; padding: 12px 8px 4px 4px; }
.handle { color: var(--faint); cursor: grab; touch-action: none; padding: 6px 2px; display: inline-flex; }
.card-h .ttl { flex: 1; min-width: 0; }
.card-h .nm { font-size: 16px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.card-h .meta { font-size: 13px; color: var(--muted); margin-top: 1px; }
.lastline { font-size: 13px; color: var(--muted); padding: 0 16px 8px; }
.lastline b { color: var(--ink); font-weight: 600; }
.cues { margin: 0 16px 8px; font-size: 14px; background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px; white-space: pre-wrap; }
.cues summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }

.setgrid { display: grid; grid-template-columns: 34px minmax(0, 1fr) 78px 66px 44px; gap: 6px; align-items: center; padding: 0 10px; }
.sethead { font-size: 12px; font-weight: 500; color: var(--faint); padding-bottom: 4px; padding-top: 4px; }
.sethead span:nth-child(3), .sethead span:nth-child(4) { text-align: center; }
.sethead span:last-child { text-align: center; }
.set { border-radius: 0; }
.set.done > .setgrid { background: var(--good-soft); }
.set > .setgrid { padding-top: 5px; padding-bottom: 5px; }
.setno { width: 32px; height: 32px; border-radius: 8px; background: var(--fill); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
.setno.warm { background: var(--warn-soft); color: var(--warn); }
.prev { font-size: 14px; color: var(--muted); line-height: 1.2; min-width: 0; }
.prev .tg { display: block; font-size: 12px; color: var(--accent); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prev .tg.hit { color: var(--good); }
.cell { width: 100%; height: 36px; border: 0; border-radius: 8px; background: var(--fill); text-align: center; font-weight: 600; font-size: 16px; padding: 0 4px; }
.set.done .cell { background: transparent; }
.cell::placeholder { color: var(--faint); font-weight: 500; }
.chk { width: 40px; height: 36px; border-radius: 9px; background: var(--fill); color: var(--faint); display: inline-flex; align-items: center; justify-content: center; justify-self: center; }
.chk[aria-pressed="true"] { background: var(--good); color: #fff; }
.chk svg.i { width: 20px; height: 20px; stroke-width: 2.6; }
.detail { padding: 4px 16px 12px 52px; display: flex; flex-direction: column; gap: 10px; background: var(--good-soft); }
.detail .lbl { font-size: 12px; font-weight: 600; color: var(--muted); min-width: 54px; }
.rate { display: flex; align-items: center; gap: 8px; }
.scale { display: flex; gap: 3px; flex: 1; min-width: 0; }
.scale button { flex: 1; min-width: 0; height: 32px; border-radius: 7px; background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink); }
.scale button.on { background: var(--accent); color: var(--accent-ink); }
.scale button.lit { background: var(--accent-soft); color: var(--accent); }
.scale.rir button { max-width: 44px; }
.resline { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.nextgoal { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.nextgoal .pick { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border-radius: 8px; padding: 4px 8px; font-weight: 600; color: var(--accent); }
.why { font-size: 13px; color: var(--muted); }
.goalchips { display: flex; gap: 6px; flex-wrap: wrap; }
.goalchips .chip { background: var(--surface); font-size: 13px; padding: 4px 12px; }
.goalchips .chip.on { background: var(--accent); }
.goalchips input { width: 90px; height: 32px; border: 0; border-radius: 8px; background: var(--surface); padding: 0 8px; font-size: 14px; }
.goalchips input.wide { width: 160px; }
.links { display: flex; gap: 14px; flex-wrap: wrap; }
.links button { font-size: 13px; color: var(--muted); font-weight: 600; }
.setnote { width: 100%; border: 0; border-radius: 8px; background: var(--surface); padding: 8px 10px; font-size: 14px; }
.lastnote { font-size: 13px; background: var(--warn-soft); border-radius: 8px; padding: 6px 10px; }
.lastnote b { color: var(--warn); font-size: 11px; margin-right: 4px; }
.advice { margin: 4px 12px 8px 52px; font-size: 13px; border-radius: 9px; padding: 8px 12px; background: var(--fill); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.advice.up { background: var(--good-soft); }
.advice.down, .advice.clean { background: var(--warn-soft); }
.advice .btn { margin-left: auto; }
.bd { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.bd label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.bd label span { display: flex; justify-content: space-between; }
.bd label b { color: var(--ink); }
.bd input[type=range] { -webkit-appearance: auto; appearance: auto; width: 100%; accent-color: var(--accent); }
.card-f { display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px; flex-wrap: wrap; }
.card-f .grow { flex: 1; }
.card-f textarea { flex: 1 1 100%; border: 0; border-radius: 9px; background: var(--fill); padding: 8px 10px; font-size: 14px; resize: vertical; min-height: 38px; }
.session-foot { display: flex; justify-content: space-between; margin-top: 14px; padding: 0 4px; }

/* rest timer */
.timer { position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(var(--tabbar) + var(--safe-b) + 10px); display: flex; align-items: center; gap: 8px;
  background: var(--primary-btn); color: var(--primary-btn-ink); border-radius: 16px; padding: 8px 8px 8px 16px; box-shadow: var(--shadow-float); max-width: 520px; margin: 0 auto; }
.timer .lbl { font-size: 12px; font-weight: 600; opacity: .7; }
.timer b { font-size: 26px; font-weight: 600; flex: 1; letter-spacing: -.01em; }
.timer button { background: color-mix(in srgb, var(--bg) 18%, transparent); color: inherit; border-radius: 10px; padding: 8px 12px; font-weight: 600; font-size: 14px; }
.timer.done { background: var(--good); color: #fff; }

/* toast */
.toast { position: fixed; z-index: 70; top: calc(var(--safe-t) + 10px); left: 50%; transform: translateX(-50%); background: var(--primary-btn); color: var(--primary-btn-ink); padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-float); max-width: calc(100% - 32px); text-align: center; animation: toast .2s var(--ease); }
@keyframes toast { from { opacity: 0; transform: translate(-50%, -6px); } }

/* ---------- history ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { background: var(--surface); border-radius: var(--r); padding: 12px; }
.tile b { display: block; font-size: 26px; font-weight: 600; letter-spacing: -.01em; line-height: 1.1; }
.tile span { font-size: 12px; color: var(--muted); font-weight: 500; }
.bars { padding: 6px 14px 12px; }
.bar { display: grid; grid-template-columns: 96px minmax(0, 1fr) 28px; gap: 10px; align-items: center; font-size: 14px; padding: 5px 0; }
.bar b { text-align: right; font-weight: 600; }
progress { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border: 0; border-radius: 99px; background: var(--fill); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--fill); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }

/* logbook */
.lbx { background: var(--surface); border-radius: var(--r); padding: 12px 16px; }
.lbx + .lbx { margin-top: 10px; }
.lbx h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.lbx table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lbx td { padding: 5px 0; border-top: .5px solid var(--line); vertical-align: top; }
.lbx td:first-child { color: var(--muted); width: 28px; }
.lbx td.r { text-align: right; }
.lbx .nt { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---------- exercises ---------- */
.exv { display: block; }
.letter { font-size: 13px; font-weight: 600; color: var(--muted); padding: 14px 6px 6px; }
.chart { width: 100%; height: auto; display: block; }
.chartbox { background: var(--surface); border-radius: var(--r); padding: 12px 8px 6px; }
.chartkey { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding: 4px 8px 4px; flex-wrap: wrap; }
.chartkey i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--accent); vertical-align: middle; margin-right: 5px; }
.chartkey i.q { background: none; border-top: 2px dashed var(--faint); height: 0; }
table.h { border-collapse: collapse; width: 100%; font-size: 14px; }
table.h th, table.h td { text-align: left; padding: 8px 16px; white-space: nowrap; }
table.h tr + tr td { border-top: .5px solid var(--line); }
table.h th { color: var(--muted); font-weight: 600; font-size: 12px; }
.tablewrap { overflow-x: auto; background: var(--surface); border-radius: var(--r); }
.panel { background: var(--surface); border-radius: var(--r); padding: 14px; }

/* ---------- settings ---------- */
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; font-size: 15px; margin: 0; padding: 12px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.credit a { color: var(--accent); font-weight: 600; text-decoration: none; }
.callout { background: var(--warn-soft); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; }
.callout.bad { background: var(--bad-soft); }
.err { color: var(--bad); font-size: 14px; font-weight: 600; min-height: 1px; }
.err:empty { display: none; }
.filebtn { cursor: pointer; }

/* ---------- onboarding ---------- */
.onboard { max-width: 560px; margin: 0 auto; padding-top: 8px; }
.progress { display: flex; gap: 4px; margin: 6px 0 18px; }
.progress span { flex: 1; height: 4px; border-radius: 4px; background: var(--fill-2); }
.progress span.on { background: var(--accent); }
.onboard .step { font-size: 13px; font-weight: 600; color: var(--muted); }
.onboard h1 { font-size: 30px; line-height: 1.12; font-weight: 600; letter-spacing: -.01em; margin: 4px 0 8px; }
.onboard .lede { color: var(--muted); margin: 0 0 8px; font-size: 16px; }
.onboard fieldset { border: 0; padding: 0; margin: 22px 0 0; min-width: 0; }
.onboard legend { font-size: 16px; font-weight: 600; padding: 0; margin-bottom: 4px; }
.onboard .help { font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.choices { background: var(--surface); border-radius: var(--r); overflow: hidden; }
.choice { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; position: relative; min-height: 54px; }
.choice + .choice::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--line); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .body { flex: 1; min-width: 0; }
.choice b { display: block; font-weight: 500; }
.choice small { display: block; color: var(--muted); font-size: 13px; }
.choice .mark { width: 24px; height: 24px; border-radius: 999px; border: 1.75px solid var(--faint); flex: none; display: inline-flex; align-items: center; justify-content: center; color: transparent; }
.choice input[type=checkbox] ~ .mark { border-radius: 7px; }
.choice input:checked ~ .mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.choice input:focus-visible ~ .mark { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice .mark svg { width: 15px; height: 15px; stroke-width: 3; }
.yn { display: flex; align-items: center; gap: 12px; padding: 12px 16px; position: relative; font-size: 15px; }
.yn + .yn::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--line); }
.yn > span:first-child { flex: 1; }
.yn .seg label { min-width: 52px; padding: 6px 10px; border-radius: 7px; font-size: 14px; font-weight: 600; text-align: center; cursor: pointer; }
.yn .seg input { position: absolute; opacity: 0; pointer-events: none; }
.yn .seg label:has(input:checked) { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.yn .seg label:has(input[value=yes]:checked) { color: var(--bad); }
.yn .seg label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.rank { list-style: none; margin: 10px 0 0; padding: 0; background: var(--surface); border-radius: var(--r); overflow: hidden; counter-reset: rk; }
.rank li { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; position: relative; counter-increment: rk; min-height: 52px; }
.rank li + li::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--line); }
.rank li::after { content: none; }
.rank .num { width: 24px; height: 24px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.rank .nm { flex: 1; font-weight: 500; }
.legal { background: var(--surface); border-radius: var(--r); padding: 16px; max-height: 44vh; overflow: auto; font-size: 15px; }
.legal h3 { font-size: 15px; margin: 14px 0 4px; }
.legal h3:first-child { margin-top: 0; }
.legal p { margin: 0 0 6px; color: var(--muted); }
.agree { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; cursor: pointer; position: relative; font-size: 15px; }
.agree + .agree::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--line); }
.agree input { position: absolute; opacity: 0; pointer-events: none; }
.agree .mark { margin-top: 1px; width: 24px; height: 24px; border-radius: 7px; border: 1.75px solid var(--faint); flex: none; display: inline-flex; align-items: center; justify-content: center; color: transparent; }
.agree input:checked ~ .mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.agree input:focus-visible ~ .mark { outline: 2px solid var(--accent); outline-offset: 2px; }
.agree .mark svg { width: 15px; height: 15px; stroke-width: 3; }
.ctabar { position: sticky; bottom: 0; padding: 14px 0 calc(var(--safe-b) + 14px); background: linear-gradient(to top, var(--bg) 70%, transparent); display: flex; gap: 10px; margin-top: 18px; }
.ctabar .btn { flex: 1; min-height: 52px; font-size: 16px; border-radius: 14px; }
.ctabar .btn.back { flex: 0 0 auto; padding: 0 20px; }
.summary { background: var(--surface); border-radius: var(--r); }
#clearBox:not(:empty) { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- sheets ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .4); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease-out; }
.modal .box { background: var(--bg); width: 100%; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 8px 16px calc(var(--safe-b) + 20px); }
.modal .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--fill-2); margin: 0 auto 8px; }
.modal .mh { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-height: 36px; }
.modal .mh h2 { font-size: 20px; font-weight: 600; margin: 0; flex: 1; letter-spacing: -.01em; }
.modal p { margin: 0 0 14px; color: var(--muted); }
.pklist { display: flex; flex-direction: column; }
.pkq { margin-bottom: 10px; }
#pkf { margin-bottom: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .tabbar { top: 0; bottom: 0; right: auto; width: 232px; height: auto; flex-direction: column; justify-content: flex-start; gap: 2px; padding: 20px 12px; border-top: 0; border-right: .5px solid var(--line); background: var(--surface); }
  .tabbar .brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; letter-spacing: -.01em; padding: 4px 10px 18px; }
  .tabbar .brand img { width: 32px; height: 32px; border-radius: 8px; }
  .tabbar button { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 15px; color: var(--ink); font-weight: 500; }
  .tabbar button svg.i { width: 21px; height: 21px; color: var(--muted); }
  .tabbar button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
  .tabbar button[aria-selected="true"] svg.i { color: var(--accent); }
  main { margin-left: 232px; max-width: none; padding: 24px 32px 120px; }
  main > section { max-width: 1060px; margin: 0 auto; }
  .train.has-rack { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
  .rack { display: block; position: sticky; top: 24px; }
  .rack .lib { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 230px); overflow: auto; background: var(--surface); border-radius: var(--r); }
  .rack .lib li { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; position: relative; cursor: grab; user-select: none; }
  .rack .lib li + li::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--line); }
  .rack .lib li.in-session .nm { color: var(--muted); }
  .rack .lib .nm { flex: 1; min-width: 0; font-weight: 500; font-size: 15px; }
  .rack .lib .grp { font-size: 12px; color: var(--muted); font-weight: 400; }
  .rack .search { margin-bottom: 10px; }
  .rack .chips { margin-bottom: 10px; }
  .timer { left: 232px; bottom: 20px; }
  .exv.split { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }
  .exv.split .exlist { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow: auto; }
  .exv .backlink { display: none; }
  .settings { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; align-items: start; }
  .modal { align-items: center; padding: 24px; }
  .modal .box { max-width: 560px; border-radius: 16px; padding: 16px 20px 20px; }
  .modal .box.wide { max-width: 760px; }
  .modal .grab { display: none; }
}
@media (max-width: 380px) {
  .setgrid { grid-template-columns: 30px minmax(0, 1fr) 70px 58px 42px; gap: 4px; padding: 0 8px; }
  .detail { padding-left: 16px; }
  .advice { margin-left: 10px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* signature: figures set like a logbook entry */
.fig, .cell, .prev, .tile b, table.h td.n, .timer b, .bar b, .lastline b, .plates span { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.cell { font-size: 16px; font-weight: 500; }
.tile b { font-weight: 500; font-size: 26px; }
.timer b { font-weight: 500; }
/* motion uses one curve */
.modal { animation-timing-function: var(--ease); }
.modal .box { animation: up .32s var(--ease); }
.btn, .chip, .seg button, .row, .chk, .iconbtn, .scale button, .tabbar button { transition: background-color .15s var(--ease), color .15s var(--ease), opacity .15s var(--ease), transform .15s var(--ease); }
.btn:active, .chk:active { transform: scale(.97); opacity: 1; }
.card, .group, .tile, .lbx, .tips, .empty-card, .chartbox, .tablewrap, .panel, .legal, .choices, .rank, .summary { box-shadow: 0 0 0 .5px var(--line); }

/* layout helpers for the rendered views */
.nav .ttl { flex: 1; min-width: 0; }
.trainmain { min-width: 0; }
.rack-hint { display: none; margin-top: 12px; }
.exlist .row.sel { background: var(--accent-soft); }
.exv .btnrow { margin-top: 16px; }
.exv .search, .exlist .search { margin-bottom: 4px; }
.row.accent svg.i { color: var(--accent); }
.row .seg { flex: none; }
.plates { display: flex; gap: 8px; flex-wrap: wrap; }
.plates span { background: var(--surface); border-radius: 8px; padding: 8px 12px; box-shadow: 0 0 0 .5px var(--line); }
.modal .ctabar { position: static; background: none; padding: 16px 0 0; }
.modal .lbx { box-shadow: 0 0 0 .5px var(--line); }
.tips .txtbtn { padding: 0; }
@media (max-width: 520px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) {
  .rack-hint { display: block; }
  .exv.split .exlist .nav { padding-top: 0; }
}

/* cobalt carries the primary actions and the logged state */
.btn.primary, .btn.accent { background: var(--accent-fill); color: #FFFFFF; }
.chip.on, .goalchips .chip.on, .scale button.on { background: var(--accent-fill); color: #FFFFFF; }
.chk[aria-pressed="true"] { background: var(--accent-fill); color: #FFFFFF; }
.set.done > .setgrid, .detail { background: var(--accent-tint); }
.set.done .setno { background: var(--accent-fill); color: #FFFFFF; }
.card-h .nm { color: var(--accent); }
.prev .tg.hit { color: var(--good-ink); }
.timer { background: var(--accent-fill); color: #FFFFFF; }
.timer button { background: rgba(255, 255, 255, .18); }
.tile:first-child b { color: var(--accent); }
.choice input:checked ~ .mark, .agree input:checked ~ .mark { background: var(--accent-fill); border-color: var(--accent-fill); }
.rank .num, .progress span.on { background: var(--accent-fill); color: #FFFFFF; }
.tabbar button[aria-selected="true"] { color: var(--accent); }
.scale button.lit { background: var(--accent-soft); color: var(--accent); }
.nav .acts .btn.primary { box-shadow: 0 1px 2px rgba(29, 78, 216, .2); }

/* combined set block: original logbook layout, native styling */
.lastline { padding: 0 16px 12px; line-height: 1.5; }
.set { padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; border-top: .5px solid var(--line); }
.set.done { background: var(--accent-tint); }
.set.warm { background: var(--warn-soft); }
.set-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.setlbl { font-weight: 600; font-size: 15px; }
.set .setno { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; }
.target { font-size: 13px; color: var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 4px 8px; }
.target b { font-weight: 600; }
.target.hit { color: var(--good-ink); background: var(--good-soft); }
.logbtn { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 16px; border-radius: 999px; background: var(--fill); font-weight: 600; font-size: 14px; color: var(--ink); }
.logbtn[aria-pressed="true"] { background: var(--accent-fill); color: #FFFFFF; }
.logbtn:active { transform: scale(.97); }
.inputs { display: flex; align-items: center; gap: 8px; }
.num { display: flex; align-items: center; background: var(--surface); border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line); flex: 1; max-width: 148px; }
.num .cell { flex: 1; min-width: 0; width: 100%; height: 44px; background: transparent; text-align: left; padding: 0 8px 0 12px; font-size: 18px; }
.set.done .num .cell { background: transparent; }
.num span { font-size: 13px; color: var(--muted); padding-right: 12px; white-space: nowrap; }
.inputs .x { color: var(--faint); font-weight: 500; }
.rate .lbl { font-size: 13px; font-weight: 500; color: var(--muted); min-width: 56px; }
.scale button { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.scale button.on { box-shadow: none; }
.set .setnote { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); height: 40px; }
.set .links { margin-top: -4px; }
.result { display: flex; flex-direction: column; gap: 8px; border-top: .5px dashed var(--line); padding-top: 12px; }
.nextgoal .lbl { font-size: 13px; font-weight: 500; color: var(--muted); }
.why b { color: var(--ink); font-weight: 500; }
.set .advice { margin: 0; }
@media (max-width: 380px) { .num { max-width: none; } .num .cell { font-size: 16px; } }
.set .setno { width: auto; height: 30px; padding: 0 12px; border-radius: 999px; font-size: 14px; font-weight: 600; }

/* more cobalt: interactive elements and key figures */
.logbtn { background: var(--accent-soft); color: var(--accent); }
.card-f .btn { background: var(--accent-soft); color: var(--accent); }
.seg button[aria-pressed="true"] { background: var(--accent-fill); color: #FFFFFF; box-shadow: none; }
.yn .seg label:has(input:checked) { background: var(--accent-fill); color: #FFFFFF; box-shadow: none; }
.yn .seg label:has(input[value=yes]:checked) { background: var(--bad); color: #FFFFFF; }
.sec { color: var(--accent); }
.tile b { color: var(--accent); }
.badge.first { background: var(--accent-soft); color: var(--accent); }
.lastline b { color: var(--accent); }
.num:focus-within, .field:focus, .search:focus, .setnote:focus { box-shadow: inset 0 0 0 2px var(--accent-fill); outline: none; }
.insert button { color: var(--accent); }
.tabbar button svg.i { padding: 2px 14px; box-sizing: content-box; border-radius: 999px; }
.tabbar button[aria-selected="true"] svg.i { background: var(--accent-soft); }
.row .chev { color: var(--accent); opacity: .7; }
@media (min-width: 900px) {
  .tabbar button svg.i { padding: 0; }
  .tabbar button[aria-selected="true"] svg.i { background: none; }
}

/* calendar */
.cal { background: var(--surface); border-radius: var(--r); padding: 8px 8px 12px; box-shadow: 0 0 0 .5px var(--line); }
.cal-h { display: flex; align-items: center; gap: 8px; padding: 0 0 8px; }
.cal-t { flex: 1; text-align: center; }
.cal-t b { display: block; font-weight: 600; }
.cal-t span { font-size: 13px; color: var(--muted); }
.cal-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-w { font-size: 12px; color: var(--faint); font-weight: 500; padding-bottom: 4px; }
.day { position: relative; height: 40px; width: 40px; margin: 0 auto; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--muted); }
.day.has { background: var(--accent-fill); color: #FFFFFF; font-weight: 600; }
.day.today { box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); font-weight: 600; }
.day.has.today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); color: #FFFFFF; }
.day i { position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 4px; background: #FFFFFF; }
/* goals */
.goalseg { margin: 4px 0 0; }
.row.goal .body progress { display: block; margin-top: 8px; height: 6px; }
.row.goal { align-items: flex-start; }
.row.goal .end { padding-top: 2px; }
.goalbar { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; }
.goalbar progress { flex: 1; height: 10px; }
.goalbar b { font-family: var(--mono); font-weight: 500; }
@media (max-width: 380px) { .day { width: 36px; height: 36px; } }
