/* ============================================================ fonts */
/* Cormorant Garamond for the greeting, quote and box titles; Source Sans 3 for everything else;
   Source Code Pro for the clock and timers. All SIL Open Font License (OFL-*.txt beside them),
   bundled so they work offline and never call out to a font service. */
@font-face {
  font-family: "Cormorant Garamond";
  src: url("/static/fonts/cormorant-garamond-latin-var.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("/static/fonts/cormorant-garamond-italic-latin-var.woff2") format("woff2");
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("/static/fonts/source-sans-3-latin-var.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: "Source Code Pro";
  src: url("/static/fonts/source-code-pro-latin-var.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}

/* ============================================================ tokens */
:root {
  --bg: #1e1f22;
  --surface: #2b2d31;
  --raised: #313338;
  --hover: #3a3c42;
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.1);
  --text: #dbdee1;
  --text-strong: #f2f3f5;
  --muted: #949ba4;
  --faint: #6d737d;
  --accent: #5865f2;
  --glow: #3f8cff;
  --ok: #23a55a;

  --q1: #ed4245;
  --q2: #5865f2;
  --q3: #f0b232;
  --q4: #80848e;

  --glass: rgba(35, 36, 40, 0.72);
  --glass-strong: rgba(43, 45, 49, 0.9);
  --radius: 14px;
  --radius-sm: 8px;
  --font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Cormorant Garamond", Garamond, Georgia, "Times New Roman", serif;
  --mono: "Source Code Pro", ui-monospace, "Cascadia Code", Consolas, monospace;

  --bg-img: none;
  --scrim: 0;
  --halo: 0 0 2px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 0.75), 0 1px 14px rgba(0, 0, 0, 0.6);
  --bg-pos: center 22%;
  --bg-pos-m: 48% 0;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

/* ============================================================ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
svg { display: block; }
h1, h2, p { margin: 0; }
::selection { background: rgba(88, 101, 242, 0.45); }

/* ============================================================ backdrop */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    /* extra shade over bright pictures: --scrim is measured per picture when it's uploaded */
    linear-gradient(180deg, rgba(8, 9, 12, var(--scrim)) 0%, rgba(8, 9, 12, calc(var(--scrim) * 0.75)) 45%, rgba(8, 9, 12, 0) 75%),
    /* readability tint for the header (the matrix's extra darkening is ::before) */
    linear-gradient(180deg, rgba(16, 17, 20, 0.5) 0%, rgba(20, 21, 24, 0.62) 30%),
    /* soft edge vignette */
    radial-gradient(120% 90% at 50% 20%, transparent 50%, rgba(10, 11, 14, 0.7) 100%),
    var(--bg-img) var(--bg-pos) / cover no-repeat, /* set per backdrop by app.js */
    var(--bg);
}
/* plain colour: shown as chosen (every palette colour is dark enough for the header text) */
:root.colour-bg .backdrop { background: var(--bg-img); }
.backdrop::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(22, 23, 26, 0.68) 75%, var(--bg) 100%);
  transition: opacity 1.2s ease;
}
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 300px;
  background: linear-gradient(90deg, rgba(12, 13, 16, 0.6) 0%, rgba(12, 13, 16, 0.3) 35%, transparent 52%,
    transparent 70%, rgba(12, 13, 16, 0.3) 85%, rgba(12, 13, 16, 0.6) 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent);
  mask-image: linear-gradient(180deg, #000 55%, transparent);
}

