/* ------------------------------------------------------------------ *
 * Tokens
 * ------------------------------------------------------------------ */

:root {
  color-scheme: light;

  --paper: #fcf8f2;
  --parchment: #f6f1ea;
  --ink: #3b3a36;
  --graphite: #4a403a;
  --faint-ink: #8b857c;
  --margin-line: #d6cfc4;
  --line-soft: rgba(214, 207, 196, 0.72);
  --field: rgba(252, 248, 242, 0.82);
  --inset: rgba(252, 248, 242, 0.58);

  --blush: #f4c6c6;
  --sage: #cfe3d4;
  --dusty: #c9d6e3;
  --butter: #f9edc9;
  --lavender: #e1d5e7;

  --accent: #4a403a;
  --danger: #a84b47;
  --danger-soft: rgba(168, 75, 71, 0.12);
  --warn: #8a6a20;
  --warn-soft: rgba(197, 154, 47, 0.18);
  --ok: #4f7e5d;
  --ok-soft: rgba(79, 126, 93, 0.14);

  --heat: 79, 126, 93;
  --rule: rgba(59, 58, 54, 0.08);
  --grain: 0.18;
  --card-bg: linear-gradient(rgba(246, 241, 234, 0.92), rgba(246, 241, 234, 0.92)),
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.5), transparent 18rem),
    var(--parchment);
  --page-bg: linear-gradient(rgba(252, 248, 242, 0.94), rgba(252, 248, 242, 0.94)),
    repeating-linear-gradient(90deg, rgba(214, 207, 196, 0.22) 0 1px, transparent 1px 72px),
    var(--paper);

  --shadow-soft: 0 4px 12px rgba(59, 58, 54, 0.06);
  --shadow-stacked: 0 2px 4px rgba(59, 58, 54, 0.04), 0 8px 16px rgba(59, 58, 54, 0.06);
  --shadow-lifted: 0 10px 30px rgba(59, 58, 54, 0.14);
  --focus-ring: rgba(74, 64, 58, 0.28);

  --radius: 10px;
  --radius-sm: 7px;

  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "EB Garamond", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

  --paper: #16151a;
  --parchment: #1d1c22;
  --ink: #e7e2d9;
  --graphite: #cec7bb;
  --faint-ink: #8f8880;
  --margin-line: #35333d;
  --line-soft: rgba(133, 126, 145, 0.24);
  --field: rgba(255, 255, 255, 0.045);
  --inset: rgba(255, 255, 255, 0.035);

  --blush: #9a6065;
  --sage: #4f7d64;
  --dusty: #4f6b8a;
  --butter: #8f7a37;
  --lavender: #6f5d86;

  --accent: #e7e2d9;
  --danger: #e79a95;
  --danger-soft: rgba(231, 154, 149, 0.14);
  --warn: #e3c179;
  --warn-soft: rgba(227, 193, 121, 0.14);
  --ok: #93cba3;
  --ok-soft: rgba(147, 203, 163, 0.14);

  --heat: 147, 203, 163;
  --rule: rgba(255, 255, 255, 0.06);
  --grain: 0.1;
  --card-bg: linear-gradient(rgba(29, 28, 34, 0.94), rgba(29, 28, 34, 0.94)),
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.06), transparent 18rem),
    var(--parchment);
  --page-bg: linear-gradient(rgba(22, 21, 26, 0.94), rgba(22, 21, 26, 0.94)),
    repeating-linear-gradient(90deg, rgba(133, 126, 145, 0.14) 0 1px, transparent 1px 72px),
    var(--paper);

  --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-stacked: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 16px rgba(0, 0, 0, 0.36);
  --shadow-lifted: 0 12px 34px rgba(0, 0, 0, 0.5);
  --focus-ring: rgba(207, 199, 187, 0.32);
}

/* ------------------------------------------------------------------ *
 * Base
 * ------------------------------------------------------------------ */

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--page-bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

h1, h2 { margin: 0; color: var(--ink); font-family: var(--serif); }

h1 { font-size: 2.6rem; font-weight: 700; line-height: 0.98; letter-spacing: -0.01em; }
h2 { font-size: 1.45rem; font-weight: 600; }

p { margin: 0; }

.mono { font-family: var(--mono); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 14px;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus { left: 0; }

:where(button, [href], input, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--graphite);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 52px;
}

/* ------------------------------------------------------------------ *
 * Topbar
 * ------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 22px 0 16px;
  border-bottom: 1px solid var(--margin-line);
  background: linear-gradient(var(--paper) 88%, transparent);
  backdrop-filter: blur(6px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
}

.eyebrow, .label, .muted, .footnote, small { color: var(--faint-ink); }

.eyebrow {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.label {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.vault-chip {
  max-width: 32ch;
  overflow: hidden;
  border: 1px solid var(--margin-line);
  border-radius: 999px;
  background: var(--field);
  color: var(--faint-ink);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 6px 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ *
 * Layout
 * ------------------------------------------------------------------ */

