/* Wrist Strength Tracker
   Look: a gym logbook. Navy ink on chalk, competition-plate yellow as the one
   accent, condensed scoreboard type for headings and numbers. */

:root {
  --chalk: #E6E9E5;      /* page */
  --paper: #F7F8F5;      /* panels */
  --ink: #18263A;        /* text, filled controls */
  --graphite: #586473;   /* secondary text */
  --rule: #D0D5D0;       /* dividers */
  --plate: #F2B705;      /* the accent: done ticks, progress */
  --rest: #6C84A3;       /* rest days */
  --on-ink: #F7F8F5;

  --red: #C8102E; --blue: #1F4E9C; --yellow: #F2B705; --green: #2F7D3A;

  --display: "DIN Condensed", "Bahnschrift SemiCondensed", "Bahnschrift", "Roboto Condensed", "sans-serif-condensed", "Arial Narrow", sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-panel: 14px;
  --r-control: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --chalk: #111922; --paper: #18222E; --ink: #E4E8E2; --graphite: #93A0AE; --rule: #283544;
    --rest: #8DA3C2; --on-ink: #111922; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --chalk: #111922; --paper: #18222E; --ink: #E4E8E2; --graphite: #93A0AE; --rule: #283544;
  --rest: #8DA3C2; --on-ink: #111922; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--text);
  background: var(--chalk);
  color: var(--ink);
  min-height: 100dvh;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--plate); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 700; line-height: 1.05; letter-spacing: .005em; }
p { margin: 0; }
.num, .display { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }
.muted { color: var(--graphite); }
.small { font-size: .875rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 560px; margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 20px 8px;
  background: var(--chalk);
}
.wordmark { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 1.35rem; line-height: 1; }
.wordmark svg { width: 30px; height: 30px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.streak {
  display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 8px;
  font-family: var(--display); font-weight: 700; font-size: 1.4rem; line-height: 1;
}
.streak svg { width: 18px; height: 22px; }
.streak.cold svg .flame-outer { fill: var(--rule); }
.streak.cold svg .flame-inner { fill: var(--graphite); }
.streak.bump { animation: bump .5s ease; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: none; color: var(--ink);
}
.icon-btn:hover { background: var(--paper); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-btn .moon { fill: currentColor; stroke: none; }
.icon-btn .sun { display: none; }
:root[data-theme="dark"] .icon-btn .sun { display: block; }
:root[data-theme="dark"] .icon-btn .moon { display: none; }

/* ---------- Layout ---------- */
main { max-width: 560px; margin: 0 auto; padding: 4px 20px 32px; }
.view { display: grid; gap: 20px; }
.panel { background: var(--paper); border-radius: var(--r-panel); border: 1px solid var(--rule); }
.panel-pad { padding: 18px; }
.heading-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.view h3 { font-size: 1.45rem; }

/* ---------- Today ---------- */
.today-head { display: grid; gap: 6px; padding-top: 6px; }
.today-head .date { color: var(--graphite); font-size: .95rem; }
.today-head h1 { font-size: clamp(2.6rem, 12vw, 3.4rem); }
.today-head .summary { color: var(--graphite); }
.safety {
  margin-top: 8px; padding: 2px 0 2px 12px;
  border-left: 3px solid var(--plate);
  font-size: .9rem; color: var(--graphite); max-width: 46ch;
}
.note-line { padding: 14px 16px; border-radius: var(--r-panel); background: var(--paper); border: 1px solid var(--rule); }
.note-line.rest { border-left: 4px solid var(--rest); }

.exercise-list { list-style: none; margin: 0; padding: 0; }
.ex + .ex { border-top: 1px solid var(--rule); }
.ex-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 4px 12px; padding: 14px 14px 14px 16px; }
.ex-order { font-family: var(--display); font-weight: 700; font-size: 1.3rem; color: var(--graphite); align-self: start; padding-top: 1px; }
.ex-main { display: grid; gap: 2px; min-width: 0; }
.ex-name { font-weight: 650; font-size: 1.08rem; line-height: 1.3; }
.ex-meta { color: var(--graphite); font-size: .92rem; }
.how {
  justify-self: start; margin: 4px 0 0 -6px; padding: 6px; min-height: 36px;
  border: 0; background: none; color: var(--ink); font-size: .9rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: underline; text-decoration-color: var(--plate); text-decoration-thickness: 2px; text-underline-offset: 4px;
}
.how svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; transition: transform .2s; }
.how[aria-expanded="true"] svg { transform: rotate(180deg); }

