:root {
  color-scheme: light dark;
  --bg: #f6f3ee;
  --card: #fffaf3;
  --ink: #1d2523;
  --muted: #68736f;
  --teal: #0c7475;
  --teal-dark: #095a5b;
  --amber: #b7791f;
  --red: #b42318;
  --green: #067647;
  --line: rgba(29, 37, 35, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { overflow-x: hidden; overflow-x: clip; max-width: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, #dff3ef, var(--bg) 42%);
  color: var(--ink);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 0.75rem;
  backdrop-filter: blur(14px);
}

h1, h2 { margin: 0; letter-spacing: -0.03em; }
h1 { font-size: clamp(1.8rem, 8vw, 3rem); }
h2 { font-size: 1.15rem; }
main { width: min(760px, 100%); margin: 0 auto; padding: 0.5rem 1rem 10.5rem; }

.card {
  background: color-mix(in srgb, var(--card) 92%, white);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 1rem;
  margin: 0.85rem 0;
  box-shadow: 0 14px 40px rgba(12, 116, 117, 0.08);
}

.hero { background: linear-gradient(135deg, #0c7475, #123f4b); color: white; }
.hero .muted, .hero .label { color: rgba(255,255,255,0.75); }
.label { margin: 0 0 0.25rem; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.eyebrow { margin: 0; color: var(--teal); font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.72rem; }
.muted { color: var(--muted); line-height: 1.45; }
.strong { font-weight: 800; margin: 0.2rem 0; }
.row { display: flex; align-items: flex-start; gap: 1rem; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 1rem; }

.dot { width: 18px; height: 18px; border-radius: 999px; background: #98a2b3; flex: 0 0 auto; margin-top: 0.35rem; }
.dot.green { background: #32d583; }
.dot.amber { background: #fdb022; }
.dot.red { background: #f97066; }

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; border-radius: 999px; padding: 0.72rem 1rem; font-weight: 800; }
.primary { background: var(--teal); color: white; }
.primary:active { background: var(--teal-dark); }
.secondary { background: #e7f3f1; color: var(--teal-dark); }
.ghost { background: rgba(255,255,255,0.7); color: var(--ink); border: 1px solid var(--line); }
.danger { background: #fff1f0; color: var(--red); margin-top: 1rem; }
.pill { display: inline-flex; white-space: nowrap; border-radius: 999px; padding: 0.25rem 0.55rem; background: #eef4f2; color: var(--teal-dark); font-size: 0.75rem; font-weight: 800; }

.checkin { display: grid; gap: 0.9rem; margin-top: 1rem; }
label { display: grid; gap: 0.35rem; font-weight: 700; }
input[type="range"] { width: 100%; max-width: 100%; min-width: 0; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; accent-color: var(--teal); display: block; }
.slider-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; min-width: 0; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem;
  background: white;
  color: var(--ink);
  max-width: 100%;
  min-width: 0;
}
.value { color: var(--teal); }
.pain-hint { font-size: 0.82rem; font-weight: 650; }
.reason-list { margin: 0.7rem 0 0; padding-left: 1.1rem; color: var(--muted); line-height: 1.45; }
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin-top: 0.7rem; }
.option-btn { display: grid; gap: 0.15rem; text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,0.75); color: var(--ink); border-radius: 16px; padding: 0.65rem; }
.option-btn span { color: var(--muted); font-size: 0.76rem; font-weight: 650; line-height: 1.25; }
.option-btn.selected { background: var(--teal); color: white; }
.option-btn.selected span { color: rgba(255,255,255,0.82); }
.option-btn:disabled { opacity: 0.48; cursor: not-allowed; }
.toggles { display: grid; gap: 0.5rem; }
.toggles label { display: flex; align-items: center; gap: 0.5rem; font-weight: 650; border: 1px solid var(--line); border-radius: 999px; padding: 0.5rem 0.7rem; background: rgba(255,255,255,0.65); }
.toggles label:has(input:checked) { background: #fff4e5; border-color: rgba(183,121,31,0.45); color: #93370d; }
.toggles input { width: 1.05rem; height: 1.05rem; accent-color: var(--amber); }

.exercise-list { list-style: none; padding: 0; margin: 0.7rem 0; display: grid; gap: 0.55rem; counter-reset: ex; }
.exercise {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.55rem;
  background: rgba(255,255,255,0.72);
}
.exercise > * { min-width: 0; }
.exercise.done { opacity: 0.62; }
.exercise .num { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 999px; background: var(--teal); color: white; font-weight: 900; font-size: 0.82rem; }
.exercise h3 { margin: 0 0 0.1rem; font-size: 0.95rem; }
.exercise-head { display: flex; align-items: flex-start; gap: 0.35rem; min-width: 0; }
.exercise-head h3 { flex: 1 1 auto; min-width: 0; }
.info-toggle {
  flex: 0 0 2rem;
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  min-height: 2rem;
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(231,243,241,0.9);
  color: var(--teal-dark);
  font-size: 1rem;
  line-height: 1;
}
.exercise-detail { margin-top: 0.35rem; }
.exercise p { margin: 0.08rem 0; line-height: 1.25; }
.dose { font-weight: 900; color: var(--teal-dark); }
.cue { color: var(--muted); font-size: 0.84rem; }
.compact-meta { font-size: 0.78rem; line-height: 1.2; }
.ex-actions { display: flex; flex-direction: row; flex-wrap: nowrap; gap: 0.3rem; }
.ex-actions button { flex: 1 1 0; padding: 0.38rem 0.3rem; font-size: 0.78rem; min-width: 0; min-height: 2.1rem; text-align: center; }
.ex-actions button.selected { background: var(--teal); color: white; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35); }
.sel-check { display: inline-block; width: 1.05em; visibility: hidden; }
button.selected .sel-check { visibility: visible; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.flags { display: grid; gap: 0.45rem; margin-top: 0.8rem; }
.floating-rest {
  position: fixed;
  left: 50%;
  bottom: max(4.5rem, calc(env(safe-area-inset-bottom) + 4.1rem));
  transform: translateX(-50%);
  z-index: 50;
  width: min(760px, calc(100vw - 1rem));
  display: grid;
  grid-template-columns: 3.6rem 3rem 4.6rem 3rem 3.3rem;
  justify-content: space-between;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid #9fc8c4;
  background: #e7f3f1;
  border-radius: 999px;
  padding: 0.45rem 0.55rem;
  box-shadow: 0 12px 30px rgba(12, 25, 25, 0.28);
}
.floating-rest-main { display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-width: 0; line-height: 1.05; }
.floating-rest-main .label { margin: 0; font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase; }
.floating-rest button { width: 100%; min-width: 0; min-height: 2.25rem; padding: 0.42rem 0.15rem; font-size: 0.78rem; text-align: center; white-space: nowrap; background: #ffffff; color: var(--teal-dark); }
#restToggle { background: var(--teal); color: white; }
.hidden { display: none !important; }
.progress { width: 100%; height: 6px; border-radius: 999px; background: rgba(12,116,117,0.18); overflow: hidden; margin-top: 0.25rem; }
.progress span { display: block; height: 100%; width: 0%; background: var(--teal); border-radius: 999px; transition: width 0.3s linear; }
.timer { grid-column: 2; border: 1px dashed rgba(12,116,117,0.35); border-radius: 12px; padding: 0.45rem; background: rgba(231,243,241,0.7); min-width: 0; }
.timer .time { font-size: 1.18rem; font-weight: 950; letter-spacing: -0.04em; color: var(--teal-dark); font-variant-numeric: tabular-nums; }
.timer .meta { color: var(--muted); font-weight: 700; font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.rest-time { font-size: 1.08rem; font-weight: 950; letter-spacing: -0.02em; color: var(--teal-dark); min-width: 0; font-variant-numeric: tabular-nums; }
.level-row { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.level-row button { padding: 0.36rem 0.5rem; font-size: 0.78rem; min-height: 2.1rem; }
.level-row button:disabled { opacity: 0.45; cursor: not-allowed; }
[data-timer-action="toggle"] { min-width: 4.8rem; text-align: center; }
.flag { border-radius: 14px; padding: 0.65rem 0.75rem; background: #fff4e5; color: #93370d; font-weight: 750; }
.flag.red { background: #fff1f0; color: var(--red); }

.integration { display: flex; justify-content: space-between; gap: 1rem; padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.integration:last-child { border-bottom: 0; }
.history { display: grid; gap: 0.6rem; margin-top: 0.8rem; }
.log { border: 1px solid var(--line); border-radius: 16px; padding: 0.75rem; background: rgba(255,255,255,0.7); }
.log p { margin: 0.15rem 0; }

.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.35rem; margin-top: 0.85rem; }
.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.12rem;
  min-width: 0;
  min-height: 5.3rem;
  padding: 0.5rem 0.15rem 0.45rem;
  border-radius: 16px;
  background: #eef4f2;
  color: var(--ink);
  text-align: center;
}
.week-day:active { background: #e2efec; }
.week-day.selected { background: #e7f3f1; box-shadow: inset 0 0 0 2px var(--teal); }
.week-day .w-dow { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); line-height: 1.1; }
.week-day.is-today .w-dow { color: var(--teal-dark); }
.week-day .w-date { font-size: 1.02rem; font-weight: 900; line-height: 1.15; font-variant-numeric: tabular-nums; }
.week-day .w-kind { display: inline-flex; align-items: center; gap: 0.22rem; max-width: 100%; font-size: 0.62rem; font-weight: 800; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-day .w-icon { font-size: 0.95rem; line-height: 1; }
.week-day .w-tiny { display: none; }
.week-day .w-status { font-size: 0.6rem; font-weight: 700; line-height: 1.2; min-height: 0.75rem; color: var(--muted); white-space: nowrap; }
.kdot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 999px; background: var(--muted); }
.kdot.k-game { background: var(--teal-dark); }
.kdot.k-strength { background: var(--teal); }
.kdot.k-ride { background: #2563eb; }
.kdot.k-rehab, .kdot.k-recovery, .kdot.k-postgame { background: var(--green); }
.kdot.k-taper, .kdot.k-gentle { background: var(--amber); }
.kdot.k-rest { background: #98a2b3; }
.week-detail { margin-top: 0.9rem; border-top: 1px solid var(--line); padding-top: 0.85rem; }
.week-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; min-width: 0; }
.week-detail-head h3 { margin: 0; font-size: 1rem; white-space: nowrap; }
.week-reason { margin: 0.55rem 0 0; font-weight: 750; color: var(--teal-dark); line-height: 1.4; }
.week-exercises { margin: 0.45rem 0; padding-left: 1.15rem; line-height: 1.5; }
.week-exercises li { min-width: 0; }

dialog { border: 0; border-radius: 24px; padding: 0; width: min(92vw, 520px); max-width: calc(100vw - 1rem); box-shadow: 0 24px 80px rgba(0,0,0,0.25); }
dialog::backdrop { background: rgba(12, 25, 25, 0.45); }
.settings, .timer-box { padding: 1.2rem; display: grid; gap: 1rem; min-width: 0; }
.settings label { min-width: 0; }
.settings input, .settings select, .settings textarea { width: 100%; min-width: 0; max-width: 100%; }
.settings .actions { flex-wrap: nowrap; }
.settings .actions button { flex: 1 1 0; min-width: 0; }
.timer-text { font-size: 4rem; font-weight: 950; text-align: center; margin: 0; letter-spacing: -0.06em; font-variant-numeric: tabular-nums; }
.timer-box .label { text-align: center; }
.value { display: inline-block; min-width: 5ch; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pain-hint { display: block; min-height: 2.5em; }
#startBtn { min-width: 10.5rem; text-align: center; }
#followSuggestion { min-width: 9.5rem; }

@media (max-width: 560px) {
  .grid.two { grid-template-columns: 1fr; }
  .option-grid { grid-template-columns: 1fr; }
  .exercise { grid-template-columns: auto 1fr; }
  .ex-actions { grid-column: 2; flex-direction: row; flex-wrap: nowrap; }
}

/* --- v0.12: bottom tabs, day plan, narrow week strip --- */
.tab-panel[hidden] { display: none !important; }
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.25rem;
  padding: 0.4rem 0.6rem max(0.45rem, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 94%, white);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(12, 25, 25, 0.10);
}
.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  min-width: 0;
  min-height: 3rem;
  padding: 0.35rem 0.25rem;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}
.tab-btn .tab-icon { font-size: 1.15rem; line-height: 1.1; }
.tab-btn.active { background: #e7f3f1; color: var(--teal-dark); }

.day-plan { list-style: none; padding: 0; margin: 0.8rem 0 0; display: grid; gap: 0.55rem; }
.day-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.6rem 0.7rem;
  background: rgba(255,255,255,0.72);
}
.day-item > * { min-width: 0; }
.day-item.is-done { opacity: 0.62; }
.day-item .d-icon { font-size: 1.3rem; line-height: 1; }
.day-item h3 { margin: 0; font-size: 0.95rem; }
.day-item .d-detail { margin: 0.12rem 0 0; font-size: 0.82rem; }
.role-tag { font-size: 0.64rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal-dark); }
.d-actions { display: flex; flex-wrap: nowrap; gap: 0.3rem; }
.d-actions button { min-width: 3.6rem; min-height: 2.25rem; padding: 0.4rem 0.5rem; font-size: 0.78rem; text-align: center; white-space: nowrap; }
.d-actions button.selected { background: var(--teal); color: white; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35); }
.week-items { margin: 0.45rem 0; padding-left: 1.15rem; line-height: 1.5; }
.week-items li { min-width: 0; }

/* Phone-width week strip: icons + tiny labels instead of squeezed words. */
@media (max-width: 480px) {
  .week-strip { gap: 0.25rem; }
  .week-day { min-height: 5.9rem; padding: 0.45rem 0.08rem 0.4rem; overflow: hidden; }
  .week-day .w-short { display: none; }
  .week-day .w-tiny { display: inline; }
  .week-day .kdot { display: none; }
  .week-day .w-icon { font-size: 1.05rem; }
  .week-day .w-kind { font-size: 0.6rem; }
}

.app-version {
  text-align: center;
  color: var(--muted, #8b98a5);
  font-size: 12px;
  margin: 18px 0 8px;
}

.whoop-facts { margin-top: 0.35rem; }
.whoop-facts ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.whoop-facts li { margin: 0.15rem 0; }
.whoop-settings { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 0.75rem; }
.a-btn { display: inline-block; text-decoration: none; text-align: center; cursor: pointer; border-radius: 999px; padding: 0.72rem 1rem; font-weight: 800; }