.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  margin: 14px 0;
  align-items: start;
}
.focus-strip { margin: 14px 0; }

/* ------------------------------------------------------------------ *
 * Cards
 * ------------------------------------------------------------------ */

.card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--margin-line);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow-soft);
  padding: 16px;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--rule) 0.6px, transparent 0.6px);
  background-size: 9px 9px;
  opacity: var(--grain);
  pointer-events: none;
}

.card > * { position: relative; }

.metric {
  min-height: 128px;
  display: grid;
  align-content: space-between;
  gap: 2px;
}

.metric strong {
  display: block;
  margin: 6px 0 2px;
  font-family: var(--mono);
  font-size: 2.05rem;
  font-weight: 600;
  line-height: 1.05;
}

.metric strong.metric-word {
  font-family: var(--serif);
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.metric-foot { display: grid; gap: 6px; }

.tone-blush { border-top: 4px solid var(--blush); }
.tone-sage { border-top: 4px solid var(--sage); }
.tone-dusty { border-top: 4px solid var(--dusty); }
.tone-butter { border-top: 4px solid var(--butter); }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

/* Sparkline + meter --------------------------------------------------- */

.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
}

.sparkline span {
  flex: 1;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: rgba(var(--heat), 0.55);
}

.sparkline span.is-today { background: rgb(var(--heat)); }

.meter {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line-soft);
}

.meter-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--ok);
  transition: width 320ms ease;
}

/* ------------------------------------------------------------------ *
 * Controls
 * ------------------------------------------------------------------ */

.chip, .pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--margin-line);
  border-radius: 999px;
  background: var(--field);
  color: var(--graphite);
  font-family: var(--serif);
  font-size: 0.82rem;
  line-height: 1;
  padding: 5px 10px;
  white-space: nowrap;
}

.chip.subtle { border-color: transparent; background: transparent; color: var(--faint-ink); }
.chip.is-live { border-color: var(--ok); color: var(--ok); }
.chip.is-work { border-color: var(--blush); }
.chip.is-break { border-color: var(--sage); }

.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  font-weight: 650;
  box-shadow: var(--shadow-soft);
  transition: transform 140ms ease, background-color 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.button { min-height: 40px; padding: 9px 14px; }

.button.secondary {
  border-color: var(--margin-line);
  background: var(--field);
  color: var(--graphite);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--faint-ink);
  font-weight: 500;
}

.button.ghost:hover { background: var(--field); color: var(--graphite); }

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.icon-button.ghost {
  border-color: var(--margin-line);
  background: var(--field);
  color: var(--graphite);
  box-shadow: none;
}

.button:hover:not(:disabled), .icon-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-stacked);
}

.button:active:not(:disabled), .icon-button:active:not(:disabled) { transform: translateY(0); }

.button:disabled, .icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

/* Busy state (refresh + form submits) */
.spinner { display: none; }

.is-busy .spinner {
  display: block;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  opacity: 0.7;
}

@keyframes spin { to { transform: rotate(360deg); } }

input, select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--margin-line);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input::placeholder { color: var(--faint-ink); }

input:focus, select:focus {
  border-color: var(--graphite);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input:focus-visible, select:focus-visible { outline: none; }

input[type="search"] { -webkit-appearance: none; appearance: none; }

.row { display: flex; gap: 10px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.stack { display: grid; gap: 10px; }

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

/* Disclosure --------------------------------------------------------- */

.disclosure {
  border: 1px dashed var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--inset);
}

.disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  color: var(--graphite);
  font-size: 0.86rem;
  list-style: none;
  padding: 9px 11px;
  user-select: none;
}

.disclosure > summary::-webkit-details-marker { display: none; }

.disclosure > summary::before {
  content: "›";
  display: inline-block;
  margin-right: 2px;
  color: var(--faint-ink);
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 160ms ease;
}

.disclosure[open] > summary::before { transform: rotate(90deg); }

.disclosure > summary > span:first-of-type { flex: 1; }

