/* Design tokens */
:root {
  color-scheme: dark;
  --bg: #0a0b0e;
  --surface: #14161b;
  --surface-2: #1c1f26;
  --surface-3: #2a2e37;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #f5f6f8;
  --text-2: #a8aeb9;
  --text-3: #868d99;
  --accent: #c8f23a;
  --accent-soft: rgba(200, 242, 58, .13);
  --on-accent: #0e1203;
  --danger: #ff7b6e;
  --danger-soft: rgba(255, 123, 110, .12);
  --good: #8fe39a;
  --heat-0: #1f2229;
  --heat-1: #46591f;
  --heat-2: #66852a;
  --heat-3: #93ba31;
  --heat-4: #c8f23a;
  --bar: #7f9c2c;

  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --r-xl: 26px;
  --gutter: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabs-h: 60px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 150ms;
  --t-med: 260ms;

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: var(--bg); overscroll-behavior-y: none; }
h1, h2, h3, p, ul, ol, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
a { touch-action: manipulation; }
img { display: block; }
[hidden] { display: none !important; }
small { font-size: 13px; }

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

.skip-link { position: absolute; left: 12px; top: -60px; background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: var(--r-s); z-index: 100; }
.skip-link:focus { top: calc(var(--safe-top) + 8px); }

/* Layout */
main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) var(--gutter) calc(var(--tabs-h) + var(--safe-bottom) + 32px);
}
main:focus { outline: none; }
body.no-tabs main { padding-bottom: calc(var(--safe-bottom) + 32px); }
body.has-restbar main { padding-bottom: calc(var(--tabs-h) + var(--safe-bottom) + 112px); }
body.no-tabs.has-restbar main { padding-bottom: calc(var(--safe-bottom) + 112px); }
main.enter > * { animation: enter var(--t-med) var(--ease) both; }

@keyframes enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.centered { text-align: center; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--text-2); }

h1 { font-size: 32px; line-height: 1.1; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 20px; line-height: 1.2; letter-spacing: -.012em; font-weight: 650; }

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 12px 0 16px; }

.topbar { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 12px; }
.topbar-title { font-weight: 650; font-size: 17px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; justify-content: flex-end; min-width: 44px; }
.iconbtn-spacer { width: 44px; }

.iconbtn {
  width: 44px; height: 44px; flex: none;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast);
}
.iconbtn:active { transform: scale(.94); background: var(--surface-3); }
.iconbtn:disabled { opacity: .35; cursor: default; }
.iconbtn-accent { background: var(--accent); color: var(--on-accent); }

