:root {
  --bg: #f4f3f1;
  --surface: #ffffff;
  --sunken: #eceae7;
  --border: #e4e1dd;
  --border-strong: #d3cfc9;

  --text: #14110f;
  --dim: #7a726c;

  --accent: #af2127;
  --accent-soft: #f7eaea;

  --chart-1: #af2127;
  --chart-2: #c96a63;
  --chart-3: #e2a9a2;
  --chart-4: #f0d3ce;

  --ink-1: #14110f;
  --ink-2: #4b4541;
  --ink-3: #8c837d;
  --ink-4: #c3bcb5;

  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(20 16 14 / 0.04);
  --shadow-lift: 0 1px 2px rgb(20 16 14 / 0.06), 0 12px 28px rgb(20 16 14 / 0.10);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --surface: #131212;
    --sunken: #1c1a1a;
    --border: #262323;
    --border-strong: #363232;

    --text: #f2efec;
    --dim: #8a827c;

    --accent: #c9353c;
    --accent-soft: #22100f;

    --chart-1: #c9353c;
    --chart-2: #9c4a4a;
    --chart-3: #6b3634;
    --chart-4: #3a2422;

    --ink-1: #f2efec;
    --ink-2: #b3aca6;
    --ink-3: #7d756f;
    --ink-4: #4a4441;

    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-lift: 0 1px 2px rgb(0 0 0 / 0.5), 0 14px 32px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #131212;
  --sunken: #1c1a1a;
  --border: #262323;
  --border-strong: #363232;

  --text: #f2efec;
  --dim: #8a827c;

  --accent: #c9353c;
  --accent-soft: #22100f;

  --chart-1: #c9353c;
  --chart-2: #9c4a4a;
  --chart-3: #6b3634;
  --chart-4: #3a2422;

  --ink-1: #f2efec;
  --ink-2: #b3aca6;
  --ink-3: #7d756f;
  --ink-4: #4a4441;

  --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-lift: 0 1px 2px rgb(0 0 0 / 0.5), 0 14px 32px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* #overview and #week set display: grid, and an id selector outranks the user
   agent's [hidden] { display: none } — so toggling `hidden` left both views
   painted, stacked one below the other. This has to win. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 1.4rem 1.6rem 4rem;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
}

h1 {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin: 0;
  padding-right: 0.35rem;
  border-left: 2px solid var(--accent);
  padding-left: 0.6rem;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--sunken);
  border-radius: 999px;
}
.tab {
  min-height: 32px;
  padding: 0 0.95rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.tab:hover { color: var(--text); }
.tab-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* The header toolbar. #scope and #btn-add sit directly in .header-tools so they
   can stay in the header on phones; every other action lives in .actions, which
   on desktop is display:contents — its buttons become items of this same row —
   and `order` puts them back in the original sequence:
   scope · Plan · Ask · Quick · Chat · Sync · Add · ⌘K · Reload · Theme · Settings · Help.
   At phone widths .actions becomes the "More" bottom sheet (see the end of the
   file and ui/mobilenav.js). */
.header-tools {
  display: flex; gap: 0.45rem; margin-left: auto;
  flex-wrap: wrap; justify-content: flex-end;
}
.actions { display: contents; }
.header-tools > #scope { order: 0; }
.actions > button { order: 1; }
.header-tools > #btn-add { order: 2; }
.actions > #btn-palette, .actions > #btn-reload, .actions > #btn-theme,
.actions > #btn-settings, .actions > #btn-help { order: 3; }
.more-toggle, .more-veil { display: none; }

button {
  min-height: 36px;
  padding: 0 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.1s var(--ease);
}
button:hover { background: var(--sunken); border-color: var(--dim); }
button:active { transform: scale(0.97); }
button:focus-visible { outline: 2px solid var(--ink-2); outline-offset: 2px; }
#btn-add { background: var(--accent); border-color: var(--accent); color: #fff; }
#btn-add:hover { filter: brightness(1.1); }
#btn-reload, #btn-theme, #btn-settings { min-width: 36px; padding: 0 0.6rem; font-size: 0.95rem; }

#scope {
  min-height: 36px;
  width: auto;
  padding: 0 1.9rem 0 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
}

#status { margin: 0 0 0.9rem; color: var(--dim); font-size: 0.8125rem; min-height: 1.25em; }
#status.red { color: var(--accent); font-weight: 400; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.7rem; margin-bottom: 0.85rem; }
.tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 0.95rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ink-4); }
.tile-accent::before { background: var(--ink-2); }
.tile-risk::before { background: var(--accent); }
.tile-label { font-size: 0.625rem; font-weight: 400; letter-spacing: 0.01em; color: var(--dim); }
.tile-value { font-size: 1.7rem; font-weight: 500; letter-spacing: -0.03em; line-height: 1.15; margin-top: 0.1rem; }
.tile-risk .tile-value { color: var(--accent); }
.tile-note { font-size: 0.6875rem; color: var(--dim); margin-top: 0.05rem; }

.risk-banner {
  display: flex; align-items: baseline; gap: 0.6rem;
  border: 1px solid var(--accent); border-left-width: 3px; border-radius: var(--radius-sm);
  background: var(--accent-soft); padding: 0.65rem 0.85rem; margin-bottom: 0.9rem;
  font-size: 0.8125rem;
}
.risk-word { font-weight: 400; color: var(--accent); letter-spacing: 0.02em; flex: 0 0 auto; }
.risk-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.risk-item { display: flex; flex-wrap: wrap; column-gap: 0.45rem; align-items: baseline; }
.risk-item-title { font-weight: 500; }
.risk-item-when { font-size: 0.75rem; color: var(--dim); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: var(--shadow);
  animation: rise 0.4s var(--ease) both;
  animation-delay: var(--stagger, 0ms);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.9rem; }
.panel-title { font-size: 0.6875rem; font-weight: 400; letter-spacing: 0.01em; color: var(--dim); }
.panel-note { font-size: 0.6875rem; color: var(--dim); }

/* minmax(0, …), not 1fr: a plain 1fr track grows to its widest panel's
   min-content — the year heatmap is ~830px — and pushed the page sideways
   below ~880px. With a zero floor the heatmap scrolls inside its own box. */
#overview { display: grid; gap: 0.85rem; grid-template-columns: minmax(0, 1fr); }
#overview > * { min-width: 0; }
@media (min-width: 900px) { .ov-split { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 0.85rem; } }

.donut-wrap { display: flex; align-items: center; gap: 1.1rem; }
.donut { flex: 0 0 auto; }
.donut circle { transition: stroke-dasharray 0.6s var(--ease); }
.donut-centre { font-size: 1.4rem; font-weight: 500; letter-spacing: -0.03em; }
.donut-centre-sub { font-size: 0.5625rem; letter-spacing: 0.01em; }
.legend { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.legend-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.legend-label { color: var(--dim); }
.legend-value { margin-left: auto; font-weight: 400; }

.daybars { display: flex; flex-direction: column; gap: 0.6rem; }
.daybar { display: grid; grid-template-columns: 42px minmax(0, 1fr) 62px; align-items: center; gap: 0.6rem; }
.daybar-name { font-size: 0.6875rem; font-weight: 400; letter-spacing: 0.04em; color: var(--dim); }
.daybar-today .daybar-name { color: var(--ink-1); }
.daybar-track { position: relative; height: 22px; background: var(--sunken); border-radius: 6px; overflow: hidden; display: flex; }
.daybar-track > div { transition: width 0.55s var(--ease); }
.seg-attended { background: var(--chart-1); }
.seg-agent { background: var(--chart-2); }
.seg-adhoc { background: var(--chart-3); }
.daybar-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: 0.35; }
.daybar-val { font-size: 0.75rem; color: var(--dim); text-align: right; }
.daybar-val.over { color: var(--accent); font-weight: 400; }

.acc { display: flex; flex-direction: column; gap: 0.65rem; }
.acc-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 0.7rem; align-items: center; }
.acc-title { font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-pair { display: flex; flex-direction: column; gap: 3px; }
.acc-bar { height: 7px; border-radius: 999px; }
.acc-est { background: var(--chart-4); }
.acc-act { background: var(--chart-1); }
.acc-delta { font-size: 0.6875rem; text-align: right; color: var(--dim); }
.acc-delta.exact { color: var(--ink-2); }
.acc-delta.over { color: var(--accent); font-weight: 400; }

.hint { font-size: 0.75rem; color: var(--dim); line-height: 1.6; }
.hint strong { font-weight: 500; color: var(--text); }

#week { display: grid; gap: 0.8rem; grid-template-columns: 1fr; }
#week { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.day {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.95rem 1rem 1rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: box-shadow 0.22s var(--ease), border-color 0.22s var(--ease), transform 0.22s var(--ease);
  animation: rise 0.4s var(--ease) both; animation-delay: var(--stagger, 0ms);
}
.day:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.day-today { border-color: var(--ink-4); box-shadow: var(--shadow), 0 0 0 1px var(--ink-4); }

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

.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.day-head h2 { font-size: 0.75rem; font-weight: 400; letter-spacing: 0.01em; margin: 0; }
.day-date { font-size: 0.6875rem; color: var(--dim); }
.day-today .day-date { color: var(--ink-1); font-weight: 500; }

.headline { margin: 0.65rem 0 0.5rem; }
.big { display: flex; align-items: baseline; gap: 0.25rem; }
.big-num { font-size: 1.8rem; font-weight: 480; letter-spacing: -0.035em; line-height: 1; }
.big-unit { font-size: 0.75rem; color: var(--dim); }
.big.tight .big-num { color: var(--ink-2); }
.big.over .big-num { color: var(--accent); }

.sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.28rem; margin-top: 0.28rem; font-size: 0.6875rem; color: var(--dim); }
.sub .dot { color: var(--border-strong); }
.sub .free { color: var(--ink-2); font-weight: 500; }
.sub .warn { color: var(--ink-2); font-weight: 400; }

.bar-wrap { margin-bottom: 0.75rem; }
.bar { position: relative; display: flex; height: 11px; border-radius: 999px; overflow: hidden; background: var(--sunken); }
.bar > div { transition: width 0.55s var(--ease); }
.bar-planned { background: var(--chart-1); }
.bar-agent { background: var(--chart-2); }
.bar-adhoc { background: var(--chart-3); }
.marker-reserve { position: absolute; top: -2px; bottom: -2px; width: 2px; border-radius: 1px; background: var(--text); opacity: 0.4; }

.windows { margin-bottom: 0.8rem; }
.windows-label { font-size: 0.5625rem; font-weight: 400; letter-spacing: 0.01em; color: var(--dim); margin-bottom: 0.28rem; }
.window-list { display: flex; gap: 4px; }
.window {
  flex: 1 1 0; min-width: 0; height: 21px; border-radius: 6px;
  background: color-mix(in srgb, var(--chart-2) 20%, transparent); border: 1px solid color-mix(in srgb, var(--chart-2) 45%, transparent); color: var(--chart-1);
  font-size: 0.5625rem; font-weight: 500; display: flex; align-items: center; justify-content: center; overflow: hidden;
}