/* ============================================================ header */
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: calc(28px + var(--safe-t)) 40px 20px 72px;
  flex: none;
}
.eyebrow {
  max-width: 90ch;
  text-wrap: balance;
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: #9fc4ff;
  text-shadow: var(--halo);
  margin-bottom: 8px;
}
.bg-next {
  width: 24px;
  height: 24px;
  margin-left: 4px;
  vertical-align: middle;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #9fc4ff;
  background: rgba(20, 21, 24, 0.55);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s, color 0.15s, transform 0.3s, opacity 0.35s;
}
.bg-next[hidden] { display: none; }
.bg-next svg { width: 13px; height: 13px; }
.bg-next:hover { background: rgba(20, 21, 24, 0.85); color: #fff; }
#bg-next:active { transform: rotate(120deg); }
/* the quote: click to edit in place */
#quote { cursor: text; border-radius: 4px; }
.eyebrow.editing #quote { display: inline-block; min-width: 12ch; outline: 1px dashed rgba(159, 196, 255, 0.6); outline-offset: 3px; }
/* no quote: just the buttons; "Add a quote" appears after them on hover (never shifts them) */
.eyebrow.no-quote { display: flex; align-items: center; gap: 4px; }
.eyebrow.no-quote #quote { order: 3; margin-left: 4px; }
.eyebrow.no-quote .bg-next { margin-left: 0; }
#quote:empty::before { content: "Add a quote"; opacity: 0; transition: opacity 0.15s; }
.eyebrow:hover #quote:empty::before, .eyebrow.editing #quote:empty::before { opacity: 0.55; }
.greeting h1 {
  font-family: var(--serif);
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-strong);
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.8), 0 2px 24px rgba(0, 0, 0, 0.6);
}
.greeting h1 .name {
  background: linear-gradient(90deg, #b9d7ff, #7aa8ff 60%, #8f98ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none; /* would paint over the gradient fill */
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.9)) drop-shadow(0 2px 10px rgba(0, 0, 0, 0.6));
}
.summary { margin-top: 6px; color: #c4c9d1; font-size: 14px; text-shadow: var(--halo); }

.clock { text-align: right; flex: none; }
.clock-time {
  font-family: var(--mono);
  font-size: clamp(34px, 4.4vw, 54px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 28px rgba(63, 140, 255, 0.35), 0 2px 18px rgba(0, 0, 0, 0.6);
}
.clock-sec { color: #8fb8ff; opacity: 0.75; font-size: 0.62em; margin-left: 2px; }
.clock-date { margin-top: 6px; color: #c4c9d1; font-size: 14px; font-weight: 500; letter-spacing: 0.02em; text-shadow: var(--halo); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: rgba(30, 31, 34, 0.7);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status[data-state="synced"] .dot { background: var(--ok); box-shadow: 0 0 8px rgba(35, 165, 90, 0.7); }
.status[data-state="syncing"] .dot { background: var(--glow); animation: pulse 1s ease-in-out infinite; }
.status[data-state="offline"] .dot { background: var(--q3); }
.status[data-state="offline"] { color: #f5d38a; }
.status[data-state="signedout"] { color: #f5d38a; cursor: pointer; }
.status[data-state="signedout"] .dot { background: var(--q3); }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ============================================================ voice */
.mic {
  width: 34px;
  height: 34px;
  margin: 10px 0 0 8px;
  vertical-align: top;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #cfe0ff;
  background: rgba(20, 21, 24, 0.7);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.35s;
}
.mic[hidden] { display: none; }
.mic svg { width: 16px; height: 16px; }
.mic .ico-stop, .mic[aria-pressed="true"] .ico-mic { display: none; }
.mic[aria-pressed="true"] .ico-stop { display: block; }
.mic:hover { background: rgba(88, 101, 242, 0.35); color: #fff; }
.mic[aria-pressed="true"] { color: #fff; background: var(--q1); border-color: transparent; animation: mic-rec 1.4s ease-out infinite; }
.mic[data-busy] { opacity: 0.6; pointer-events: none; animation: pulse 1s ease-in-out infinite; }
#speak[aria-pressed="true"] { background: var(--accent); animation: none; } /* reading aloud: tap to stop */

/* ============================================================ settings */
.settings {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
/* light enough to watch the background change behind the panel */
.settings::backdrop { background: rgba(10, 11, 13, 0.3); }
.settings form { display: grid; gap: 10px; }
.settings h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; color: var(--text-strong); margin-bottom: 2px; }
.settings label, .settings-label { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.settings label span, .settings-label span { display: block; font-weight: 400; color: var(--muted); }
.settings-group { display: grid; gap: 10px; margin: 6px 0 4px; }
.bg-tiles { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 2px 6px; } /* wraps, so + is never hidden */
.settings { overflow-y: auto; }
.bg-tile {
  position: relative;
  flex: none;
  width: 72px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg) center / cover no-repeat;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.bg-tile[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.bg-tile:focus-visible { outline: 2px solid var(--text-strong); outline-offset: 2px; }
.bg-tile.add { border-style: dashed; background: transparent; }
.bg-tile.add:hover { color: var(--text-strong); border-color: var(--text); }
.bg-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: rgba(10, 11, 14, 0.75);
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.bg-tile:hover .bg-remove, .bg-tile:focus-within .bg-remove, .bg-remove:focus-visible { opacity: 1; }
@media (hover: none) { .bg-remove { opacity: 1; } }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches[hidden] { display: none; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.12); cursor: pointer; }
.swatch[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.swatch:focus-visible { outline: 2px solid var(--text-strong); outline-offset: 2px; }
/* pictures dragged over the page */
body.dropping::after {
  content: "Drop pictures to add them as backgrounds";
  position: fixed;
  inset: 12px;
  z-index: 100;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(159, 196, 255, 0.75);
  border-radius: 18px;
  background: rgba(10, 11, 14, 0.55);
  color: #dbe6ff;
  font-size: 18px;
  font-weight: 600;
  pointer-events: none;
}
.settings input, .settings textarea {
  font: inherit;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text-strong);
}
.settings input:focus-visible, .settings textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* the task panel: same panel as Settings, plus a notes box, the date and time, and the reminder switch */
.settings textarea { resize: vertical; min-height: 84px; }
#tp-title { overflow-wrap: anywhere; outline: none; }
#welcome-title { outline: none; }
/* date + time read as one quiet field: a hairline between them, the chip's mono digits, dim picker icons */
.tp-when {
  display: flex;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
.tp-when:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.settings .tp-when input {
  min-width: 0;
  padding: 8px 10px 8px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 13.5px;
  letter-spacing: -0.01em;
}
.settings .tp-when input:focus-visible { outline: none; }
.tp-when input[type="date"] { flex: 1; }
.tp-when input[type="time"] { width: 9em; border-left: 1px solid var(--line-strong); } /* room for "08:00 AM" + icon */
.settings .tp-when input.empty { color: var(--faint); } /* nothing picked yet: the mm/dd/yyyy and --:-- stay quiet */
.tp-when input::-webkit-calendar-picker-indicator { opacity: 0.4; cursor: pointer; transition: opacity 0.15s; }
.tp-when input:hover::-webkit-calendar-picker-indicator,
.tp-when input:focus::-webkit-calendar-picker-indicator { opacity: 0.85; }
.settings .tp-remind { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 8px; margin-top: 4px; cursor: pointer; }
.settings .tp-remind span { grid-column: 2; }
.settings .tp-remind input { width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
.settings .tp-remind input:disabled { cursor: default; }
/* sign-in: the welcome and landing panel, and your key in Settings */
.welcome[open] { display: grid; gap: 14px; }
.welcome .landing { display: grid; gap: 18px; }
.welcome [hidden] { display: none; }
.welcome-note { font-size: 13px; color: var(--muted); }
.welcome-note[role="alert"] { color: #f5d38a; }
.welcome-note a { color: var(--text-strong); }
.welcome::backdrop { background: rgba(10, 11, 13, 0.55); }
/* nobody is signed in on this device: there's no board to show behind the landing */
body.signed-out .matrix-wrap, body.signed-out .tabbar, body.signed-out .greeting, body.signed-out .mic, body.signed-out .status { visibility: hidden; }
.set-key { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.set-key code { font-family: var(--mono); font-weight: 500; margin-left: 4px; user-select: all; }
.set-key span { display: block; font-weight: 400; color: var(--muted); }
.settings-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.settings-actions button {
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.settings-actions .primary { background: var(--accent); border-color: transparent; color: #fff; }
.settings-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@keyframes mic-rec { 0% { box-shadow: 0 0 0 0 rgba(237, 66, 69, 0.6); } 100% { box-shadow: 0 0 0 12px rgba(237, 66, 69, 0); } }
.voice-log {
  margin-top: 6px;
  max-width: 70ch;
  font-size: 13px;
  color: #c4c9d1;
  white-space: pre-line;
  text-shadow: var(--halo);
}
.voice-log[data-tone="error"] { color: #ffb4b5; }
/* a reminder firing: stays until Dismiss or a snooze */
.reminder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 8px;
  max-width: 70ch;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  text-shadow: var(--halo);
}
.reminder[hidden] { display: none; }
.reminder-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.reminder button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--glass-strong);
  color: var(--text);
  text-shadow: none;
  cursor: pointer;
}
.reminder button:hover { color: var(--text-strong); border-color: rgba(255, 255, 255, 0.25); }
.reminder button:first-child { background: var(--accent); border-color: transparent; color: #fff; }
.reminder button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================ matrix layout */
.matrix-wrap {
  /* Track sizes shared by the matrix and its axis labels; an expanded box
     takes the big tracks and the others shrink to --mini-w / --mini-h. */
  --cols: minmax(0, 1fr) minmax(0, 1fr);
  --rows: minmax(0, 1fr) minmax(0, 1fr);
  --mini-w: 280px;
  --mini-h: 60px;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 32px 1fr;
  grid-template-rows: auto 1fr;
  gap: 8px 8px;
  padding: 0 40px 28px 32px;
}
.axis {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  display: grid;
  gap: 16px;
  text-shadow: 0 1px 8px rgba(0,0,0,.8);
}
.matrix-wrap[data-focus="1"] { --cols: minmax(0, 1fr) var(--mini-w); --rows: minmax(0, 1fr) var(--mini-h); }
.matrix-wrap[data-focus="2"] { --cols: var(--mini-w) minmax(0, 1fr); --rows: minmax(0, 1fr) var(--mini-h); }
.matrix-wrap[data-focus="3"] { --cols: minmax(0, 1fr) var(--mini-w); --rows: var(--mini-h) minmax(0, 1fr); }
.matrix-wrap[data-focus="4"] { --cols: var(--mini-w) minmax(0, 1fr); --rows: var(--mini-h) minmax(0, 1fr); }
.axis-top { grid-column: 2; grid-row: 1; grid-template-columns: var(--cols); text-align: center; }
.axis-side { grid-column: 1; grid-row: 2; grid-template-rows: var(--rows); }
/* vertical labels don't fit beside a shrunken strip */
.matrix-wrap[data-focus="1"] .axis-side span:last-child,
.matrix-wrap[data-focus="2"] .axis-side span:last-child,
.matrix-wrap[data-focus="3"] .axis-side span:first-child,
.matrix-wrap[data-focus="4"] .axis-side span:first-child { visibility: hidden; }
.axis-side span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.matrix {
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--cols);
  grid-template-rows: var(--rows);
  gap: 16px;
}

/* ============================================================ quadrant */
.quadrant {
  --qc: var(--accent);
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.quadrant::before {
  /* coloured top edge */
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--qc), transparent 85%);
  opacity: 0.9;
}
.quadrant[data-q="1"] { --qc: var(--q1); }
.quadrant[data-q="2"] { --qc: var(--q2); }
.quadrant[data-q="3"] { --qc: var(--q3); }
.quadrant[data-q="4"] { --qc: var(--q4); }
.quadrant.drop-target {
  border-color: color-mix(in srgb, var(--qc) 55%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--qc) 35%, transparent), 0 10px 40px rgba(0,0,0,.4);
}

.q-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
  flex: none;
}
.q-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--qc);
  background: color-mix(in srgb, var(--qc) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--qc) 28%, transparent);
}
.q-titles { flex: 1; min-width: 0; }
.q-titles h2 { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--text-strong); line-height: 1.15; }
.q-titles p { font-size: 12px; color: var(--muted); margin-top: 1px; }
.q-count {
  min-width: 26px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
.q-head { cursor: pointer; user-select: none; -webkit-user-select: none; border-radius: var(--radius) var(--radius) 0 0; }
.q-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.q-expand {
  flex: none;
  width: 28px;
  height: 28px;
  margin-right: -4px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--faint);
  transition: color 0.15s, background 0.15s;
}
.q-expand svg { width: 15px; height: 15px; }
.q-head:hover .q-expand { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.q-expand .ico-collapse, .quadrant.focus .q-expand .ico-expand { display: none; }
.quadrant.focus .q-expand .ico-collapse { display: block; }

/* ============================================================ task list */
.task-list {
  list-style: none;
  margin: 0;
  padding: 2px 10px 6px;
  flex: 1;
  min-height: 48px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #1a1b1e transparent;
}
.task-list::-webkit-scrollbar { width: 8px; }
.task-list::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 8px; }
.task-list:empty::before {
  content: "Nothing here. Enjoy the view.";
  display: block;
  padding: 18px 8px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
}
.quadrant[data-q="1"] .task-list:empty::before { content: "No fires to put out."; }
.quadrant[data-q="2"] .task-list:empty::before { content: "Plan something that matters."; }
.quadrant[data-q="3"] .task-list:empty::before { content: "Nothing to hand off."; }
.quadrant[data-q="4"] .task-list:empty::before { content: "Nothing to drop."; }

.task {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px 9px 10px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  background: rgba(49, 51, 56, 0.55);
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, opacity 0.25s, transform 0.25s;
}
.task:hover { background: rgba(58, 60, 66, 0.8); border-color: var(--line); }
.task.editing { background: var(--raised); border-color: var(--line-strong); }

.check {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--qc) 75%, transparent);
  display: grid;
  place-items: center;
  color: transparent;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.check svg { width: 12px; height: 12px; }
.check:hover { background: color-mix(in srgb, var(--qc) 22%, transparent); color: var(--qc); }
.check:active { transform: scale(0.9); }
.task.completing .check { background: var(--qc); color: #fff; }
.task.completing { opacity: 0; transform: translateX(24px); }

.task-body { flex: 1; min-width: 0; }
.task-title {
  color: var(--text-strong);
  font-weight: 500;
  word-wrap: break-word;
  outline: none;
  border-radius: 4px;
  cursor: text;
}
.task-title[contenteditable="true"] { box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.5); padding: 0 3px; margin: 0 -3px; }

.task-meta {
  display: flex;
  flex-wrap: wrap; /* on a narrow card the due chip drops to its own line rather than squeezing the timer */
  align-items: center;
  gap: 4px 10px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.elapsed { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.elapsed svg { width: 12px; height: 12px; opacity: 0.8; }
.elapsed time { font-family: var(--mono); font-size: 11.5px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.elapsed.stale { color: #f5a97a; }
.elapsed.old { color: #f38b8d; }

/* details button (opens the task panel): tinted when the task has notes */
.details { display: inline-flex; align-items: center; gap: 4px; color: var(--faint); border-radius: 4px; padding: 1px 3px; }
.details svg { width: 13px; height: 13px; }
.details:hover { color: var(--text); background: rgba(255,255,255,.06); }
.task.has-notes .details { color: #9fb2ff; }

/* due chip: quiet; amber on the day and red once late (the age timer's 3-day and 1-week colours) */
.due-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 17px;
  white-space: nowrap;
  cursor: pointer;
}
.due-chip[hidden] { display: none; }
.due-chip:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.22); }
.due-chip .bell { display: none; width: 11px; height: 11px; }
.due-chip.remind .bell { display: block; }
.due-chip[data-state="today"] { color: #f5a97a; border-color: rgba(245, 169, 122, 0.45); }
.due-chip[data-state="late"] { color: #f38b8d; border-color: rgba(243, 139, 141, 0.5); }

.task.ringing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 18px rgba(88, 101, 242, 0.45); }

.task-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.task:hover .task-actions, .task:focus-within .task-actions { opacity: 1; }
.handle, .del {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
}
.handle { cursor: grab; }
.handle svg, .del svg { width: 15px; height: 15px; }
.handle:hover { background: rgba(255,255,255,.06); color: var(--text); }
.del:hover { background: rgba(237, 66, 69, 0.15); color: var(--q1); }

/* "Immediate" tag: the single up-next task, pinned to the top of Do */
.imm { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); }
.imm svg { width: 15px; height: 15px; }
.imm:hover { background: rgba(237, 66, 69, 0.14); color: #ff8a8c; }
.imm[aria-pressed="true"] { color: #ff8a8c; }
.imm[aria-pressed="true"] path { fill: currentColor; }

.imm-chip { display: none; }
.task.immediate {
  padding: 12px 10px 11px 14px;
  margin-bottom: 8px;
  background: linear-gradient(120deg, rgba(237, 66, 69, 0.22), rgba(49, 51, 56, 0.72) 65%);
  border-color: rgba(237, 66, 69, 0.45);
  animation: imm-glow 3.2s ease-in-out infinite;
}
.task.immediate::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--q1);
  box-shadow: 0 0 10px rgba(237, 66, 69, 0.8);
}
.task.immediate:hover { background: linear-gradient(120deg, rgba(237, 66, 69, 0.28), rgba(58, 60, 66, 0.85) 65%); border-color: rgba(237, 66, 69, 0.6); }
.task.immediate .imm-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ff8a8c;
}
.task.immediate .imm-chip svg { width: 11px; height: 11px; filter: drop-shadow(0 0 4px rgba(237, 66, 69, 0.9)); }
.task.immediate .imm-chip span { color: var(--muted); font-weight: 600; letter-spacing: 0.04em; text-transform: none; }
.task.immediate .task-title { font-size: 16px; font-weight: 650; }
.task.immediate .check { width: 22px; height: 22px; margin-top: 16px; border-color: var(--q1); }
.task.immediate .task-actions { opacity: 1; }
@keyframes imm-glow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(237, 66, 69, 0.12), 0 6px 20px rgba(237, 66, 69, 0.12); }
  50% { box-shadow: 0 0 0 1px rgba(237, 66, 69, 0.3), 0 6px 26px rgba(237, 66, 69, 0.28); }
}
.summary-next { display: inline-block; color: #ff9b9d; font-weight: 600; }

/* SortableJS states */
.task.sortable-ghost { opacity: 0.35; background: color-mix(in srgb, var(--qc) 20%, transparent); }
.task.sortable-chosen { background: var(--raised); }
.task.sortable-drag { box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5); border-color: var(--line-strong); }

/* ============================================================ add form */
.add-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 10px 12px;
  padding: 0 12px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(30, 31, 34, 0.7);
  border: 1px solid var(--line);
  flex: none;
  transition: border-color 0.15s, background 0.15s;
}
.add-form:focus-within { border-color: color-mix(in srgb, var(--qc) 60%, transparent); background: rgba(30, 31, 34, 0.9); }
.add-plus { color: var(--qc); font-size: 18px; font-weight: 600; line-height: 1; }
.add-form input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: none;
  border: 0;
  outline: none;
  color: var(--text-strong);
  font: inherit;
}
.add-form input::placeholder { color: var(--faint); }

/* ============================================================ expanded / shrunken boxes */
/* Shrunken boxes: header plus (where there's room) a compact list of titles. */
.quadrant.mini { cursor: pointer; }
.quadrant.mini:hover { border-color: color-mix(in srgb, var(--qc) 45%, transparent); }
.quadrant.mini .q-head { padding: 12px 14px; gap: 10px; }
.quadrant.mini .q-icon { width: 28px; height: 28px; font-size: 13px; }
.quadrant.mini .q-titles p,
.quadrant.mini .add-form { display: none; }
.quadrant.mini .task-list { overflow: hidden; padding-top: 0; }
/* the two boxes in the shrunken row are header-only strips */
.matrix-wrap:is([data-focus="1"], [data-focus="2"]) .quadrant:is([data-q="3"], [data-q="4"]) .task-list,
.matrix-wrap:is([data-focus="3"], [data-focus="4"]) .quadrant:is([data-q="1"], [data-q="2"]) .task-list { display: none; }
.quadrant.mini .task-list:empty::before { padding: 6px 8px; font-size: 12px; text-align: left; }
.quadrant.mini .task {
  pointer-events: none;
  padding: 6px 10px;
  margin-bottom: 3px;
  animation: none;
  box-shadow: none;
}
.quadrant.mini .task .check,
.quadrant.mini .task .task-meta,
.quadrant.mini .task .task-actions,
.quadrant.mini .task .imm-chip { display: none; }
.quadrant.mini .task-title,
.quadrant.mini .task.immediate .task-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Expanded box on wider screens: tasks flow into columns so more fit at once. */
@media (min-width: 768px) {
  .quadrant.focus .task-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    align-content: start;
    gap: 6px;
  }
  .quadrant.focus .task { margin-bottom: 0; }
  .quadrant.focus .task.immediate,
  .quadrant.focus .task-list:empty::before { grid-column: 1 / -1; }
}

/* Morph animation between layouts (browsers with View Transitions). */
.vt .quadrant[data-q="1"] { view-transition-name: q1; }
.vt .quadrant[data-q="2"] { view-transition-name: q2; }
.vt .quadrant[data-q="3"] { view-transition-name: q3; }
.vt .quadrant[data-q="4"] { view-transition-name: q4; }
::view-transition-group(q1), ::view-transition-group(q2),
::view-transition-group(q3), ::view-transition-group(q4) {
  animation-duration: 0.3s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: clip;
  border-radius: var(--radius);
}
::view-transition-old(q1), ::view-transition-new(q1),
::view-transition-old(q2), ::view-transition-new(q2),
::view-transition-old(q3), ::view-transition-new(q3),
::view-transition-old(q4), ::view-transition-new(q4) {
  height: 100%;
  object-fit: none;
  object-position: left top;
}

/* ============================================================ toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 10px 10px 16px;
  border-radius: 10px;
  background: #111214;
  border: 1px solid var(--line-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  font-size: 14px;
  z-index: 50;
  max-width: calc(100vw - 32px);
  animation: toast-in 0.2s ease-out;
}
.toast[hidden] { display: none; }
.toast #toast-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button {
  flex: none;
  padding: 6px 14px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}
.toast button:hover { background: #4752c4; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ============================================================ tab bar (mobile) */
.tabbar { display: none; }

/* ============================================================ idle */
.matrix-wrap, .tabbar { transition: opacity 0.35s ease, visibility 0s; }
body.idle .matrix-wrap, body.idle .tabbar {
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.2s ease, visibility 0s 1.2s;
}
body.idle .backdrop::before { opacity: 0; }
/* the buttons go too (🎤 🔊 ⚙ and the picture buttons by the quote): the idle screen is words and the clock */
body.idle :is(.clock .mic, .eyebrow .bg-next) {
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.2s ease, visibility 0s 1.2s;
}
/* Weekly stats: idle screen only, styled like the summary line above it. */
.week-stats { display: none; margin-top: 4px; font-size: 14px; color: #c4c9d1; text-shadow: var(--halo); }
body.idle .week-stats { display: block; animation: week-in 1.2s ease both; }
@keyframes week-in { from { opacity: 0; } }
body.idle { cursor: pointer; }

/* ============================================================ responsive */
@media (max-width: 1100px) {
  .topbar { padding-left: 40px; }
}

@media (max-width: 767px) {
  body { overflow: auto; display: block; }
  .backdrop {
    background:
      linear-gradient(180deg, rgba(8, 9, 12, var(--scrim)) 0%, rgba(8, 9, 12, calc(var(--scrim) * 0.75)) 40%, rgba(8, 9, 12, 0) 62vh),
      linear-gradient(180deg, rgba(16, 17, 20, 0.45) 0%, rgba(20, 21, 24, 0.62) 30%, rgba(22, 23, 26, 0.92) 60%, var(--bg) 100%),
      var(--bg-img) var(--bg-pos-m) / auto 62vh no-repeat,
      var(--bg);
  }
  .backdrop::before { display: none; } /* phone gradient also blends the image's bottom edge */
  .backdrop::after {
    height: 340px;
    background: linear-gradient(90deg, rgba(12, 13, 16, 0.55) 0%, rgba(12, 13, 16, 0.35) 60%, rgba(12, 13, 16, 0.2) 100%);
  }
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: calc(22px + var(--safe-t)) 16px 18px;
  }
  .clock {
    text-align: left;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 12px;
  }
  .clock-date { margin-top: 0; }
  .status { margin-top: 8px; flex-basis: auto; }

  .matrix-wrap { display: block; padding: 0 12px calc(84px + var(--safe-b)); }
  .axis { display: none; }
  .matrix { display: flex; flex-direction: column; gap: 14px; }
  .quadrant { overflow: visible; scroll-margin-top: 12px; }
  .quadrant::before { border-radius: var(--radius) var(--radius) 0 0; }
  .task-list { overflow: visible; flex: none; }
  .quadrant.mini .task-list { display: none; } /* shrunken = header bar only */
  .task-actions { opacity: 1; }
  .handle, .del, .imm { width: 32px; height: 32px; }
  .check { width: 22px; height: 22px; }
  .add-form { height: 44px; }
  .add-form input, #task-panel input, #task-panel textarea { font-size: 16px; } /* prevents iOS zoom on focus */

  .tabbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + var(--safe-b));
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 5px;
    border-radius: 14px;
    background: rgba(17, 18, 20, 0.85);
    border: 1px solid var(--line-strong);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px 5px;
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    position: relative;
  }
  .tabbar a.active { background: rgba(255, 255, 255, 0.07); color: var(--text-strong); }
  .tab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--qc); }
  .tabbar a[data-q="1"] { --qc: var(--q1); }
  .tabbar a[data-q="2"] { --qc: var(--q2); }
  .tabbar a[data-q="3"] { --qc: var(--q3); }
  .tabbar a[data-q="4"] { --qc: var(--q4); }
  .tabbar b {
    position: absolute;
    top: 3px;
    right: calc(50% - 22px);
    font-size: 10px;
    font-weight: 700;
    color: var(--text);
    opacity: 0.7;
  }
  .tabbar b:empty, .tabbar b[data-zero] { display: none; }
  .toast { bottom: calc(86px + var(--safe-b)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