.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head .muted { font-size: 14px; text-align: right; }
.prose { color: var(--text); line-height: 1.55; margin: 12px 0; max-width: 60ch; }
.hint { font-size: 13px; color: var(--text-2); line-height: 1.45; }
.error { color: var(--danger); font-size: 14px; margin-top: 6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px;
  border-radius: var(--r-m);
  font-weight: 650; font-size: 16px; text-align: center;
  transition: transform var(--t-fast) var(--ease), filter var(--t-fast), background var(--t-fast);
  cursor: pointer;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:active { filter: brightness(.9); }
.btn-secondary { background: var(--surface-3); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-danger { background: var(--danger); color: #240604; }
.btn-danger-ghost { background: var(--danger-soft); color: var(--danger); }
.btn-block { display: flex; width: 100%; }
.btn-large { min-height: 56px; font-size: 17px; border-radius: var(--r-l); }
.btn-small { min-height: 44px; padding: 8px 14px; font-size: 14px; border-radius: var(--r-s); }

.linkbtn {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; padding: 0 4px;
  color: var(--text-2); font-size: 14px; font-weight: 600;
}
.linkbtn-center { display: flex; margin: 8px auto 0; }

/* Chips and segmented controls */
.chip {
  min-height: 44px; min-width: 44px; padding: 0 12px;
  background: var(--surface-2); color: var(--text-2);
  border-radius: 12px; font-weight: 600; font-size: 15px;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease);
  flex: 1;
}
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.chip-wide { flex: none; padding: 0 16px; white-space: nowrap; }
.chiprow {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 12px calc(var(--gutter) * -1); padding: 0 var(--gutter);
}
.chiprow::-webkit-scrollbar { display: none; }
.chiprow-center { justify-content: safe center; }
.chipwrap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.segmented { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 12px; }
.segmented button {
  flex: 1; min-height: 40px; padding: 0 8px;
  border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.segmented button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }

/* Media: a photo over a designed placeholder */
.media { position: relative; overflow: hidden; background: var(--surface-2); }
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media-fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: rgba(200, 242, 58, .32);
  background:
    radial-gradient(120% 90% at 78% 12%, rgba(200, 242, 58, .13), transparent 60%),
    linear-gradient(150deg, #252932 0%, #15171c 72%);
}
.hero-media .media-fallback, .cover-media .media-fallback, .session-media .media-fallback { place-items: start end; padding: 24px; }
.hero-media .media-fallback svg, .cover-media .media-fallback svg { width: 120px; height: 120px; stroke-width: 1; }
.session-media .media-fallback svg { width: 88px; height: 88px; stroke-width: 1.25; }
.cover-media .media-fallback { padding-top: calc(var(--safe-top) + 72px); }
.thumb { width: 84px; height: 84px; flex: none; border-radius: var(--r-m); }
.thumb .media-fallback svg { width: 32px; height: 32px; }
.thumb-sm { width: 52px; height: 52px; border-radius: var(--r-s); }
.thumb-sm .media-fallback svg { width: 24px; height: 24px; }

/* Home */
.daystrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 16px; }
.daychip {
  display: grid; justify-items: center; gap: 6px;
  min-height: 62px; padding: 10px 0 9px;
  border-radius: var(--r-m); color: var(--text-2);
  font-weight: 600; font-size: 14px;
  transition: background var(--t-fast), color var(--t-fast);
}
.daychip.is-today { color: var(--text); }
.daychip[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.daychip-mark {
  display: grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--line-strong);
}
.daychip.is-today .daychip-mark { border-color: var(--accent); }
.daychip-mark.rest { border-style: dotted; }
.daychip-mark.done { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.daychip-mark svg { stroke-width: 3; }

.hero {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 400px;
  border-radius: var(--r-xl); overflow: hidden; isolation: isolate;
  background: var(--surface);
}
.hero-media { position: absolute; inset: 0; z-index: -1; }
.hero-media::after, .cover-media::after, .session-media::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10, 11, 14, .05) 20%, rgba(10, 11, 14, .6) 58%, rgba(10, 11, 14, .96) 100%);
}
.hero-body { padding: 20px; display: grid; gap: 6px; }
.hero-body h2 { font-size: 28px; line-height: 1.12; letter-spacing: -.02em; font-weight: 700; }
.hero-body p { color: #d4d8df; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 14px; color: #d4d8df; font-size: 14px; margin-top: 2px; }
.hero-meta span { display: inline-flex; align-items: center; gap: 5px; }
.hero-action { margin-top: 12px; position: relative; z-index: 1; display: grid; }
.stretched::after { content: ''; position: absolute; inset: 0; }
.badge {
  justify-self: start; display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px 4px 8px; border-radius: 99px;
  background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 650;
}

.resume {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 14px 16px; margin-bottom: 14px;
  background: var(--accent-soft); border: 1px solid rgba(200, 242, 58, .35);
  border-radius: var(--r-l);
}
.resume b, .resume small { display: block; }
.resume small { color: var(--text-2); }
.resume-go { display: inline-flex; align-items: center; color: var(--accent); font-weight: 650; font-size: 14px; white-space: nowrap; }
.resume-pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.meter { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.meter div { height: 100%; background: var(--accent); border-radius: 6px; transform-origin: left; transition: transform var(--t-med) var(--ease); }
.section > .meter { margin-bottom: 14px; }

/* Lists */
.list, .insights { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.dayrow b, .exrow b, .insight b { overflow-wrap: anywhere; }
.dayrow, .exrow {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 60px; padding: 10px 12px 10px 10px;
  background: var(--surface); border-radius: var(--r-l);
  text-align: left; color: var(--text);
  transition: background var(--t-fast), transform var(--t-fast) var(--ease);
}
.dayrow:active, .exrow:active { background: var(--surface-2); transform: scale(.99); }
.dayrow > svg:last-child, .exrow > svg:last-child { color: var(--text-3); flex: none; }
.dayrow.is-selected { box-shadow: inset 0 0 0 1px var(--line-strong); }
.dayrow b, .exrow b { display: block; font-weight: 600; line-height: 1.25; }
.dayrow small, .exrow small { display: block; color: var(--text-2); margin-top: 2px; }
.dayrow-icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; background: var(--surface-2); border-radius: 12px; color: var(--text-2); }
.dayrow-icon.done { background: var(--accent); color: var(--on-accent); }
.exrow-last { color: var(--accent) !important; opacity: .9; }
.exrow-stat { padding-left: 14px; }
.setsline { line-height: 1.5; color: var(--text) !important; font-size: 14px; }
.datebox { width: 42px; flex: none; text-align: center; }
.datebox b { font-size: 19px; line-height: 1; font-variant-numeric: tabular-nums; }
.datebox small { margin-top: 2px; font-size: 12px; }

.notice {
  display: flex; align-items: center; gap: 12px; margin-top: 16px;
  padding: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-l);
}
.notice b, .notice small { display: block; }
.notice small { color: var(--text-2); margin-top: 2px; }
.notice > svg:first-child { color: var(--accent); flex: none; }
.notice > svg:last-child:not(:first-child) { color: var(--text-3); flex: none; }
.notice-static { margin-top: 0; align-items: flex-start; }

/* Cover header on detail screens */
.cover {
  position: relative; isolation: isolate;
  margin: calc((var(--safe-top) + 12px) * -1) calc(var(--gutter) * -1) 0;
  padding: calc(var(--safe-top) + 12px) var(--gutter) 16px;
  min-height: 300px; display: flex; flex-direction: column;
}
.cover-tall { min-height: 340px; }
.cover-media { position: absolute; inset: 0; z-index: -1; }
.cover .iconbtn { background: rgba(20, 22, 27, .72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.cover-body { margin-top: auto; display: grid; gap: 6px; }
.cover-body p { color: #d4d8df; }

.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.stats3 > div { padding: 12px 8px; background: var(--surface); border-radius: var(--r-m); text-align: center; }
.stats3 b { display: block; font-size: 20px; font-weight: 700; }
.stats3 span { font-size: 13px; color: var(--text-2); }

.sticky-cta {
  position: sticky; bottom: calc(var(--tabs-h) + var(--safe-bottom) + 12px);
  margin-top: 16px; z-index: 3;
}
body.has-restbar .sticky-cta { bottom: calc(var(--tabs-h) + var(--safe-bottom) + 92px); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pill { padding: 6px 12px; background: var(--surface-2); border-radius: 99px; font-size: 14px; color: var(--text); }
.pill-link { min-height: 44px; display: inline-flex; align-items: center; padding: 0 16px; }

/* Forms */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
label, .label, legend { font-size: 14px; font-weight: 600; color: var(--text-2); }
legend { padding: 0; margin-bottom: 8px; }
input[type="text"], input[type="search"], input[type="date"], textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-m);
  font-size: 16px; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); }
[aria-invalid="true"] { border-color: var(--danger) !important; }

.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 15px; color: var(--text-2); pointer-events: none; }
.search input { padding-left: 40px; }

.stepper { display: grid; gap: 6px; min-width: 0; }
.stepper-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; align-items: center; background: var(--surface-2); border-radius: var(--r-m); }
.stepbtn { height: 56px; display: grid; place-items: center; color: var(--text); border-radius: var(--r-m); transition: background var(--t-fast); }
.stepbtn:active { background: var(--surface-3); }
.stepper-value { display: flex; align-items: baseline; justify-content: center; gap: 4px; min-width: 0; }
.stepper-value input {
  width: 100%; min-width: 0; min-height: 44px; padding: 0;
  background: transparent; border: 0; border-radius: 8px;
  font-size: 24px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums;
}
.stepper-value span { font-size: 13px; color: var(--text-2); flex: none; padding-right: 4px; }
.stepper-value input:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.rpe legend span { font-weight: 400; color: var(--text-3); }
.rpe-row { display: flex; gap: 6px; flex-wrap: wrap; }
.rpe .hint { margin-top: 8px; }

