/* Dad Workout — visual style: clean Android (Material-like) app.
 * Big, readable sizes for a 60-year-old; neutral surfaces, one green accent, system font (Roboto). */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #15181d;          /* 17:1 on white */
  --ink2: #565d6b;         /* 7:1 on white */
  --line: #e3e6eb;
  --primary: #0b7a55;      /* white text 5.3:1 */
  --primary-press: #08603f;
  --primary-tint: #e1f2ea;
  --tonal: #eceff3;
  --tonal-press: #dfe3e9;
  --danger: #c0352b;
  --warn-bg: #fff3e0;
  --dark: #101318;
  --dark-2: #1b1f26;
  --photo: #dfe0e2;        /* studio grey behind the NIA photos (see tools/neutral_bg.py) */
  --r-card: 20px;
  --r-btn: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .06);
  --nav-h: 80px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { font-size: 19px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.4;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain;
}
h1, h2, h3, p { margin: 0; }
button, label.row, label.btn { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, label:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
ul { margin: 0; padding: 0; list-style: none; }
svg { display: block; }
.muted { color: var(--ink2); }
.muted.big { font-size: 1.15rem; }
.pad { padding: 0 4px; }

/* ---------- layout ---------- */
.screen { padding: 8px 16px calc(var(--nav-h) + 24px); max-width: 600px; margin: 0 auto; }
.appbar { padding: 16px 4px 14px; }
.appbar-sub { color: var(--ink2); font-size: 1rem; }
.appbar-title { font-size: 1.75rem; font-weight: 700; letter-spacing: -.01em; }
.appbar.row-bar { display: flex; align-items: center; gap: 6px; padding: 8px 0 8px; }
.appbar-small { font-size: 1.05rem; color: var(--ink2); font-weight: 500; }

.card { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-size: 1.2rem; font-weight: 700; }
.card-title.xl { font-size: 1.6rem; }
.list-h { display: flex; align-items: center; gap: 8px; font-size: .95rem; font-weight: 600; color: var(--ink2); margin: 22px 6px 8px; }
.stack { display: grid; gap: 10px; margin-top: 16px; }
.note { font-size: .95rem; color: var(--ink2); margin: 12px 6px 0; }
.note.warn { color: #7a3300; background: var(--warn-bg); padding: 12px 14px; border-radius: 12px; }
.note.credit { font-size: .85rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ph, var(--primary)); flex: none; display: inline-block; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  border: 0; border-radius: var(--r-btn); font-weight: 600; text-align: center; padding: 0 18px;
  min-height: 52px; font-size: 1.05rem; transition: background-color .15s, transform .08s;
  touch-action: manipulation;
}
.btn svg { width: 24px; height: 24px; flex: none; }
.btn.md { min-height: 52px; font-size: 1rem; padding: 0 12px; }
.btn.lg { min-height: 56px; font-size: 1.1rem; }
.btn.xl { min-height: 64px; font-size: 1.3rem; border-radius: 18px; }
.btn.xl svg { width: 28px; height: 28px; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-press); }
.btn.tonal { background: var(--tonal); color: var(--ink); }
.btn.tonal:active { background: var(--tonal-press); }
.btn.sel { background: var(--primary-tint); color: var(--primary-press); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.light { background: #fff; color: var(--ink); }
.btn:active { transform: scale(.985); }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center;
  padding: 0; flex: none; color: var(--ink);
}
.icon-btn:active { background: var(--tonal); }
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn:disabled { opacity: .3; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; min-height: 44px;
  padding: 0 16px 0 12px; font-weight: 600; font-size: 1rem;
}
.pill svg { width: 20px; height: 20px; }
.glass { background: rgba(16, 19, 24, .55); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.chip { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: .95rem; }

/* ---------- list rows (Android-style) ---------- */
.list.card { padding: 4px 0; overflow: hidden; }
.row {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; background: none; border: 0;
  padding: 14px 18px; min-height: 64px;
}
.list li + li .row, .list .row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--tonal); }
.row-t { flex: 1; font-size: 1.08rem; font-weight: 500; }
.row-t small { display: block; font-size: .9rem; color: var(--ink2); font-weight: 400; margin-top: 2px; }
.danger-t { color: var(--danger); }
.chev svg { width: 22px; height: 22px; color: #9aa1ad; }
.switch { width: 52px; height: 32px; border-radius: 16px; background: #c4c9d2; position: relative; flex: none; transition: background-color .2s; }
.switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(20px); }

/* exercise rows */
.prow { padding: 12px 14px; gap: 14px; }
.pthumb { width: 64px; height: 64px; border-radius: 12px; overflow: hidden; background: var(--photo); flex: none; }
.ph-thumb { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; display: block; }
.ptext { flex: 1; min-width: 0; }
.ptext b { display: block; font-size: 1.05rem; font-weight: 600; line-height: 1.25; }
.ptext > span { display: block; color: var(--ink2); font-size: .92rem; margin-top: 2px; }
.prow.skipped .ptext b { text-decoration: line-through; color: var(--ink2); }
.prow.skipped .pthumb { opacity: .45; }
.tag { display: inline-block !important; margin: 6px 6px 0 0; padding: 2px 10px; border-radius: 999px; font-size: .82rem !important; font-weight: 600; color: var(--ink) !important; }
.tag.skip { background: var(--tonal); }
.tag.easy { background: #fff1c2; }

/* ---------- bottom navigation ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, 1fr);
}
.tab { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--ink2); }
.tab-ic { width: 64px; height: 34px; border-radius: 17px; display: grid; place-items: center; transition: background-color .2s; }
.tab-ic svg { width: 26px; height: 26px; }
.tab-l { font-size: .9rem; font-weight: 600; }
.tab.on { color: var(--primary-press); }
.tab.on .tab-ic { background: var(--primary-tint); }

/* ---------- Today ---------- */
.workout-card { padding: 0; overflow: hidden; }
.cover { position: relative; height: 190px; background: var(--photo); }
.cover img { width: 100%; height: 100%; object-fit: cover; object-position: center 28%; display: block; }
.cover-chip { position: absolute; left: 14px; top: 14px; background: #fff; color: var(--primary-press); font-weight: 700; font-size: .9rem; padding: 6px 12px; border-radius: 999px; }
.card-body { padding: 18px; }
.card-body .muted { margin-top: 2px; font-size: 1.05rem; }
.phase-list { margin: 14px 0 18px; border-top: 1px solid var(--line); }
.phase-list li { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 1.05rem; }
.pl-name { flex: 1; font-weight: 500; }
.tip { margin: 0 0 16px; padding: 12px 14px; background: var(--primary-tint); border-radius: 12px; font-size: .98rem; }
.done-card, .rest-card { text-align: center; padding: 26px 18px; }
.done-card .muted, .rest-card .muted { margin-top: 6px; }
.rest-card .btn { margin-top: 18px; }
.done-ic, .rest-ic { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; }
.done-ic { background: var(--primary); color: #fff; }
.rest-ic { background: var(--tonal); color: var(--ink2); }
.done-ic svg, .rest-ic svg { width: 38px; height: 38px; }
.wstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.wday { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wd-label { font-size: .85rem; font-weight: 600; color: var(--ink2); }
.wd-dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); font-weight: 700; font-size: .95rem; color: var(--ink2); }
.wday.planned .wd-dot { background: var(--primary-tint); color: var(--primary-press); }
.wday.done .wd-dot { background: var(--primary); color: #fff; }
.wd-dot svg { width: 22px; height: 22px; }
.wday.today .wd-label { color: var(--primary-press); }
.wday.today .wd-dot { box-shadow: 0 0 0 2px var(--primary); }

/* ---------- History ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 16px 18px; }
.stat b { display: block; font-size: 2.2rem; line-height: 1.1; font-weight: 700; }
.stat span { color: var(--ink2); font-size: .95rem; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin: -4px -6px 8px; }
.cal-nav h2 { font-size: 1.15rem; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-h { font-size: .82rem; font-weight: 600; color: var(--ink2); padding-bottom: 6px; }
.cal-d { aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; font-size: 1rem; font-weight: 500; }
.cal-d.today { box-shadow: inset 0 0 0 2px var(--primary); font-weight: 700; }
.cal-d.done { background: var(--primary); color: #fff; font-weight: 700; }
.cal-d.mini { display: inline-block; width: 14px; height: 14px; aspect-ratio: auto; vertical-align: middle; margin-right: 6px; }
.legend { margin-top: 10px; color: var(--ink2); font-size: .9rem; }
.prog li, .last li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.prog li:last-child, .last li:last-child { border-bottom: 0; }
.prog .pn { display: block; font-weight: 600; }
.prog .pv { display: flex; align-items: center; gap: 6px; color: var(--ink2); }
.prog .pv b { color: var(--primary-press); }
.prog .arrow svg { width: 18px; height: 18px; }
.prog em { font-style: normal; background: #fff1c2; padding: 0 8px; border-radius: 8px; font-size: .85rem; }
.last li b { display: block; font-weight: 600; }
.last li span { color: var(--ink2); font-size: .95rem; }

/* ---------- Plan ---------- */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; }
.day-t { aspect-ratio: 1; border-radius: 50%; border: 0; background: var(--tonal); font-weight: 700; font-size: .95rem; padding: 0; color: var(--ink2); }
.day-t.on { background: var(--primary); color: #fff; }
.sched { margin-top: 14px; border-top: 1px solid var(--line); }
.sched li { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.sched li:last-child { border-bottom: 0; }
.segs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--tonal); padding: 4px; border-radius: 14px; margin: 18px 0 8px; }
.seg { border: 0; border-radius: 11px; background: transparent; min-height: 48px; font-weight: 600; font-size: 1rem; color: var(--ink2); }
.seg.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.file input { display: none; }

/* plan detail */
.detail .stage { position: relative; height: 300px; border-radius: var(--r-card); overflow: hidden; background: var(--photo); }
.detail-title { font-size: 1.6rem; font-weight: 700; margin-top: 16px; line-height: 1.2; }
.stepper { display: inline-flex; align-items: center; gap: 4px; margin-top: 12px; background: var(--card); border-radius: 999px; box-shadow: var(--shadow); padding: 4px; }
.stepper span { min-width: 120px; text-align: center; font-size: 1.05rem; }
.stepper b { font-size: 1.3rem; }
.step-b { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--tonal); font-size: 1.6rem; font-weight: 500; }
.info-card { margin-top: 16px; }
.why { font-size: 1.08rem; font-weight: 600; }
.sub { font-size: 1rem; font-weight: 700; margin-top: 16px; color: var(--ink2); }
.how { margin-top: 8px; display: grid; gap: 8px; }
.how li { position: relative; padding-left: 22px; font-size: 1.08rem; line-height: 1.35; }
.how li::before { content: ''; position: absolute; left: 4px; top: .55em; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.watch { margin-top: 14px; padding: 12px 14px; background: #fdecea; border-radius: 12px; font-size: 1.02rem; }
.easier { margin-top: 12px; padding: 12px 14px; background: #fff6d6; border-radius: 12px; font-size: 1.05rem; line-height: 1.35; }

/* ---------- exercise photos (adapted from NIA) ---------- */
.stage, .next-fig { position: relative; }
.has-ph { background: var(--photo); }
.ph { position: absolute; inset: 0; display: flex; gap: 2px; }
.ph figure { position: relative; flex: 1 1 0; margin: 0; overflow: hidden; transition: opacity .35s ease, filter .35s ease; }
.ph img { width: 100%; height: 100%; display: block; object-fit: contain; object-position: center bottom; }
.ph-n2 figure { opacity: .45; filter: saturate(.5); }
.ph-n2 figure.on { opacity: 1; filter: none; }
.ph-num { position: absolute; left: 10px; bottom: 10px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.9); color: var(--ink);
  font-weight: 700; font-size: 1rem; display: grid; place-items: center; }
.ph-n2 figure.on .ph-num { background: var(--primary); color: #fff; }
.frames { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 14px; }
.frames.one { grid-template-columns: 1fr; }
.frames figure { margin: 0; background: var(--photo); border-radius: 14px; overflow: hidden; position: relative; }
.frames img { width: 100%; height: 230px; display: block; object-fit: contain; object-position: center bottom; }
.frames figcaption { position: absolute; left: 8px; bottom: 8px; background: rgba(255,255,255,.92); font-weight: 600; font-size: .9rem; padding: 3px 10px; border-radius: 999px; }

/* NIA video floats over the .stage */
.vid { position: absolute; z-index: 4; overflow: hidden; background: #000; opacity: 0; transition: opacity .35s ease; pointer-events: none; }
.vid.on { opacity: 1; }
.vid iframe { width: 100%; height: 100%; border: 0; display: block; }
.vid-credit { position: absolute; right: 10px; bottom: 30px; font-size: .75rem; color: #fff; background: rgba(0,0,0,.45); padding: 2px 8px; border-radius: 8px; }

/* ---------- workout: exercise ---------- */
.wk { height: 100vh; height: 100dvh; overflow-y: auto; max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; background: var(--card); }
.media { position: relative; flex: 1 1 44vh; min-height: 210px; max-height: 52vh; background: var(--photo); }
.media .stage { position: absolute; inset: 0 0 22px 0; }
.media-top { position: absolute; left: 0; right: 0; top: 0; z-index: 5; padding: 10px 12px 0; padding-top: calc(10px + env(safe-area-inset-top)); }
.media-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.segbar { height: 5px; border-radius: 3px; background: rgba(255,255,255,.55); overflow: hidden; }
.segbar span { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width .4s; }
.panel { position: relative; z-index: 5; background: var(--card); border-radius: 24px 24px 0 0; margin-top: -22px; padding: 20px 18px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; flex: 0 0 auto; box-shadow: 0 -4px 16px rgba(16,24,40,.08); }
.ex-name { font-size: 1.55rem; font-weight: 700; line-height: 1.2; }
.target { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.target b { font-size: 3rem; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.target span { font-size: 1.05rem; font-weight: 600; color: var(--ink2); line-height: 1.2; }
.target .set { font-style: normal; color: var(--ink); }
.target.running b { color: var(--primary); }
.tbar { height: 8px; border-radius: 4px; background: var(--tonal); overflow: hidden; margin-top: 10px; }
.tbar span { display: block; height: 100%; background: var(--primary); transform-origin: left center; }
.wk-ex .how { margin-top: 12px; gap: 6px; }
.wk-ex .how li { font-size: 1.05rem; }
.wk-actions { display: grid; gap: 10px; padding-top: 16px; margin-top: auto; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.duo .btn { white-space: nowrap; }

/* ---------- workout: rest (dark) ---------- */
.wk-rest { background: var(--dark); color: #fff; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); padding-top: calc(12px + env(safe-area-inset-top)); }
.wk-rest .segbar { background: rgba(255,255,255,.18); }
.rest-top { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.rest-label { font-size: 1.3rem; font-weight: 700; }
.wk-rest .ring {
  --pct: 1; width: min(66vw, 270px); aspect-ratio: 1; margin: 28px auto 14px; border-radius: 50%; flex: none;
  background: conic-gradient(#3ccf91 calc(var(--pct) * 360deg), rgba(255,255,255,.12) 0); display: grid; place-items: center;
}
.wk-rest .ring span { width: calc(100% - 16px); aspect-ratio: 1; border-radius: 50%; background: var(--dark); display: grid; place-items: center;
  font-size: 4.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rest-msg { text-align: center; font-size: 1.1rem; color: rgba(255,255,255,.75); }
.next { display: flex; align-items: center; gap: 14px; margin-top: 24px; background: var(--dark-2); border-radius: var(--r-card); padding: 12px; }
.next-fig { width: 96px; height: 96px; border-radius: 14px; overflow: hidden; flex: none; }
.next-sub { font-size: .95rem; color: rgba(255,255,255,.65); }
.next-name { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.wk-rest .wk-actions { margin-top: auto; }

/* ---------- workout: done ---------- */
.wk-done { padding: 24px 18px; justify-content: center; text-align: center; background: var(--bg); }
.wk-done h1 { font-size: 2.2rem; font-weight: 700; }
.wk-done .q { margin: 28px 0 12px; font-size: 1.25rem; font-weight: 700; }
.wk-done .list.card { text-align: left; }
.rate .row-t { font-size: 1.15rem; font-weight: 600; }
.big-check { width: 96px; height: 96px; margin: 0 auto 16px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; flex: none; }
.big-check svg { width: 54px; height: 54px; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

/* ---------- bottom sheet / dialog ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 20; background: rgba(16, 19, 24, .5); display: grid; align-items: end; }
.modal { background: #fff; border-radius: 28px 28px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 10px;
  max-width: 600px; width: 100%; margin: 0 auto; max-height: 92vh; max-height: 92dvh; overflow-y: auto; }
.handle { width: 40px; height: 4px; border-radius: 2px; background: #c4c9d2; margin: 0 auto 6px; }
.modal-q { font-size: 1.3rem; font-weight: 700; margin: 6px 0 8px; }
.sheet-title { font-size: 1.4rem; font-weight: 700; margin-top: 4px; }

/* ---------- motion ---------- */
.enter { animation: enter .25s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes enter { from { opacity: 0; } to { opacity: 1; } }
.big-check.draw { animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.big-check.draw path { stroke-dasharray: 26; stroke-dashoffset: 26; animation: draw .4s .2s ease-out forwards; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- small phones ---------- */
@media (max-width: 380px) {
  html { font-size: 18px; }
  .duo .btn svg { display: none; }
}
@media (max-height: 760px) {
  .media { min-height: 170px; }
  .ex-name { font-size: 1.35rem; }
  .target b { font-size: 2.5rem; }
  .wk-ex .how li { font-size: 1rem; }
  .btn.xl { min-height: 58px; }
}
@media (prefers-reduced-motion: reduce) {
  .enter, .big-check.draw { animation: none; }
  .big-check.draw path { stroke-dashoffset: 0; animation: none; }
  .ph figure, .vid, .switch, .switch::after { transition: none; }
}