.empty { font-size: 0.75rem; color: var(--dim); padding: 0.45rem 0 0.15rem; font-style: italic; }

.chips { display: flex; flex-direction: column; gap: 0.35rem; }
.chip {
  display: flex; align-items: center; gap: 0;
  border: 1px solid var(--border); border-left: 2px solid var(--ink-4);
  border-radius: var(--radius-sm); background: var(--surface);
  overflow: hidden;
  transition: opacity 0.3s var(--ease), border-color 0.3s var(--ease), background 0.3s var(--ease),
    box-shadow 0.35s var(--ease), transform 0.35s var(--ease);
}

.chip-risk { border-left-color: var(--accent); }

.chip-title { font-size: 0.8125rem; font-weight: 500; line-height: 1.35; }
.chip-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.28rem; font-size: 0.625rem; color: var(--dim); }

.chip-side {
  flex: 0 0 auto; align-self: stretch;
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 1px;
  padding: 0.4rem 0.7rem 0.4rem 0.55rem; min-width: 54px;
  border-left: 1px dashed var(--border);
}
.chip-side-h { font-size: 0.75rem; font-weight: 500; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.chip-side-agent { font-size: 0.5625rem; color: var(--ink-2); white-space: nowrap; }

.tag { padding: 0.05rem 0.32rem; border-radius: 999px; font-size: 0.5rem; font-weight: 400; letter-spacing: 0.01em; }
.tag-gap { background: var(--sunken); color: var(--ink-2); }
.tag-reserve { background: var(--sunken); color: var(--dim); }
.tag-promised { background: var(--sunken); color: var(--ink-2); }
.tag-risk { background: var(--accent); color: #fff; }

dialog {
  width: min(30rem, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); overflow-y: auto;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text);
  padding: 1.3rem; box-shadow: var(--shadow-lift);
}
dialog::backdrop { background: rgb(10 8 8 / 0.55); backdrop-filter: blur(3px); }
/* The transform lives on the inner body, never on <dialog> itself. A
   transformed ancestor becomes the containing block for position:fixed
   descendants — with it on the dialog, every popup was positioned inside the
   dialog's coordinate space and clipped by its overflow, landing hundreds of
   pixels from its trigger. */
dialog[open] { animation: fade 0.2s var(--ease); }
dialog[open] #dialog-body { animation: pop 0.24s var(--ease); }
dialog[open]::backdrop { animation: fade 0.24s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.975); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

dialog h2 { font-size: 1rem; font-weight: 500; margin: 0 0 0.95rem; letter-spacing: -0.015em; }
dialog h3 { font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.01em; color: var(--dim); margin: 1.15rem 0 0.45rem; }
dialog hr { border: 0; border-top: 1px solid var(--border); margin: 1.15rem 0 0; }
dialog .numbers { font-size: 0.75rem; color: var(--dim); line-height: 1.6; }
dialog .numbers.red { color: var(--accent); font-weight: 400; }

label { display: block; margin: 0 0 0.28rem; font-size: 0.625rem; font-weight: 400; letter-spacing: 0.01em; color: var(--dim); }

input, select {
  width: 100%; min-height: 38px; padding: 0 0.65rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.875rem;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
input:hover, select:hover { border-color: var(--dim); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

.row { display: flex; gap: 0.6rem; margin-bottom: 0.8rem; }
.row > * { flex: 1; min-width: 0; }
.field { margin-bottom: 0.8rem; }
.row > .field { margin-bottom: 0; }

.dialog-actions { display: flex; gap: 0.5rem; margin-top: 1.3rem; }
.dialog-actions button { flex: 1; min-height: 40px; }
.dialog-actions button:first-child { background: var(--accent); border-color: var(--accent); color: #fff; }
.dialog-actions button:first-child:hover { filter: brightness(1.1); }
.danger { border-color: var(--accent); color: var(--accent); }
.danger:hover { background: var(--accent-soft); }

.amber { color: var(--ink-2); font-weight: 400; }
.red { color: var(--accent); font-weight: 400; }

@media (max-width: 640px) {
  body { padding: 1rem 1rem 2.5rem; }
  header { gap: 0.6rem; }
  h1 { font-size: 0.9375rem; }
  /* (tabs and header actions: see the phone section at the end of the file) */
  .summary { gap: 0.45rem; }
  .tile { padding: 0.6rem 0.65rem; }
  .tile-value { font-size: 1.3rem; }
  .tile-note { display: none; }
  .donut-wrap { flex-direction: column; align-items: flex-start; gap: 0.8rem; }
  .legend { width: 100%; }
  button, input, select, #scope { min-height: 44px; }
  .dialog-actions button { min-height: 46px; }
  dialog { padding: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, .day, .panel, dialog[open], dialog[open]::backdrop { animation: none !important; transition: none !important; }
}

.grow { animation: grow-x 0.55s var(--ease) both; transform-origin: left center; }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.donut.sweep { animation: sweep-in 0.6s var(--ease) both; transform-origin: center; }
@keyframes sweep-in { from { opacity: 0; transform: rotate(-24deg) scale(0.9); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .grow, .donut.sweep { animation: none !important; transform: none !important; }
}

.big-unit { background: none; border: 0; padding: 0 0 0 1px; min-height: 0; font: inherit; font-size: 0.75rem; color: var(--dim); cursor: pointer; border-bottom: 1px dashed transparent; }
.big-unit:hover { color: var(--text); border-bottom-color: var(--border-strong); }
.big-unit-set { color: var(--ink-2); border-bottom-color: currentColor; }
.daybar-val-custom { position: relative; }
.daybar-val-custom::after { content: "·"; color: var(--accent); margin-left: 2px; font-weight: 500; }

/* Dock-style magnification on the view tabs — neighbours ease aside as one
   grows, the effect from the reference site. Pure transform, so it costs
   nothing and degrades to a plain tab bar if animation is off. */
.tabs { position: relative; }
.tab { transform-origin: center bottom; will-change: transform; }
.tabs:hover .tab { transform: scale(0.97); opacity: 0.65; }
.tabs .tab:hover { transform: scale(1.09); opacity: 1; }
.tabs .tab:hover + .tab, .tab:has(+ .tab:hover) { transform: scale(1.03); opacity: 0.85; }
.tab { transition: transform 0.28s var(--ease), opacity 0.28s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease); }

/* The active pill slides rather than blinking between tabs. */
.tab-active { position: relative; }
.tab-active::before {
  content: ""; position: absolute; inset: 0; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow); z-index: -1;
  animation: pill 0.3s var(--ease) both;
}
@keyframes pill { from { transform: scaleX(0.7); opacity: 0; } to { transform: none; opacity: 1; } }

/* Numbers and labels cross-fade when a value changes rather than snapping. */
.tile-value, .big-num, .daybar-val { transition: color 0.25s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  .tabs:hover .tab, .tabs .tab:hover, .tabs .tab:hover + .tab, .tab:has(+ .tab:hover) { transform: none; opacity: 1; }
  .tab-active::before { animation: none; }
}


/* Hover on the task list: the hovered card slides out and lifts, neighbours
   recede. Transform, shadow and opacity ONLY — the previous version animated
   padding, which forces a layout pass every frame and read as choppy. Nothing
   here may change an element's size. */
.chips:hover .chip { opacity: 0.7; }
.chips .chip:hover { opacity: 1; box-shadow: var(--shadow-lift); border-left-color: var(--accent); transform: translateX(3px); z-index: 2; }
.chips .chip:focus-within { opacity: 1; }

.chip-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem;
  padding: 0.55rem 0.6rem;
  border: 0; border-radius: 0; background: none; color: var(--text);
  font: inherit; text-align: left; min-height: 44px; justify-content: center; cursor: pointer;
}
.chip-main:focus-visible { outline: 2px solid var(--ink-2); outline-offset: -2px; }

/* Things-style circle checkbox: quiet until you mean it, filled once done. */
.chip-done {
  flex: 0 0 20px; width: 20px; height: 20px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  margin: 0 0.1rem 0 0.6rem; padding: 0; min-height: 0;
  border: 1.5px solid var(--border-strong); border-radius: 50%;
  background: transparent; color: transparent; cursor: pointer;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease), color 0.3s var(--ease);
}
.chip-done:hover { border-color: var(--chart-1); color: var(--chart-1); background: transparent; }
.chip-done:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-tick { font-size: 0.5625rem; line-height: 1; transition: transform 0.3s var(--ease); }
.chip-done:hover .chip-tick { transform: scale(1.2); }

@media (prefers-reduced-motion: reduce) {
  .chips:hover .chip, .chips .chip:hover { opacity: 1; transform: none; }
}

/* Custom select / date controls. The native element stays in the DOM as the
   source of truth and is only visually replaced — every form still reads its
   .value, so nothing downstream had to change. */
.xs-native { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; margin: 0; padding: 0; border: 0; }

.xs-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  width: 100%; min-height: 38px; padding: 0 0.6rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.8125rem;
  font-weight: 400; text-align: left; cursor: pointer;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.xs-trigger:hover { background: var(--surface); border-color: var(--dim); }
.xs-trigger[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.xs-trigger:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.xs-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xs-placeholder { color: var(--dim); }
.xs-caret { flex: 0 0 auto; color: var(--dim); font-size: 0.75rem; transition: transform 0.2s var(--ease); }
.xs-trigger[aria-expanded="true"] .xs-caret { transform: rotate(180deg); }

.xs-popup {
  position: fixed; z-index: 50; max-height: 300px; overflow-y: auto;
  padding: 4px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-lift);
  animation: xs-in 0.16s var(--ease) both;
}
@keyframes xs-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }

.xs-option {
  display: block; width: 100%; min-height: 34px; padding: 0 0.55rem;
  border: 0; border-radius: 6px; background: none; color: var(--text);
  font: inherit; font-size: 0.8125rem; font-weight: 400; text-align: left; cursor: pointer;
  transition: background 0.12s var(--ease);
}
.xs-option:hover { background: var(--sunken); }
.xs-option-on { background: var(--accent-soft); color: var(--accent); }
.xs-option:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.xs-cal { padding: 0.6rem; }
.xs-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.xs-cal-title { font-size: 0.8125rem; font-weight: 500; }
.xs-cal-nav {
  min-height: 26px; min-width: 26px; padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--dim); font-size: 0.95rem; cursor: pointer;
}
.xs-cal-nav:hover { background: var(--sunken); color: var(--text); }
.xs-cal-grid { display: grid; grid-template-columns: repeat(7, 30px); gap: 2px; }
.xs-cal-dow { font-size: 0.5625rem; color: var(--dim); text-align: center; padding-bottom: 3px; }
.xs-cal-pad { height: 30px; }
.xs-cal-day {
  height: 30px; border: 0; border-radius: 6px; background: none; color: var(--text);
  font: inherit; font-size: 0.75rem; cursor: pointer; transition: background 0.12s var(--ease), transform 0.12s var(--ease);
}
.xs-cal-day:hover { background: var(--sunken); transform: scale(1.1); }
.xs-cal-today { box-shadow: inset 0 0 0 1px var(--border-strong); }
.xs-cal-on { background: var(--accent); color: #fff; }
.xs-cal-on:hover { background: var(--accent); }
.xs-cal-foot { display: flex; gap: 4px; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.xs-cal-action {
  flex: 1; min-height: 30px; padding: 0; border: 0; border-radius: 6px;
  background: var(--sunken); color: var(--text); font: inherit; font-size: 0.75rem; cursor: pointer;
}
.xs-cal-action:hover { background: var(--border); }

@media (max-width: 640px) { .xs-trigger { min-height: 44px; } .xs-cal-grid { grid-template-columns: repeat(7, 36px); } .xs-cal-day, .xs-cal-pad { height: 36px; } }
@media (prefers-reduced-motion: reduce) { .xs-popup { animation: none; } .xs-cal-day:hover { transform: none; } }

.done-label { display: flex; align-items: center; gap: 0.5rem; margin: 0.7rem 0 0.35rem; font-size: 0.625rem; color: var(--dim); }
.done-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.chips-done .chip { opacity: 0.5; border-left-color: var(--border); }
.chips-done .chip:hover { opacity: 0.85; }
.chips-done .chip-title { text-decoration: line-through; text-decoration-color: var(--dim); }
.chip-done-on { background: var(--chart-1); border-color: var(--chart-1); color: #fff; }
.chip-done-on:hover { background: var(--dim); border-color: var(--dim); color: #fff; }
.chip-main:disabled { cursor: default; }

/* Day-detail rows share the circle tick, centred in a fixed gutter. */
.drow-tick { align-self: center; margin: 0 0.35rem 0 0.75rem; }
.hint-text { display: block; margin-top: 0.22rem; font-size: 0.625rem; line-height: 1.45; color: var(--dim); }

@media (min-width: 900px) { .ov-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.85rem; } }
.ov-pair { display: grid; gap: 0.85rem; }

.wins-control { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.75rem; }
.wins-control label { margin: 0; white-space: nowrap; font-size: 0.6875rem; }
.wins-control input[type="range"] { flex: 1; min-height: 0; height: 4px; padding: 0; border: 0; background: var(--sunken); border-radius: 999px; appearance: none; cursor: pointer; }
.wins-control input[type="range"]::-webkit-slider-thumb { appearance: none; width: 15px; height: 15px; border-radius: 50%; background: var(--chart-1); border: 2px solid var(--surface); box-shadow: var(--shadow); cursor: grab; }
.wins-control input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.15); }
.wins-readout { font-size: 0.75rem; font-weight: 500; min-width: 38px; text-align: right; }

.wins-list { display: flex; flex-direction: column; gap: 4px; }
.win-row { display: flex; }
.win-bar {
  height: 26px; min-width: 34px; border-radius: 6px; border: 0;
  display: flex; align-items: center; padding: 0 0.45rem;
  font-size: 0.625rem; font-weight: 500; color: #fff; cursor: pointer;
  transition: background 0.25s var(--ease), opacity 0.25s var(--ease), transform 0.16s var(--ease);
}
.win-bar:hover { transform: translateX(2px); }
.win-fits { background: var(--chart-1); opacity: 1; }
.win-short { background: var(--sunken); color: var(--dim); opacity: 0.75; }

.wins-verdict { margin-top: 0.7rem; font-size: 0.6875rem; line-height: 1.5; color: var(--dim); }
.wins-verdict.wins-none { color: var(--accent); }

.prom { display: flex; flex-direction: column; gap: 0.55rem; }
.prom-row { display: grid; grid-template-columns: minmax(0, 1fr) 54px auto; gap: 0.6rem; align-items: center; }
.prom-title { font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prom-track { position: relative; height: 4px; background: var(--sunken); border-radius: 999px; }
.prom-mark { position: absolute; left: 50%; top: -3px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--chart-2); }
.prom-late .prom-mark { background: var(--accent); }
.prom-when { font-size: 0.625rem; color: var(--dim); white-space: nowrap; }
.prom-late .prom-when { color: var(--accent); }

@media (prefers-reduced-motion: reduce) { .win-bar:hover { transform: none; } }

.chip[draggable="true"] { cursor: grab; }
.chip[draggable="true"]:active { cursor: grabbing; }
.chip-dragging { opacity: 0.35 !important; border-style: dashed; }
.day-drop { border-color: var(--accent); box-shadow: var(--shadow), 0 0 0 2px var(--accent); }
.day-drop .chips { outline: 1px dashed var(--accent); outline-offset: 4px; border-radius: var(--radius-sm); }

.delta {
  margin: 0.15rem 0 0.6rem; padding: 0.5rem 0.65rem; border-radius: var(--radius-sm);
  font-size: 0.75rem; background: var(--sunken); color: var(--dim);
  border-left: 2px solid var(--border-strong);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.delta:empty { display: none; }
.delta-exact { border-left-color: var(--chart-2); color: var(--text); }
.delta-over { border-left-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.delta-under { border-left-color: var(--chart-2); color: var(--text); background: var(--sunken); }

/* Free windows breathe gently so they read as live time rather than a static
   block, and each says what it is good for instead of hiding it in a tooltip. */
.window {
  position: relative; overflow: hidden;
  animation: breathe 3.6s var(--ease) infinite both;
  animation-delay: var(--wstagger, 0ms);
  transition: flex-grow 0.4s var(--ease), background 0.25s var(--ease), color 0.25s var(--ease);
}
@keyframes breathe {
  0%, 100% { background: color-mix(in srgb, var(--chart-2) 18%, transparent); }
  50%      { background: color-mix(in srgb, var(--chart-2) 34%, transparent); }
}
.window-min { transition: transform 0.28s var(--ease), opacity 0.2s var(--ease); }
.window-say {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 0 4px; font-size: 0.5rem; letter-spacing: 0.01em; color: var(--chart-1);
  opacity: 0; transform: translateY(6px); white-space: nowrap; overflow: hidden;
  transition: opacity 0.24s var(--ease), transform 0.24s var(--ease);
}
.windows:hover .window { animation-play-state: paused; }
.window:hover { background: color-mix(in srgb, var(--chart-2) 45%, transparent); }
.window:hover .window-min { transform: translateY(-9px); opacity: 0; }
.window:hover .window-say { opacity: 1; transform: none; }

/* Day cards reveal their spare capacity on hover rather than stating it. */
.day .headline { position: relative; }
.day:hover .sub .free { color: var(--chart-1); }

/* Donut slices lift out slightly as you read the legend. */
.legend-row:hover { color: var(--text); }
.legend-row:hover .legend-dot { transform: scale(1.4); }
.legend-dot { transition: transform 0.22s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  .window { animation: none; background: color-mix(in srgb, var(--chart-2) 22%, transparent); }
  .window-say, .window-min { transition: none; }
}

/* ---- "Can I take this?" ------------------------------------------------- */

#btn-ask { border-color: var(--accent); color: var(--accent); background: transparent; }
#btn-ask:hover { background: var(--accent-soft); border-color: var(--accent); }

.ask-verdict {
  margin: 0.3rem 0 0.2rem; padding: 0.8rem 0.95rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); border-left-width: 3px; background: var(--sunken);
  animation: rise 0.3s var(--ease) both;
}
.ask-yes { border-left-color: var(--chart-1); }
.ask-no { border-left-color: var(--accent); background: var(--accent-soft); }
.ask-head { font-size: 0.875rem; font-weight: 500; letter-spacing: -0.01em; }
.ask-no .ask-head { color: var(--accent); }
.ask-sub { font-size: 0.75rem; color: var(--dim); line-height: 1.55; margin-top: 0.3rem; }
.ask-warn {
  margin-top: 0.55rem; font-size: 0.75rem; line-height: 1.5;
  color: var(--accent); border-top: 1px dashed var(--border-strong); padding-top: 0.55rem;
}
.ask-wins { display: flex; flex-direction: column; gap: 4px; margin-top: 0.65rem; }
.ask-load { margin-top: 0.65rem; }
.ask-load-track { position: relative; display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface); }
.ask-load-new {
  background: repeating-linear-gradient(-45deg,
    color-mix(in srgb, var(--accent) 55%, transparent) 0 5px,
    color-mix(in srgb, var(--accent) 25%, transparent) 5px 10px);
}
.ask-book {
  margin-top: 0.75rem; width: 100%;
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.ask-book:hover { background: var(--accent); filter: brightness(1.1); }

/* ---- donut: slices ease outward under the pointer ----------------------- */

.donut-seg {
  transition: stroke-dasharray 0.6s var(--ease), transform 0.32s var(--ease);
  cursor: default;
}
.donut-pop { transform: translate(var(--dx, 0), var(--dy, 0)); }
.donut-centre, .donut-centre-sub { pointer-events: none; }
.legend-row { cursor: default; }

/* ---- day detail (Tasks view, single-day scope) --------------------------- */

.detail {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.15rem 1.3rem 1.3rem; box-shadow: var(--shadow);
  animation: rise 0.4s var(--ease) both;
}
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.detail-day { font-size: 1.35rem; font-weight: 500; letter-spacing: -0.025em; margin: 0; }
.detail-date { font-size: 0.75rem; color: var(--dim); margin-top: 0.1rem; }
.detail-nav { display: flex; gap: 0.45rem; }
.ghost {
  min-height: 32px; padding: 0 0.75rem; font-size: 0.75rem; font-weight: 500;
  background: transparent; border-color: var(--border);
}
.ghost:hover { background: var(--sunken); border-color: var(--border-strong); }

.detail-hero { margin-top: 1rem; }
.detail-big { display: flex; align-items: baseline; gap: 0.3rem; }
.detail-big-num { font-size: 2.4rem; font-weight: 480; letter-spacing: -0.04em; line-height: 1; }
.detail-big-unit { font-size: 0.875rem; color: var(--dim); }
.detail-big.tight .detail-big-num { color: var(--ink-2); }
.detail-big.over .detail-big-num { color: var(--accent); }

.detail-bar {
  position: relative; display: flex; height: 18px; border-radius: 999px;
  overflow: hidden; background: var(--sunken); margin-top: 0.7rem;
}
.detail-bar > div { transition: width 0.55s var(--ease); }

.detail-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6rem; margin-top: 0.85rem;
}
.dstat { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.55rem 0.7rem; }
.dstat-label { font-size: 0.5625rem; letter-spacing: 0.02em; color: var(--dim); }
.dstat-value { font-size: 1.15rem; font-weight: 500; letter-spacing: -0.02em; margin-top: 0.1rem; }
.dstat-note { font-size: 0.625rem; color: var(--dim); margin-top: 0.05rem; }
.dstat-warn .dstat-value { color: var(--accent); }
.dstat-warn { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }

.detail-windows { margin-top: 1rem; }
.detail-windows .window { min-height: 30px; }

.detail-label {
  display: flex; align-items: center; gap: 0.5rem; margin: 1.15rem 0 0.5rem;
  font-size: 0.625rem; letter-spacing: 0.02em; color: var(--dim);
}
.detail-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.drows { display: flex; flex-direction: column; gap: 0.4rem; }
.drow {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius-sm);
  background: var(--surface); overflow: hidden;
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.drow:hover { box-shadow: var(--shadow-lift); border-left-color: var(--accent); }
.drow-risk { border-left-color: var(--accent); }
/* (circle tick shared with week chips — placement handled near .chip-done-on) */
.drow-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 0.3rem;
  text-align: left; border: 0; border-radius: 0; background: transparent;
  padding: 0.65rem 0.85rem; min-height: 0; font-weight: 400; cursor: pointer;
}
.drow-main:hover { background: transparent; }
.drow-main-static { cursor: default; }
.drow-title { font-size: 0.875rem; font-weight: 500; line-height: 1.35; }
.drow-title-done { text-decoration: line-through; text-decoration-color: var(--dim); color: var(--dim); }
.drow-meta { font-size: 0.6875rem; color: var(--dim); line-height: 1.5; }
.drow-bar { display: flex; height: 6px; border-radius: 999px; overflow: hidden; background: var(--sunken); max-width: 420px; margin-top: 0.15rem; }
.drow-seg-att { background: var(--chart-1); }
.drow-seg-agent { background: var(--chart-2); }
.drow-num {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 0.15rem;
  padding: 0.65rem 0.9rem; border-left: 1px dashed var(--border); min-width: 118px;
}
.drow-num-big { font-size: 1rem; font-weight: 500; letter-spacing: -0.02em; }
.drow-num-sub { font-size: 0.5625rem; color: var(--dim); }
.drow-done { opacity: 0.65; }
.drow-done:hover { opacity: 1; border-left-color: var(--border); }

