/* Routine: one stylesheet for every page.
   Colour comes from places: each place name hashes to a hue (see place.js) and
   components read it from --h. Everything else stays neutral. */

@font-face {
  font-family: "Bricolage";
  src: url("/static/fonts/bricolage.woff2") format("woff2-variations"), url("/static/fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
}

/* Registered so a change of place sweeps smoothly through the hue wheel. */
@property --h { syntax: "<number>"; inherits: true; initial-value: 250; }
@property --left { syntax: "<number>"; inherits: true; initial-value: 1; }
@property --lift { syntax: "<number>"; inherits: true; initial-value: 0; }

:root {
  --paper: #eef0f3;
  --raised: #f8f9fb;
  --line: #d6dbe2;
  --ink: #17202c;
  --muted: #5b6474;
  --faint: #666e7c;
  --on-ink: #f4f6f9;

  /* place colour recipe (light) */
  --field-l: 0.885;
  --field-c: 0.075;
  --tide-l: 0.835;
  --tide-c: 0.095;
  --mark-l: 0.6;
  --mark-c: 0.15;
  --text-l: 0.36;
  --text-c: 0.08;

  --r-lg: 30px;
  --r-md: 16px;
  --r-sm: 11px;
  --tabs-h: 64px;
  --font: "Bricolage", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161c;
    --raised: #1a1f27;
    --line: #2a313c;
    --ink: #e9edf2;
    --muted: #9aa3b1;
    --faint: #838c9b;
    --on-ink: #12161c;
    --field-l: 0.33;
    --field-c: 0.06;
    --tide-l: 0.41;
    --tide-c: 0.085;
    --mark-l: 0.72;
    --mark-c: 0.13;
    --text-l: 0.9;
    --text-c: 0.04;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
a.plain { text-decoration: none; }
a.plain:hover { text-decoration: underline; text-underline-offset: 4px; }
[hidden] { display: none !important; }
.grow { flex: 1; min-width: 0; }

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

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

/* an element without a place stays neutral */
[data-neutral] { --field-c: 0; --tide-c: 0; --mark-c: 0.01; --text-c: 0; }

/* ------------------------------------------------------------ page frame */
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px);
}
.app.wide { max-width: 1080px; }

.top {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; margin-bottom: 10px;
}
.top h1 { font-size: 30px; font-weight: 750; font-stretch: 88%; letter-spacing: -0.01em; margin: 0; line-height: 1.1; }
.top .clock { font-size: 17px; font-weight: 600; color: var(--muted); }
.top .grow { flex: 1; }

.now-side { display: none; }
@media (min-width: 1100px) {
  .app.now-app { max-width: 1120px; }
  .now-grid { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 56px; align-items: start; }
  .now-side { display: block; position: sticky; top: 72px; max-height: calc(100dvh - 90px); overflow: auto; padding-right: 4px; }
  .side-title { font-size: 30px; font-weight: 750; font-stretch: 88%; margin: 0; line-height: 1.1; }
}

/* ------------------------------------------------------------ bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 12px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--paper) 97%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid var(--line);
}
.tabs a {
  flex: 0 1 140px;
  display: grid; justify-items: center; gap: 2px;
  padding: 6px 8px 4px; border-radius: 12px;
  text-decoration: none; color: var(--muted);
  font-size: 12.5px; font-weight: 600;
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current="page"] { color: var(--ink); }

@media (min-width: 900px) {
  /* On the laptop the tabs move to the top right, out of the way. */
  .tabs {
    top: 0; bottom: auto; left: auto; right: 16px; border: 0; background: none;
    backdrop-filter: none; -webkit-backdrop-filter: none; padding-top: calc(env(safe-area-inset-top) + 12px);
  }
  .tabs a { flex: none; grid-auto-flow: column; gap: 6px; font-size: 14px; padding: 8px 12px; }
  .tabs a svg { width: 18px; height: 18px; }
  .tabs a[aria-current="page"] { background: var(--raised); }
  .app { padding-top: calc(env(safe-area-inset-top) + 64px); padding-bottom: 48px; }
}

