/* Layout: one calm column, like a notebook on the bedside table; the timer is the lamp.
   Dark-first ("blue hour" ink with lamplight amber); a cool paper light theme for daytime edits. */
:root {
  color-scheme: dark;
  --ink: #14162a;
  --dusk: #1c1f37;
  --dusk-2: #262a48;
  --line: #343959;
  --text: #ece9f5;
  --muted: #a3a6c3;
  --faint: #6f7394;
  --lamp: #f4b54f;
  --on-lamp: #2b1c05;
  --danger: #f0908a;
  --scrim: rgba(6, 7, 18, 0.62);
  --stone-shine: rgba(255, 255, 255, 0.24);
  --glass: rgba(20, 22, 42, 0.86);
  --shadow: 0 18px 40px rgba(3, 4, 14, 0.45);

  --hue-breathe: #66c7b6;
  --hue-journal: #f4b54f;
  --hue-puzzle: #92a9fa;
  --hue-color: #5fb98a;
  --hue-read: #c39ff7;
  --hue-close: #f7a884;
  --hue-body: #e59ad3;
  --hue-custom: #b9bed8;
  --hue-scene: #a9b4d8;
  --moon: #ecdcaa;
  --noise-1: #66c7b6;
  --noise-2: #b9dc84;
  --noise-3: #f2d27a;
  --noise-4: #f4a35a;
  --noise-5: #f2837f;

  --font-display: "Literata", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: 1.375rem;
  --step-3: 1.75rem;
  --step-4: 2.25rem;

  --radius: 18px;
  --radius-sm: 12px;
  --col: 35rem;
  --tabbar: 66px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --ink: #eceef5;
    --dusk: #ffffff;
    --dusk-2: #e2e5f0;
    --line: #d0d4e4;
    --text: #1c1f35;
    --muted: #53587a;
    --faint: #8a8ea9;
    --lamp: #8f5900;
    --on-lamp: #fff8ee;
    --danger: #b0352f;
    --scrim: rgba(28, 31, 53, 0.4);
    --stone-shine: rgba(255, 255, 255, 0.38);
    --glass: rgba(236, 238, 245, 0.9);
    --shadow: 0 14px 34px rgba(28, 31, 53, 0.14);
    --hue-breathe: #17786c;
    --hue-journal: #8f5900;
    --hue-puzzle: #3c5cc8;
    --hue-color: #1f7f55;
    --hue-read: #8a46a8;
    --hue-close: #b4522e;
    --hue-body: #a33d86;
    --hue-custom: #5c6386;
    --hue-scene: #56608a;
    --moon: #8a7224;
    --noise-1: #17786c;
    --noise-2: #447c1e;
    --noise-3: #8a6d00;
    --noise-4: #a8560c;
    --noise-5: #b3343f;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink: #eceef5;
  --dusk: #ffffff;
  --dusk-2: #e2e5f0;
  --line: #d0d4e4;
  --text: #1c1f35;
  --muted: #53587a;
  --faint: #8a8ea9;
  --lamp: #8f5900;
  --on-lamp: #fff8ee;
  --danger: #b0352f;
  --scrim: rgba(28, 31, 53, 0.4);
  --stone-shine: rgba(255, 255, 255, 0.38);
  --glass: rgba(236, 238, 245, 0.9);
  --shadow: 0 14px 34px rgba(28, 31, 53, 0.14);
  --hue-breathe: #17786c;
  --hue-journal: #8f5900;
  --hue-puzzle: #3c5cc8;
  --hue-color: #1f7f55;
  --hue-read: #8a46a8;
  --hue-close: #b4522e;
  --hue-body: #a33d86;
  --hue-custom: #5c6386;
  --hue-scene: #56608a;
  --moon: #8a7224;
  --noise-1: #17786c;
  --noise-2: #447c1e;
  --noise-3: #8a6d00;
  --noise-4: #a8560c;
  --noise-5: #b3343f;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.4; }
a { color: var(--lamp); }

:focus-visible { outline: 2px solid var(--lamp); outline-offset: 3px; border-radius: 6px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.icon { display: inline-flex; width: 1.4em; height: 1.4em; flex: none; }
.icon svg { width: 100%; height: 100%; }

/* ---- Type ---------------------------------------------------------------- */

.display {
  font-family: var(--font-display);
  font-weight: 500;
  font-optical-sizing: auto;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0;
}
.display.xl { font-size: clamp(2.25rem, 9vw, 3rem); font-weight: 450; }
.display.lg { font-size: clamp(1.9rem, 7vw, var(--step-4)); }
.display.md { font-size: var(--step-2); }

.eyebrow {
  margin: 0;
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.label { margin: 0; font-size: var(--step-0); font-weight: 700; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: var(--step--1); }

/* ---- Page shell ---------------------------------------------------------- */

.page {
  max-width: var(--col);
  margin: 0 auto;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  padding-block: 28px calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 32px);
}

.view { display: flex; flex-direction: column; gap: 22px; }
.masthead { display: flex; flex-direction: column; gap: 8px; }
.moonline { display: flex; align-items: center; gap: 8px; letter-spacing: 0.06em; }
.moon { width: 18px; height: 18px; flex: none; }
.block { display: flex; flex-direction: column; gap: 10px; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar-inner {
  max-width: var(--col);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: var(--tabbar);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; color: var(--faint);
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em;
}
.tab .icon { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--lamp); }
.tab:hover { color: var(--text); }
.tab[aria-current="page"]:hover { color: var(--lamp); }

/* ---- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; text-decoration: none; text-align: center;
  transition: transform 0.12s ease, background-color 0.2s ease;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn .icon { width: 20px; height: 20px; }
.btn.primary { background: var(--lamp); color: var(--on-lamp); }
.btn.quiet { background: var(--dusk); color: var(--text); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover:not(:disabled), .btn.quiet:hover:not(:disabled) { background: var(--dusk-2); }
.btn.danger { background: var(--danger); color: var(--ink); }
.btn.big { min-height: 58px; width: 100%; font-size: var(--step-1); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: var(--step--1); }
.btn.wide { width: 100%; }
.danger-text { color: var(--danger) !important; }

.link {
  background: none; border: 0; padding: 10px 4px;
  color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
  align-self: center;
}
.link:hover { color: var(--text); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: transparent; color: var(--text);
}
.icon-btn:hover:not(:disabled) { background: var(--dusk-2); }
.icon-btn .icon { width: 22px; height: 22px; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.row-actions.wrap { justify-content: flex-start; }

.back {
  display: inline-flex; align-items: center; gap: 4px; align-self: flex-start;
  border: 0; background: none; color: var(--muted); padding: 6px 8px 6px 0; font-weight: 700;
}

/* ---- Segmented control --------------------------------------------------- */

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  padding: 4px; border-radius: 16px;
  background: var(--dusk); border: 1px solid var(--line);
}
.seg {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; padding: 8px 6px;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted);
  font-weight: 700; line-height: 1.2;
}
.seg-sub { font-size: var(--step--1); font-weight: 400; font-variant-numeric: tabular-nums; }
.seg[aria-checked="true"], .seg[aria-selected="true"] {
  background: var(--dusk-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}
.seg[aria-checked="true"] .seg-sub, .seg[aria-selected="true"] .seg-sub { color: var(--lamp); }
.segmented.small .seg { min-height: 42px; font-size: var(--step--1); }

/* ---- Tonight ------------------------------------------------------------- */

.stack-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 18px 16px;
  background: var(--dusk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stack-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.stack-list { list-style: none; margin: 0; padding: 0; }
.stack-row {
  display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}
.stack-row:last-child { border-bottom: 0; }
.pebble-slot { display: flex; }

/* A stone-shaped bar: wider for longer steps. Open-ended steps fade out. */
.pebble {
  display: inline-flex; align-items: center;
  height: 34px; padding-left: 9px;
  background: var(--hue); color: var(--ink);
  border-radius: 48% 52% 46% 54% / 58% 54% 46% 42%;
}
.pebble .icon { width: 18px; height: 18px; }
.pebble.open {
  -webkit-mask-image: linear-gradient(90deg, #000 62%, transparent);
  mask-image: linear-gradient(90deg, #000 62%, transparent);
}
.row-text { display: flex; flex-direction: column; min-width: 0; }
.row-name { font-weight: 700; }
.row-sub { color: var(--muted); font-size: var(--step--1); }
.row-time { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.stack-total {
  margin: 8px 0 0; padding-top: 10px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: var(--step--1); font-variant-numeric: tabular-nums;
}

.cta { display: flex; flex-direction: column; gap: 10px; }

.week { display: flex; flex-direction: column; gap: 10px; }
.week-head { display: flex; justify-content: space-between; align-items: baseline; }
.week-days { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); }
.week-days li { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.day-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--dusk-2); }
.week-days .done .day-dot { background: var(--lamp); }
.week-days .today .day-dot { box-shadow: 0 0 0 2px var(--ink), 0 0 0 3.5px var(--muted); }
.week-days .future .day-dot { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.day-name { font-size: 0.75rem; color: var(--faint); font-weight: 700; }
.week-days .today .day-name { color: var(--text); }

/* ---- Routine editor ------------------------------------------------------ */

.edit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.edit-row { background: var(--dusk); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.edit-row.open { border-color: color-mix(in srgb, var(--hue) 55%, var(--line)); }
.edit-head {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 24px; align-items: center; gap: 12px;
  width: 100%; padding: 10px 12px; border: 0; background: none; text-align: left;
}
.pebble-icon {
  display: inline-grid; place-items: center; width: 40px; height: 34px; flex: none;
  background: var(--hue); color: var(--ink);
  border-radius: 48% 52% 46% 54% / 58% 54% 46% 42%;
}
.pebble-icon .icon { width: 20px; height: 20px; }
.chev { color: var(--muted); }
.edit-body { display: flex; flex-direction: column; gap: 14px; padding: 4px 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--step--1); font-weight: 700; color: var(--muted); }
input[type="text"], input[type="time"], textarea {
  width: 100%; padding: 12px 14px;
  background: var(--ink); border: 1px solid var(--line); border-radius: 10px;
}
textarea { resize: vertical; line-height: 1.45; }
input[type="time"] { width: auto; min-width: 7.5rem; font-variant-numeric: tabular-nums; }
input::placeholder, textarea::placeholder { color: var(--faint); }
.stepper {
  display: inline-flex; align-items: center; gap: 4px; align-self: flex-start;
  border: 1px solid var(--line); border-radius: 999px; padding: 2px;
}
.stepper output { min-width: 5.5rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-choice {
  display: inline-grid; place-items: center; width: 42px; height: 42px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--ink); color: var(--muted);
}
.icon-choice[aria-checked="true"] { background: var(--hue); color: var(--ink); border-color: transparent; }
.edit-body .setting { padding: 2px 0; border-bottom: 0; }
.why {
  display: flex; gap: 8px; margin: 0; padding: 10px 12px;
  background: var(--ink); border-radius: 10px;
  color: var(--muted); font-size: var(--step--1);
}
.why .icon { width: 18px; height: 18px; color: var(--hue); margin-top: 1px; }

.picker { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--dusk); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.picker-head { display: flex; justify-content: space-between; align-items: center; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 8px; }
.pick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink);
}
.pick:hover { border-color: var(--hue); }

/* ---- Progress ------------------------------------------------------------ */

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px; background: var(--dusk); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.stat.wide { grid-column: 1 / -1; }
.stat-label { font-size: var(--step--1); color: var(--muted); font-weight: 700; }
.stat-value { font-family: var(--font-display); font-size: var(--step-4); line-height: 1.1; font-variant-numeric: tabular-nums lining-nums; }
.stat-value .arrow { color: var(--faint); font-size: 0.7em; }
.stat-unit { font-size: var(--step--1); color: var(--muted); }

.week-cairns {
  list-style: none; margin: 0; padding: 14px 6px 10px;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); align-items: end; gap: 4px;
  min-height: 112px; background: var(--dusk); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.week-cairns li { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.week-cairns .cairn { width: 100%; max-width: 44px; height: auto; }
.cairn-empty { width: 18px; height: 5px; border-radius: 50%; background: var(--dusk-2); }
.week-cairns .today .day-name { color: var(--text); }

.cal-wrap { display: flex; flex-direction: column; gap: 6px; }
.cal-head, .cal { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; justify-items: center; }
.cal-head li { font-size: 0.75rem; color: var(--faint); font-weight: 700; }
.cal-cell { width: 100%; max-width: 30px; aspect-ratio: 1; border-radius: 50%; background: var(--dusk-2); }
.cal-cell.lvl-1 { background: color-mix(in srgb, var(--lamp) 45%, var(--dusk-2)); }
.cal-cell.lvl-2 { background: color-mix(in srgb, var(--lamp) 72%, var(--dusk-2)); }
.cal-cell.lvl-3 { background: var(--lamp); }
.cal-cell.today { box-shadow: 0 0 0 2px var(--ink), 0 0 0 3.5px var(--muted); }
.cal-cell.future { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }

.history { list-style: none; margin: 0; padding: 0; }
.history-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.history-main { display: flex; flex-direction: column; min-width: 0; }
.history-dots { display: flex; gap: 3px; }
.mini-dot { width: 7px; height: 7px; border-radius: 50%; box-shadow: inset 0 0 0 1.2px var(--hue); }
.mini-dot.done { background: var(--hue); }
.history-noise { display: flex; align-items: center; gap: 2px; min-width: 64px; color: var(--faint); }
.history-noise .arrow { font-size: 0.8em; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 28px 8px; }
.empty .muted { max-width: 30ch; }

/* ---- Settings ------------------------------------------------------------ */

.group {
  display: flex; flex-direction: column;
  padding: 16px 16px 6px; background: var(--dusk); border: 1px solid var(--line); border-radius: var(--radius);
}
.group > .label { margin-bottom: 4px; }
.group > .setting-hint { margin: 4px 0 12px; }
.group > .row-actions { margin-bottom: 12px; }
.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.setting:last-child { border-bottom: 0; }
.setting.column { flex-direction: column; align-items: stretch; gap: 8px; }
.setting-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; }
.setting-label { font-weight: 700; }
.setting-hint { color: var(--muted); font-size: var(--step--1); margin: 0; }
.link-row { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; color: var(--text); }
.link-row .icon { color: var(--muted); }
.about { padding: 12px 0; }
.volume { display: flex; align-items: center; gap: 10px; }
input[type="range"] { accent-color: var(--lamp); width: min(9rem, 36vw); }

.switch {
  appearance: none; -webkit-appearance: none; flex: none;
  position: relative; width: 50px; height: 30px; margin: 0;
  border-radius: 999px; background: var(--dusk-2); border: 1px solid var(--line);
  transition: background-color 0.2s ease;
}
.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s ease, background-color 0.2s ease;
}
.switch:checked { background: var(--lamp); border-color: var(--lamp); }
.switch:checked::before { transform: translateX(20px); background: var(--on-lamp); }

/* ---- Science ------------------------------------------------------------- */

.science-section {
  display: flex; flex-direction: column; gap: 10px;
  padding-top: 18px; border-top: 1px solid var(--line);
}
.science-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.science-section p { margin: 0; max-width: 65ch; }
.chip {
  display: inline-flex; padding: 3px 10px; border-radius: 999px;
  font-size: var(--step--1); font-weight: 700;
  color: var(--ink); background: var(--hue, var(--lamp));
}
.refs { margin: 0; padding-left: 1.1em; color: var(--muted); font-size: var(--step--1); display: flex; flex-direction: column; gap: 4px; }

/* ---- Session overlay ----------------------------------------------------- */

.overlay {
  position: fixed; inset: 0; z-index: 20;
  overflow-y: auto;
  background: var(--ink);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.session {
  max-width: var(--col); min-height: 100%;
  margin: 0 auto;
  display: flex; flex-direction: column;
}
.session-top {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding-block: 8px;
}
.session-count { font-size: var(--step--1); color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.dots { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; justify-content: center; }
.dots li { width: 8px; height: 8px; border-radius: 999px; background: var(--line); transition: width 0.3s ease; }
.dots li.done { background: var(--hue); }
.dots li.skipped { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.dots li.current { width: 24px; background: var(--hue); }

.session-body {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding-block: 8px 28px;
  text-align: center;
}
.session-body.centered { justify-content: center; }
.session-top, .session-body { transition: opacity 0.3s ease; }
.session.dimmed .session-top, .session.dimmed .session-body { opacity: 0.32; transition: opacity 2.5s ease; }
.session-body .tip { margin: 0; max-width: 34ch; color: var(--muted); text-wrap: pretty; }
.session-body .eyebrow { color: var(--hue, var(--muted)); }

.step-head { display: flex; align-items: center; gap: 12px; text-align: left; }
.step-icon { width: 44px; height: 44px; padding: 9px; border-radius: 48% 52% 46% 54% / 58% 54% 46% 42%; background: var(--hue); color: var(--ink); }
.step-icon.big { width: 64px; height: 64px; padding: 14px; }
.step-detail { margin: 0; color: var(--muted); font-size: var(--step--1); }
.step-head .display { font-size: var(--step-3); }

.dial-wrap { width: min(70vw, 290px, 38vh); aspect-ratio: 1; max-width: 100%; margin-top: 4px; }
.dial { display: block; width: 100%; height: 100%; }
.dial-face { fill: var(--dusk); stroke: var(--line); stroke-width: 1; }
.dial-ticks line { stroke: var(--faint); stroke-width: 1.4; stroke-linecap: round; }
.dial-ticks line.major { stroke: var(--muted); stroke-width: 2.2; }
.dial-wedge { fill: var(--hue); }
.count-up .dial-wedge { fill: color-mix(in srgb, var(--hue) 78%, var(--dusk)); }
.dial-hub { fill: var(--ink); stroke: var(--hue); stroke-width: 2.5; }
.paused .dial-wedge { opacity: 0.45; }
.has-nudge .dial-wrap { width: min(50vw, 200px, 26vh); }

.readout { display: flex; flex-direction: column; align-items: center; gap: 0; }
.digits {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(3.25rem, 15vw, 4.5rem); line-height: 1;
  font-variant-numeric: tabular-nums lining-nums; letter-spacing: -0.02em;
}
.digits.small { font-size: var(--step-4); color: var(--muted); }
.caption { margin: 6px 0 0; color: var(--muted); font-size: var(--step--1); min-height: 1.5em; }

.controls { display: flex; gap: 12px; justify-content: center; margin-top: 4px; }
.ctrl {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 84px; height: 72px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--dusk); color: var(--text);
  font-size: var(--step--1); font-weight: 700;
}
.ctrl:hover { background: var(--dusk-2); }
.ctrl .icon { width: 24px; height: 24px; }
.ctrl.primary { background: var(--lamp); color: var(--on-lamp); border-color: transparent; }
.up-next { margin: 4px 0 0; color: var(--faint); font-size: var(--step--1); }

.nudge {
  display: flex; flex-direction: column; gap: 10px;
  max-width: 30rem; padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--hue) 14%, var(--dusk));
  border: 1px solid color-mix(in srgb, var(--hue) 40%, var(--line));
}
.nudge p { margin: 0; text-wrap: pretty; }

.breather { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--step--1); }
.breather .link { padding: 4px; }
.transition .btn.big { max-width: 22rem; margin-top: 8px; }