.check {
  width: 56px; height: 56px; border: 0; background: none; padding: 0;
  display: grid; place-items: center; border-radius: 12px;
}
.check .box {
  width: 40px; height: 40px; border-radius: 9px;
  border: 2.5px solid var(--ink); display: grid; place-items: center;
  transition: background .15s;
}
.check svg { width: 24px; height: 24px; fill: none; stroke: var(--plate); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 26; stroke-dashoffset: 26; transition: stroke-dashoffset .22s ease .04s; }
.ex.done .check .box { background: var(--ink); }
.ex.done .check svg { stroke-dashoffset: 0; }
.ex.done .ex-name { color: var(--graphite); }
:root[data-theme="dark"] .ex.done .check .box { background: var(--plate); border-color: var(--plate); }
:root[data-theme="dark"] .ex.done .check svg { stroke: #18263A; }
.ex.pop .check .box { animation: press .35s ease; }

.details { padding: 0 16px 18px 56px; display: grid; gap: 14px; }
.demo { display: grid; gap: 8px; }
.demo-frame { background: var(--chalk); border-radius: var(--r-control); padding: 6px 6px 2px; }
.demo-cue { font-size: .92rem; color: var(--graphite); max-width: 48ch; }
.ex-notes { font-size: .9rem; color: var(--graphite); }
.fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field { display: grid; gap: 4px; font-size: .82rem; color: var(--graphite); font-weight: 600; }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 9px 11px; border-radius: var(--r-control);
  border: 1.5px solid var(--rule); background: var(--chalk); color: var(--ink); font-size: 1rem; font-weight: 500;
}
.field input[type="number"] { font-family: var(--display); font-size: 1.3rem; font-weight: 700; padding-top: 10px; }
.field textarea { min-height: 60px; resize: vertical; }
.input:focus, .field input:focus, .field textarea:focus { border-color: var(--ink); outline: none; }

/* SVG exercise demos */
.demo-svg { width: 100%; height: auto; display: block; max-height: 150px; }
.demo-svg polyline, .demo-svg line, .demo-svg path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.demo-svg .body, .demo-svg .limb { stroke: var(--ink); stroke-width: 5; }
.demo-svg .far { stroke: var(--graphite); stroke-width: 5; opacity: .55; }
.demo-svg .head, .demo-svg .fist { fill: var(--ink); }
.demo-svg .hand, .demo-svg .palms { stroke: var(--ink); stroke-width: 6.5; }
.demo-svg .dumbbell { fill: var(--plate); stroke: var(--ink); stroke-width: 2.5; }
.demo-svg .bar { stroke: var(--ink); stroke-width: 3; }
.demo-svg .plate { fill: var(--plate); }
.demo-svg .far-weight { opacity: .4; }
.demo-svg .ground { stroke: var(--rule); stroke-width: 1.5; }
.demo-svg .prop { stroke: var(--rule); stroke-width: 8; }
.demo-svg .prop-fill, .demo-svg .torso { fill: var(--rule); stroke: none; }
.demo-svg .prop-label { fill: var(--graphite); font-size: 9px; font-family: var(--text); }
.demo-svg .effort { stroke: var(--plate); stroke-width: 3; }
.demo-svg .timer-track { fill: var(--rule); }
.demo-svg .timer-fill { fill: var(--plate); transform-origin: 20px 0; animation: hold var(--hold, 10s) linear infinite; }
.demo-svg .int-jog { fill: var(--plate); }