@media (max-width: 640px) {
  .drow-num { min-width: 0; padding: 0.55rem 0.6rem; }
  .detail { padding: 0.9rem 0.95rem 1rem; }
}

/* ---- completion burst ----------------------------------------------------- */

.burst { position: fixed; z-index: 2147483647; pointer-events: none; width: 0; height: 0; }
.burst i { position: absolute; left: -3px; top: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.burst .burst-alt { width: 5px; height: 5px; background: var(--chart-2); border-radius: 2px; }

/* ---- view transitions ----------------------------------------------------- */

::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.22s; }

@media (prefers-reduced-motion: reduce) {
  .donut-seg { transition: none; }
  .drow, .detail { animation: none; transition: none; }
}

/* ---- vendored-library era: springs and canvases --------------------------- */

/* When Motion drives the press feel, the CSS press effect steps aside. */
.has-springs button:active { transform: none; }
.has-springs .xs-popup { animation: none; }

.chart-holder { position: relative; width: 100%; }
.chart-mini-legend {
  display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 0.6rem;
  font-size: 0.6875rem; color: var(--dim);
}
.chart-mini-legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }

/* ---- command palette ------------------------------------------------------- */

.palette-veil {
  position: fixed; inset: 0; z-index: 1000;
  background: rgb(10 8 8 / 0.35);
  backdrop-filter: blur(2px);
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 14vh;
}
.palette {
  width: min(620px, calc(100vw - 2rem));
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}
.palette-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text);
  font: inherit; font-size: 0.95rem; padding: 0.95rem 1.1rem;
  outline: none;
}
.palette-input::placeholder { color: var(--dim); }
.palette-list { max-height: 46vh; overflow-y: auto; padding: 0.35rem; }
.palette-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.8rem;
  width: 100%; text-align: left; border: 0; border-radius: 8px;
  background: transparent; padding: 0.6rem 0.75rem; min-height: 0;
  font-weight: 400; cursor: pointer;
}
.palette-item:hover { background: var(--sunken); }
.palette-item-on { background: var(--accent-soft); }
.palette-item-on .palette-label { color: var(--accent); font-weight: 500; }
.palette-item:disabled { opacity: 0.55; cursor: default; }
.palette-label { font-size: 0.8125rem; }
.palette-hint { font-size: 0.6875rem; color: var(--dim); white-space: nowrap; }
.palette-none { padding: 0.8rem 0.9rem; font-size: 0.75rem; color: var(--dim); }
#btn-palette { min-width: 40px; padding: 0 0.55rem; font-size: 0.75rem; color: var(--dim); }
#btn-palette:hover { color: var(--text); }

