/* Apple-style theme: off-white canvas, white rounded cards, system (SF) type, blue accent, light only. */
:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, .1);
  --accent: #0071e3;
  --accent-ink: #ffffff;
  --tile: #f5f5f7;
  --note-bg: #eef5fd;
  --red: #ff3b30;
  --glass: rgba(245, 245, 247, .85);
  --nav-glass: rgba(255, 255, 255, .86);
  --chip: rgba(0, 0, 0, .05);
  --chip-hover: rgba(0, 0, 0, .09);
  --accent-soft: rgba(0, 113, 227, .09);
  --orange-bg: rgba(255, 149, 0, .16);
  --orange-fg: #8a4b00;
  --done-fg: #1a7f37;
  --pill-bg: rgba(29, 29, 31, .92);
  --orange: #ff9500;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --r-lg: 22px;
  --r-md: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 17px; line-height: 1.47;
  -webkit-font-smoothing: antialiased; letter-spacing: -.011em;
  padding-block: 28px 72px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
img { max-width: 100%; }
[hidden] { display: none !important; }
.wrap { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; min-width: 0; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: clamp(2.3rem, 8vw, 3.6rem); line-height: 1.05; font-weight: 700; letter-spacing: -.03em; }
h2 { font-size: 1.75rem; line-height: 1.12; font-weight: 700; letter-spacing: -.025em; }
h3 { font-size: 1.3rem; line-height: 1.2; font-weight: 600; letter-spacing: -.02em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid rgba(0, 113, 227, .5); outline-offset: 2px; }
button { font-family: inherit; }