.noise-scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; width: 100%; max-width: 30rem; margin-top: 10px; }
.noise {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 2px 12px; border-radius: 16px;
  background: var(--dusk); border: 1px solid var(--line);
  font-size: var(--step--1); font-weight: 700;
}
.noise .wave { color: var(--wave, var(--lamp)); width: 100%; max-width: 44px; height: auto; }
.noise:hover { border-color: var(--wave, var(--lamp)); background: var(--dusk-2); }

.summary .cairn { margin-bottom: 6px; max-width: 100%; height: auto; }
.noise-delta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.noise-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 10px;
  border-radius: 999px; background: var(--dusk); border: 1px solid var(--line); font-weight: 700;
}
.noise-chip .wave { color: var(--wave, var(--lamp)); }
.noise-delta .arrow { color: var(--faint); }
.note { margin: 0; max-width: 32ch; color: var(--muted); text-wrap: pretty; }
.summary .btn.big { max-width: 22rem; margin-top: 10px; }

/* Breathing pacer */
.pacer { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; }
.orb-wrap { position: relative; width: min(64vw, 260px, 34vh); aspect-ratio: 1; display: grid; place-items: center; }
.orb-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px dashed color-mix(in srgb, var(--hue) 50%, transparent);
}
.orb {
  width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 36% 32%, color-mix(in srgb, var(--hue) 70%, white 30%), var(--hue) 55%, color-mix(in srgb, var(--hue) 55%, var(--ink)) 100%);
  box-shadow: 0 0 70px color-mix(in srgb, var(--hue) 32%, transparent);
  transform: scale(0.52);
  will-change: transform, opacity;
}
.pacer-label { margin: 0; min-height: 2.6em; max-width: 22ch; font-family: var(--font-display); font-size: var(--step-2); line-height: 1.25; text-wrap: balance; }
.grounding { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 22rem; }
.ground {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 16px; border-radius: 14px; text-align: left;
  border: 1px solid var(--line); background: var(--dusk); font-weight: 700;
}
.ground .icon { width: 22px; height: 22px; color: var(--faint); }
.ground[aria-pressed="true"] { border-color: var(--hue); background: color-mix(in srgb, var(--hue) 16%, var(--dusk)); }
.ground[aria-pressed="true"] .icon { color: var(--hue); }
.calm .display { font-size: var(--step-2); max-width: 24ch; }
.calm-line { margin: 0; max-width: 30ch; color: var(--muted); min-height: 3em; text-wrap: balance; }