/* ---- pinned promise -------------------------------------------------------- */

.pin {
  display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap;
  border: 1px solid var(--border); border-left: 3px solid var(--chart-2);
  border-radius: var(--radius-sm); background: var(--surface);
  padding: 0.55rem 0.85rem; margin-bottom: 0.85rem;
  font-size: 0.8125rem; box-shadow: var(--shadow);
}
.pin-word { font-size: 0.625rem; letter-spacing: 0.02em; color: var(--dim); }
.pin-title { font-weight: 500; }
.pin-when { color: var(--ink-2); font-size: 0.75rem; }
.pin-slack { color: var(--dim); font-size: 0.6875rem; margin-left: auto; }
.pin-hot { border-left-color: var(--accent); }
.pin-hot .pin-when { color: var(--accent); font-weight: 500; }

/* ---- day story ------------------------------------------------------------- */

.day-story {
  font-size: 0.6875rem; color: var(--dim); line-height: 1.5;
  margin: 0.1rem 0 0.55rem;
}
.detail-story { max-width: 60ch; margin-top: 0.35rem; }

/* ---- the now-line ---------------------------------------------------------- */

.now-line {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: var(--accent); border-radius: 1px; z-index: 2;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
  animation: now-pulse 2.6s ease-in-out infinite;
}
.now-line::after {
  content: ""; position: absolute; top: -3px; left: -2px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
@keyframes now-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) { .now-line { animation: none; } }

/* ---- rituals: segmented choices and decision rows -------------------------- */

.ritual-rows { display: flex; flex-direction: column; gap: 0.45rem; margin: 0.3rem 0 0.5rem; }
.ritual-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.7rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem; background: var(--surface);
}
.ritual-row-stack { flex-direction: column; align-items: stretch; }
.ritual-row-stack > .ritual-row { border: 0; padding: 0; }
.ritual-info { min-width: 0; }
.ritual-title { font-size: 0.8125rem; font-weight: 500; line-height: 1.35; }
.ritual-meta { font-size: 0.6875rem; color: var(--dim); margin-top: 0.1rem; }
.ritual-actuals { display: flex; gap: 0.5rem; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px dashed var(--border); }
.ritual-actuals .field { flex: 1; margin-bottom: 0; }

.seg { display: flex; gap: 2px; padding: 2px; background: var(--sunken); border-radius: 999px; flex: 0 0 auto; }
.seg-btn {
  min-height: 28px; padding: 0 0.65rem; border: 0; border-radius: 999px;
  background: transparent; color: var(--dim); font: inherit; font-size: 0.6875rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
.seg-btn:hover { color: var(--text); background: transparent; border: 0; }
.seg-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg-on:hover { background: var(--surface); }
.seg-btn:disabled { opacity: 0.4; cursor: default; }

/* ---- nudges and inline actions --------------------------------------------- */

.stranded {
  display: block; width: 100%; text-align: left;
  border: 1px dashed var(--border-strong); border-left: 3px solid var(--ink-2); border-radius: var(--radius-sm);
  background: var(--sunken); color: var(--ink-2);
  padding: 0.55rem 0.85rem; margin-bottom: 0.85rem;
  font-size: 0.8125rem; font-weight: 500; min-height: 0;
}
.stranded:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.rebalance-link {
  align-self: flex-start; margin: 0.15rem 0 0.6rem; padding: 0.25rem 0.6rem; min-height: 0;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); border-radius: 999px;
  background: transparent; color: var(--accent); font-size: 0.6875rem; font-weight: 500;
}
.rebalance-link:hover { background: var(--accent-soft); border-color: var(--accent); }

.panel-act {
  min-height: 0; padding: 0.2rem 0.55rem; border: 1px solid var(--border);
  border-radius: 999px; background: transparent; color: var(--dim);
  font-size: 0.625rem; font-weight: 500;
}
.panel-act:hover { color: var(--text); border-color: var(--border-strong); background: var(--sunken); }

.suggest-row { display: flex; align-items: center; gap: 0.6rem; margin: -0.3rem 0 0.8rem; }
.suggest-row .hint-text { margin-top: 0; }
#btn-ritual { color: var(--ink-2); }

/* Gone days read as a record: quieter card, no planning furniture. */
.day-record { opacity: 0.82; }
.day-record:hover { opacity: 1; }
.day-record .big-unit { pointer-events: auto; }

/* ---- promise runways -------------------------------------------------------- */

.runways { display: flex; flex-direction: column; gap: 0.6rem; }
.runway { display: grid; grid-template-columns: minmax(0, 1fr) minmax(80px, 1.1fr) auto; gap: 0.6rem; align-items: center; }
.runway-title { font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runway-track { position: relative; height: 8px; background: var(--sunken); border-radius: 999px; }
.runway-bar {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--chart-2) 45%, transparent);
  transition: width 0.55s var(--ease);
}
.runway-dot {
  position: absolute; top: -3px; width: 14px; height: 14px; margin-left: -7px;
  border-radius: 50%; background: var(--chart-1); border: 2px solid var(--surface);
  box-shadow: var(--shadow); transition: left 0.55s var(--ease);
}
.runway-late .runway-bar { background: var(--accent-soft); }
.runway-late .runway-dot { background: var(--accent); }
.runway-when { font-size: 0.625rem; color: var(--dim); white-space: nowrap; }
.runway-late .runway-when { color: var(--accent); }
.runway-axis { display: flex; justify-content: space-between; margin-top: 0.5rem; font-size: 0.5625rem; color: var(--dim); }

/* ---- the year at a glance ---------------------------------------------------- */