/* ------------------------------------------------------------ buttons */
.btn {
  appearance: none; border: 0; border-radius: 999px;
  min-height: 48px; padding: 0 22px;
  font-size: 17px; font-weight: 650;
  background: var(--raised); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
  transition: transform 0.12s var(--ease), background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn.ink { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 15px; }
.btn.quiet { background: none; box-shadow: none; color: var(--muted); padding: 0 8px; }
.btn.danger { color: oklch(0.55 0.17 25); }
@media (prefers-color-scheme: dark) { .btn.danger { color: oklch(0.72 0.15 25); } }
.btn:disabled { opacity: 0.45; }

.switch {
  appearance: none; border: 0; background: none; padding: 6px 4px;
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 15px; font-weight: 600;
}
.switch .knob {
  width: 40px; height: 24px; border-radius: 99px; background: var(--line); position: relative;
  transition: background 0.2s var(--ease);
}
.switch .knob::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--raised); box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: transform 0.2s var(--ease);
}
.switch[aria-checked="true"] { color: var(--ink); }
.switch[aria-checked="true"] .knob { background: var(--ink); }
#floor[aria-checked="true"] .knob { background: oklch(0.7 0.15 70); }
.switch[aria-checked="true"] .knob::after { transform: translateX(16px); }

/* ------------------------------------------------------------ the field (Now hero) */
.field {
  --h: 250;
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: var(--r-lg);
  background: oklch(var(--field-l) var(--field-c) var(--h));
  color: oklch(var(--text-l) var(--text-c) var(--h));
  padding: 26px 24px 22px;
  min-height: min(62dvh, 520px);
  display: flex; flex-direction: column;
  transition: --h 0.7s var(--ease), background 0.5s var(--ease), color 0.5s var(--ease);
}
.field .tide {
  position: absolute; inset: auto 0 0 0; z-index: -1;
  height: calc(var(--left) * 100%);
  background: oklch(var(--tide-l) var(--tide-c) var(--h));
  transition: height 1s linear;
}
.field .routine { font-size: 16px; font-weight: 600; opacity: 0.8; }
.field .place {
  font-size: clamp(48px, 15vw, 76px); font-weight: 800; font-stretch: 78%;
  line-height: 0.92; letter-spacing: -0.015em; margin: 14px 0 8px;
  overflow-wrap: break-word; hyphens: manual; text-wrap: balance;
}
.field .what { font-size: 24px; font-weight: 600; line-height: 1.2; margin: 0; overflow-wrap: anywhere; }
.field .cue { margin: 14px 0 0; font-size: 16px; max-width: 34ch; opacity: 0.9; }
.field .spacer { flex: 1; min-height: 18px; }
.field .up-next { margin: 0 0 12px; font-size: 16px; opacity: 0.85; display: grid; gap: 2px; }
.field .up-next .lbl { font-size: 13.5px; font-weight: 600; opacity: 0.85; }
.field .up-next .row { display: flex; align-items: baseline; gap: 7px; }
.field .up-next .row .dot { align-self: center; }
.field .up-next strong { font-weight: 650; }
.field .up-next .dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: oklch(calc(var(--mark-l) + var(--lift)) var(--mark-c) var(--h)); box-shadow: 0 0 0 1.5px oklch(1 0 0 / .6);
}
.field .time { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.field .left { font-size: 40px; font-weight: 750; font-stretch: 85%; line-height: 1; }
.field .left small { font-size: 20px; font-weight: 600; }
.field .until { font-size: 16px; font-weight: 500; opacity: 0.85; }
.field .actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.field .actions .btn { min-height: 58px; font-size: 19px; }
.field .actions .btn.ink { background: oklch(var(--text-l) var(--text-c) var(--h)); color: oklch(var(--field-l) var(--field-c) var(--h)); }
.field .actions .btn.extend { background: color-mix(in oklch, oklch(var(--field-l) var(--field-c) var(--h)) 55%, white); box-shadow: none; color: inherit; }
@media (prefers-color-scheme: dark) {
  .field .actions .btn.extend { background: color-mix(in oklch, oklch(var(--field-l) var(--field-c) var(--h)) 70%, black); }
}
.field-links { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.field-links .btn { color: inherit; opacity: 0.75; font-size: 15px; min-height: 40px; }
.notice.suggestion { margin: 14px 0 0; }

.field.entering .place, .field.entering .what { animation: rise 0.45s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* idle and done states share the field shape, without a place colour */
.field.idle {
  min-height: 0; padding-bottom: 24px;
  background: var(--raised); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line);
}
.field.idle .routine { color: var(--muted); opacity: 1; }
.field.idle .tide { display: none; }
.field.idle .place { font-size: clamp(40px, 12vw, 60px); }
.field .floor-prompt { align-self: flex-start; margin: 14px 0 -6px -8px; color: var(--muted); font-size: 15px; min-height: 40px; }
.field .idle-actions { margin-top: 18px; }
.field .tomorrow { margin: 12px 0 0; color: var(--muted); font-size: 16px; }
.field .idle-actions .floor-prompt { margin: 0; padding: 0 6px; }
.field.done .check { width: 64px; height: 64px; margin: 8px 0 4px; }
.field.done .check path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 0.6s 0.1s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ------------------------------------------------------------ path (what comes next) */
.block { margin-top: 28px; }
.block > h2 { font-size: 19px; font-weight: 700; margin: 0 0 10px 2px; }
.path { list-style: none; margin: 0; padding: 0; }
.path li {
  --h: 250;
  position: relative; display: grid; grid-template-columns: 52px 22px 1fr; align-items: start;
  padding: 8px 0 12px;
}
.path .at { color: var(--muted); font-size: 15px; font-weight: 600; padding-top: 1px; }
.path .dot {
  width: 14px; height: 14px; border-radius: 50%; margin: 4px 0 0 1px;
  background: oklch(calc(var(--mark-l) + var(--lift)) var(--mark-c) var(--h));
  box-shadow: 0 0 0 3px var(--paper);
  position: relative; z-index: 1;
}
.path li:not(:last-child)::before {
  content: ""; position: absolute; left: 59px; top: 22px; bottom: -10px; width: 2px;
  background: var(--line);
}
.path .jump { appearance: none; border: 0; background: none; padding: 0; text-align: left; border-radius: 8px; }
.path .jump:hover .what { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.path .what { font-weight: 600; line-height: 1.3; }
.path .where { color: var(--muted); font-size: 15px; }
.path li.end .dot { background: var(--paper); box-shadow: inset 0 0 0 2px var(--faint), 0 0 0 3px var(--paper); }
.path li.end .what { color: var(--muted); font-weight: 500; }

/* ------------------------------------------------------------ simple rows (later, start) */
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rows li { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); min-height: 60px; }
.rows .main { flex: 1; min-width: 0; }
.rows .name { font-weight: 650; }
.rows .sub { color: var(--muted); font-size: 15px; }
.linkish {
  display: inline-block; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 550;
  color: var(--muted); padding: 6px 0; margin: -2px 0 -6px; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px;
}
.linkish:hover { color: var(--ink); text-decoration-color: currentColor; }
.rows .at { min-width: 52px; color: var(--muted); font-weight: 600; font-size: 15px; }
.swatches { display: inline-flex; gap: 3px; vertical-align: middle; margin-right: 6px; }
.swatches i { width: 8px; height: 8px; border-radius: 2px; background: oklch(calc(var(--mark-l) + var(--lift)) var(--mark-c) var(--h)); }

/* ------------------------------------------------------------ notices */
.notice {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 12px 14px 12px 16px; border-radius: var(--r-md); margin-bottom: 14px;
  background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); font-size: 15.5px;
}
.notice p { margin: 0; }
.notice .btn { white-space: nowrap; flex: none; }
.notice .ed-inline { flex: none; gap: 4px; }
@media (max-width: 420px) { .notice:has(.ed-inline) { flex-direction: column; align-items: flex-start; } }
.floor-band {
  margin: -2px 0 14px; padding: 10px 14px; border-radius: var(--r-md); font-size: 15px;
  background: oklch(var(--field-l) var(--field-c) 70); color: oklch(var(--text-l) var(--text-c) 70);
}
.floor-band.welcome { background: oklch(var(--field-l) var(--field-c) 145); color: oklch(var(--text-l) var(--text-c) 145); }
.floor-band.paused {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: oklch(var(--field-l) var(--field-c) 250); color: oklch(var(--text-l) var(--text-c) 250);
}
.floor-band.paused p { margin: 0; }
.floor-band.paused .btn { flex: none; }
@media (max-width: 420px) { .floor-band.paused { flex-direction: column; align-items: flex-start; } }
.pause-offer { margin: 18px 2px 0; }
.notice.pause-pick { margin-top: 18px; flex-direction: column; align-items: flex-start; }
.notice.pause-pick .ed-inline { flex-wrap: wrap; flex: initial; gap: 6px; }

.toast {
  position: fixed; left: 50%; z-index: 30; transform: translate(-50%, 20px);
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px);
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: var(--on-ink);
  padding: 10px 10px 10px 18px; border-radius: 999px; font-size: 15.5px; font-weight: 550;
  width: max-content; max-width: calc(100% - 32px); opacity: 0; pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast span { flex: 1; min-width: 0; }
.toast button {
  appearance: none; border: 0; border-radius: 999px; padding: 7px 14px;
  background: color-mix(in srgb, var(--on-ink) 18%, transparent); color: var(--on-ink); font-weight: 700;
}
.toast:not(:has(button)) { padding-right: 18px; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ------------------------------------------------------------ day view */
.days {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  background: var(--raised); border-radius: 14px; padding: 4px; box-shadow: inset 0 0 0 1px var(--line);
  margin-bottom: 22px;
}
.days button {
  appearance: none; border: 0; background: none; border-radius: 10px;
  padding: 8px 0 7px; font-size: 15px; font-weight: 650; color: var(--muted);
  display: grid; justify-items: center; gap: 1px; line-height: 1.1;
}
.days button small { font-size: 11.5px; font-weight: 600; color: var(--faint); }
.days button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.days button[aria-pressed="true"] small { color: inherit; opacity: 0.75; }

/* Week at a glance */
.top .view-switch { margin-left: auto; }
.top .view-switch span { padding: 6px 12px; }
.week { margin: 4px 0 10px; }
.wk-axis { position: relative; height: 18px; margin-left: 44px; font-size: 12px; font-weight: 600; color: var(--faint); }
.wk-axis span { position: absolute; transform: translateX(-50%); }
.wk-axis span:first-child { transform: none; }
.wk-row {
  appearance: none; display: grid; grid-template-columns: 44px 1fr; align-items: center; width: 100%;
  border: 0; background: none; padding: 5px 0; text-align: left; border-radius: 8px;
}
.wk-row:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.wk-day { display: grid; line-height: 1.1; font-size: 15px; font-weight: 650; color: var(--muted); }
.wk-day small { font-size: 11px; font-weight: 600; color: var(--faint); min-height: 1em; }
.wk-row.today .wk-day { color: var(--ink); }
.wk-track {
  position: relative; display: block; height: 30px; border-radius: 8px; overflow: hidden;
  background: var(--raised); box-shadow: inset 0 0 0 1px var(--line);
}
.wk-row:hover .wk-track { box-shadow: inset 0 0 0 1px var(--muted); }
.wk-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.wk-seg, .wk-label {
  --pad: 5px; --lane: 0; --lanes: 1;
  position: absolute; top: calc(var(--pad) + (100% - 2 * var(--pad)) * var(--lane) / var(--lanes));
  height: calc((100% - 2 * var(--pad)) / var(--lanes) - (var(--lanes) - 1) * 1px);
}
.wk-seg {
  --h: 250; min-width: 3px; border-radius: 3px;
  background: oklch(calc(var(--mark-l) + var(--lift)) var(--mark-c) var(--h));
}
.wk-seg.approx {
  background-image: repeating-linear-gradient(135deg, transparent 0 4px, oklch(1 0 0 / .45) 4px 6px);
}
.wk-seg.skipped { opacity: .3; }
.wk-now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); }
.wk-label { display: none; }
.wk-note { color: var(--muted); font-size: 15px; margin: 6px 0 24px; }
@media (min-width: 900px) {
  .wk-track { height: 48px; }
  .wk-seg, .wk-label { --pad: 6px; }
  /* Names only where they fit whole: each label measures itself. */
  .wk-label { display: flex; align-items: center; container-type: inline-size; pointer-events: none; }
  .wk-label span {
    margin-left: 4px; padding: 3px 6px; border-radius: 4px; font-size: 12.5px; font-weight: 700; line-height: 1;
    color: var(--ink); background: color-mix(in oklch, var(--raised) 82%, transparent);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
  }
  @container (max-width: 60px) { .wk-label span { display: none; } }
}