.actions { display: grid; gap: 6px; }
.btn {
  min-height: 52px; padding: 0 20px; border-radius: var(--r-control); border: 0;
  font-weight: 650; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary {
  background: var(--ink); color: var(--on-ink); min-height: 64px; width: 100%;
  font-family: var(--display); font-weight: 700; font-size: 1.6rem; letter-spacing: .01em; padding-top: 3px;
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary.ready { box-shadow: inset 0 -5px 0 var(--plate); }
.btn-text { background: none; color: var(--graphite); min-height: 48px; font-weight: 500; }
.btn-text:hover { color: var(--ink); }
.btn-outline { background: none; border: 1.5px solid var(--ink); color: var(--ink); }
.btn-danger { background: none; border: 1.5px solid var(--red); color: var(--red); min-height: 44px; font-size: .92rem; }
:root[data-theme="dark"] .btn-danger { border-color: #ff8a8a; color: #ff8a8a; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.done-today { display: grid; justify-items: start; gap: 6px; padding: 20px 18px 16px; }
.done-today h2 { font-size: 2.2rem; }
.done-today .bar-wrap { width: 100%; margin: 6px 0 2px; }
.undo { margin-left: -6px; padding: 6px; border: 0; background: none; color: var(--graphite); text-decoration: underline; text-underline-offset: 3px; min-height: 40px; }

/* ---------- Barbell (weekly progress) ---------- */
.barbell { width: 100%; height: auto; display: block; overflow: visible; }
.barbell .shaft { fill: var(--graphite); }
.barbell .sleeve { fill: var(--graphite); }
.barbell .collar { fill: var(--ink); }
.barbell .slot { fill: none; stroke: var(--rule); stroke-width: 2; stroke-dasharray: 4 4; }
.barbell .p { stroke: rgba(0,0,0,.18); stroke-width: 1; }
.barbell .p-red { fill: var(--red); } .barbell .p-blue { fill: var(--blue); }
.barbell .p-yellow { fill: var(--yellow); } .barbell .p-green { fill: var(--green); }
.barbell .p.new { animation: load .5s cubic-bezier(.2,.9,.3,1.3) both; transform-box: fill-box; transform-origin: center; }

.week-head { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; text-align: center; }
.week-head h2 { font-size: 1.9rem; }
.week-head .range { color: var(--graphite); font-size: .9rem; margin-top: 2px; }
.week-head .icon-btn svg { stroke-width: 2.2; }
.week-head .icon-btn:disabled { opacity: .3; cursor: default; }
.week-progress { display: grid; gap: 10px; padding: 18px 16px 16px; }
.week-progress .count { display: flex; align-items: baseline; gap: 8px; }
.week-progress .count .big { font-family: var(--display); font-weight: 700; font-size: 3rem; line-height: .9; }

.strip { display: grid; grid-template-columns: repeat(7, 1fr); }
.day { display: grid; justify-items: center; gap: 6px; padding: 12px 0 14px; color: var(--graphite); font-size: .8rem; position: relative; }
.day + .day { border-left: 1px solid var(--rule); }
.day .n { font-family: var(--display); font-weight: 700; font-size: 1.5rem; line-height: 1; color: var(--ink); }
.day .mark { width: 18px; height: 18px; }
.day.today::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: 0; height: 3px; border-radius: 2px; background: var(--plate); }
.key { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 12px 16px; border-top: 1px solid var(--rule); font-size: .82rem; color: var(--graphite); }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key svg { width: 14px; height: 14px; }

.day-list { list-style: none; margin: 0; padding: 0; }
.day-list li { display: grid; grid-template-columns: 44px 1fr auto; align-items: baseline; gap: 10px; padding: 12px 16px; }
.day-list li + li { border-top: 1px solid var(--rule); }
.day-list .d { font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.day-list .state { font-size: .85rem; color: var(--graphite); }
.day-list .state.done { color: var(--ink); font-weight: 650; }
.day-list .state.done::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--plate); margin-right: 6px; vertical-align: 1px; }
.day-list li.is-today { background: var(--chalk); }

/* ---------- Progress ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; }
.stat { padding: 16px 18px; display: grid; gap: 2px; }
.stat:nth-child(2n) { border-left: 1px solid var(--rule); }
.stat:nth-child(n+3) { border-top: 1px solid var(--rule); }
.stat .v { font-family: var(--display); font-weight: 700; font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--graphite); font-size: .88rem; }
.chart { width: 100%; height: auto; display: block; margin-top: 12px; overflow: visible; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }
.chart .pt.best { fill: var(--plate); }
.chart text { fill: var(--graphite); font-size: 11px; font-family: var(--text); }
.chart .yl { font-family: var(--display); font-size: 12px; font-weight: 700; }
.select { width: auto; min-height: 40px; padding: 6px 10px; font-size: .92rem; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.rows li + li { border-top: 1px solid var(--rule); }
.rows .right { margin-left: auto; text-align: right; white-space: nowrap; }
.rows .date { color: var(--graphite); font-size: .82rem; }
.pb { font-family: var(--display); font-weight: 700; font-size: 1.25rem; }
.win-mark { width: 22px; height: 22px; flex: none; }
.note-text { min-width: 0; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 16px 8px; padding: 18px 12px; }
.badge { display: grid; justify-items: center; gap: 6px; text-align: center; }
.badge svg { width: 64px; height: 64px; }
.badge .b-name { font-size: .82rem; font-weight: 650; line-height: 1.2; }
.badge .b-sub { font-size: .75rem; color: var(--graphite); line-height: 1.25; }
.medal .rim { stroke: rgba(0,0,0,.2); stroke-width: 1; }
.medal .m-red { fill: var(--red); } .medal .m-blue { fill: var(--blue); }
.medal .m-yellow { fill: var(--yellow); } .medal .m-green { fill: var(--green); }
.medal .hub { fill: var(--paper); stroke: rgba(0,0,0,.15); }
.medal .ring { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 1.5; }
.medal text { font-family: var(--display); font-weight: 700; fill: #fff; }
.medal.m-on-yellow text { fill: #18263A; }
.medal.locked .disc { fill: none; stroke: var(--rule); stroke-width: 2.5; stroke-dasharray: 5 5; }
.medal.locked text { fill: var(--graphite); }
.medal.locked .hub, .medal.locked .ring { display: none; }

/* ---------- Settings ---------- */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 60px; padding: 10px 16px; }
.setting + .setting { border-top: 1px solid var(--rule); }
.setting .hint { display: block; color: var(--graphite); font-size: .85rem; font-weight: 400; }
.setting b { font-weight: 600; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--rule); transition: background .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--paper); transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--plate); }
.switch input:focus-visible + span { outline: 2.5px solid var(--plate); outline-offset: 2px; }
details.editor + details.editor { border-top: 1px solid var(--rule); }
details.editor summary { min-height: 56px; padding: 0 16px; display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
details.editor summary::-webkit-details-marker { display: none; }
details.editor summary .s-name { font-weight: 600; }
details.editor summary .s-sub { color: var(--graphite); font-size: .9rem; margin-left: auto; text-align: right; }
details.editor summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--graphite); border-bottom: 2px solid var(--graphite); transform: rotate(-45deg); transition: transform .2s; flex: none; margin-left: 4px; }
details.editor[open] summary::after { transform: rotate(45deg); }
.editor-body { display: grid; gap: 12px; padding: 0 16px 18px; }
.checks { display: grid; gap: 2px; }
.checks label { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.checks input { width: 20px; height: 20px; accent-color: var(--ink); }
.footnote { color: var(--graphite); font-size: .85rem; max-width: 52ch; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--rule);
}
.tabbar button {
  position: relative; border: 0; background: none; min-height: 60px;
  display: grid; justify-items: center; align-content: center; gap: 3px;
  color: var(--graphite); font-size: .76rem; font-weight: 600;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button[aria-current="page"] { color: var(--ink); }
.tabbar button[aria-current="page"] svg { stroke-width: 2.4; }
.tabbar button[aria-current="page"]::before { content: ""; position: absolute; top: -5px; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--plate); }
@media (min-width: 600px) {
  .tabbar { max-width: 560px; margin: 0 auto 14px; border-radius: 16px; border: 1px solid var(--rule); }
  .tabbar button[aria-current="page"]::before { top: -4px; }
}

/* ---------- Toasts, confetti ---------- */
.toasts {
  position: fixed; left: 0; right: 0; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30;
  display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 20px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  max-width: 480px; padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--on-ink); font-weight: 550;
  box-shadow: 0 8px 24px rgba(10, 20, 30, .22);
  animation: toast-in .28s ease both;
}
.toast svg { width: 28px; height: 28px; flex: none; }
.toast.out { animation: toast-out .25s ease both; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 40; }

@keyframes press { 0% { transform: scale(1); } 40% { transform: scale(.86); } 100% { transform: scale(1); } }
@keyframes bump { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
@keyframes load { from { transform: translateX(14px) scaleY(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes hold { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