.year-scroll { overflow-x: auto; padding-bottom: 0.4rem; }
.year-months { display: grid; grid-auto-flow: column; grid-auto-columns: 13px; font-size: 0.5625rem; color: var(--dim); margin-bottom: 3px; height: 14px; }
.year-month { grid-row: 1; white-space: nowrap; }
.year-grid { display: grid; grid-auto-flow: column; grid-auto-columns: 13px; gap: 2px; }
.year-cell {
  width: 11px; height: 11px; min-height: 0; padding: 0; border: 0; border-radius: 3px;
  background: var(--sunken); cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.year-cell:hover { transform: scale(1.35); box-shadow: var(--shadow-lift); z-index: 2; position: relative; background: var(--sunken); border: 0; }
.year-cell.y1 { background: var(--chart-4); }
.year-cell.y2 { background: var(--chart-3); }
.year-cell.y3 { background: var(--chart-1); }
.year-cell.y4 { background: var(--accent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--text) 40%, transparent); }
.year-cell.y1:hover { background: var(--chart-4); } .year-cell.y2:hover { background: var(--chart-3); }
.year-cell.y3:hover { background: var(--chart-1); } .year-cell.y4:hover { background: var(--accent); }
.year-today { outline: 2px solid var(--text); outline-offset: 1px; }
.legend-dot.year-key { border-radius: 3px; background: var(--sunken); border: 1px solid var(--border-strong); }
.legend-dot.year-key.y1 { background: var(--chart-4); border: 0; }
.legend-dot.year-key.y2 { background: var(--chart-3); border: 0; }
.legend-dot.year-key.y3 { background: var(--chart-1); border: 0; }
.legend-dot.year-key.y4 { background: var(--accent); border: 0; }

/* ---- sparklines, compare bar, report button ---------------------------------- */

.spark { display: block; margin-top: 0.35rem; opacity: 0.9; }
.compare-bar { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.compare-vs { font-size: 0.6875rem; color: var(--dim); }
.panel-select {
  min-height: 32px; padding: 0 1.6rem 0 0.6rem; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.75rem; font-weight: 500; cursor: pointer;
}
.report-copy {
  display: block; margin: -0.25rem 0 0.85rem auto; min-height: 0;
  padding: 0.3rem 0.7rem; border: 1px dashed var(--border-strong); border-radius: 999px;
  background: transparent; color: var(--dim); font-size: 0.6875rem; font-weight: 500;
}
.report-copy:hover { color: var(--text); border-color: var(--text); background: var(--sunken); }

/* ---- filter bar --------------------------------------------------------------- */

.filterbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap;
  padding: 0.45rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.filterbar-input {
  flex: 1; min-width: 160px; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 0.8125rem; padding: 0.25rem 0.45rem; outline: none;
}
.filterbar-input::placeholder { color: var(--dim); }
.filter-pill {
  min-height: 28px; padding: 0 0.7rem; border: 1px solid var(--border-strong); border-radius: 999px;
  background: transparent; color: var(--dim); font-size: 0.6875rem; font-weight: 500;
}
.filter-pill:hover { color: var(--text); background: var(--sunken); }
.filter-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.filter-on:hover { background: var(--accent-soft); color: var(--accent); }
.chip-filtered { display: none !important; }

/* ---- zen: the persistent standup / working screen ---------------------------- */

.zen {
  position: fixed; inset: 0; z-index: 1200; background: var(--bg);
  display: flex; flex-direction: column;
}
.zen-topbar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.9rem 1.5rem;
}
.zen-date { font-size: 0.9375rem; color: var(--dim); letter-spacing: 0.01em; }
.zen-topbar-right { display: flex; align-items: center; gap: 0.9rem; }
.zen-clock { font-size: 0.9375rem; color: var(--text); font-variant-numeric: tabular-nums; }
.zen-close {
  width: 30px; height: 30px; min-height: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); border-radius: 50%;
  background: transparent; color: var(--dim); font-size: 0.8125rem;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.3s var(--ease);
}
.zen-close:hover { background: transparent; color: var(--text); border-color: var(--dim); transform: scale(1.08); }

.zen-body { flex: 1; overflow-y: auto; padding: 0 1.5rem 3rem; }

.zen-hero { text-align: center; max-width: 900px; margin: 0.5rem auto 1.9rem; }
.zen-big { margin: 0.4rem 0 0.7rem; }
.zen-big-num { font-size: 4.5rem; font-weight: 480; letter-spacing: -0.04em; line-height: 1; }
.zen-big-unit { font-size: 1.25rem; color: var(--dim); }
.zen-story { font-size: 0.9375rem; color: var(--ink-2); line-height: 1.6; max-width: 52ch; margin: 0 auto; }
.zen-streak { margin-top: 0.5rem; font-size: 0.8125rem; color: var(--chart-1); font-weight: 500; }

.zen-cols {
  display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 2.2rem; align-items: start; max-width: 980px; margin: 0 auto;
}
@media (max-width: 900px) {
  .zen-cols { grid-template-columns: minmax(0, 1fr); gap: 1.7rem; }
}

.zen-col-label {
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--dim); margin-bottom: 0.7rem;
}
.zen-done-label { margin-top: 1.5rem; }

.zen-list { display: flex; flex-direction: column; gap: 0.45rem; }
.zen-row {
  display: flex; align-items: center; gap: 0.35rem;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid transparent; border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s var(--ease), transform 0.3s var(--ease), border-color 0.3s var(--ease);
}
.zen-row:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.zen-row-risk { border-left-color: var(--accent); }

.zen-row-tick { align-self: center; flex: 0 0 22px; width: 22px; height: 22px; margin: 0 0.2rem 0 0.7rem; }

.zen-row-main {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; align-items: stretch; gap: 0.15rem;
  text-align: left; padding: 0.7rem 0.9rem 0.7rem 0.5rem;
  border: 0; border-radius: 0; background: transparent; font-weight: 400; cursor: pointer;
}
.zen-row-main:hover { background: transparent; border-color: transparent; }
.zen-row-title { font-size: 0.9375rem; font-weight: 500; line-height: 1.35; color: var(--text); transition: color 0.3s var(--ease); }
button.zen-row-main:hover .zen-row-title { color: var(--accent); }
.zen-row-meta { font-size: 0.75rem; color: var(--dim); line-height: 1.45; }

.zen-row-done { opacity: 0.62; }
.zen-row-done:hover { transform: none; box-shadow: var(--shadow); }
.zen-row-done .zen-row-title { text-decoration: line-through; font-weight: 400; color: var(--ink-2); }
.zen-row-main-static { cursor: default; }

.zen-empty { padding: 1.1rem 0.2rem; font-size: 0.875rem; color: var(--dim); line-height: 1.5; }

.zen-side { display: flex; flex-direction: column; gap: 1.3rem; }
.zen-side .zen-col-label { margin-bottom: 0; }
.zen-wins { display: flex; flex-direction: column; gap: 0.4rem; }
.zen-win {
  display: flex; align-items: baseline; gap: 0.6rem; padding: 0.45rem 0.9rem;
  border-radius: 999px; background: color-mix(in srgb, var(--chart-2) 18%, transparent);
}
.zen-win-min { font-size: 0.875rem; font-weight: 600; color: var(--chart-1); font-variant-numeric: tabular-nums; }
.zen-win-say { font-size: 0.75rem; color: var(--ink-2); }

.zen-promise {
  padding: 0.8rem 0.95rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.zen-promise-word {
  display: block; font-size: 0.625rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent); margin-bottom: 0.3rem;
}
.zen-promise-title { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text); }
.zen-promise-when { display: block; margin-top: 0.15rem; font-size: 0.75rem; color: var(--dim); }

.zen-room { font-size: 0.8125rem; color: var(--ink-2); }
.zen-room-over { color: var(--accent); font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  .zen-row, .zen-row:hover, .zen-close, .zen-close:hover { transition: none; transform: none; }
}

/* ---- per-task timer and toasts ------------------------------------------------ */

.timer-wrap { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.timer-btn {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  font: inherit;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.28rem 0.55rem;
  min-height: 0;
  cursor: pointer;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.timer-btn:hover, .timer-btn:focus-visible { color: var(--accent); border-color: var(--accent); background: var(--surface); }
.timer-live {
  color: var(--accent);
  border-color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.timer-sub { padding: 0.28rem 0.3rem; min-width: 1.4rem; text-align: center; }
.timer-paused .timer-btn { border-style: dashed; color: var(--dim); border-color: var(--border); }
.timer-paused .timer-live { color: var(--dim); border-color: var(--border-strong); }
.timer-paused .timer-btn:hover, .timer-paused .timer-btn:focus-visible { color: var(--accent); border-color: var(--accent); }
.timer-edit {
  width: 3.6rem; min-height: 0; padding: 0.22rem 0.4rem;
  border: 1px solid var(--accent); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.72rem; text-align: center;
}
.timer-edit:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

#toasts {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 1300;
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem;
  max-width: min(22rem, calc(100vw - 2rem)); pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; box-shadow: var(--shadow-lift);
  padding: 0.6rem 0.9rem; font-size: 0.85rem; line-height: 1.35; cursor: pointer;
}
.toast-in { animation: toast-in 0.3s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.toast-out { opacity: 0; transform: translateY(8px); transition: opacity 0.3s var(--ease), transform 0.3s var(--ease); }
@media (prefers-reduced-motion: reduce) {
  .toast-in { animation: none; }
  .toast-out { transition: none; }
}

/* ---- history view --------------------------------------------------------------- */

.history { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 0.85rem; }

.hist-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.hist-controls {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.45rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.hist-search {
  flex: 1; min-width: 160px; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 0.8125rem; padding: 0.25rem 0.45rem; outline: none;
}
.hist-search::placeholder { color: var(--dim); }
.hist-count { font-size: 0.6875rem; color: var(--dim); white-space: nowrap; }
.hist-export {
  min-height: 28px; padding: 0 0.7rem; border: 1px dashed var(--border-strong);
  border-radius: 999px; background: transparent; color: var(--dim);
  font-size: 0.6875rem; font-weight: 500; cursor: pointer;
}
.hist-export:hover { color: var(--text); border-color: var(--text); background: var(--sunken); }

.hist-group { animation: rise 0.4s var(--ease) both; animation-delay: var(--stagger, 0ms); }
.hist-group-head {
  display: flex; align-items: center; gap: 0.5rem; margin: 0.3rem 0 0.5rem;
  font-size: 0.625rem; letter-spacing: 0.02em; color: var(--dim);
}
.hist-group-rule { flex: 1; height: 1px; background: var(--border); }
.hist-group-hours { font-weight: 500; color: var(--text); }

.hist-rows { display: flex; flex-direction: column; gap: 0.4rem; }
.hist-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow); overflow: hidden;
  transition: box-shadow 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.3s var(--ease);
}
.hist-row:hover { box-shadow: var(--shadow-lift); border-left-color: var(--accent); transform: translateY(-1px); }
.hist-tick { margin: 0 0.35rem 0 0.75rem; }
.hist-main { min-width: 0; padding: 0.6rem 0.85rem; }
.hist-title { font-size: 0.875rem; font-weight: 500; line-height: 1.35; }
.hist-meta { font-size: 0.6875rem; color: var(--dim); line-height: 1.5; }
.hist-hours {
  display: flex; align-items: center; justify-content: flex-end; align-self: stretch;
  padding: 0.6rem 0.9rem; border-left: 1px dashed var(--border); min-width: 84px;
}
.hist-hours-big { font-size: 1rem; font-weight: 500; letter-spacing: -0.02em; }

.hist-hidden { display: none !important; }
.hist-nomatch { padding: 0.35rem 0.1rem; }

@media (max-width: 640px) {
  .hist-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hist-controls { flex-wrap: wrap; }
  .hist-search { min-width: 120px; }
  .hist-hours { min-width: 0; padding: 0.55rem 0.6rem; }
  .hist-main { padding: 0.55rem 0.65rem; }
}

@media (prefers-reduced-motion: reduce) {
  .hist-group { animation: none; }
  .hist-row { transition: none; }
  .hist-row:hover { transform: none; }
}

/* ---- history: findings and per-type record ------------------------------------ */

.hi-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0.6rem; }
.hi-card {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--chart-1);
  border-radius: var(--radius-sm); padding: 0.75rem 0.9rem; box-shadow: var(--shadow);
  animation: rise 0.4s var(--ease) both; animation-delay: var(--stagger, 0ms);
}
.hi-head { font-size: 0.875rem; font-weight: 500; letter-spacing: -0.01em; line-height: 1.35; }
.hi-detail { margin-top: 0.3rem; font-size: 0.75rem; color: var(--dim); line-height: 1.55; }