.routine-plan { margin-bottom: 26px; }
.routine-plan.skipped .ribbon, .routine-plan.skipped .plan-steps, .routine-plan.skipped .rp-name { opacity: .45; }
.routine-plan.skipped .ribbon { filter: saturate(.4); }
.routine-plan .skip-note { margin: -2px 0 10px; color: var(--muted); font-size: 15px; }
.routine-plan .total, .routine-plan .when { white-space: nowrap; }
.routine-plan header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-bottom: 8px; }
.routine-plan .rp-name { margin: 0; font-size: 21px; font-weight: 750; font-stretch: 90%; }
.routine-plan .when { color: var(--muted); font-size: 15px; font-weight: 600; }
.routine-plan .total { margin-left: auto; color: var(--faint); font-size: 14px; font-weight: 600; }
.ribbon { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; margin-bottom: 10px; }
.ribbon i { --h: 250; background: oklch(calc(var(--mark-l) + var(--lift)) var(--mark-c) var(--h)); min-width: 4px; }
.plan-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.plan-steps li { --h: 250; display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: baseline; padding: 5px 0; }
.plan-steps .at { color: var(--muted); font-size: 15px; font-weight: 600; }
.untimed .plan-steps li { grid-template-columns: 1fr auto; }
.plan-steps li:has(> .ps) { display: block; padding: 0; }
.plan-steps .ps {
  appearance: none; border: 0; background: none; font: inherit; color: inherit; text-align: left; width: 100%;
  display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: baseline;
  padding: 5px 6px; margin: 0 -6px; width: calc(100% + 12px); border-radius: 8px; cursor: pointer;
}
.untimed .plan-steps .ps { grid-template-columns: 1fr auto; }
.plan-steps .ps:hover { background: var(--raised); }
.plan-steps .ps:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 0; }
.plan-steps .what::before {
  content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 9px;
  background: oklch(calc(var(--mark-l) + var(--lift)) var(--mark-c) var(--h)); vertical-align: 1px;
}
.plan-steps .where { color: var(--muted); font-size: 15px; }
.plan-steps .min { color: var(--faint); font-size: 14px; font-weight: 600; }
.now-badge {
  text-decoration: none; font-size: 13.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--ink); color: var(--on-ink);
}
.plan-steps li.current .what { font-weight: 750; }
.plan-steps li.current .what::before { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px oklch(calc(var(--mark-l) + var(--lift)) var(--mark-c) var(--h)); }
.group-title { font-size: 15px; font-weight: 650; color: var(--muted); margin: 30px 0 12px 2px; }

