/* SENSEI: white, minimal, one accent. Dark mode follows the phone. */
:root {
  --bg: #ffffff; --ink: #1c1c1e; --muted: #8e8e93; --line: #e5e5ea; --card: #f5f5f7;
  --accent: #e5484d; --on-ink: #ffffff; --warn-bg: #fff4e5; --warn-ink: #8a4b00;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --ink: #f2f2f7; --muted: #8e8e93; --line: #2c2c2e; --card: #1c1c1e;
    --on-ink: #000000; --warn-bg: #3a2a12; --warn-ink: #ffcf8a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif; -webkit-font-smoothing: antialiased; }
#app {
  max-width: 520px; margin: 0 auto; min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 16px) 20px calc(env(safe-area-inset-bottom) + 24px);
  display: flex; flex-direction: column;
}

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-bottom: 8px; }
.top .logo { width: 32px; height: 36px; }
.iconbtn { background: none; border: 0; color: var(--ink); font-size: 15px; padding: 10px 4px; min-height: 44px; min-width: 44px; cursor: pointer; }
.iconbtn.muted { color: var(--muted); }

/* Logo swaps for dark mode */
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) { .logo-light { display: none; } .logo-dark { display: inline; } }

/* Type */
h1 { font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; margin: 8px 0 12px; }
h2 { font-size: 20px; font-weight: 650; margin: 28px 0 10px; letter-spacing: -0.01em; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.proverb { font-style: italic; color: var(--muted); margin: 0 0 20px; }

/* Welcome */
.welcome { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; }
.welcome .logo { width: 108px; height: 124px; margin-bottom: 16px; }
.welcome .brand { font-size: 34px; font-weight: 800; letter-spacing: 0.18em; margin: 0; }
.welcome .stack { width: 100%; display: grid; gap: 12px; margin-top: 40px; }

/* Buttons */
.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 17px 20px; font: inherit; font-weight: 600;
  background: var(--ink); color: var(--on-ink); cursor: pointer; text-align: center;
}
.btn.secondary { background: var(--card); color: var(--ink); }
.btn.ghost { background: none; color: var(--muted); font-weight: 500; }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn:active:not(:disabled) { transform: scale(0.985); }
.actions { margin-top: auto; padding-top: 24px; display: grid; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.row3 .btn { padding: 15px 8px; font-size: 15px; min-height: 52px; }
/* Long screens: keep the finish buttons in thumb reach. */
.actions.sticky { position: sticky; bottom: 0; margin: 0 -20px; padding: 16px 20px calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(to bottom, transparent, var(--bg) 18px); }

/* Progress */
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 4px 0 24px; }
.progress > div { height: 100%; background: var(--ink); border-radius: 4px; transition: width .25s ease; }

/* Choice chips */
.choices { display: grid; gap: 10px; }
.choices.grid2 { grid-template-columns: 1fr 1fr; }
.chip {
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 14px; padding: 15px 16px;
  font: inherit; text-align: left; cursor: pointer; min-height: 52px;
}
.chip.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .chip { padding: 10px 16px; border-radius: 99px; font-size: 15px; min-height: 44px; }
input[type=text], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 0; border-radius: 14px; padding: 16px; outline: none;
}
textarea { min-height: 90px; resize: vertical; margin-top: 12px; }
input[type=text]:focus, textarea:focus { box-shadow: 0 0 0 2px var(--ink); }

/* Inputs with a unit */
.field { position: relative; display: block; }
.field input { padding-right: 56px; font-size: 22px; font-weight: 600; }
.field .unit { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.grid2.gap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-card { display: flex; align-items: center; gap: 14px; justify-content: space-between; }
.small-btn { width: auto; padding: 12px 18px; min-height: 44px; flex: none; }

/* Settings groups (iOS-style) */
.group-label { margin: 26px 0 8px; }
.card.group { padding: 4px 16px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 60px; padding: 10px 0; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.switch { flex: none; width: 52px; height: 32px; border-radius: 99px; border: 0; background: var(--line); position: relative; cursor: pointer; padding: 0; transition: background .2s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch::after { content: ''; position: absolute; inset: -8px -4px; } /* 48 px tap target */
.switch.on { background: #34c759; }
.switch.on span { transform: translateX(20px); }

/* Setup steps */
.mono { font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; user-select: all; -webkit-user-select: all; }
.steps { padding-left: 22px; margin: 16px 0; display: grid; gap: 12px; font-size: 15px; }
.steps li::marker { color: var(--muted); font-weight: 600; }
.steps.big { font-size: 17px; gap: 14px; margin: 20px 0; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; }
.note { background: var(--warn-bg); color: var(--warn-ink); border-radius: 14px; padding: 14px 16px; font-size: 15px; margin: 12px 0; }
.workout-card { padding: 22px; }
.workout-card .type { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0 6px; }
.meta { display: flex; gap: 16px; color: var(--muted); font-size: 15px; margin-bottom: 14px; flex-wrap: wrap; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 6px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--ink); }
.label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 4px; }

/* Exercise list */
.section { margin-top: 26px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.section-head h2 { margin: 0; }
.ex { border-bottom: 1px solid var(--line); padding: 14px 0; cursor: pointer; }
.ex:last-child { border-bottom: 0; }
.ex-top { display: flex; gap: 12px; align-items: baseline; }
.ex-top { align-items: center; }
.ex-check { flex: none; width: 44px; height: 44px; margin: -10px 0 -10px -10px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; }
.ex-check span { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 14px; font-weight: 700; color: var(--on-ink); }
.ex-check.on span { background: var(--ink); border-color: var(--ink); }
.ex.is-done .ex-name { color: var(--muted); text-decoration: line-through; }
.ex-label { font-size: 13px; font-weight: 700; color: var(--muted); min-width: 24px; }
.ex-name { font-weight: 600; flex: 1; }
.ex-dose { color: var(--muted); font-size: 15px; white-space: nowrap; }
.ex-sub { color: var(--muted); font-size: 14px; margin: 2px 0 0 36px; }
.ex.has-check .ex-sub, .ex.has-check .ex-more { margin-left: 82px; }
.ex-more { margin: 10px 0 2px 36px; font-size: 15px; display: grid; gap: 6px; }
.ex-more b { font-weight: 600; }

/* Stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 16px; }
.stat { background: var(--card); border-radius: 14px; padding: 16px; }
.stat b { display: block; font-size: 26px; letter-spacing: -0.02em; }

/* Sheet */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet {
  background: var(--bg); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(env(safe-area-inset-bottom) + 20px); max-height: 90dvh; overflow: auto;
}
.sheet h2 { margin-top: 0; }

.center { text-align: center; }
.done { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.done .logo { width: 76px; height: 88px; margin: 0 auto 18px; }