.tp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.6rem; }
.tp-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem; box-shadow: var(--shadow);
  animation: rise 0.4s var(--ease) both; animation-delay: var(--stagger, 0ms);
}
.tp-label { font-size: 0.75rem; font-weight: 500; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-nums { display: flex; align-items: baseline; gap: 0.4rem; margin-top: 0.25rem; }
.tp-hours { font-size: 1.05rem; font-weight: 500; letter-spacing: -0.02em; }
.tp-count { font-size: 0.6875rem; color: var(--dim); }
.tp-bar { height: 5px; border-radius: 999px; background: var(--sunken); overflow: hidden; margin: 0.4rem 0 0.35rem; }
.tp-fill { height: 100%; border-radius: 999px; background: var(--chart-2); transition: width 0.55s var(--ease); }
.tp-miss { font-size: 0.625rem; color: var(--dim); }
.tp-miss-over { color: var(--accent); }

/* Week groups fold; the caret says which way. */
.hist-group-head { width: 100%; border: 0; background: transparent; padding: 0; cursor: pointer; font: inherit; min-height: 0; }
.hist-group-head:hover { background: transparent; }
.hist-group-head:hover .hist-group-week { color: var(--text); }
.hist-group-caret { display: inline-block; transition: transform 0.3s var(--ease); color: var(--dim); transform: rotate(90deg); }
.hist-collapsed .hist-group-caret { transform: rotate(0deg); }
.hist-collapsed .hist-rows { display: none; }

/* ---- quick add ------------------------------------------------------------------- */

.qa-search {
  width: 100%; margin: 0.2rem 0 0.6rem; padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.8125rem;
}
.qa-search:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.qa-grid { max-height: 260px; overflow-y: auto; }
.qa-none { grid-column: 1 / -1; }

.qa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
  margin: 0.4rem 0 1rem;
}
.qa-card {
  display: flex; flex-direction: column; gap: 0.15rem; text-align: left;
  padding: 0.6rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font: inherit; cursor: pointer;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease),
    box-shadow 0.3s var(--ease), transform 0.3s var(--ease);
}
.qa-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); border-color: var(--border-strong); }
.qa-card-on, .qa-card-on:hover { border-color: var(--accent); background: var(--accent-soft); }
.qa-card-label { font-size: 0.8125rem; font-weight: 500; }
.qa-card-sum { font-size: 0.6875rem; color: var(--dim); line-height: 1.45; }
.qa-name { flex: 2; }
.qa-foot { margin: 0.9rem 0 0; }

/* ---- repeats manager --------------------------------------------------------------- */

.rf-rows { display: flex; flex-direction: column; gap: 0.45rem; margin: 0.3rem 0 0.5rem; }
.rf-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.rf-info { flex: 1; min-width: 0; }
.rf-title { font-size: 0.8125rem; font-weight: 500; }
.rf-meta { font-size: 0.6875rem; color: var(--dim); line-height: 1.45; }
.rf-mini { flex: 0 0 auto; padding: 0.25rem 0.7rem; font-size: 0.6875rem; border-radius: 999px; min-height: 0; }
.rf-armed, .rf-armed:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.rf-add { margin: 0.2rem 0 0.4rem; }

.rf-form {
  margin: 0.6rem 0 0.2rem; padding: 0.8rem 0.9rem;
  background: var(--sunken);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.rf-form-actions { display: flex; gap: 0.5rem; margin-top: 0.8rem; }
.rf-days { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.rf-pill {
  padding: 0.3rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--dim);
  font: inherit; font-size: 0.75rem; cursor: pointer; min-height: 0;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.rf-pill:hover { color: var(--text); border-color: var(--border-strong); }
.rf-pill-on, .rf-pill-on:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- header sync button ------------------------------------------------------------ */

#btn-quick { color: var(--ink-2); }
#btn-sync { min-width: 36px; padding: 0 0.6rem; font-size: 0.95rem; position: relative; }
#btn-sync.sync-busy { opacity: 0.55; pointer-events: none; }
/* Amber dot: the auto-sync probe found drift between the file and main. */
#btn-sync.sync-behind::after {
  content: ""; position: absolute; top: 4px; right: 4px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--chart-2); border: 1px solid var(--surface);
}
#btn-chat { min-width: 36px; padding: 0 0.6rem; color: var(--accent); }

/* ---- quick add: refresh-from-history candidates -------------------------------------- */

.qa-foot { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.9rem; }
.qa-foot .hint-text { margin-top: 0; }
#qa-cands { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.6rem; }
.qa-cand {
  display: flex; align-items: center; justify-content: space-between; gap: 0.7rem;
  padding: 0.5rem 0.7rem; background: var(--sunken);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
}
.qa-cand-info { min-width: 0; }
.qa-cand-add { flex: 0 0 auto; }

/* ---- the chat drawer (Ask Claude) ----------------------------------------------------- */

.chat {
  position: fixed; top: 0; right: 0; height: 100%; z-index: 1150;
  width: min(400px, 100vw);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lift);
  transform: translateX(105%);
  transition: transform 0.3s var(--ease);
}
.chat-open { transform: translateX(0); }

.chat-header {
  flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between;
  gap: 0.75rem; padding: 0.9rem 1rem 0.8rem; border-bottom: 1px solid var(--border);
}
.chat-head-text { min-width: 0; }
.chat-title { font-size: 1rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.chat-sub { margin-top: 0.2rem; font-size: 0.72rem; color: var(--dim); line-height: 1.4; }
.chat-head-actions { display: flex; align-items: center; gap: 0.5rem; flex: 0 0 auto; }

.chat-clear {
  min-height: 0; padding: 0.25rem 0.4rem; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--dim);
  font: inherit; font-size: 0.75rem; cursor: pointer;
  transition: color 0.3s var(--ease);
}
.chat-clear:hover { background: transparent; color: var(--accent); }

.chat-close {
  width: 28px; height: 28px; min-height: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); border-radius: 50%;
  background: transparent; color: var(--dim); font-size: 0.8125rem; cursor: pointer;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.chat-close:hover { background: transparent; color: var(--text); border-color: var(--dim); }

.chat-list {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1rem;
}

.chat-bubble {
  max-width: 88%; padding: 0.55rem 0.8rem;
  border-radius: var(--radius); font-size: 0.875rem; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text);
}
.chat-user { align-self: flex-end; background: var(--accent-soft); }
.chat-assistant { align-self: flex-start; background: var(--sunken); }
.chat-system {
  align-self: flex-start; background: transparent;
  border: 1px dashed var(--border-strong); color: var(--dim);
}
.chat-hint {
  align-self: flex-start; background: transparent;
  border: 1px solid var(--border); color: var(--ink-2); font-size: 0.8125rem;
}

.chat-thinking { color: var(--dim); }
.chat-dots::after { content: '…'; animation: chat-dots 1.2s steps(1, end) infinite; }
@keyframes chat-dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75%, 100% { content: '…'; }
}

.chat-composer {
  flex: 0 0 auto; display: flex; align-items: flex-end; gap: 0.5rem;
  padding: 0.75rem 1rem; border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1; min-width: 0; min-height: 0; max-height: 8.5rem;
  resize: none; overflow-y: auto;
  padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 0.875rem; line-height: 1.45;
  transition: border-color 0.3s var(--ease);
}
.chat-input:focus-visible { outline: none; border-color: var(--accent); }
.chat-input:disabled { opacity: 0.6; cursor: wait; }
.chat-send {
  flex: 0 0 auto; min-height: 0; padding: 0.5rem 0.9rem;
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
  font: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer;
  transition: box-shadow 0.3s var(--ease);
}
.chat-send:hover { background: var(--accent-soft); box-shadow: var(--shadow-lift); }
.chat-send:disabled { opacity: 0.55; cursor: wait; box-shadow: none; }

@media (max-width: 640px) {
  .chat { width: 100vw; }
}

@media (prefers-reduced-motion: reduce) {
  .chat, .chat-clear, .chat-close, .chat-input, .chat-send { transition: none; }
  .chat-dots::after { animation: none; }
}
#btn-help { min-width: 36px; padding: 0 0.6rem; font-weight: 600; color: var(--ink-2); }

/* ---- help: the guided tour ----------------------------------------------------------- */

.help {
  position: fixed; inset: 0; z-index: 1250; background: var(--bg);
  display: flex; flex-direction: column;
}
.help-topbar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.9rem 1.5rem;
}
.help-brand { display: flex; align-items: baseline; gap: 0.7rem; }
.help-title { font-size: 0.9375rem; font-weight: 500; letter-spacing: -0.01em; }
.help-sub { font-size: 0.75rem; color: var(--dim); }
.help-body { flex: 1; overflow-y: auto; padding: 0 1.5rem 3rem; }

.help-hero { text-align: center; max-width: 720px; margin: 1.2rem auto 1.6rem; }
.help-hero-big { font-size: 1.5rem; font-weight: 500; letter-spacing: -0.02em; line-height: 1.3; }
.help-hero-accent { margin-top: 0.35rem; font-size: 1.5rem; font-weight: 500; letter-spacing: -0.02em; line-height: 1.3; color: var(--accent); }
.help-hero-sub { margin: 0.8rem auto 0; max-width: 56ch; font-size: 0.875rem; color: var(--dim); line-height: 1.6; }

.help-search {
  display: block; width: min(34rem, 100%); margin: 0 auto 1.4rem; padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.875rem; text-align: center;
}
.help-search:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