.switchrow { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 14px; background: var(--surface); border-radius: var(--r-l); cursor: pointer; }
.switchrow b { display: block; color: var(--text); font-size: 16px; }
.switchrow small { display: block; color: var(--text-2); font-weight: 400; margin-top: 2px; }
.switch {
  -webkit-appearance: none; appearance: none; position: relative; flex: none;
  width: 52px; height: 32px; margin: 0; border-radius: 32px;
  background: var(--surface-3); cursor: pointer;
  transition: background var(--t-fast);
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%; background: #fff;
  transition: transform var(--t-med) var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); background: var(--on-accent); }

.filebtn { position: relative; overflow: hidden; color: var(--text); }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.edititems { display: grid; gap: 12px; margin-bottom: 4px; }
.edititem { padding: 12px; background: var(--surface); border-radius: var(--r-l); display: grid; gap: 12px; }
.edititem-head { display: flex; align-items: center; gap: 6px; }
.edititem-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
.edititem-fields input[type="text"]:not(.stepper-value input) { min-height: 56px; }

/* Session */
.session-bar { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; margin-bottom: 10px; }
.session-clock { text-align: center; line-height: 1.2; }
.session-clock b { display: block; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.session-clock small { color: var(--text-2); }

.exstrip { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1) 12px; padding: 2px var(--gutter); }
.exstrip::-webkit-scrollbar { display: none; }
.exchip {
  flex: 1 0 44px; height: 44px; display: grid; place-items: center;
  background: var(--surface-2); border-radius: 12px; color: var(--text-2);
  font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums;
}
.exchip.done { color: var(--accent); }
.exchip.done svg { stroke-width: 3; }
.exchip[aria-current="step"] { background: var(--text); color: var(--bg); }