.detail-hint {
  color: var(--faint-ink);
  font-family: var(--mono);
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-fields, .habit-fields {
  display: grid;
  gap: 10px;
  padding: 0 11px 11px;
}

.task-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.habit-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.task-fields label, .habit-fields label { display: grid; gap: 5px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }

/* Toolbar ------------------------------------------------------------ */

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.filters { display: flex; flex-wrap: wrap; gap: 6px; }

.chip.filter {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.78rem;
  padding: 6px 11px;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.chip.filter:hover { border-color: var(--graphite); }

.chip.filter.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.chip.filter[data-count]::after {
  content: attr(data-count);
  color: inherit;
  font-family: var(--mono);
  font-size: 0.7rem;
  opacity: 0.65;
}

/* ------------------------------------------------------------------ *
 * Timer
 * ------------------------------------------------------------------ */

.focus-card { display: grid; align-content: start; gap: 14px; }

.focus-body {
  display: grid;
  grid-template-columns: auto minmax(210px, 0.8fr) minmax(250px, 1fr);
  align-items: center;
  gap: 16px 24px;
}

.focus-controls { display: grid; align-content: center; gap: 12px; }

.timer-face {
  display: grid;
  place-items: center;
}

.timer-face > * { grid-area: 1 / 1; }

.timer-ring {
  width: 184px;
  height: auto;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--line-soft);
  stroke-width: 6;
}

.ring-value {
  fill: none;
  stroke: var(--ok);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 900ms linear, stroke 300ms ease;
}

.timer-face[data-mode="break"] .ring-value { stroke: var(--dusty); }

.timer-readout { display: grid; gap: 4px; justify-items: center; text-align: center; }

.timer-readout span {
  font-family: var(--mono);
  font-size: 2.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.timer-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.timer-controls label, .volume-control, .soundtrack-station { display: grid; gap: 5px; min-width: 0; }

/* ------------------------------------------------------------------ *
 * Soundtrack — the radio is bound to the timer, so it has no transport
 * controls of its own: one on/off toggle, a station, and volume.
 * ------------------------------------------------------------------ */

.soundtrack {
  display: grid;
  align-content: center;
  gap: 9px;
  min-width: 0;
  border-left: 1px solid var(--line-soft);
  padding-left: 24px;
}

.soundtrack-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.soundtrack-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.soundtrack .icon-button[aria-pressed="true"] {
  border-color: var(--ok);
  color: var(--ok);
}

.icon-speaker {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-speaker .cone { fill: currentColor; stroke-width: 1.2; }
[aria-pressed="false"] .icon-speaker .wave { display: none; }
[aria-pressed="true"] .icon-speaker .mute { display: none; }

.soundtrack-note {
  overflow: hidden;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input[type="range"] {
  min-height: 34px;
  border: none;
  background: transparent;
  padding: 0;
  accent-color: var(--ok);
}

/* ------------------------------------------------------------------ *
 * Lists
 * ------------------------------------------------------------------ */

.list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 7px;
}

.list li {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--inset);
  padding: 9px 11px;
  transition: border-color 140ms ease, background-color 140ms ease, opacity 200ms ease, transform 200ms ease;
}

.list li:hover { border-color: var(--margin-line); background: var(--field); }

.list li.is-empty, .list li.is-skeleton {
  justify-content: center;
  border-style: dashed;
  border-left-style: dashed;
  color: var(--faint-ink);
}

.list li.is-leaving { opacity: 0; transform: translateX(10px); }

/* Skeletons */
.is-skeleton { pointer-events: none; }

.skeleton-bar {
  width: 100%;
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--line-soft) 25%, var(--field) 37%, var(--line-soft) 63%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer { to { background-position: -150% 0; } }

/* Task rows ---------------------------------------------------------- */

.task-item[data-priority="highest"] { border-left-color: var(--danger); }
.task-item[data-priority="high"] { border-left-color: var(--blush); }
.task-item[data-priority="medium"] { border-left-color: var(--butter); }
.task-item[data-overdue="true"] { border-top-color: var(--danger-soft); border-right-color: var(--danger-soft); border-bottom-color: var(--danger-soft); }

.task-main { display: grid; gap: 4px; min-width: 0; flex: 1; }

.task-title {
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.tag {
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  padding: 2px 6px;
  white-space: nowrap;
}

.tag.file {
  color: var(--faint-ink);
  overflow: hidden;
  padding-left: 0;
  text-overflow: ellipsis;
}

.tag.due { background: var(--field); color: var(--graphite); }
.tag.due.is-overdue { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.tag.due.is-today { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.tag.prio { background: var(--field); color: var(--graphite); text-transform: uppercase; }
.tag.prio.is-highest, .tag.prio.is-high { background: var(--danger-soft); color: var(--danger); }

/* Round check control shared by tasks and habits */
.check {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1.5px solid var(--faint-ink);
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  color: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.check:hover:not(:disabled) {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
  transform: none;
}

.check[aria-checked="true"] {
  border-color: var(--ok);
  background: var(--ok);
  color: var(--paper);
}

:root[data-theme="dark"] .check[aria-checked="true"] { color: var(--paper); }

.check:disabled { cursor: progress; opacity: 0.5; }

/* Habit rows --------------------------------------------------------- */

.habit-item[data-complete="true"] { border-left-color: var(--sage); }
.habit-item[data-complete="true"] .task-title { color: var(--faint-ink); text-decoration: line-through; }

.streak {
  display: flex;
  flex: none;
  gap: 3px;
  align-items: center;
}

.streak span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-soft);
}

.streak span.is-on { background: var(--ok); }

.list-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  min-height: 4px;
}

/* ------------------------------------------------------------------ *
 * History strip
 * ------------------------------------------------------------------ */

.history {
  display: grid;
  grid-template-columns: repeat(21, minmax(0, 1fr));
  align-items: end;
  gap: 6px;
}

.day {
  display: grid;
  gap: 5px;
  justify-items: center;
  border-radius: var(--radius-sm);
  padding: 6px 2px;
  cursor: default;
}

.day.is-today { background: var(--field); box-shadow: inset 0 0 0 1px var(--margin-line); }

.day-dow, .day-num {
  color: var(--faint-ink);
  font-family: var(--mono);
  font-size: 0.62rem;
  line-height: 1;
}

.day.is-today .day-dow, .day.is-today .day-num { color: var(--ink); font-weight: 600; }

.day-track {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 62px;
  border-radius: 4px;
  background: var(--inset);
  box-shadow: inset 0 0 0 1px var(--line-soft);
  overflow: hidden;
}

.day-fill {
  width: 100%;
  min-height: 2px;
  border-radius: 4px;
  background: rgb(var(--heat));
  transition: height 400ms ease;
}

.day[data-level="0"] .day-fill { background: transparent; }
.day[data-level="1"] .day-fill { background: rgba(var(--heat), 0.32); }
.day[data-level="2"] .day-fill { background: rgba(var(--heat), 0.52); }
.day[data-level="3"] .day-fill { background: rgba(var(--heat), 0.74); }
.day[data-level="4"] .day-fill { background: rgb(var(--heat)); }

.day-tasks {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}

.day-tasks span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--graphite);
}

.history-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.legend-scale { display: flex; align-items: center; gap: 4px; }

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--line-soft);
}