.help-section-label {
  max-width: 980px; margin: 1.3rem auto 0.55rem;
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--dim);
}
.help-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.7rem; max-width: 980px; margin: 0 auto;
}
.help-points { margin: 0.2rem 0 0.9rem; padding-left: 1.1rem; font-size: 0.875rem; line-height: 1.75; color: var(--ink-2); }
.help-points li { margin-bottom: 0.45rem; }
.help-points strong { color: var(--text); font-weight: 500; }
.help-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem; text-align: left;
  padding: 0.9rem 1rem; min-height: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); font-weight: 400; cursor: pointer;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}
.help-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--border-strong); background: var(--surface); }
.help-card-glyph {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px; font-size: 0.9375rem;
  background: var(--accent-soft); color: var(--accent);
}
.help-card-title { font-size: 0.875rem; font-weight: 500; letter-spacing: -0.01em; }
.help-card-tag { font-size: 0.6875rem; color: var(--dim); line-height: 1.5; }
.help-none { max-width: 980px; margin: 1rem auto; text-align: center; }

.help-topic { max-width: 640px; margin: 0.6rem auto 0; }
.help-back { margin-bottom: 1.1rem; }
.help-topic-head { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.9rem; }
.help-topic-glyph { width: 40px; height: 40px; font-size: 1.15rem; border-radius: 12px; }
.help-topic-title { margin: 0; font-size: 1.25rem; font-weight: 500; letter-spacing: -0.02em; }
.help-topic-tag { font-size: 0.8125rem; color: var(--dim); margin-top: 0.1rem; }
.help-p { font-size: 0.9375rem; line-height: 1.7; color: var(--ink-2); margin: 0 0 0.8rem; }
.help-steps { margin: 0.2rem 0 0.9rem; padding-left: 1.2rem; font-size: 0.875rem; line-height: 1.9; color: var(--text); }
.help-example {
  display: flex; flex-direction: column; gap: 0.25rem;
  margin: 0.9rem 0; padding: 0.8rem 0.95rem;
  background: var(--sunken); border-left: 3px solid var(--chart-2); border-radius: var(--radius-sm);
  font-size: 0.8125rem; line-height: 1.6; color: var(--ink-2);
}
.help-example-word { font-size: 0.625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
.help-try {
  margin-top: 0.6rem; padding: 0 1.1rem; min-height: 40px;
  background: var(--accent); border-color: var(--accent); color: #fff; border-radius: 999px;
}
.help-try:hover { background: var(--accent); border-color: var(--accent); color: #fff; filter: brightness(1.1); }

@media (prefers-reduced-motion: reduce) {
  .help-card, .help-card:hover { transition: none; transform: none; }
  .hist-group-caret { transition: none; }
}

/* ---- timing pass ------------------------------------------------------------
   Fast enough to feel immediate, slow enough to be seen. The earlier values
   were tuned for subtlety and read as nothing at all. */

button { transition: background 0.28s var(--ease), border-color 0.28s var(--ease), color 0.28s var(--ease), transform 0.22s var(--ease); }
.tab { transition: transform 0.4s var(--ease), opacity 0.4s var(--ease), background 0.3s var(--ease), color 0.3s var(--ease); }
.window-min { transition: transform 0.4s var(--ease), opacity 0.32s var(--ease); }
.window-say { transition: opacity 0.36s var(--ease), transform 0.36s var(--ease); }
dialog[open] { animation: fade 0.28s var(--ease); }
dialog[open] #dialog-body { animation: pop 0.34s var(--ease); }
dialog[open]::backdrop { animation: fade 0.34s var(--ease); }
.panel { animation-duration: 0.55s; }
.day { animation-duration: 0.55s; }
.legend-dot { transition: transform 0.32s var(--ease); }
.donut-seg { transition: stroke-dasharray 0.6s var(--ease), transform 0.45s var(--ease); }
.win-bar { transition: background 0.4s var(--ease), color 0.4s var(--ease), transform 0.3s var(--ease); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.32s; }

/* ==== phones and the Android app ==============================================
   At 760px and below the app is laid out for a thumb: a slim sticky header
   (name · period · Add · ⋯), the view tabs as a bottom navigation bar, one
   column of content, dialogs as bottom sheets, overlays full-screen. It runs
   edge to edge (viewport-fit=cover), so every bar pads itself with the safe
   areas. Colours come only from the tokens at the top of the file, so theme
   skins carry straight through. This block sits last so it wins the cascade;
   nothing in it applies above 760px. */

@media (max-width: 760px) {
  :root {
    --m-pad-l: max(1rem, env(safe-area-inset-left, 0px));
    --m-pad-r: max(1rem, env(safe-area-inset-right, 0px));
    --m-nav-h: 61px; /* 48px tab + 6px padding above and below + 1px rule */
  }

  /* A stray wide element must never make the whole page wobble sideways on a
     phone. `clip` (not hidden) so the sticky header keeps working. */
  body {
    overflow-x: clip;
    padding: 0 var(--m-pad-r) calc(var(--m-nav-h) + env(safe-area-inset-bottom, 0px) + 1.25rem) var(--m-pad-l);
  }
  body.more-open { overflow: hidden; }

  /* ---- header: name · period · Add · ⋯ ---------------------------------------
     Sticky, full-bleed, and a stacking context of its own — the bottom nav, the
     More sheet and its backdrop are fixed-position children of it and layer
     inside it (nav 1 < veil 2 < sheet 3). Never give it a transform, filter or
     backdrop-filter: that would make it the containing block for those fixed
     children and pin them to the header instead of the screen. */
  header {
    position: sticky; top: 0; z-index: 920;
    flex-wrap: nowrap; gap: 0.4rem;
    margin: 0 calc(-1 * var(--m-pad-r)) 0.85rem calc(-1 * var(--m-pad-l));
    padding: calc(0.55rem + env(safe-area-inset-top, 0px)) var(--m-pad-r) 0.55rem var(--m-pad-l);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    transition: background 0.3s var(--ease);
  }
  h1 {
    flex: 1 1 auto; min-width: 0; padding-right: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  /* Every pixel here is spoken for at 360px: name ~78 + period ~130 + Add ~50
     + ⋯ 44 + gaps. ⋯ sits last, where Android puts its overflow menu. */
  .header-tools { flex: 0 0 auto; flex-wrap: nowrap; gap: 0.3rem; margin-left: 0; }
  #scope { min-height: 44px; padding: 0 1.5rem 0 0.5rem; font-size: 16px; }
  #btn-add { padding: 0 0.7rem; }
  .more-toggle {
    order: 4;
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; min-width: 44px; padding: 0; color: var(--ink-2);
  }
  .more-toggle svg { display: block; }
  .more-toggle[aria-expanded="true"] { background: var(--sunken); color: var(--text); }

  /* ---- the More sheet: .actions, opened by body.more-open (ui/mobilenav.js) -- */
  .more-veil {
    display: block; position: fixed; inset: 0; z-index: 2;
    background: color-mix(in srgb, var(--bg) 60%, transparent);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s var(--ease), visibility 0s linear 0.3s;
  }
  body.more-open .more-veil { opacity: 1; visibility: visible; transition: opacity 0.3s var(--ease), visibility 0s; }

  .actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
    width: min(100%, 40rem); margin: 0 auto;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem;
    max-height: 85vh; max-height: 85dvh; overflow-y: auto; overscroll-behavior: contain;
    padding: 0.85rem var(--m-pad-r) calc(1rem + env(safe-area-inset-bottom, 0px)) var(--m-pad-l);
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    box-shadow: var(--shadow-lift);
    transform: translateY(calc(100% + 24px));
    visibility: hidden;
    transition: transform 0.32s var(--ease), visibility 0s linear 0.32s;
  }
  body.more-open .actions {
    transform: none; visibility: visible;
    transition: transform 0.32s var(--ease), visibility 0s;
  }
  .actions::before {
    content: "More"; grid-column: 1 / -1;
    padding: 0 0.2rem 0.1rem;
    font-size: 0.6875rem; letter-spacing: 0.01em; color: var(--dim);
  }
  /* Each action is a full-width row: name on the left, glyph on the right. The
     icon-only buttons have no visible name, so it is printed from aria-label. */
  #more-sheet > button {
    display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
    width: 100%; min-width: 0; min-height: 48px; padding: 0.35rem 0.85rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg); color: var(--text);
    font-size: 0.875rem; font-weight: 500; line-height: 1.25;
    text-align: left; white-space: normal;
  }
  #more-sheet > button:hover { background: var(--sunken); border-color: var(--border-strong); }
  #more-sheet > button[aria-label] { font-size: 1rem; color: var(--dim); }
  #more-sheet > button[aria-label]::before {
    content: attr(aria-label); min-width: 0;
    font-size: 0.875rem; font-weight: 500; color: var(--text);
  }
  #more-sheet > #btn-ask, #more-sheet > #btn-chat { color: var(--accent); }

  /* ---- view tabs → bottom navigation bar ------------------------------------ */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1;
    gap: 0.35rem;
    padding: 6px var(--m-pad-r) calc(6px + env(safe-area-inset-bottom, 0px)) var(--m-pad-l);
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 0;
    transition: transform 0.25s var(--ease);
  }
  .tab {
    flex: 1 1 0; min-width: 0; min-height: 48px; padding: 0 0.5rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
  }
  /* The desktop dock magnification sticks after a tap on touch screens. */
  .tabs:hover .tab, .tabs .tab:hover, .tabs .tab:hover + .tab, .tab:has(+ .tab:hover) { transform: none; opacity: 1; }
  .tab-active, .tab-active::before { background: var(--accent-soft); box-shadow: none; }
  .tab-active, .tab-active:hover { color: var(--accent); }
  /* While typing into the page (filter, search), the keyboard is up — get the
     bar out of the way rather than have it ride on top of the keyboard. */
  body:has(:is(input:not([type="range"]):not([type="checkbox"]):not([type="radio"]), textarea):focus) .tabs {
    transform: translateY(calc(100% + 2px));
  }

  /* ---- one column; wide things scroll inside their own box ------------------- */
  #overview, #week, #history { grid-template-columns: minmax(0, 1fr); }
  .panel, .day, .detail, .history, .hist-group, .filterbar, .chart-holder, .ov-split > *, .ov-pair > * { min-width: 0; }
  .chart-holder { max-width: 100%; }
  .year-scroll { overscroll-behavior-x: contain; }
  .panel-head { flex-wrap: wrap; }
  .filterbar-input { flex: 1 1 100%; min-width: 0; }
  .hi-cards, .help-grid { grid-template-columns: minmax(0, 1fr); }
  .tp-grid { grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); }
  .qa-grid { grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr)); max-height: 40vh; max-height: 40dvh; }
  .rf-row, .qa-cand { flex-wrap: wrap; }
  .ritual-row { flex-direction: column; align-items: stretch; }
  .seg { width: 100%; }
  .seg-btn { flex: 1 1 0; min-width: 0; white-space: normal; line-height: 1.2; }
  .ritual-actuals { flex-wrap: wrap; }
  .ritual-actuals .field { flex: 1 1 6rem; }

  /* ---- touch targets and form text -------------------------------------------
     44px is the floor for anything tapped. 16px is the floor for anything typed
     into — below it iOS zooms the page on focus. */
  button, input, select { min-height: 44px; }
  .xs-native { min-height: 0; }
  :is(input, select, textarea):not([type="range"]):not([type="checkbox"]):not([type="radio"]) { font-size: 16px; }
  label { font-size: 0.75rem; }
  .hint-text { font-size: 0.6875rem; }
  .ghost, .filter-pill, .hist-export, .seg-btn, .rf-pill, .rf-mini, .panel-select,
  .xs-cal-action, .chat-send, .chat-clear, .help-try, .stranded, .report-copy,
  .rebalance-link, .hist-group-head, .win-bar { min-height: 44px; }
  .chat-clear { padding: 0 0.6rem; }
  .zen-close, .chat-close { width: 44px; height: 44px; }
  .timer-edit { width: 4.4rem; }
  /* Small controls that sit inside dense rows keep their look; an invisible
     ::after grows what the finger can hit to ~44px. */
  .chip-done, .timer-btn, .panel-act, .big-unit { position: relative; }
  .chip-done::after, .timer-btn::after, .panel-act::after, .big-unit::after {
    content: ""; position: absolute; inset: -12px;
  }
  .timer-btn { padding: 0.45rem 0.65rem; }
  .timer-btn::after { inset: -8px -2px; }
  .panel-act { padding: 0.35rem 0.7rem; font-size: 0.6875rem; }
  .panel-act::after { inset: -8px -4px; }
  .big-unit::after { inset: -13px -6px; }
  /* The "if a job took" slider: a 44px-tall input with the 4px track painted
     through its middle, and a thumb big enough for a finger. */
  .wins-control input[type="range"] {
    height: 44px;
    background: linear-gradient(var(--sunken), var(--sunken)) center / 100% 4px no-repeat;
  }
  .wins-control input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; }

  /* ---- dialog → bottom sheet ---------------------------------------------------
     No transform on <dialog> (see the note at its desktop rule: it would trap
     the fixed-position select/date popups) — the slide-up animates `bottom`. */
  dialog {
    width: min(100%, 40rem); max-width: 100%;
    max-height: 92vh; max-height: 92dvh;
    margin: auto auto 0;
    padding: 1.15rem var(--m-pad-r) 0 var(--m-pad-l);
    border: 0; border-top: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    overscroll-behavior: contain;
  }
  dialog[open] { animation: sheet-up 0.36s var(--ease); }
  dialog[open] #dialog-body { animation: none; }
  #dialog-body { padding-bottom: calc(1.15rem + env(safe-area-inset-bottom, 0px)); }
  #dialog-body:has(> .dialog-actions:last-child) { padding-bottom: 0; }
  /* The buttons stay reachable however long the form: they stick to the bottom
     of the sheet, full-bleed, above the home-bar inset. */
  .dialog-actions {
    position: sticky; bottom: 0; z-index: 2;
    margin: 1.1rem calc(-1 * var(--m-pad-r)) 0 calc(-1 * var(--m-pad-l));
    padding: 0.7rem var(--m-pad-r) calc(0.7rem + env(safe-area-inset-bottom, 0px)) var(--m-pad-l);
    background: var(--surface);
    border-top: 1px solid var(--border);
  }
  .dialog-actions button { min-height: 46px; }

  /* ---- custom select / date popups → docked picker -----------------------------
     controls.js anchors each popup under its trigger with inline top/left and a
     min-width the trigger's size. On a phone that can run off the screen, so the
     popup docks to the bottom instead, centred and capped — the inline values
     are overridden, the JS is untouched. */
  .xs-popup {
    top: auto !important; left: 0 !important; right: 0;
    bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    width: min(calc(100% - 1rem), 26rem); min-width: 0 !important;
    margin: 0 auto;
    max-height: min(60vh, 26rem); max-height: min(60dvh, 26rem);
    padding: 6px;
    border-radius: var(--radius);
    overscroll-behavior: contain;
  }
  .xs-popup.xs-cal { max-height: min(85vh, 34rem); max-height: min(85dvh, 34rem); padding: 0.75rem; }
  .xs-option { min-height: 44px; font-size: 1rem; }
  .xs-cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .xs-cal-day, .xs-cal-pad { height: 44px; }
  .xs-cal-day { font-size: 0.9375rem; }
  .xs-cal-nav { min-width: 44px; min-height: 44px; }
  .xs-cal-title { font-size: 0.9375rem; }
  .xs-trigger { min-height: 44px; font-size: 1rem; }

  /* ---- command palette: full screen ---------------------------------------------
     palette.js closes on any pointerdown outside .palette and has no close
     button of its own. The title strip and the ✕ below are pseudo-elements of
     the veil — so they ARE that outside, and a tap on them closes it. */
  .palette-veil {
    align-items: stretch;
    padding: calc(env(safe-area-inset-top, 0px) + 3.5rem) 0 0;
    background: var(--surface);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .palette-veil::before {
    content: "Commands"; position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 1.1rem); left: var(--m-pad-l);
    font-size: 0.9375rem; font-weight: 500; color: var(--text);
  }
  .palette-veil::after {
    content: "✕"; position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 0.4rem); right: var(--m-pad-r);
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-strong); border-radius: 50%;
    color: var(--dim); font-size: 0.8125rem; cursor: pointer;
  }
  .palette {
    width: 100%; display: flex; flex-direction: column;
    border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none;
  }
  .palette-input { flex: 0 0 auto; padding: 0.85rem var(--m-pad-r) 0.85rem var(--m-pad-l); }
  .palette-list {
    flex: 1 1 auto; min-height: 0; max-height: none;
    padding: 0.35rem calc(var(--m-pad-r) - 0.5rem) calc(0.5rem + env(safe-area-inset-bottom, 0px)) calc(var(--m-pad-l) - 0.5rem);
  }
  .palette-item { min-height: 48px; align-items: center; }
  .palette-label { font-size: 0.9375rem; }

  /* ---- chat drawer: full screen --------------------------------------------- */
  .chat {
    width: 100%; border-left: 0; box-shadow: none;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
  }
  .chat-composer { padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)); }
  /* At 16px the placeholder wraps; two lines tall shows it whole instead of a
     sliver of its second line. */
  .chat-input { min-height: calc(2.9em + 1rem + 2px); }
  .chat-bubble { max-width: 92%; }

  /* ---- zen and help: already full screen; pad for notch and home bar -------- */
  .zen-topbar, .help-topbar {
    padding: calc(0.6rem + env(safe-area-inset-top, 0px)) var(--m-pad-r) 0.6rem var(--m-pad-l);
  }
  .zen-body, .help-body {
    padding: 0 var(--m-pad-r) calc(2rem + env(safe-area-inset-bottom, 0px)) var(--m-pad-l);
  }
  .zen-hero { margin-bottom: 1.4rem; }
  .zen-big-num { font-size: 3.25rem; }
  .zen-big-unit { font-size: 1rem; }
  .help-brand { flex-wrap: wrap; row-gap: 0.1rem; min-width: 0; }
  .help-hero-big, .help-hero-accent { font-size: 1.2rem; }

  /* ---- toasts clear the bottom bar -------------------------------------------- */
  #toasts {
    left: var(--m-pad-l); right: var(--m-pad-r);
    bottom: calc(var(--m-nav-h) + env(safe-area-inset-bottom, 0px) + 0.6rem);
    max-width: none; align-items: stretch;
  }
}

