:root {
  color-scheme: light;
  --bg: #efe7e1; --surface: #ffffff; --raised: #f6f4f1; --text: #111111; --muted: #5b5550; --line: #e4dfda; --sand-line: #d3c7be;
  --accent: #4a4fb8; --on-accent: #ffffff; --danger: #b8341f; --sun: #f8d066; --sun-text: #3e3518;
  --watts: #7c3aed; --pulse: #b4235a; --weight: #3f3f46; --plain: #efefed; --pause: #b9b5b0;
  --ride: #1f77c2; --run: #dc6a1e; --gym: #4a4fb8; --hike: #3f8a46; --other: #5f6d78; --rest: #c3cbd2;
  --good: #1b8450; --ok: #9a6b00; --low: #c0321f;
  --z1: #9fb8c9; --z2: #6fa8a0; --z3: #d9b44a; --z4: #dd8a4a; --z5: #c9503f; --z6: #a8365e; --z7: #6b2d5c;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: inherit; }
h1 { font-size: 28px; line-height: 1.15; margin: 0; }
h2 { font-size: 14px; color: var(--muted); font-weight: 600; margin: 32px 0 12px; }
h3 { font-size: 18px; margin: 0; }
p { margin: 0; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 0 16px; height: 56px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tabs a { display: flex; align-items: center; padding: 0 12px; color: var(--muted); text-decoration: none; font-size: 15px; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

main { margin: 0 auto; padding: 24px 16px 64px; }
main.wide { max-width: 1600px; }
main.narrow { max-width: 900px; }
main.editor { max-width: 1040px; }

button, select, input, textarea { font: inherit; font-size: 14px; color: var(--text); }
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 14px; cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled), .button:hover { background: var(--raised); }
button:disabled { opacity: .35; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.primary:hover:not(:disabled), .button.primary:hover { background: var(--accent); filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.icon { width: 40px; padding: 0; font-size: 16px; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
textarea { resize: vertical; }
input[aria-invalid="true"] { border-color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { color: var(--muted); font-size: 12px; }

.eyebrow, .muted { color: var(--muted); font-size: 14px; }
.note { color: var(--muted); font-size: 13px; margin-top: 12px; }
.error { background: var(--surface); border: 1px solid var(--z5); border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Calendar */
.month-title { text-transform: capitalize; }
.calendar-frame { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 1px 3px rgba(20, 35, 50, .08); }
.weekdays, .week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) 196px; }
.weekdays { position: sticky; top: 56px; z-index: 5; background: var(--surface); border-bottom: 2px solid var(--line); border-radius: 6px 6px 0 0; color: var(--text); font-size: 13px; font-weight: 600; }
.weekdays div { padding: 8px 10px; }
.week { border-bottom: 1px solid var(--line); }
.week:last-child { border-bottom: 0; }
.day { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 190px; padding: 6px; border-right: 1px solid var(--line); background: var(--surface); }
.day.outside { background: var(--raised); }
.day.outside .day-number { color: var(--muted); font-weight: 500; }
.day.today { box-shadow: inset 0 3px 0 var(--accent); background: #f0f7fc; }
.day.today .day-number { color: var(--accent); }
.day.drop { background: #dcecf8; }
.day-head { display: flex; align-items: center; justify-content: space-between; min-height: 26px; padding: 0 2px; }
.day-number { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.day-number .weekday { display: none; }
.add { width: 26px; min-height: 26px; padding: 0; border-color: transparent; background: transparent; color: var(--accent); font-size: 20px; line-height: 1; opacity: 0; }
.day:hover .add, .add:focus-visible { opacity: 1; }
@media (hover: none) { .add { opacity: 1; } }
.day-items { display: grid; gap: 6px; flex: 1; align-content: start; }

.workout { display: grid; gap: 2px; width: 100%; min-height: 0; padding: 7px 8px; border: 1px solid var(--line); border-left: 4px solid var(--sport); border-radius: 4px; background: var(--surface); box-shadow: 0 1px 2px rgba(20, 35, 50, .12); color: var(--text); text-align: left; text-decoration: none; font-size: 14px; line-height: 1.3; white-space: normal; cursor: pointer; }
.workout:hover:not(:disabled) { background: var(--surface); border-color: var(--sport); box-shadow: 0 2px 6px rgba(20, 35, 50, .2); }
.workout.planned { border-style: dashed; border-left-style: dashed; background: var(--raised); box-shadow: none; cursor: grab; }
.workout-head { display: flex; align-items: center; justify-content: space-between; min-height: 20px; }
.workout-status { color: var(--muted); font-size: 12px; font-weight: 600; }
.workout strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.workout-time { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.workout-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 8px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.sport-icon { display: inline-flex; width: 18px; height: 18px; color: var(--sport); }
.sport-icon svg { width: 100%; height: 100%; }
.sport-gym { --sport: var(--gym); }
.sport-ride { --sport: var(--ride); }
.sport-run { --sport: var(--run); }
.sport-hike { --sport: var(--hike); }
.sport-other { --sport: var(--other); }

.vitals { display: grid; gap: 1px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--raised); font-size: 12px; color: var(--muted); }
.vital { display: flex; justify-content: space-between; gap: 6px; }
.vital b { color: var(--text); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.vital b small { color: var(--muted); font-size: 11px; font-weight: 400; }
.vital b.good { color: var(--good); }
.vital b.ok { color: var(--ok); }
.vital b.low { color: var(--low); }

.week-summary { display: grid; align-content: start; gap: 8px; padding: 8px 10px; background: var(--raised); font-size: 13px; min-width: 0; }
.summary-group { display: grid; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.summary-group:last-child { padding-bottom: 0; border-bottom: 0; }
.summary-line { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }
.summary-line b { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.summary-sport { display: inline-flex; align-items: center; gap: 6px; }
.summary-sport .sport-icon { width: 15px; height: 15px; }

dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(20, 35, 50, .45); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.pick-list { display: grid; gap: 6px; margin-top: 12px; }
.pick { display: block; width: 100%; min-height: 0; padding: 10px 12px; text-align: left; white-space: normal; }
.pick small { display: block; color: var(--muted); font-size: 13px; }
.preview-block { padding: 10px 0; border-top: 1px solid var(--line); }
.preview-block header { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; font-size: 14px; }
.preview-block ol { margin: 6px 0 0; padding: 0; list-style: none; }
.preview-block li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-size: 14px; }
.preview-block li span:last-child { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.preview-block li small { display: block; color: var(--muted); font-size: 12px; }

.strip-time { display: flex; gap: 1px; height: 18px; border-radius: 4px; overflow: hidden; background: var(--line); }
.strip-time i { display: block; min-width: 1px; background: var(--other); }
.strip-time .exercise { background: var(--gym); }
.strip-time .cardio { background: var(--run); }
.strip-time .rest { background: var(--rest); }
.sport-ride .strip-time .cardio { background: var(--ride); }

/* Library */
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; background: color-mix(in srgb, var(--sport) 15%, transparent); color: var(--sport); font-size: 12px; font-weight: 600; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 8px; }

/* Workout editor */
.editor-meta { display: grid; grid-template-columns: 1fr 160px; gap: 12px; }
.editor-meta .field.full { grid-column: 1 / -1; }
.summary { position: sticky; top: 56px; z-index: 5; display: grid; gap: 8px; margin: 16px -16px; padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.summary-stats { display: flex; flex-wrap: wrap; gap: 4px 24px; font-size: 14px; color: var(--muted); }
.summary-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.block { margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.block-head { display: grid; grid-template-columns: 28px minmax(140px, 1fr) 72px 136px auto; gap: 8px; align-items: end; padding: 12px; background: var(--raised); border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.block-index { display: flex; align-items: center; justify-content: center; width: 28px; height: 40px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.tool { width: 34px; min-height: 34px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); font-size: 15px; }
.tool:hover:not(:disabled) { color: var(--text); }
.tools { display: flex; align-items: center; }
.step { display: grid; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.step.rest { background: color-mix(in srgb, var(--rest) 12%, transparent); }
.step-main { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.step-main .step-name { flex: 1 1 200px; min-width: 0; }
.step-main > .field { width: 72px; }
.step-main > .field.time { width: 84px; }
.step-main > .field.select { width: 112px; }
.step-main .tools { margin-left: auto; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; height: 40px; }
.segmented button { border: 0; border-radius: 0; background: transparent; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.block-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; }
.add-block { width: 100%; border-style: dashed; color: var(--muted); }
.step-note input { min-height: 34px; padding: 4px 10px; font-size: 13px; }

/* Day view */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; min-width: 0; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.day-nav button { width: 40px; padding: 0; font-size: 18px; }
.session { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.session-head { display: flex; justify-content: space-between; gap: 16px; }
.effect { color: var(--accent); font-weight: 600; font-size: 13px; white-space: nowrap; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin: 16px 0; }
.metrics b { display: block; font-variant-numeric: tabular-nums; }
.metrics span { color: var(--muted); font-size: 13px; }
.zones { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--line); }
.zones i { display: block; }
.zone-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.strip { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; height: 96px; align-items: end; }
.bar { background: var(--line); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar.active { background: var(--accent); }
.strip-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }
.chart-toggle, .chart-panel { margin-top: 16px; }
.chart-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.chart-tools label { color: var(--muted); font-size: 13px; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chart-tools select { width: auto; }
.window-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 12px; margin-bottom: 12px; }
.window-stats b { display: block; font-variant-numeric: tabular-nums; }
.window-stats span { color: var(--muted); font-size: 13px; }
.u-select { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.uplot { font-family: inherit; color: var(--muted); }

@media (max-width: 760px) {
  .weekdays { display: none; }
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .day-number .weekday { display: inline; margin-left: 6px; color: var(--muted); font-size: 14px; font-weight: 500; }
  .vitals { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; }
  .add { opacity: 1; }
  .block-head { grid-template-columns: 28px minmax(0, 1fr) 72px; }
  .block-head .field:nth-of-type(3) { grid-column: 1 / -1; }
  .block-head .tools { grid-column: 1 / -1; justify-content: flex-end; }
  .step-main .step-name { flex-basis: 100%; }
  .editor-meta { grid-template-columns: 1fr; }
  .stats, .stats.three { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 24px; }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .weekdays, .week { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .weekdays div:last-child { display: none; }
  .week-summary { grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; border-top: 1px solid var(--line); }
  .summary-group { padding-bottom: 0; border-bottom: 0; }
}

/* Followed workout */
.plan-box:not(:empty) { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.plan-box h4 { margin: 0 0 4px; font-size: 16px; }
.plan-scroll { overflow-x: auto; margin-top: 12px; }
.plan { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.plan th, .plan td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.plan thead th { color: var(--muted); font-size: 12px; font-weight: 600; }
.plan td:first-child { white-space: normal; min-width: 130px; }
.plan-group th { background: var(--raised); font-size: 13px; font-weight: 600; }
.plan .hit { color: var(--good); font-weight: 600; }
.plan .miss { color: var(--ok); font-weight: 600; }
.tone { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 2px; }
.tone-warm { background: #5b8fb9; }
.tone-easy { background: #7c8a94; }
.tone-hard { background: #7c3aed; }
.step-readout { min-height: 22px; margin-bottom: 8px; font-size: 14px; font-weight: 600; }

/* Login */
.logout { margin-left: auto; }
.logout[hidden] { display: none; }
.topbar[hidden] { display: none; }
.login { max-width: 360px; margin: 12vh auto 0; }

/* LAB 17 look: soft sand ground, white rounded cards, one big number */
body { min-height: 100vh; background: linear-gradient(180deg, #ebe1da 0%, #efe7e1 55%, #f6f1ec 100%); font-family: 'Inter Tight', sans-serif; line-height: 1.35; }
.dune { position: fixed; inset: auto 0 0 0; width: 100%; height: 40vh; z-index: -1; pointer-events: none; }
.dune path { fill: #cdb3a3; fill-opacity: .55; }
h1 { font-size: 44px; font-weight: 500; letter-spacing: -1.4px; line-height: 1.1; }
h2 { color: var(--text); font-size: 20px; font-weight: 500; letter-spacing: -.3px; }
h3 { font-weight: 500; letter-spacing: -.4px; font-size: 22px; }

.topbar { position: static; margin: 14px 14px 0; height: 68px; padding: 0 12px 0 24px; border: 0; border-radius: 28px; box-shadow: 0 1px 2px rgba(60, 40, 30, .06); }
.brand { display: inline-flex; }
.brand img { display: block; height: 34px; }
.login-logo { display: block; height: 56px; }
.tabs { gap: 20px; margin-left: 12px; }
.tabs a { color: var(--text); font-size: 16px; font-weight: 500; border-bottom: 0; padding: 0 4px; }
.tabs a.active { font-weight: 700; border-bottom: 0; text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }

main { padding: 28px 34px 64px; }
main.narrow { max-width: 1000px; }
main.editor { max-width: 1320px; }

button, .button { min-height: 44px; padding: 0 20px; border: 0; border-radius: 22px; background: var(--plain); font-size: 15px; font-weight: 500; }
button:hover:not(:disabled), .button:hover { background: #e4e3e0; }
button.primary, .button.primary { background: #111111; border: 0; color: #ffffff; }
button.primary:hover:not(:disabled), .button.primary:hover { background: #2b2b2b; filter: none; }
button.icon { width: 44px; }
input, select, textarea { font-size: 16px; min-height: 44px; border-radius: 12px; border-color: #dcd7d2; }
textarea { min-height: 140px; line-height: 1.45; }
.field > span { font-size: 14px; }
.eyebrow, .muted { font-size: 15px; }
.note { font-size: 14px; }
.error { border-radius: 16px; }
.page-head { margin-bottom: 24px; }
.page-head a.button { min-width: 44px; }

/* Calendar */
.calendar-frame { border: 0; border-radius: 24px; box-shadow: 0 1px 2px rgba(60, 40, 30, .06); }
.weekdays { top: 0; border-radius: 24px 24px 0 0; font-size: 14px; }
.weekdays div { padding: 12px 12px; }
.week:last-child .day:first-child { border-bottom-left-radius: 24px; }
.week:last-child .week-summary { border-bottom-right-radius: 24px; }
.day { background: transparent; padding: 8px; min-height: 200px; }
.day.outside { background: #faf8f6; }
.day.today { background: #f2f1fb; box-shadow: inset 0 3px 0 var(--accent); }
.day.drop { background: #e4e3f6; }
.day-number { font-size: 16px; }
.workout { padding: 8px 10px; border: 0; border-left: 0; border-radius: 14px; background: color-mix(in srgb, var(--sport) 10%, #ffffff); box-shadow: none; }
.workout:hover:not(:disabled) { background: color-mix(in srgb, var(--sport) 18%, #ffffff); box-shadow: none; }
.workout.planned { background: var(--sun); border: 0; }
.workout.planned:hover:not(:disabled) { background: #f4c64e; }
.workout.planned .workout-status { color: var(--sun-text); }
.workout strong { font-size: 14px; }
.workout-time { font-size: 16px; }
.workout-meta { font-size: 13px; }
.vitals { border: 0; border-radius: 12px; padding: 6px 9px; }
.vital { font-size: 13px; }
.vital b { font-size: 14px; }
.week-summary { background: #faf8f6; font-size: 14px; padding: 10px 12px; }

dialog { border: 0; border-radius: 24px; padding: 24px; }
.pick { min-height: 56px; padding: 10px 16px; border-radius: 16px; display: block; }
.preview-block li { align-items: center; padding: 4px 0; font-size: 15px; }
.preview-block li span:last-child { color: inherit; }
.preview-block li .pill { color: inherit; }
.preview-block header { font-size: 15px; }

/* Labels and bars. Colour always means what a value measures. */
.pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.pill { padding: 4px 12px; border-radius: 13px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill-plain { background: var(--plain); color: #111111; }
.pill-watts { background: var(--watts); color: #ffffff; }
.pill-pulse { background: var(--pulse); color: #ffffff; }
.pill-weight { background: var(--weight); color: #ffffff; }
.preview-block li .pill-watts, .preview-block li .pill-pulse, .preview-block li .pill-weight, .plan .pill-watts, .plan .pill-pulse { color: #ffffff; }
.bars { display: flex; gap: 2px; height: 36px; align-items: flex-end; }
.bars.large { gap: 3px; height: 96px; }
.bars i { display: block; min-width: 3px; border-radius: 4px 4px 0 0; }
.bars.large i { border-radius: 6px 6px 0 0; }
.tone-pulse { background: var(--pulse); }
.tone-watts { background: var(--watts); }
.tone-exercise { background: var(--weight); }
.tone-cardio { background: #8c857e; }
.tone-rest { background: var(--pause); }
.bars-card { padding: 20px 26px; border-radius: 30px; background: var(--surface); }
.ai-card { display: grid; gap: 10px; margin-bottom: 16px; padding: 18px 26px; border-radius: 30px; background: var(--surface); }
.ai-usage { display: grid; gap: 6px; font-size: 14px; }
.ai-usage:empty { display: none; }
.ai-usage-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-weight: 600; }
.ai-usage-head .muted { font-weight: 400; }
.ai-meter { height: 8px; overflow: hidden; border-radius: 999px; background: #ececea; }
.ai-meter i { display: block; height: 100%; min-width: 4px; border-radius: 999px; background: #7c3aed; }
.ai-message { margin: 0; font-size: 15px; font-weight: 600; }
.ai-message:empty { display: none; }
.ai-message.neutral { color: var(--muted); }
.ai-message.done { color: #0f766e; }
.ai-message.failed { color: #b4235a; }
.bars-stats { display: flex; flex-wrap: wrap; gap: 6px 32px; margin-bottom: 16px; color: var(--muted); }
.bars-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.bar-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 12px; font-size: 15px; color: var(--muted); }
.bar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bar-legend i { display: block; width: 12px; height: 12px; border-radius: 2px; }

/* Big number and yellow card */
.hero p { margin-top: 8px; font-size: 18px; font-weight: 500; }
.hero-number { font-size: 132px; font-weight: 500; letter-spacing: -6px; line-height: .95; font-variant-numeric: tabular-nums; }
.hero-number.small { font-size: 112px; letter-spacing: -5px; }
.sun-card { padding: 20px 22px; border-radius: 28px; background: var(--sun); }
.sun-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 18px; font-weight: 600; }
.chip-indigo { padding: 3px 12px; border-radius: 12px; background: var(--accent); color: #ffffff; font-size: 14px; font-weight: 500; }
.sun-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.sun-facts.two { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sun-facts b { display: block; font-size: 32px; font-weight: 600; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.sun-facts span { color: var(--sun-text); font-size: 15px; }

/* Dashboard */
.home-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 24px; padding-bottom: 18px; margin-bottom: 28px; border-bottom: 1px solid var(--sand-line); }
.home-head p { margin-bottom: 6px; font-size: 21px; font-weight: 600; letter-spacing: -.3px; }
.home { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; }
.home-left { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.home-middle { flex: 2 1 460px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.home-right { flex: 1 1 300px; min-width: 0; }
.vitals-card { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 16px 20px; border-radius: 24px; background: var(--surface); }
.hrv-card { display: grid; gap: 12px; padding: 16px 20px; border-radius: 24px; background: var(--surface); }
.hrv-card[hidden] { display: none; }
.hrv-card svg { display: block; width: 100%; height: auto; }
.hrv-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hrv-facts span { display: block; color: var(--muted); font-size: 14px; }
.hrv-facts b { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hrv-band { fill: #e6e1da; }
.hrv-night { fill: #b4235a; opacity: .3; }
.hrv-weekly { fill: none; stroke: #b4235a; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.hrv-chart-mark { fill: #111111; font-size: 14px; font-weight: 700; text-anchor: middle; }
.hrv-mark { display: inline-grid; place-items: center; width: 1.25em; height: 1.25em; margin-left: .3em; border-radius: 50%; background: #f8d066; color: #111111; font-size: .8em; font-weight: 700; vertical-align: .08em; cursor: help; }
.chip-hrv { padding: 2px 10px; border-radius: 999px; background: #ececea; font-size: 13px; font-weight: 600; }
.chip-hrv.good { color: var(--good); }
.chip-hrv.ok { color: var(--ok); }
.chip-hrv.low { color: var(--low); }
.vitals-card span { display: block; color: var(--muted); font-size: 15px; }
.vitals-card b { font-size: 26px; font-weight: 600; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.home-card { padding: 22px 26px; border-radius: 30px; background: var(--surface); }
.home-card header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-bottom: 14px; border-bottom: 1px solid #ececea; }
.home-card h2 { margin: 0; font-size: 24px; letter-spacing: -.5px; }
.home-card dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0 0; }
.home-card dt { color: var(--muted); font-size: 15px; }
.home-card dd { margin: 0; font-size: 17px; font-weight: 500; }
.home-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.card-link { display: block; text-decoration: none; border-radius: 30px; }
.card-link:hover .home-card { box-shadow: 0 2px 10px rgba(60, 40, 30, .12); }
.tag-pill { padding: 3px 12px; border-radius: 12px; font-size: 14px; font-weight: 600; }
.tag-sun { background: var(--sun); color: #111111; }
.tag-done { background: #1f7a55; color: #ffffff; }
.home-days-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.home-days-head h2 { margin: 0; font-size: 24px; letter-spacing: -.5px; }
.home-days-head a { padding: 10px 0; font-weight: 600; text-decoration: none; }
.home-days { margin: 8px 0 0; padding: 0; list-style: none; }
.home-days li { border-top: 1px solid var(--sand-line); }
.home-days a { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; text-decoration: none; }
.home-days small { display: block; min-height: 20px; color: #4d4843; font-size: 15px; }
.home-days .current > a > span > b { text-decoration: underline; text-underline-offset: 4px; }

/* Library */
.library { gap: 16px; }
.card { padding: 22px 24px; border: 0; border-radius: 28px; }
.tag { padding: 3px 12px; border-radius: 12px; font-size: 14px; }
.empty { border-radius: 24px; border-color: var(--sand-line); }

/* Editor */
.editor-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid var(--sand-line); }
.editor-title { flex: 1 1 420px; min-width: 0; }
.back { font-weight: 600; text-decoration: none; }
.title-input { display: block; width: 100%; min-height: 56px; margin-top: 4px; padding: 0; border: 0; border-radius: 8px; background: transparent; font-size: 44px; font-weight: 500; letter-spacing: -1.4px; }
.editor-note { margin-bottom: 16px; }
.editor-layout { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; margin-top: 24px; }
.editor-side { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.editor-blocks { flex: 3 1 620px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.side-card { display: grid; gap: 12px; padding: 18px 20px; border-radius: 24px; background: var(--surface); }
.side-card .pills { justify-content: flex-start; }
.block { margin: 0; padding: 18px 26px 14px; border: 0; border-radius: 30px; }
.block-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; padding: 0 0 12px; background: transparent; border: 0; border-bottom: 1px solid #ececea; border-radius: 0; }
.block-name { flex: 1 1 240px; width: auto; min-width: 0; padding: 0; border: 0; border-radius: 8px; font-size: 23px; font-weight: 500; letter-spacing: -.5px; }
.block-head .field.rounds { width: 72px; }
.block-head .field.time { width: 96px; }
.block-head .tools { padding-bottom: 4px; }
.tool { min-height: 40px; width: 40px; padding: 0; background: transparent; }
.step { display: block; padding: 0; border-bottom: 1px solid #f2f2f0; }
.step-summary { display: flex; flex-wrap: wrap; width: 100%; min-height: 48px; align-items: center; justify-content: space-between; gap: 4px 20px; padding: 8px 0; border-radius: 0; background: transparent; color: var(--text); font-size: 16px; font-weight: 400; text-align: left; white-space: normal; }
.step-summary:hover:not(:disabled) { background: transparent; }
.step-summary:hover .step-title b { text-decoration: underline; text-underline-offset: 3px; }
.step-title { flex: 1 1 240px; min-width: 0; }
.step-title b { font-weight: 500; }
.step-title small { color: var(--muted); font-size: 15px; }
.step-form { display: grid; gap: 8px; padding: 4px 0 14px; }
.step-main { gap: 8px; }
.step-main .step-name { flex: 1 1 220px; }
.step-main > .field { width: 84px; }
.step-main > .field.time { width: 96px; }
.step-main > .field.select { width: 124px; }
.step-form .tools { justify-content: flex-end; }
.step-note input { min-height: 40px; font-size: 15px; }
.segmented { height: 44px; border: 0; border-radius: 22px; background: var(--plain); padding: 3px; }
.segmented button { min-height: 38px; padding: 0 14px; border-radius: 19px; }
.segmented button[aria-pressed="true"] { background: #111111; color: #ffffff; }
.block-foot { padding: 12px 0 0; }
.add-block { width: 100%; min-height: 52px; border-radius: 26px; color: #ffffff; border-style: none; }

/* Day view */
.stat { border: 0; border-radius: 22px; padding: 14px 16px; }
.stat b { font-size: 26px; font-weight: 600; letter-spacing: -.6px; }
.stat span { font-size: 15px; }
.session { border: 0; border-radius: 30px; padding: 22px 26px; }
.effect { font-size: 14px; }
.metrics span { font-size: 14px; }
.plan { font-size: 15px; }
.plan .pill { font-size: 14px; }
.window-stats span { font-size: 14px; }
.strip { background: transparent; }
.bar { background: #d9cfc7; }
.bar.active { background: #111111; }
.tone.tone-hard { background: var(--watts); }

/* Login */
.logout { margin-left: auto; }
.login { max-width: 400px; margin-top: 12vh; padding: 30px; border-radius: 30px; }
.login h1 { font-size: 34px; font-weight: 700; letter-spacing: -1px; }

@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 4px 16px; padding: 10px 12px 10px 18px; position: static; }
  .tabs { margin-left: 0; height: 40px; order: 3; width: 100%; gap: 14px; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { font-size: 15px; padding: 0 2px; }
  .logout { min-height: 40px; }
  main { padding: 20px 16px 56px; }
  h1, .title-input { font-size: 32px; }
  .hero-number { font-size: 96px; }
  .hero-number.small { font-size: 88px; }
  .block { padding: 16px 16px 12px; border-radius: 24px; }
  .bars-card, .home-card, .session { padding: 18px; border-radius: 24px; }
  .calendar-frame { border-radius: 20px; }
  .day { min-height: 0; }
  .home-card dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Drag handles */
.step { display: flex; align-items: flex-start; gap: 4px; }
.step-body { flex: 1 1 auto; min-width: 0; }
.grip { display: inline-flex; align-items: center; justify-content: center; width: 28px; min-height: 48px; flex: none; color: #8c857e; font-size: 16px; letter-spacing: -2px; cursor: grab; touch-action: none; user-select: none; }
.grip:hover { color: #111111; }
.block-head .grip { min-height: 40px; }
.block-steps { min-height: 12px; }
.drag-ghost { opacity: .4; }
.refresh-note { align-self: center; font-size: 14px; color: var(--muted); }

/* Training view */
main.full { max-width: 1680px; }
.activity-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 24px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--sand-line); }
.activity-head p { margin-bottom: 6px; font-size: 18px; font-weight: 600; }
.activity-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.activity-layout { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.chart-card { flex: 3 1 680px; min-width: 0; padding: 18px 22px; border-radius: 30px; background: var(--surface); }
.activity-side { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.map-card { padding: 10px; border-radius: 30px; background: var(--surface); }
.map-card[hidden] { display: none; }
.map-box { height: 300px; border-radius: 22px; overflow: hidden; z-index: 0; }
.tc-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.tc-hint { margin-top: 10px; font-size: 14px; }
.tc-readout { min-height: 24px; margin: 6px 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric-toggle { min-height: 40px; padding: 0 14px; border: 2px solid var(--metric); background: var(--metric); color: #ffffff; font-weight: 600; }
.metric-toggle:hover:not(:disabled) { background: var(--metric); filter: brightness(1.1); }
.metric-toggle[aria-pressed="false"] { background: #ffffff; color: var(--metric); }
.metric-toggle[aria-pressed="false"]:hover:not(:disabled) { background: #ffffff; }
.tc-pane { position: relative; border-top: 1px solid #ececea; }
.tc-pane[hidden] { display: none; }
.tc-label { position: absolute; z-index: 3; top: 6px; left: 64px; padding: 0 6px; border-radius: 6px; background: rgba(255, 255, 255, .85); font-size: 13px; font-weight: 700; pointer-events: none; }
.tc-chart .u-over { cursor: grab; touch-action: pan-y; }
.tc-chart .u-over.dragging { cursor: grabbing; }
.tc-chart[data-tool="select"] .u-over { cursor: crosshair; }
.tc-overview { position: relative; height: 44px; margin-top: 6px; border-radius: 10px; background: #f3f1ee; overflow: hidden; touch-action: none; cursor: pointer; }
.tc-overview-line { position: absolute; inset: 0; width: 100%; height: 100%; }
.tc-window { position: absolute; top: 0; bottom: 0; min-width: 8px; background: rgba(248, 208, 102, .45); border-left: 2px solid #111111; border-right: 2px solid #111111; cursor: grab; }
.tc-handle { position: absolute; top: 0; bottom: 0; width: 12px; cursor: ew-resize; }
.tc-handle.left { left: -6px; }
.tc-handle.right { right: -6px; }
.fragment-range { font-size: 15px; color: var(--sun-text); }
.fragment-card h2 { margin: 2px 0 14px; font-size: 24px; font-weight: 600; letter-spacing: -.5px; }
.fragment-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 12px; }
.fragment-facts b { display: block; font-size: 22px; font-weight: 600; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.fragment-facts span { color: var(--sun-text); font-size: 14px; }
.fragment-card .home-actions button:not(.primary) { background: #ffffff; }
.fragment-form { display: grid; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid #d9b13f; }
.fragment-form .field > span { color: var(--sun-text); }
.fragment-error { color: var(--danger); font-size: 14px; }
.activity-lists { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.list-card { min-width: 0; padding: 18px 22px; border-radius: 30px; background: var(--surface); }
.list-card:first-child { flex: 3 1 680px; }
.list-card:last-child { flex: 1 1 360px; }
.list-card h2 { margin: 0 0 10px; font-size: 22px; }
.steps-scroll { overflow-x: auto; }
.steps-list { min-width: 720px; }
.step-row { display: grid; grid-template-columns: minmax(0, 1.5fr) 70px 140px 80px 60px 70px 60px; gap: 8px; align-items: center; width: 100%; min-height: 44px; padding: 6px 10px; border: 0; border-top: 1px solid #f0efed; border-radius: 12px; background: transparent; color: var(--text); font-size: 15px; font-weight: 400; text-align: left; white-space: normal; font-variant-numeric: tabular-nums; }
.step-row:hover:not(:disabled) { background: #f6f4f1; }
.step-row.head { min-height: 32px; border: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.step-row.head:hover { background: transparent; }
.step-row.child { padding-left: 34px; color: #2f2c29; }
.step-row.active, .step-row.active:hover:not(:disabled) { background: var(--sun); }
.step-row-name { font-weight: 600; }
.step-row.child .step-row-name { font-weight: 500; }
.step-row .pill { justify-self: start; font-size: 14px; padding: 2px 10px; }
.step-row .hit { color: var(--good); font-weight: 600; }
.step-row .miss { color: var(--ok); font-weight: 600; }
.saved-row { display: flex; align-items: center; gap: 2px; border-top: 1px solid #f0efed; border-radius: 12px; }
.saved-row.active { background: var(--sun); }
.saved-open { flex: 1 1 auto; display: block; min-width: 0; min-height: 52px; padding: 6px 10px; border-radius: 12px; background: transparent; text-align: left; white-space: normal; }
.saved-open:hover:not(:disabled) { background: transparent; }
.saved-open b { display: block; font-weight: 600; }
.saved-open small { color: var(--muted); font-size: 14px; }
@media (max-width: 760px) {
  .chart-card, .list-card { padding: 14px; border-radius: 24px; }
  .tc-toolbar .row { width: 100%; }
}

.chat-card { display: grid; gap: 12px; margin-top: 16px; padding: 22px 24px; border-radius: 28px; background: var(--surface); }
.chat-card h2 { margin: 0; font-size: 22px; }
.chat-log { display: grid; gap: 12px; max-height: 560px; overflow-y: auto; }
.chat-log:empty { display: none; }
.chat-message { display: grid; gap: 6px; padding: 12px 14px; border-radius: 16px; background: #f4f1ec; }
.chat-message.user { background: #ece9fb; }
.chat-meta { margin: 0; color: var(--muted); font-size: 13px; }
.chat-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-save { justify-self: start; min-height: 34px; font-size: 13px; }
.chat-scope { margin: 0; color: var(--muted); font-size: 14px; }
.chat-working { border: 1px solid var(--sand-line); }
.chat-chart { display: grid; gap: 8px; margin: 4px 0; padding: 14px 16px; border-radius: 16px; background: var(--surface); min-width: 0; }
.chat-chart figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-weight: 600; }
.chat-chart figcaption span { color: var(--muted); font-weight: 400; font-size: 13px; }
.cc-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 13px; }
.cc-legend span, .cc-tip-row { display: inline-flex; align-items: center; gap: 6px; }
.cc-legend i, .cc-tip-row i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.cc-plot { position: relative; min-width: 0; touch-action: pan-y; }
.cc-plot svg { display: block; }
.cc-grid { stroke: var(--line); stroke-width: 1; }
.cc-baseline { stroke: var(--sand-line); stroke-width: 1; }
.cc-guide { stroke: var(--muted); stroke-width: 1; }
.cc-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.cc-axis { fill: var(--muted); font-size: 12px; }
.cc-dot { stroke: var(--surface); stroke-width: 2; }
.cc-tip { position: absolute; top: 4px; display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--surface); box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); font-size: 13px; pointer-events: none; white-space: nowrap; }
.cc-tip[hidden] { display: none; }
.range-picker { display: grid; gap: 10px; padding: 14px 16px; border-radius: 16px; background: var(--raised); }
.range-label { margin: 0; color: var(--muted); font-size: 14px; }
.range-label strong { color: var(--text); font-weight: 600; }
.range-track { position: relative; height: 28px; }
.range-track::before { content: ''; position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--line); }
.range-fill { position: absolute; top: 12px; height: 4px; border-radius: 2px; background: var(--accent); }
.range-track input[type=range] { position: absolute; inset: 0; width: 100%; height: 28px; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.range-track input[type=range]:focus { box-shadow: none; outline: none; }
.range-track input[type=range]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
.range-track input[type=range]::-webkit-slider-runnable-track { height: 28px; background: none; border: none; }
.range-track input[type=range]::-moz-range-track { background: none; border: none; }
.range-track input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 24px; height: 24px; margin-top: 2px; border: 3px solid var(--surface); border-radius: 50%; background: var(--accent); box-shadow: 0 1px 4px rgb(0 0 0 / 0.25); cursor: grab; }
.range-track input[type=range]::-moz-range-thumb { pointer-events: auto; width: 18px; height: 18px; border: 3px solid var(--surface); border-radius: 50%; background: var(--accent); box-shadow: 0 1px 4px rgb(0 0 0 / 0.25); cursor: grab; }
.range-scale { position: relative; height: 26px; margin: -6px 12px 0; }
.range-mark { position: absolute; top: 0; display: grid; justify-items: center; transform: translateX(-50%); }
.range-mark i { width: 1px; height: 6px; background: var(--sand-line); }
.range-mark small { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.2; white-space: nowrap; }
.range-mark.year i { height: 10px; background: var(--muted); }
.range-mark.year small { color: var(--text); font-weight: 600; }
.range-mark.quiet small { visibility: hidden; }
.range-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.range-presets button { min-height: 32px; padding: 4px 12px; font-size: 13px; }
@media (max-width: 760px) {
  .chat-page .chat-card { padding: 16px 12px; }
  .chat-page .chat-message { padding: 12px; }
  .chat-chart { padding: 10px 8px; }
}
.chat-chart details summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.cc-table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.cc-table th, .cc-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.cc-table th:first-child, .cc-table td:first-child { text-align: left; }
.chat-working-line { display: flex; align-items: baseline; gap: 10px; margin: 0; font-size: 16px; }
.chat-spinner { width: 1.2em; color: var(--run); font-size: 20px; line-height: 1; text-align: center; }
.chat-verb { color: var(--run); font-weight: 600; }
.chat-elapsed { color: var(--muted); font-variant-numeric: tabular-nums; }
.insights-main { display: grid; gap: 16px; min-width: 0; }
.chat-page { display: grid; gap: 16px; }
.chat-page .chat-card { margin-top: 0; }
.chat-page .chat-log { max-height: none; overflow: visible; gap: 16px; }
.chat-page .chat-message { padding: 16px 20px; }
.chat-page .chat-text { font-size: 16px; line-height: 1.6; }
.insight-list { display: grid; gap: 16px; }
.insight { display: grid; gap: 10px; padding: 20px 24px; border-radius: 24px; background: var(--surface); min-width: 0; }
.insight header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.insight h2 { margin: 0; font-size: 19px; }
.insight-meta { margin: 0; color: var(--muted); font-size: 14px; }
.period-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.zone-layout { display: grid; gap: 16px; }
.zone-card { display: grid; gap: 14px; }
.zone-card h2 { margin: 0; font-size: 22px; }
.zone-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.zone-table th { padding: 6px 8px; color: var(--muted); font-size: 13px; font-weight: 500; text-align: left; }
.zone-table td { padding: 10px 8px; border-top: 1px solid var(--line); }
.zone-table td:first-child { display: flex; align-items: center; gap: 10px; }
.zone-table th:not(:first-child), .zone-table td:not(:first-child) { text-align: right; white-space: nowrap; }
.zone-table td small { display: block; color: var(--muted); font-size: 12px; }
.zone-chip { display: inline-grid; place-items: center; min-width: 34px; padding: 2px 6px; border-radius: 8px; color: #fff; font-size: 12px; font-weight: 700; }
.zone-chip.z1 { background: var(--z1); color: var(--text); } .zone-chip.z2 { background: var(--z2); } .zone-chip.z3 { background: var(--z3); color: var(--text); }
.zone-chip.z4 { background: var(--z4); } .zone-chip.z5 { background: var(--z5); } .zone-chip.z6 { background: var(--z6); } .zone-chip.z7 { background: var(--z7); }
.zone-source, .zone-note { margin: 0; color: var(--muted); font-size: 13px; }
.zone-note { margin-top: 16px; }
@media (max-width: 760px) { .zone-table td, .zone-table th { padding-left: 4px; padding-right: 4px; font-size: 14px; } }

.zone-editors { display: grid; gap: 20px; }
.zone-editors h3 { margin: 0 0 6px; font-size: 17px; }
.zone-edit { display: grid; gap: 8px; justify-items: start; }
.zone-table.editable td { padding: 6px 4px; }
.zone-table.editable td:first-child { display: table-cell; width: 44px; }
.zone-table.editable input { width: 100%; min-width: 0; min-height: 38px; padding: 6px 8px; text-align: right; }
.zone-table.editable input.zone-name { text-align: left; }
.zone-table.editable th:nth-child(3), .zone-table.editable th:nth-child(4), .zone-table.editable td:nth-child(3), .zone-table.editable td:nth-child(4) { width: 22%; }
.zone-remove { min-height: 34px; padding: 2px 10px; }
.zone-table.editable th:nth-child(2) { text-align: left; }
.pr-badge { margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--sun); color: var(--sun-text); font-size: 12px; font-weight: 600; }

/* Loading: shimmering placeholders shaped like the screen. */
.sk-page, .sk-group { display: grid; gap: 16px; }
.sk-group { gap: 10px; padding: 4px 0; }
.sk-card { display: grid; gap: 12px; padding: 20px 22px; border-radius: 28px; background: var(--surface); }
.sk-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.sk-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.sk-stats .sk-card { padding: 14px 16px; border-radius: 22px; }
.sk {
  border-radius: 8px;
  background: linear-gradient(100deg, #ece6e0 30%, #f7f3ef 50%, #ece6e0 70%) 0 0 / 300% 100%;
  animation: sk-shimmer 1.4s ease-in-out infinite;
}
.sk-title { width: min(320px, 60%); height: 40px; border-radius: 12px; }
.sk-heading { width: 40%; height: 20px; }
.sk-number { width: 60%; height: 26px; }
.sk-line { height: 14px; }
.sk-line.short { width: 55%; }
.sk-chip { width: 70%; height: 22px; border-radius: 999px; }
.sk-chart { height: 180px; border-radius: 16px; }
.sk-chart.tall { height: 360px; }
.sk-calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.sk-day { display: grid; gap: 10px; align-content: start; min-height: 96px; padding: 10px; border-radius: 16px; background: var(--surface); }
.sk-page > .sk { background-image: linear-gradient(100deg, #e0d6cd 30%, #ece4dc 50%, #e0d6cd 70%); }
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Motion: views slide in, controls respond to touch, new content appears softly. */
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
#app > :not(.sk-page) { animation: view-in .28s cubic-bezier(.2, .7, .2, 1) both; }
#app > :not(.sk-page):nth-child(2) { animation-delay: .03s; }
#app > :not(.sk-page):nth-child(3) { animation-delay: .06s; }
.sk-page { animation: fade-in .2s ease both; }
button, .button { transition: transform .12s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease; }
button:active:not(:disabled), .button:active { transform: scale(.97); }
input, textarea, select { transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease; }
.tabs a { transition: color .15s ease, text-decoration-color .2s ease; }
.list-card, .stat, .insight, .chart-card, .chat-card, .zone-card, .day { transition: box-shadow .2s ease, transform .2s ease; }
.chat-message.fresh, .fragment-card > * { animation: pop-in .26s cubic-bezier(.2, .7, .2, 1) both; }
.ai-message:not(:empty) { animation: fade-in .25s ease both; }
.zone-table.editable tbody tr { animation: fade-in .2s ease both; }
dialog[open] { animation: pop-in .22s cubic-bezier(.2, .7, .2, 1) both; }
dialog::backdrop { animation: fade-in .2s ease both; }
@media (hover: hover) {
  .saved-row:not(.active) .saved-open:hover, .step-row:not(.head):not(.active):hover { background: var(--raised); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .sk { animation: none; }
}
@media (max-width: 760px) {
  .sk-calendar { grid-template-columns: 1fr; }
  .sk-day { min-height: 64px; }
}

/* Chat screen: the window is fixed, only the conversation scrolls. */
body.chat-mode { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
body.chat-mode .topbar { flex: none; }
body.chat-mode main { flex: 1; min-height: 0; width: 100%; max-width: 900px; display: flex; flex-direction: column; padding-top: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); box-sizing: border-box; }
main.chat .chat-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-page .chat-screen-card { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0; margin: 0; padding: 0; background: transparent; }
.chat-screen-card .chat-log, .chat-screen-card .chat-log:empty { display: flex; flex-direction: column; gap: 16px; flex: 1; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; padding: 4px 2px 16px; }
.chat-screen-card .chat-message { flex: none; padding: 16px 20px; }
.chat-screen-card .chat-text { font-size: 16px; line-height: 1.6; }
.composer { flex: none; display: grid; gap: 8px; padding-top: 8px; }
.composer-box { display: grid; gap: 4px; padding: 8px 10px 8px 14px; border: 1px solid #dcd7d2; border-radius: 24px; background: var(--surface); box-shadow: 0 2px 14px rgb(60 40 30 / .07); transition: border-color .15s ease, box-shadow .15s ease; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 2px 18px rgb(74 79 184 / .14); }
.composer-box textarea { min-height: 0; max-height: 40vh; padding: 8px 2px; border: 0; border-radius: 0; background: transparent; box-shadow: none; resize: none; overflow-y: auto; font-size: 16px; line-height: 1.45; }
.composer-box textarea:focus { outline: none; box-shadow: none; }
.composer-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
.composer-actions button { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.composer-actions button:first-child { margin-right: auto; }
.composer .ai-message { margin: 0; }
.composer .ai-message:empty { display: none; }
.composer .ai-usage { font-size: 12px; }
.range-fold { display: grid; gap: 8px; }
.range-picker[hidden] { display: none; }
.range-toggle { justify-self: start; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border-radius: 999px; font-size: 13px; }
.range-toggle-label { color: var(--muted); }
.range-toggle-arrow { transition: transform .2s ease; }
.range-toggle[aria-expanded="true"] .range-toggle-arrow { transform: rotate(180deg); }
.range-fold .range-picker:not([hidden]) { animation: pop-in .22s cubic-bezier(.2, .7, .2, 1) both; }
@media (max-width: 760px) {
  body.chat-mode .topbar { margin: 8px 8px 0; }
  body.chat-mode main { padding-left: 10px; padding-right: 10px; }
  .chat-screen-card .chat-message { padding: 12px 14px; }
  .composer-actions { flex-wrap: nowrap; gap: 4px; }
  .composer-actions button { min-height: 34px; padding: 6px 10px; font-size: 13px; white-space: nowrap; }
}

/* Redrawn lists: elements keep a name, so the browser animates what was added, removed or moved. */
#app > .swapped { animation: none; }
::view-transition-group(root) { animation: none; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-group(*) { animation-duration: .26s; animation-timing-function: cubic-bezier(.2, .7, .2, 1); }
::view-transition-image-pair(*) { overflow: clip; }
::view-transition-old(*), ::view-transition-new(*) { height: 100%; object-fit: cover; object-position: top; animation-duration: .2s; }
::view-transition-new(*):only-child { animation: item-in .26s cubic-bezier(.2, .7, .2, 1) both; }
::view-transition-old(*):only-child { animation: item-out .18s ease-in both; }
@keyframes item-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes item-out { to { opacity: 0; transform: scale(.95); } }

/* Months slide sideways as one; the cards inside travel with the grid. */
html[data-motion^="month"] .workout { view-transition-name: none !important; }
html[data-motion^="month"] .month-grid { view-transition-name: month-grid; }
html[data-motion^="month"] .month-title { view-transition-name: month-title; }
::view-transition-group(month-grid) { animation: none; }
::view-transition-image-pair(month-grid) { overflow: visible; }
::view-transition-old(month-grid), ::view-transition-new(month-grid) { height: auto; animation-duration: .3s; animation-timing-function: cubic-bezier(.2, .7, .2, 1); animation-fill-mode: both; }
html[data-motion="month-next"]::view-transition-old(month-grid) { animation-name: month-out-left; }
html[data-motion="month-next"]::view-transition-new(month-grid) { animation-name: month-in-right; }
html[data-motion="month-prev"]::view-transition-old(month-grid) { animation-name: month-out-right; }
html[data-motion="month-prev"]::view-transition-new(month-grid) { animation-name: month-in-left; }
@keyframes month-out-left { to { opacity: 0; transform: translateX(-48px); } }
@keyframes month-in-right { from { opacity: 0; transform: translateX(48px); } }
@keyframes month-out-right { to { opacity: 0; transform: translateX(48px); } }
@keyframes month-in-left { from { opacity: 0; transform: translateX(-48px); } }
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }

/* Search and filters over workout lists. */
.workout-filter { display: grid; gap: 10px; margin-bottom: 16px; }
.filter-search { min-height: 44px; border-radius: 999px; padding: 8px 18px; background: var(--surface); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip { min-height: 34px; padding: 4px 14px; border-radius: 999px; font-size: 14px; }
.filter-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
dialog .pick-list { min-height: 240px; max-height: 46vh; overflow-y: auto; align-content: start; }

/* HRV page. */
a.hrv-link { color: inherit; text-decoration: none; cursor: pointer; transition: box-shadow .2s ease, transform .2s ease; }
a.hrv-link:hover { box-shadow: 0 2px 10px rgba(60, 40, 30, .12); }
a.hrv-link:active { transform: scale(.99); }
.hrv-page { display: grid; gap: 16px; }
.hrv-page[aria-busy="true"] { opacity: .55; transition: opacity .15s ease; }
.hrv-legend { margin-bottom: 8px; }
.hrv-legend i.legend-night { border-radius: 50%; background: #b4235a; opacity: .3; }
.hrv-legend i.legend-weekly { height: 3px; background: #b4235a; }
.hrv-legend i.legend-band { background: #e6e1da; }
.hrv-table { display: grid; }
.hrv-row { display: grid; grid-template-columns: 1.4fr .8fr .7fr .7fr 1.3fr .6fr .6fr; align-items: center; gap: 8px; padding: 10px 6px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; font-variant-numeric: tabular-nums; }
.hrv-row.head { border-top: 0; color: var(--muted); font-size: 13px; }
a.hrv-row:hover { background: var(--raised); }
@media (max-width: 760px) {
  .hrv-row { grid-template-columns: 1.5fr .8fr .8fr 1.2fr; }
  .hrv-row > :nth-child(3), .hrv-row > :nth-child(6), .hrv-row > :nth-child(7) { display: none; }
}