.legend-swatch.level-1 { background: rgba(var(--heat), 0.32); }
.legend-swatch.level-2 { background: rgba(var(--heat), 0.52); }
.legend-swatch.level-3 { background: rgba(var(--heat), 0.74); }
.legend-swatch.level-4 { background: rgb(var(--heat)); }

/* ------------------------------------------------------------------ *
 * Footer + toasts
 * ------------------------------------------------------------------ */

.footnote {
  display: grid;
  gap: 8px;
  max-width: 760px;
  margin: 20px 0 0;
  font-size: 0.88rem;
}

.shortcuts { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

kbd {
  border: 1px solid var(--margin-line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--field);
  color: var(--graphite);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 1px 5px;
}

code {
  border: 1px solid var(--margin-line);
  border-radius: 4px;
  background: var(--field);
  color: var(--graphite);
  padding: 1px 5px;
}

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100% - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid var(--margin-line);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius-sm);
  background: var(--parchment);
  box-shadow: var(--shadow-lifted);
  color: var(--ink);
  font-size: 0.88rem;
  padding: 11px 13px;
  pointer-events: auto;
  animation: toast-in 220ms ease;
}

.toast.is-error { border-left-color: var(--danger); }
.toast.is-leaving { animation: toast-out 200ms ease forwards; }
.toast strong { font-weight: 600; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */

@media (max-width: 1020px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two { grid-template-columns: 1fr; }
  .task-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Drop the soundtrack below the timer rather than squeezing three columns. */
  .focus-body { grid-template-columns: auto minmax(0, 1fr); }
  .soundtrack {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid var(--line-soft);
    padding-left: 0;
    padding-top: 14px;
  }
}

@media (max-width: 700px) {
  .shell { width: calc(100% - 24px); }
  h1 { font-size: 2.15rem; }
  /* A sticky header would eat a third of a phone viewport. */
  .topbar {
    position: static;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    backdrop-filter: none;
  }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .vault-chip { max-width: 18ch; }
  .disclosure > summary { flex-wrap: wrap; }
  .detail-hint { display: none; }
  .stats { grid-template-columns: 1fr; }
  .metric { min-height: 0; }
  .task-fields, .habit-fields { grid-template-columns: 1fr; }
  .focus-body { grid-template-columns: 1fr; justify-items: center; }
  .focus-controls { width: 100%; }
  .soundtrack { width: 100%; }
  /* Four transport buttons in one flex row wrap mid-word on a phone. */
  .button-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .day-track { height: 48px; }
  .toasts { right: 12px; bottom: 12px; }
}

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