/* Narrow phones: form fields stack — three side-by-side number fields leave
   each about 90px, which their labels and hints cannot fit. */
@media (max-width: 560px) {
  .row { flex-direction: column; gap: 0.8rem; }
}

/* Phone on its side: header plus bottom bar would eat half the height, so the
   header scrolls away instead of sticking. It stays a stacking context so the
   bottom bar and More sheet still layer correctly. */
@media (max-width: 760px) and (max-height: 500px) {
  header { position: relative; }
}

@keyframes sheet-up { from { bottom: -100%; } to { bottom: 0; } }

/* Touch screens have no hover; a tap leaves :hover stuck on the element until
   the next tap elsewhere, so the hover-only lifts and dims are switched off. */
@media (hover: none) {
  .tabs:hover .tab, .tabs .tab:hover, .tabs .tab:hover + .tab, .tab:has(+ .tab:hover) { transform: none; opacity: 1; }
  .chips:hover .chip { opacity: 1; }
  .chips-done:hover .chip { opacity: 0.5; }
  .chips .chip:hover { transform: none; box-shadow: none; }
  .day:hover, .zen-row:hover, .hist-row:hover, .qa-card:hover, .help-card:hover,
  .win-bar:hover, .xs-cal-day:hover, .zen-close:hover { transform: none; }
}

/* ---- browser mode: the sample-data banner and the "Your data" tools --------- */

.demo-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem;
  margin: 0 0 0.85rem; padding: 0.6rem 0.85rem;
  background: var(--accent-soft); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius-sm); font-size: 0.8125rem;
}
.demo-banner span { flex: 1 1 16rem; min-width: 0; }
.demo-banner button { min-height: 32px; padding: 0 0.8rem; font-size: 0.75rem; }
.demo-fresh { background: var(--accent); border-color: var(--accent); color: #fff; }
.demo-fresh:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.08); }
.demo-keep { background: transparent; }

.data-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.2rem; }
.data-tools .ghost, .data-import {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 0.85rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: inherit; font-size: 0.8125rem; font-weight: 500;
  cursor: pointer;
}
.data-import:hover { background: var(--sunken); }
.data-tools .danger { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.data-tools .ghost:disabled { opacity: 0.55; cursor: default; }

/* Settings → Sync across devices: one status line above the buttons. A long
   email address wraps instead of widening a 320px dialog. */
.cloud-line { margin: 0 0 0.45rem; font-size: 0.8125rem; line-height: 1.45; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .demo-banner button, .data-tools .ghost, .data-import { min-height: 44px; }
  .demo-banner span { flex-basis: 100%; }
}
/* On the narrowest phones the name would truncate to "Workl…" next to the
   period selector; the app icon says the same thing in 28px. */
@media (max-width: 420px) {
  /* !important: a style (themes.css, loaded later) may dress the wordmark as
     a sticker; at this width the icon IS the wordmark and must win. */
  header h1 {
    font-size: 0 !important; border: 0 !important; padding: 0 !important; margin: 0;
    width: 28px; height: 28px; flex: 0 0 28px; box-shadow: none !important;
    background: url("./icons/icon.svg") center / contain no-repeat !important;
  }
}