/* ------------------------------------------------------------ forms */
input, select, textarea {
  background: var(--raised); border: 0; box-shadow: inset 0 0 0 1px var(--line);
  border-radius: var(--r-sm); padding: 11px 13px; width: 100%; min-width: 0; font-size: 17px;
}
input:focus, select:focus, textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ink); }
input::placeholder { color: var(--faint); }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 15.5px; color: var(--muted); }
label.check input { width: 20px; height: 20px; accent-color: var(--ink); box-shadow: none; padding: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { position: relative; }
.chips input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chips span {
  display: inline-block; min-width: 40px; text-align: center;
  padding: 7px 10px; border-radius: 999px; font-size: 14.5px; font-weight: 650;
  color: var(--muted); box-shadow: inset 0 0 0 1px var(--line);
}
.chips input:checked + span { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.chips input:focus-visible + span { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.chips.small span { min-width: 36px; padding: 7px 7px; font-size: 13.5px; }

.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; max-width: 100%; background: var(--raised); border-radius: 12px; padding: 3px; box-shadow: inset 0 0 0 1px var(--line); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; white-space: nowrap; padding: 7px 13px; border-radius: 9px; font-size: 15px; font-weight: 650; color: var(--muted); }
.seg input:checked + span { background: var(--ink); color: var(--on-ink); }
.seg input:focus-visible + span { outline: 2.5px solid var(--ink); outline-offset: 2px; }
@media (max-width: 360px) { .seg span { padding: 7px 8px; font-size: 14px; } }

/* ------------------------------------------------------------ routines (editor) */
.ed-grid { display: grid; grid-template-columns: 280px minmax(0, 720px); gap: 40px; align-items: start; justify-content: center; }
.ed-side, .ed-main { min-width: 0; }
.side-extra { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); }
@media (max-width: 899px) { .ed-grid { grid-template-columns: minmax(0, 1fr); } }

.rlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rlist button, .rlist a.plain {
  appearance: none; border: 0; width: 100%; text-align: left; background: none;
  padding: 12px 14px; border-radius: var(--r-md); display: grid; gap: 4px;
}
@media (max-width: 899px) { .rlist button, .rlist a.plain { padding: 12px 4px; } .rlist button[aria-current="true"] { padding: 12px 14px; } }
.rlist button:hover, .rlist a.plain:hover { background: var(--raised); }
.rlist button[aria-current="true"] { background: var(--raised); box-shadow: inset 0 0 0 1.5px var(--ink); }
.rlist .name { font-weight: 700; font-size: 18px; }
.rlist .sub { color: var(--muted); font-size: 14.5px; }
.rlist .off .name { color: var(--faint); }
.mobile-back { display: none; }
@media (max-width: 899px) {
  /* phone: list first, editor replaces it when a routine is open */
  .ed-grid.editing .ed-side { display: none; }
  .ed-grid:not(.editing) .ed-main { display: none; }
  .mobile-back { display: inline-flex; }
}

.ed-main .name-input {
  font-size: 30px; font-weight: 750; font-stretch: 88%; background: none; box-shadow: none;
  padding: 4px 2px; border-radius: 8px; letter-spacing: -0.01em;
}
.ed-main .name-input:focus { box-shadow: inset 0 -2px 0 var(--ink); border-radius: 0; }
.ed-row { display: grid; gap: 10px; margin: 18px 0; grid-template-columns: minmax(0, 1fr); }
.ed-row > .label { font-size: 15px; font-weight: 650; color: var(--muted); }
.ed-inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ed-inline input[type="time"] { width: auto; }
.ed-title { display: flex; align-items: center; gap: 12px; }
.ed-title .switch { flex: none; }
.hint { color: var(--muted); font-size: 14.5px; margin: 0; }
.clash {
  margin: 0 0 10px; padding: 10px 14px; border-radius: 12px; font-size: 15px; line-height: 1.4;
  background: color-mix(in oklch, oklch(0.75 0.13 70) 18%, var(--raised)); box-shadow: inset 0 0 0 1px color-mix(in oklch, oklch(0.7 0.13 70) 40%, transparent);
}
.saved { color: var(--faint); font-size: 14.5px; font-weight: 600; min-height: 1em; }
.saved.err { color: oklch(0.55 0.17 25); }

.steps { display: grid; gap: 8px; }
.stepcard { --h: 250; border-radius: var(--r-md); background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); }
.stepcard[data-open] { box-shadow: inset 0 0 0 1.5px var(--ink); }
.stepcard .head { display: flex; align-items: stretch; }
.stepcard .head .sum { flex: 1; min-width: 0; }
.stepcard .grip {
  appearance: none; border: 0; background: none; width: 40px; margin-left: -8px; flex: none;
  display: grid; place-items: center; cursor: grab; touch-action: none; border-radius: var(--r-md); color: var(--faint);
}
.stepcard .grip span {
  width: 12px; height: 14px;
  background: radial-gradient(circle, currentColor 1.6px, transparent 1.9px) 0 0 / 6px 5px;
}
.stepcard .grip:hover, .stepcard .grip:focus-visible { color: var(--ink); }
.steps.sorting .stepcard { transition: transform .16s var(--ease); }
.steps.sorting .stepcard.dragging {
  transition: none; position: relative; z-index: 2; cursor: grabbing;
  box-shadow: inset 0 0 0 1.5px var(--ink), 0 10px 24px -8px oklch(0 0 0 / .3);
}
.stepcard .sum {
  appearance: none; border: 0; background: none; width: 100%; text-align: left;
  display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; align-items: center;
  padding: 13px 14px; border-radius: var(--r-md);
}
.stepcard .sum .dot { width: 14px; height: 14px; border-radius: 50%; background: oklch(calc(var(--mark-l) + var(--lift)) var(--mark-c) var(--h)); }
.stepcard .sum .t { font-weight: 650; overflow-wrap: anywhere; }
.stepcard .sum .p { color: var(--muted); font-size: 15px; }
.stepcard .sum .m { color: var(--muted); font-size: 15px; font-weight: 600; text-align: right; white-space: nowrap; }
.stepcard .sum .tags { display: block; color: var(--faint); font-size: 13.5px; font-weight: 600; }
.stepcard .body { padding: 0 14px 14px; display: grid; gap: 12px; }
.stepcard .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stepcard .dur { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.stepcard .dur input { width: 76px; }
.stepcard .dur .chip { min-height: 32px; padding: 0 11px; font-size: 14px; }
.stepcard .tools { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.stepcard .tools .grow { flex: 1; }
.add-step { justify-self: start; }

.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.template {
  appearance: none; border: 0; text-align: left; padding: 16px; border-radius: var(--r-md);
  background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: 8px;
}
.template:hover { box-shadow: inset 0 0 0 1.5px var(--ink); }
.template .name { font-weight: 750; font-size: 18px; }
.template .sub { color: var(--muted); font-size: 14.5px; }

.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.setup { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.sub-title { font-size: 20px; font-weight: 750; font-stretch: 92%; margin: 18px 0 0; }
.steps-list { margin: 0; padding-left: 24px; display: grid; gap: 8px; max-width: 62ch; }
.steps-list li::marker { font-weight: 700; color: var(--muted); }
.setup ol { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.copyline { display: flex; gap: 8px; align-items: center; }
.copyline code {
  flex: 1; min-width: 0; overflow-wrap: anywhere;
  font: 500 14px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--r-sm); padding: 10px 12px;
}

/* ------------------------------------------------------------ login */
.login { max-width: 380px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16vh) 20px 40px; }
.login .mark { width: 64px; height: 64px; border-radius: 16px; display: block; margin-bottom: 22px; }
.login h1 { font-size: 44px; font-weight: 800; font-stretch: 80%; margin: 0 0 6px; line-height: 1; }
.login p { color: var(--muted); margin: 0 0 26px; }
.login form { display: grid; gap: 12px; }
.login .error { color: oklch(0.55 0.17 25); font-size: 15px; min-height: 22px; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .field.done .check path { stroke-dashoffset: 0; }
}

/* Build my default day */
.lede { font-size: 17px; line-height: 1.45; margin: 0 0 18px; max-width: 60ch; }
.bq-form { display: grid; gap: 10px; margin-bottom: 8px; }
.bq-form fieldset {
  border: 0; margin: 0; padding: 14px 16px; border-radius: var(--r-md); background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: 10px; min-width: 0;
}
.bq-form legend { float: left; width: 100%; padding: 0; font-weight: 700; font-size: 16px; }
.bq-form legend + * { clear: both; }
.bq-form .hint { margin: 0; }
.bq-row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; }
.bq-time { display: grid; gap: 4px; font-size: 14.5px; color: var(--muted); }
.bq-time input { font: inherit; font-size: 17px; color: var(--ink); }
.bq-preview { margin: 4px 0 8px; }
.bq-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.bq-list li { display: grid; grid-template-columns: 56px 1fr; align-items: baseline; font-size: 15.5px; }
.bq-list .meta { color: var(--muted); margin-left: 8px; }
.template.featured { box-shadow: inset 0 0 0 2px var(--ink); }

/* Places in Setup */
.places-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.places-list li { --h: 250; display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; }
.places-list .dot { width: 12px; height: 12px; border-radius: 50%; background: oklch(calc(var(--mark-l) + var(--lift)) var(--mark-c) var(--h)); }
.places-list input { min-width: 0; }
.places-list .n { color: var(--muted); font-size: 14px; white-space: nowrap; }

/* On bad days */
.guide { max-width: 640px; }
.guide .rules { margin: 0 0 22px; padding-left: 1.3em; display: grid; gap: 12px; font-size: 17px; line-height: 1.45; }
.guide .rules li::marker { font-weight: 700; color: var(--muted); }
.guide p, .guide .help { font-size: 16px; line-height: 1.5; }
.guide .help { padding-left: 1.1em; display: grid; gap: 8px; }
.guide a { color: inherit; }

/* ------------------------------------------------------------ ideas */
.ideas-lead { margin: -4px 2px 16px; }
.as-text { appearance: none; border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.idea-on {
  --h: 145;
  padding: 18px 20px 20px; border-radius: var(--r-lg, 22px);
  background: oklch(var(--field-l) var(--field-c) var(--h)); color: oklch(var(--text-l) var(--text-c) var(--h));
}
.idea-on.empty { background: var(--raised); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.idea-on .label { margin: 0 0 4px; font-size: 14px; font-weight: 650; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.04em; }
.idea-on .title { display: block; margin: 0 0 6px; font-size: clamp(26px, 7vw, 34px); font-weight: 750; font-stretch: 88%; line-height: 1.1; }
.idea-on.empty .title { color: var(--muted); }
.idea-on .note { margin: 0 0 12px; white-space: pre-wrap; opacity: 0.85; }
.idea-on .ed-inline { margin-top: 14px; }
.idea-on .btn.ink { background: oklch(var(--text-l) var(--text-c) var(--h)); color: oklch(var(--field-l) var(--field-c) var(--h)); }
.idea-add { display: flex; gap: 8px; margin: 18px 0 0; }
.idea-add input { flex: 1; min-width: 0; }
.rows.ideas li { gap: 10px; }
.rows.ideas .main { text-align: left; }
.rows.ideas .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows.ideas li.swap .sub { white-space: normal; }
.rows.ideas li.editing { display: block; padding: 12px 0; }
.idea-editor { display: grid; gap: 10px; }
.idea-editor .grow { flex: 1; }
.idea-on .idea-editor input, .idea-on .idea-editor textarea { background: color-mix(in oklch, white 70%, transparent); }
@media (prefers-color-scheme: dark) { .idea-on .idea-editor input, .idea-on .idea-editor textarea { background: color-mix(in oklch, black 45%, transparent); } }
a.notice.idea-line { text-decoration: none; color: inherit; margin-top: 18px; }
.idea-line .label { color: var(--muted); font-weight: 600; }
.idea-line .chev { color: var(--faint); font-size: 22px; line-height: 1; }
@media (max-width: 420px) { .rows.ideas li.swap { flex-direction: column; align-items: flex-start; } }