.session-hero { position: relative; aspect-ratio: 16 / 10; border-radius: var(--r-xl); overflow: hidden; isolation: isolate; display: flex; align-items: flex-end; }
.session-media { position: absolute; inset: 0; z-index: -1; }
.session-hero-body { padding: 16px; display: grid; gap: 2px; }
.session-hero-body .eyebrow { color: #d4d8df; }
.session-hero-body h1 { font-size: 26px; }

.howto { margin-top: 8px; background: var(--surface); border-radius: var(--r-m); }
.howto summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; font-weight: 600; font-size: 14px; color: var(--text-2); cursor: pointer; list-style: none; }
.howto summary::-webkit-details-marker { display: none; }
.howto p { padding: 0 12px 12px; line-height: 1.5; }

.lastinfo { margin-top: 8px; padding: 12px; background: var(--surface); border-radius: var(--r-m); display: grid; gap: 2px; font-size: 14px; }
.lastinfo b { font-weight: 600; }
.cue { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); margin-top: 4px; font-weight: 600; }

.setlist { display: grid; gap: 6px; margin-top: 12px; }
.setrow {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 52px; padding: 8px 12px;
  background: var(--surface); border-radius: var(--r-m); text-align: left;
}
.setrow > svg { color: var(--text-3); flex: none; }
.setrow b { font-weight: 600; font-variant-numeric: tabular-nums; }
.setrow-num {
  width: 26px; height: 26px; flex: none; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2);
  border-radius: 50%; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.setrow.is-done .setrow-num svg { stroke-width: 3; color: var(--on-accent); }
