/* One column of cards, phone first: home list -> workout card stack -> how-to page.
   Light tokens on :root; the two dark blocks redefine them (system dark, or an explicit
   data-theme="dark" from the artifact viewer). The program accent is set inline per view. */
:root {
  --bg: #f6f6f7;
  --card: #ffffff;
  --fg: #16171a;
  --muted: #6b6e75;
  --line: #e4e5e8;
  --pic: #ffffff;
  --done: #2b8a3e;
  --skip: #868e96;
  --accent: #d9480f;
  --on-accent: #ffffff;
  --toast-bg: #26282c;
  --toast-fg: #ffffff;
  --toast-btn: rgb(255 255 255 / 14%);
  --tool-bg: rgb(255 255 255 / 90%);
  --tool-fg: #2b2d31;
  --like: #e03131;
  --dislike-on: #2b2d31;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  --toast-shadow: 0 6px 24px rgb(0 0 0 / 25%);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1012;
    --card: #1a1b1e;
    --fg: #f1f2f3;
    --muted: #9a9ea6;
    --line: #2a2c31;
    --skip: #9aa1a8;
    --toast-bg: #2e3035;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --toast-shadow: 0 6px 24px rgb(0 0 0 / 50%);
    --tool-bg: rgb(32 33 37 / 88%);
    --tool-fg: #eceef0;
    --like: #ff6b6b;
    --dislike-on: #f1f3f5;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1012;
  --card: #1a1b1e;
  --fg: #f1f2f3;
  --muted: #9a9ea6;
  --line: #2a2c31;
  --skip: #9aa1a8;
  --toast-bg: #2e3035;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  --toast-shadow: 0 6px 24px rgb(0 0 0 / 50%);
  --tool-bg: rgb(32 33 37 / 88%);
  --tool-fg: #eceef0;
  --like: #ff6b6b;
  --dislike-on: #f1f3f5;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  padding-block: 0 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
/* paints the band above the sticky bar, under the phone's status bar */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
button { touch-action: manipulation; font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
img { display: block; -webkit-user-drag: none; user-select: none; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.loading { padding: 40vh 0 0; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------- home */
.home-head { padding: 28px 4px 18px; }
.home-head h1 { margin: 0; font-size: 34px; letter-spacing: -0.02em; }
.home-head .date { margin: 2px 0 0; color: var(--muted); font-size: 15px; }

.list { display: grid; gap: 10px; }
.program {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px 14px 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.12s;
}
.program:active { transform: scale(0.985); }
.program .day {
  display: grid; place-items: center;
  width: 52px; height: 52px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-weight: 700; font-size: 15px; letter-spacing: 0.02em;
}
.program .name { font-size: 18px; font-weight: 650; line-height: 1.2; }
.program .sub { display: block; margin-top: 3px; font-size: 13.5px; color: var(--muted); }
.program .chev { color: var(--muted); font-size: 22px; }
.program .today {
  margin-left: 6px; padding: 2px 7px; border-radius: 99px; vertical-align: 2px;
  background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
.program.agent { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, var(--card)), var(--card) 70%); }
.program.agent .day { background: var(--accent); color: var(--on-accent); font-size: 22px; }
.program.resume { outline: 2px solid var(--accent); }

.section-title { margin: 26px 4px 10px; font-size: 13px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.program.small { grid-template-columns: 40px 1fr auto; padding: 10px 14px 10px 10px; }
.program.small .day { width: 40px; height: 40px; border-radius: 11px; font-size: 18px; }
.program.small .name { font-size: 16px; }

.foot { margin: 30px 4px 8px; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.foot button { color: var(--accent); text-decoration: underline; }
.sync-form { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin: 4px 0 6px; }
.sync-form input {
  flex: 1 1 100%; min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--fg); font: inherit; font-size: 16px; /* 16px: no zoom-in on iOS */
}
.sync-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ------------------------------------------------------------- top bar */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: grid; grid-template-columns: 44px 1fr 64px; align-items: center;
  padding-block: 6px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.bar .title { text-align: center; font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .count { text-align: right; padding-right: 8px; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-size: 22px; color: var(--muted); }
.icon-btn:active { background: var(--line); }
.progress { height: 4px; margin: 2px 0 12px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }

/* ------------------------------------------------------------- session */
/* The workout screen is exactly one screen: nothing scrolls or pans while you swipe.
   html.locked is set by the app while the workout view is open. */
html.locked, html.locked body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.locked #app { height: 100%; min-height: 0; display: flex; flex-direction: column; padding-block-end: 12px; }
.stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.card {
  position: relative;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: none; /* the card owns every gesture that starts on it */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  cursor: grab;
  will-change: transform;
}
.card.enter { animation: enter 0.22s ease-out; }
@keyframes enter { from { transform: translateY(14px) scale(0.96); opacity: 0.5; } }
.card .pic { background: var(--pic); overflow: hidden; }
.card .pic img, .mini .pic img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-touch-callout: none; }
.current { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.current .pic { flex: 1; min-height: 110px; width: 100%; } /* takes whatever height is left */
.current .info { padding: 10px 18px 14px; }
.part { font-size: 12px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--accent); }
.current h2 { margin: 3px 0 2px; font-size: 22px; line-height: 1.2; letter-spacing: -0.01em; }
.current .meta { font-size: 14px; color: var(--muted); }
.current .dose { margin-top: 6px; font-size: 26px; font-weight: 750; color: var(--accent); letter-spacing: -0.01em; }
.current .cue { margin: 6px 0 0; font-size: 14px; line-height: 1.4; color: var(--muted); }

.stamp {
  position: absolute; top: 64px; z-index: 2;
  padding: 6px 12px; border: 3px solid; border-radius: 10px;
  font-weight: 800; font-size: 22px; letter-spacing: 0.08em;
  opacity: 0; pointer-events: none;
  background: color-mix(in srgb, var(--card) 80%, transparent);
}
.stamp.done { right: 16px; color: var(--done); transform: rotate(10deg); opacity: var(--done-o, 0); }
.stamp.skip { left: 16px; color: var(--skip); transform: rotate(-10deg); opacity: var(--skip-o, 0); }

.actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 10px 0 4px; }
.actions button {
  height: 46px; border-radius: 14px; font-weight: 650; font-size: 16px;
  background: var(--card); box-shadow: var(--shadow);
}
.actions .done-btn { color: var(--done); }
.actions .skip-btn { color: var(--skip); text-align: center; }
.actions .done-btn { text-align: center; }
.actions .hint { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.3; }

.next h3 { margin: 12px 2px 6px; font-size: 13px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.next-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini { display: block; width: 100%; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.mini .pic { height: clamp(64px, 14dvh, 140px); width: 100%; background: var(--pic); overflow: hidden; }
.mini .t { padding: 6px 10px 8px; }
.mini .n { font-size: 13.5px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mini .d { margin-top: 2px; font-size: 13px; color: var(--accent); font-weight: 650; }
.mini.placeholder { display: grid; place-items: center; min-height: 120px; color: var(--muted); font-size: 14px; box-shadow: none; background: transparent; border: 1.5px dashed var(--line); }

/* ------------------------------------------------------------- detail */
.detail .pic { position: relative; aspect-ratio: 1; max-height: 50vh; margin: 4px auto 0; border-radius: 22px; overflow: hidden; background: var(--pic); box-shadow: var(--shadow); }
.detail .pic img { width: 100%; height: 100%; object-fit: contain; }
.detail h1 { margin: 16px 0 4px; font-size: 26px; line-height: 1.2; letter-spacing: -0.015em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.chip { padding: 4px 10px; border-radius: 99px; background: var(--card); box-shadow: var(--shadow); font-size: 13px; }
.chip.accent { background: var(--accent); color: var(--on-accent); font-weight: 650; box-shadow: none; }
.detail .cue { margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 10%, var(--card)); font-size: 15px; line-height: 1.45; }
.detail section { margin-top: 22px; }
.detail h2 { margin: 0 0 6px; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.detail p, .detail li { font-size: 16px; line-height: 1.5; }
.detail p { margin: 0; }
.detail ol, .detail ul { margin: 0; padding-left: 22px; }
.detail li { margin: 0 0 6px; }
.detail details { padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail summary { font-weight: 600; cursor: pointer; }
.detail details p { margin-top: 6px; color: var(--muted); }
.detail .source { margin: 26px 0 8px; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------- summary */
.summary { text-align: center; padding-top: 7vh; }
.summary .big { font-size: 64px; line-height: 1; }
.summary h1 { margin: 14px 0 4px; font-size: 28px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 24px 0; }
.stat { padding: 14px 6px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 26px; }
.stat span { font-size: 13px; color: var(--muted); }
.result-list { text-align: left; margin: 0 0 24px; padding: 0; list-style: none; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.result-list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 15px; }
.result-list li:last-child { border-bottom: 0; }
.result-list .ok { color: var(--done); font-weight: 700; }
.result-list .no { color: var(--skip); }
.primary {
  display: block; width: 100%; height: 52px; border-radius: 16px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 17px; text-align: center;
}

/* ------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 20;
  display: flex; align-items: center; gap: 14px;
  width: max-content; max-width: calc(100% - 32px); padding: 10px 10px 10px 16px;
  transform: translateX(-50%);
  background: var(--toast-bg); color: var(--toast-fg); border-radius: 14px; box-shadow: var(--toast-shadow);
  font-size: 15px;
  animation: toast-in 0.2s ease-out;
}
.toast[hidden] { display: none; }
.toast span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast button { flex: none; }
.toast button { padding: 6px 12px; border-radius: 10px; background: var(--toast-btn); color: var(--toast-fg); font-weight: 650; }
@keyframes toast-in { from { transform: translate(-50%, 20px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .card.enter, .toast { animation: none; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card:focus-visible { outline-offset: -2px; }

/* ------------------------------------------------------------- picture buttons */
.pic-tools { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 3; display: flex; gap: 8px; pointer-events: none; }
.pic-tools .grow { flex: 1; }
.tool {
  pointer-events: auto;
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--tool-bg); color: var(--tool-fg);
  box-shadow: 0 1px 4px rgb(0 0 0 / 18%);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform 0.12s;
}
.tool:active { transform: scale(0.9); }
.tool svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool.like[aria-pressed="true"] { color: var(--like); }
.tool.dislike[aria-pressed="true"] { color: var(--dislike-on); }
.tool[aria-pressed="true"] svg { fill: currentColor; }
.mini .heart { color: var(--like); }

/* ------------------------------------------------------------- alternatives */
.alts { margin-top: 28px; }
.alts-hint { margin: 0 0 4px; font-size: 14px; }
.alt-group { margin: 16px 2px 8px; font-size: 13px; font-weight: 650; color: var(--fg); }
.alt-list { display: grid; gap: 8px; }
.alt {
  display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 6px 12px 6px 6px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
}
.alt:active { transform: scale(0.99); }
.alt[disabled] { opacity: 0.55; cursor: default; }
.alt.disliked { opacity: 0.6; }
.alt .thumb { width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: var(--pic); }
.alt .thumb img { width: 100%; height: 100%; object-fit: contain; }
.alt .t { min-width: 0; display: grid; gap: 2px; }
.alt .n { font-size: 15px; font-weight: 600; line-height: 1.25; }
.alt .m { font-size: 13px; color: var(--muted); }
.alt .badge { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.alt .badge.liked { color: var(--like); }