/* ---- Dialog and toast ---------------------------------------------------- */

dialog.sheet {
  width: min(26rem, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--line); border-radius: 22px;
  background: var(--dusk); color: var(--text);
  box-shadow: var(--shadow);
}
dialog.sheet::backdrop { background: var(--scrim); }
dialog.sheet h2 { margin: 0 0 8px; font-family: var(--font-display); font-weight: 500; font-size: var(--step-2); }
dialog.sheet p { margin: 0 0 18px; color: var(--muted); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions .btn { padding: 0 12px; }

.toast {
  position: fixed; left: 16px; right: 16px; top: calc(env(safe-area-inset-top, 0px) + 14px); z-index: 60;
  width: fit-content; max-width: 30rem; margin-inline: auto; text-align: center;
  padding: 10px 18px; border-radius: 999px;
  background: var(--text); color: var(--ink); font-weight: 700; font-size: var(--step--1);
  box-shadow: var(--shadow);
  transform: translateY(-150%); opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ---- Small screens and motion -------------------------------------------- */

@media (max-width: 380px) {
  .stack-row { grid-template-columns: 84px minmax(0, 1fr) auto; }
  .ctrl { width: 76px; }
}

@media (max-height: 640px) {
  .dial-wrap { width: min(60vw, 220px, 34vh); }
  .session-body { gap: 10px; }
}

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