.setrow.is-done .setrow-num:has(svg) { background: var(--accent); }
.setrow.is-upcoming { opacity: .55; min-height: 44px; }
.setrow-rpe { font-size: 13px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.setrow-pr { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 650; color: var(--accent); white-space: nowrap; }
.setrow-pr svg { flex: none; }

.setpanel { padding: 14px; background: var(--surface); border-radius: var(--r-l); box-shadow: inset 0 0 0 1.5px var(--line-strong); display: grid; gap: 14px; }
.setpanel-head { display: flex; align-items: center; gap: 10px; }
.setpanel-head .setrow-num { background: var(--accent); color: var(--on-accent); }
.setpanel-head b { flex: 1; font-weight: 650; }
.setpanel-head small { color: var(--text-2); text-align: right; }
.setpanel-fields { display: grid; gap: 12px; }

.set-adjust { display: flex; justify-content: space-between; gap: 12px; margin: 4px 0 8px; }

/* Workout summary */
.summary { text-align: center; padding-top: 24px; }
.summary-check {
  width: 84px; height: 84px; margin: 0 auto 16px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); border-radius: 50%;
  animation: pop 420ms var(--ease) both;
}
.summary-check svg { stroke-width: 2.5; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.summary .tiles, .summary .section { text-align: left; }
.summary .tiles { margin-top: 20px; }
.summary-actions { display: grid; gap: 4px; margin-top: 24px; }
.prrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border-radius: var(--r-l); }
.prrow > svg { color: var(--accent); flex: none; }
.prrow b, .prrow small { display: block; }
.prrow small { color: var(--text-2); }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.tile { padding: 14px; background: var(--surface); border-radius: var(--r-l); display: grid; gap: 2px; align-content: start; }
.tile span { font-size: 13px; color: var(--text-2); }
.tile b { font-size: 24px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.tile small { color: var(--text-2); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta-up { color: var(--good) !important; }
.delta-down { color: var(--text-2) !important; }
.delta-down svg { transform: rotate(45deg); }

/* Progress */
.card { background: var(--surface); border-radius: var(--r-l); }
.card-pad, .card-chart { padding: 14px; }
.card-chart .segmented { margin-bottom: 12px; }
.chart-head { margin-bottom: 8px; display: grid; gap: 2px; }
.chart-empty { padding: 24px 8px; text-align: center; }

.weekcard { display: grid; grid-template-columns: minmax(0, 1fr) 118px; gap: 16px; padding: 16px; align-items: stretch; }
.weekcard-main { display: grid; gap: 4px; align-content: start; }
.weekcard-main .meter { margin-top: 8px; }
.herofig { font-size: 44px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; }
.herofig span { font-size: 22px; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.chart-head .herofig { font-size: 36px; }
.weekcard-streak { display: grid; justify-items: start; align-content: start; gap: 2px; padding-left: 16px; border-left: 1px solid var(--line); }
.weekcard-streak svg { color: var(--accent); }
.weekcard-streak b { font-size: 28px; line-height: 1.1; font-weight: 700; }
.weekcard-streak small { color: var(--text-2); line-height: 1.25; }

.filterbar { position: sticky; top: calc(var(--safe-top) + 6px); z-index: 3; margin: 28px 0 12px; }
.filterbar .segmented { background: var(--surface-2); box-shadow: 0 0 0 4px var(--bg); }
.topbar + .filterbar { margin-top: 0; }

.chart { position: relative; touch-action: pan-y; cursor: crosshair; border-radius: 6px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: rgba(255, 255, 255, .07); stroke-width: 1; }
.chart .tick { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .endlabel { fill: var(--text); font-size: 13px; font-weight: 650; }
.chart .series-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { fill: var(--accent); opacity: .1; }
.chart .marker { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .active-dot { fill: var(--text); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--line-strong); stroke-width: 1; }
.chart .bar { fill: var(--bar); transition: fill var(--t-fast); }
.chart .bar-current { fill: var(--accent); }
.chart .bar.is-active { fill: var(--text); }
.chart .cell { transition: stroke var(--t-fast); stroke: transparent; stroke-width: 1.5; }
.chart .cell-today { stroke: var(--text-2); }
.chart .cell.is-active { stroke: var(--text); }
.chart .level-0, .heatlegend .level-0 { fill: var(--heat-0); background: var(--heat-0); }
.chart .level-1, .heatlegend .level-1 { fill: var(--heat-1); background: var(--heat-1); }
.chart .level-2, .heatlegend .level-2 { fill: var(--heat-2); background: var(--heat-2); }
.chart .level-3, .heatlegend .level-3 { fill: var(--heat-3); background: var(--heat-3); }
.chart .level-4, .heatlegend .level-4 { fill: var(--heat-4); background: var(--heat-4); }

.chart-tip {
  position: absolute; left: 0; top: 0; transform: translateX(-50%);
  padding: 6px 10px; max-width: 240px; width: max-content;
  background: var(--surface-3); border-radius: var(--r-s);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
  pointer-events: none; z-index: 2; text-align: center;
}
.chart-tip b { display: block; font-size: 14px; font-weight: 650; }
.chart-tip span { display: block; font-size: 12px; color: var(--text-2); }

.heatlegend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.heatlegend i { width: 12px; height: 12px; border-radius: 3px; }
.heatlegend span:first-child { margin-right: 2px; }
.heatlegend span:last-child { margin-left: 2px; }

.tableview { margin-top: 10px; font-size: 14px; }
.tableview summary { min-height: 44px; display: flex; align-items: center; color: var(--text-2); font-weight: 600; cursor: pointer; list-style: none; }
.tableview summary::-webkit-details-marker { display: none; }
.tableview summary::after { content: '›'; margin-left: 6px; transition: transform var(--t-fast); }
.tableview[open] summary::after { transform: rotate(90deg); }
.tablewrap { max-height: 280px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 600; color: var(--text-2); position: sticky; top: 0; background: var(--surface); }
th, td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); }

.hbars { display: grid; gap: 10px; margin-bottom: 12px; }
.hbars li { display: grid; grid-template-columns: 76px minmax(0, 1fr) 36px; align-items: center; gap: 8px; font-size: 14px; }
.hbar-track { height: 10px; border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar-track i { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; transform-origin: left; transition: transform var(--t-med) var(--ease); }
.hbar-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.spark polyline { fill: none; stroke: var(--text-2); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--accent); }
.spark { flex: none; }

.insight { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border-radius: var(--r-l); }
.insight b, .insight small { display: block; }
.insight b { font-weight: 600; line-height: 1.25; }
.insight small { color: var(--text-2); margin-top: 2px; }
.insight > svg { color: var(--text-3); flex: none; }
.insight-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.insight-up { background: var(--accent-soft); color: var(--accent); }
.insight-gap { color: var(--danger); background: var(--danger-soft); }

.empty { text-align: center; padding: 48px 16px; display: grid; gap: 8px; justify-items: center; }
.empty-icon { width: 68px; height: 68px; display: grid; place-items: center; background: var(--surface-2); border-radius: 50%; color: var(--accent); margin-bottom: 8px; }
.empty p { color: var(--text-2); max-width: 34ch; margin-bottom: 12px; }

/* Timer tab */
.timerface { position: relative; width: min(76vw, 300px); aspect-ratio: 1; margin: 4px auto 16px; }
.ring { width: 100%; height: 100%; display: block; }
.ring circle { fill: none; stroke-width: 10; }
.ring-track { stroke: var(--surface-2); }
.ring-value { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 200ms linear; }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px; }
.ring-center small { color: var(--text-2); font-size: 15px; font-weight: 600; }
.clock { font-size: clamp(52px, 16vw, 68px); line-height: 1; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.timer-adjust { display: flex; justify-content: center; gap: 8px; }
.timer-controls { display: flex; justify-content: center; align-items: center; gap: 20px; margin: 16px 0; }
.roundbtn { width: 60px; height: 60px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); transition: transform var(--t-fast) var(--ease); }
.roundbtn:active { transform: scale(.94); }
.roundbtn-primary { width: 84px; height: 84px; background: var(--accent); color: var(--on-accent); }
.roundbtn-spacer { width: 60px; }

/* Rest bar */
.restbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabs-h) + var(--safe-bottom) + 10px);
  width: min(calc(100% - 24px), 536px);
  display: flex; align-items: center; gap: 4px;
  padding: 6px 6px 6px 12px;
  overflow: hidden;
  background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: var(--r-l);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .55);
  z-index: 8;
  animation: rise var(--t-med) var(--ease) both;
}
body.no-tabs .restbar { bottom: calc(var(--safe-bottom) + 12px); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.restbar-main { flex: 1; min-width: 0; min-height: 52px; display: flex; align-items: center; gap: 12px; text-align: left; }
.restbar-main span small { display: block; color: var(--text-2); font-size: 12px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.restbar-main b { font-size: 24px; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; }
.restbar-btn { width: 48px; height: 48px; flex: none; display: grid; place-items: center; background: rgba(255, 255, 255, .07); border-radius: 12px; font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums; }
.restbar-skip { background: var(--accent); color: var(--on-accent); }
.restbar-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; }
.restbar-progress div { height: 100%; background: var(--accent); transform-origin: left; transition: transform 200ms linear; }

/* Tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
  display: flex; justify-content: center;
  padding: 6px 8px var(--safe-bottom);
  background: rgba(14, 15, 19, .86);
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--line);
}
body.no-tabs .tabs { display: none; }
.tabs a {
  flex: 1; max-width: 140px; min-height: 52px;
  display: grid; justify-items: center; align-content: center; gap: 2px;
  color: var(--text-2); font-size: 11px; font-weight: 600;
  transition: color var(--t-fast);
}
.tabs a[aria-current="page"] { color: var(--accent); }

/* Toasts */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-top) + 10px);
  width: min(calc(100% - 24px), 536px);
  display: grid; gap: 8px; z-index: 20; pointer-events: none;
}
.toast {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 10px 14px;
  background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: var(--r-m);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  font-size: 15px; font-weight: 550; pointer-events: auto;
  animation: drop var(--t-med) var(--ease) both;
}
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.toast button { color: var(--accent); font-weight: 650; min-height: 44px; padding: 0 4px; white-space: nowrap; }
.toast-accent { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.toast-error { background: #3a1613; border-color: var(--danger); }

/* Bottom sheet */
.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto;
  width: 100%; max-width: 560px; max-height: 88dvh;
  padding: 0; border: 0; color: var(--text);
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  overflow: auto; overscroll-behavior: contain;
}
.sheet[open] { animation: sheet-in var(--t-med) var(--ease) both; }
.sheet::backdrop { background: rgba(0, 0, 0, .6); animation: fade var(--t-med) var(--ease) both; }
@keyframes sheet-in { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-body { padding: 8px var(--gutter) calc(var(--safe-bottom) + 16px); display: grid; gap: 12px; }
.sheet-grip { width: 36px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 0 auto 8px; }
.sheet-title { font-size: 21px; }
.sheet-text { color: var(--text-2); line-height: 1.5; }
.sheet-actions { display: grid; gap: 8px; margin-top: 8px; }
.sheet-list { max-height: 50dvh; overflow: auto; }
.sheet .stepper-row, .sheet input[type="text"], .sheet input[type="date"] { background: var(--surface-2); }
.sheet .exrow { background: var(--surface-2); }

@media (min-width: 700px) {
  :root { --gutter: 24px; }
  main { padding-top: calc(var(--safe-top) + 24px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

@media (forced-colors: active) {
  .chart .bar, .chart .series-line { forced-color-adjust: none; }
}