.hero { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.eyebrow { font-size: .8rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }

/* tabs */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 20; background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.tabs { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 15; display: flex; gap: 6px; overflow-x: auto; padding: 10px 2px; margin-inline: -2px; scrollbar-width: none;
  background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; font-size: .95rem; font-weight: 500; color: var(--fg); background: var(--chip); border: 0; padding: 8px 16px; border-radius: 980px; cursor: pointer; transition: background .2s, color .2s; }
.tabs button:hover { background: var(--chip-hover); }
.tabs button.on { background: var(--fg); color: var(--bg); }

.panel-tab { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.js .panel-tab { display: none; }
.js .panel-tab.active { display: flex; }

.panel { background: var(--surface); border-radius: var(--r-lg); padding: 28px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 520px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .95rem; }
th { font-size: .75rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
tbody tr:last-child td { border-bottom: 0; }
td strong { font-weight: 600; }
.rest { color: var(--muted); }
ul.rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.note { background: var(--note-bg); color: var(--fg); padding: 14px 16px; border-radius: var(--r-md); font-size: .95rem; }
.foot { color: var(--muted); font-size: .85rem; }
.sources ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; overflow-wrap: anywhere; font-size: .93rem; }

.cards3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.stat { background: var(--tile); border-radius: var(--r-md); padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.stat strong { font-size: 1.7rem; line-height: 1.1; font-weight: 700; letter-spacing: -.025em; }
.stat span { color: var(--muted); font-size: .85rem; }

/* day header */
.dayhead { display: flex; align-items: center; gap: 16px; background: var(--surface); border-radius: var(--r-lg); padding: 20px 24px; }
.dayhead > div { min-width: 0; }
.dayhead p { color: var(--muted); }
.dayhead .when { color: var(--accent); font-weight: 600; font-size: .9rem; margin-top: 2px; }
.dayhead .figs { margin-left: auto; }
.dk { font-size: 1.9rem; font-weight: 700; background: var(--accent); color: var(--accent-ink); width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; flex: none; }

.sumbox { background: var(--surface); border-radius: var(--r-lg); padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sum { min-width: 330px; }
.sum a { color: var(--fg); font-weight: 600; }
.sum a:hover { color: var(--accent); }
.reset { align-self: flex-start; font-size: .9rem; color: var(--accent); background: var(--accent-soft); border: 0; padding: 8px 16px; border-radius: 980px; cursor: pointer; }

/* exercise card */
.ex { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; display: grid; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); min-width: 0; scroll-margin-top: 70px; }
.pics { display: grid; grid-template-rows: 1fr 1fr; gap: 2px; background: var(--bg); }
.pics figure { margin: 0; position: relative; background: #fff; }
.pics img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; }
.pics figcaption { position: absolute; left: 10px; top: 10px; font-size: .72rem; font-weight: 600; background: rgba(29, 29, 31, .72); color: #fff; padding: 3px 10px; border-radius: 980px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.body { padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.n { color: var(--accent); margin-right: 8px; font-variant-numeric: tabular-nums; }
.tag { margin-left: 8px; font-size: .7rem; font-weight: 600; background: var(--tile); color: var(--muted); padding: 3px 10px; border-radius: 980px; vertical-align: middle; }
.ex h4, .grip h4 { font-size: .75rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.musblock { display: flex; gap: 16px; align-items: flex-start; }
.muscles { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.mrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ml { font-size: .72rem; font-weight: 600; color: var(--muted); min-width: 118px; }
.mchip { font-size: .85rem; padding: 3px 12px; border-radius: 980px; }
.mchip.p { background: var(--red); color: #fff; font-weight: 600; }
.mchip.s { background: var(--orange-bg); color: var(--orange-fg); }
.legend { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot.r { background: #fc0000; } .dot.o { background: #f57900; margin-left: 6px; }
.figs { display: flex; gap: 6px; flex: none; }
.fig { margin: 0; position: relative; aspect-ratio: 200 / 362; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.fig img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fig figcaption { position: absolute; left: 0; right: 0; bottom: 0; font-size: .6rem; font-weight: 600; text-align: center; background: rgba(29, 29, 31, .75); color: #fff; padding: 2px 0; z-index: 2; }
.specs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.specs div { background: var(--tile); border-radius: 12px; padding: 10px 14px; }
.specs .wide { grid-column: 1 / -1; }
.specs dt { font-size: .72rem; font-weight: 600; color: var(--muted); }
.specs dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.grip { display: flex; flex-direction: column; gap: 8px; background: var(--tile); border-radius: var(--r-md); padding: 14px 16px; min-width: 0; }
.grip .tablewrap { background: var(--surface); border-radius: 10px; padding: 0 4px; }
.gt { min-width: 0; width: 100%; }
.gt th, .gt td { font-size: .9rem; }
.gt td:first-child { width: 42%; font-weight: 600; }
.feel { font-size: .93rem; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; font-size: .97rem; }
.galti { font-size: .93rem; color: var(--muted); }
.galti strong { color: var(--fg); }
.log { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; border-top: 1px solid var(--line); padding-top: 12px; }
.chk { display: flex; gap: 8px; align-items: center; font-weight: 600; cursor: pointer; }
.chk input { width: 22px; height: 22px; accent-color: var(--accent); }
.wl { display: flex; gap: 8px; align-items: center; font-size: .93rem; color: var(--muted); }
.wt { width: 88px; font: inherit; color: var(--fg); background: var(--tile); border: 1px solid transparent; border-radius: 10px; padding: 7px 10px; }

/* diet */
.menus { display: flex; flex-direction: column; gap: 8px; }
.dd { background: var(--tile); border-radius: var(--r-md); overflow: hidden; }
.dd summary { cursor: pointer; padding: 14px 18px; display: flex; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 1.05rem; }
.dd .tot { font-size: .85rem; color: var(--accent); font-weight: 600; align-self: center; }
.dd .tablewrap { background: var(--surface); margin: 0 6px 6px; border-radius: 10px; }
.mt { min-width: 340px; }
.mt .tm { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.mt .pr { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }

/* weekday view */
.phasebtns, .filters { display: flex; flex-wrap: wrap; gap: 6px; }
.phasebtns button, .filters button { font-size: .92rem; font-weight: 500; color: var(--fg); background: var(--tile); border: 0; padding: 8px 16px; border-radius: 980px; cursor: pointer; }
.phasebtns button.on, .filters button.on { background: var(--fg); color: var(--bg); }
.js .weekset { display: none; }
.js .weekset.on { display: block; }
.weekgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.wd { text-align: left; font: inherit; color: var(--fg); background: var(--tile); border: 0; border-radius: var(--r-md); padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.wd.work { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.wd.work:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, .08); }
.wd.off { color: var(--muted); }
.wdn { font-size: .75rem; font-weight: 600; color: var(--accent); }
.wd strong { font-size: 1.1rem; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; color: var(--fg); }
.wd.off strong { color: var(--muted); }
.wd .go { font-size: .85rem; color: var(--muted); }
.wd.work .go { color: var(--accent); font-weight: 600; }
.wd .figs { gap: 4px; }
.daycard { text-align: left; font: inherit; color: var(--fg); background: var(--tile); border: 0; border-radius: var(--r-md); padding: 14px; cursor: pointer; }

/* optional exercises */
.optsec { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.opth { font-size: 1.75rem; }
.opth span { color: var(--muted); font-weight: 500; font-size: 1.2rem; }
.optlist { display: flex; flex-direction: column; gap: 10px; }
.opt { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; min-width: 0; }
.opt[hidden] { display: none; }
.opt summary { display: flex; gap: 14px; align-items: center; padding: 10px 18px 10px 10px; cursor: pointer; list-style: none; }
.opt summary::-webkit-details-marker { display: none; }
.opt summary img { width: 76px; height: 57px; object-fit: contain; background: #fff; border-radius: 10px; flex: none; }
.on2 { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.on2 strong { font-size: 1.02rem; font-weight: 600; line-height: 1.2; }
.on2 small { color: var(--muted); font-size: .82rem; }
.eqp { flex: none; font-size: .72rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); padding: 3px 10px; border-radius: 980px; }
.opt summary::after { content: "+"; font-size: 1.5rem; font-weight: 300; color: var(--muted); flex: none; width: 20px; text-align: center; }
.opt[open] summary::after { content: "–"; }
.opt[open] > summary { border-bottom: 1px solid var(--line); }
.opt .ex { border-radius: 0; }

@media (max-width: 700px) {
  body { font-size: 16px; padding-block: 20px 56px; }
  .panel { padding: 20px; border-radius: 20px; }
  .ex { grid-template-columns: minmax(0, 1fr); }
  .pics { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  .body { padding: 18px; }
  .musblock { flex-direction: column; }
  .ml { min-width: 100%; }
  .dayhead { flex-wrap: wrap; padding: 18px; }
  .dayhead .figs { margin-left: 0; }
  .eqp { display: none; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .wd.work { transition: none; } }

/* ================= v2: friendlier UX ================= */
button, summary, a { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }

/* today card */
.today { background: linear-gradient(135deg, #0071e3, #4aa3ff); color: #fff; border-radius: var(--r-lg); padding: 26px 28px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.today[hidden] { display: none; }
.today .eyebrow { color: rgba(255, 255, 255, .8); }
.today h2 { font-size: 2rem; }
.today p { color: rgba(255, 255, 255, .92); max-width: 46ch; }
.cta { margin-top: 6px; font-size: 1rem; font-weight: 600; color: var(--accent); background: #fff; border: 0; padding: 12px 22px; border-radius: 980px; cursor: pointer; min-height: 44px; }

/* accordion panels */
.panel.acc { padding: 0; gap: 0; }
.panel.acc > summary { list-style: none; cursor: pointer; padding: 20px 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.panel.acc > summary::-webkit-details-marker { display: none; }
.panel.acc > summary h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.02em; }
.panel.acc > summary::after { content: ""; flex: none; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; margin-right: 4px; }
.panel.acc[open] > summary::after { transform: rotate(-135deg); }
.accbody { padding: 0 28px 26px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* day list + progress */
.proghead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ptxt { font-size: .9rem; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--tile); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.jump { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; }
.jump li + li { border-top: 1px solid var(--line); }
.jump a { display: flex; align-items: center; gap: 14px; padding: 12px 2px; min-height: 56px; color: var(--fg); text-decoration: none; }
.jn { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--tile); display: grid; place-items: center; font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.jt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.jt strong { font-weight: 600; font-size: 1rem; line-height: 1.25; }
.jt small { color: var(--muted); font-size: .84rem; }
.jc { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); position: relative; }
.jump .done .jc { background: #34c759; border-color: #34c759; }
.jump .done .jc::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.jump .done .jn { background: rgba(52, 199, 89, .15); color: var(--done-fg); }

/* exercise card v2 */
.exh h3 { display: flex; align-items: baseline; flex-wrap: wrap; }
.exsub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.ex.complete { box-shadow: inset 0 0 0 2px #34c759; }
.log { display: flex; flex-direction: column; gap: 10px; border-top: 0; padding-top: 0; align-items: stretch; }
.setrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ml2 { font-size: .8rem; font-weight: 600; color: var(--muted); margin-right: 2px; }
.setb { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); color: var(--fg); font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; }
.setb:active { transform: scale(.94); }
.setb.on { background: #34c759; border-color: #34c759; color: #fff; }
.timerb { margin-left: auto; min-height: 44px; padding: 0 16px; font-size: .92rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 0; border-radius: 980px; cursor: pointer; }
.wl { font-size: .93rem; }
.wt { min-height: 40px; }
details.sec { border-top: 1px solid var(--line); padding-top: 4px; }
details.sec > summary { list-style: none; cursor: pointer; padding: 12px 0; min-height: 48px; display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 1rem; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; margin-right: 4px; }
details.sec[open] > summary::after { transform: rotate(-135deg); }
details.sec[open] { padding-bottom: 6px; }
details.sec > p, details.sec > .tablewrap, details.sec > .steps, details.sec > .musblock { margin-bottom: 10px; }
.pics figure { cursor: zoom-in; }

/* meals */
.meals { list-style: none; margin: 0; padding: 4px 18px 12px; display: flex; flex-direction: column; }
.meals li { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.meals li:first-child { border-top: 0; }
.meals .tm { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9rem; padding-top: 2px; }
.meals p { color: var(--fg); font-size: .95rem; margin-top: 2px; }
.meals .pr { font-weight: 600; font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--accent); white-space: nowrap; padding-top: 2px; }

/* weekday: today marker */
.wd.today { box-shadow: inset 0 0 0 2px var(--accent); background: var(--surface); }
.wd.today .wdn::after { content: " · aaj"; }

/* bottom nav + timer + lightbox */
.bnav { display: none; }
.rt { position: fixed; z-index: 40; right: 20px; bottom: 20px; display: flex; align-items: center; gap: 10px; background: var(--pill-bg); color: #fff; padding: 8px 8px 8px 18px; border-radius: 980px; box-shadow: 0 8px 28px rgba(0, 0, 0, .25); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.rt[hidden] { display: none; }
.rt.done { background: #34c759; }
.rtl { font-size: .8rem; opacity: .75; }
.rtt { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2ch; }
.rt button { min-width: 44px; min-height: 44px; border-radius: 980px; border: 0; background: rgba(255, 255, 255, .16); color: #fff; font-size: .9rem; font-weight: 600; cursor: pointer; }
.lb { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .88); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.lb[hidden] { display: none; }
.lb img { max-width: 100%; max-height: 88vh; border-radius: 12px; background: #fff; }
.lb button { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 16px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .2); color: #fff; font-size: 1.1rem; cursor: pointer; }

@media (max-width: 700px) {
  .tabs { display: none; }
  body { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
  body::before { display: none; }
  h1 { font-size: 2.2rem; }
  .hero { padding-top: 0; }
  .today { padding: 22px 20px; }
  .today h2 { font-size: 1.7rem; }
  .panel.acc > summary { padding: 16px 20px; }
  .accbody { padding: 0 20px 22px; }
  .dayhead { gap: 14px; }
  .dayhead .figs { display: none; }
  .meals li { grid-template-columns: 44px 1fr auto; gap: 10px; }
  .timerb { margin-left: 0; }
  .bnav { display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    padding: 6px max(6px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
    background: var(--nav-glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--line); }
  .bnav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border: 0; background: none; color: var(--muted); font-size: .66rem; font-weight: 500; cursor: pointer; border-radius: 12px; }
  .bnav button b { width: 24px; height: 24px; border-radius: 50%; border: 1.8px solid currentColor; display: grid; place-items: center; font-size: .78rem; font-weight: 700; }
  .bnav button.on { color: var(--accent); }
  .rt { right: 12px; left: 12px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); justify-content: space-between; }
  .rtt { flex: 1; text-align: center; }
}

/* ================= v3: dark theme, theme switch, video link, back-to-top ================= */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1c1c1e;
  --fg: #f5f5f7;
  --muted: #98989d;
  --line: rgba(255, 255, 255, .14);
  --accent: #0a84ff;
  --tile: #2c2c2e;
  --note-bg: rgba(10, 132, 255, .16);
  --glass: rgba(0, 0, 0, .78);
  --nav-glass: rgba(28, 28, 30, .88);
  --chip: rgba(255, 255, 255, .1);
  --chip-hover: rgba(255, 255, 255, .16);
  --accent-soft: rgba(10, 132, 255, .2);
  --orange-bg: rgba(255, 159, 10, .2);
  --orange-fg: #ffb340;
  --done-fg: #30d158;
  --pill-bg: rgba(72, 72, 74, .96);
}
:root[data-theme="dark"] a:focus-visible, :root[data-theme="dark"] button:focus-visible { outline-color: rgba(10, 132, 255, .7); }
:root[data-theme="dark"] .wd.work:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .5); }
:root[data-theme="dark"] .setb.on { color: #fff; }
:root[data-theme="dark"] .pics figure, :root[data-theme="dark"] .fig { border-color: rgba(255, 255, 255, .08); }
:root[data-theme="dark"] .cta { background: #fff; color: #0066cc; }
:root[data-theme="dark"] .wt { color: var(--fg); }

/* theme switch */
.theme { align-self: flex-end; display: inline-flex; gap: 2px; padding: 3px; background: var(--chip); border-radius: 980px; }
.theme button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 0; border-radius: 980px; background: transparent; color: var(--muted); font-size: .85rem; font-weight: 600; cursor: pointer; }
.theme button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }

/* form video link */
.vid { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; min-height: 40px; padding: 0 16px; border-radius: 980px; background: var(--accent-soft); color: var(--accent); font-size: .92rem; font-weight: 600; text-decoration: none; }
.vid:hover { text-decoration: none; filter: brightness(.95); }
.exh { display: flex; flex-direction: column; }

/* back to top */
.totop { position: fixed; z-index: 35; right: 20px; bottom: 24px; width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--glass); color: var(--fg); box-shadow: 0 4px 16px rgba(0, 0, 0, .18), inset 0 0 0 1px var(--line); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px); cursor: pointer; }
.totop[hidden] { display: none; }
.totop:active { transform: scale(.94); }
.rt:not([hidden]) ~ .totop { bottom: 92px; }
@media (max-width: 700px) {
  .theme { margin-bottom: -4px; }
  .totop { right: 14px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .rt:not([hidden]) ~ .totop { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }
}
