/* Daybook website. Same colours as the phone app (apps/android/.../ui/Theme.kt).
   Light: cool paper, ink blue, a highlighter stroke behind view titles.
   Dark: neutral charcoal with tasks on raised cards, and each view in its own colour. */

:root {
  color-scheme: light;
  --paper: #f6f7f9;
  --surface: #ffffff;
  --sunken: #eef1f5;
  --ink: #1c2633;
  --muted: #637083;
  --rule: #dde2e9;
  --accent: #2b4c7e;
  --accent-soft: #e3eaf5;
  --on-accent: #ffffff;
  --highlight: #f5d547;
  --star: #b7791f;
  --late: #b4432a;
  --ok: #3a9a5b;
  --warn: #d08a1e;
  --myday: #c47e0a;
  --important: #b83b66;
  --planned: #17786c;
  --calendar: #6b4fa8;
  --p1: #d1453b;
  --p2: #db7a06;
  --p3: #246fe0;
  --list-red: #d1453b;
  --list-orange: #db7a06;
  --list-yellow: #b8900a;
  --list-green: #2f9a4c;
  --list-teal: #17867a;
  --list-blue: #2f6fd6;
  --list-purple: #7a4fc4;
  --list-pink: #c2407a;
  --list-grey: #74808f;
  --view: var(--accent);
  --shadow: rgb(20 30 50 / 0.35);

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;

  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.0625rem;
  --step-4: 2.75rem;

  --sidebar: 264px;
  --detail: 368px;
  --radius-row: 6px;
  --radius-panel: 12px;
}

/* Set on <html> by the script in index.html: the theme picked in Settings, or the system's. */
:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #1e1e1e;
  --surface: #2b2b2b;
  --sunken: #333333;
  --ink: #f3f3f3;
  --muted: #ababab;
  --rule: #3a3a3a;
  --accent: #7ca3f7;
  --accent-soft: #2a3446;
  --on-accent: #121212;
  --highlight: #b89a24;
  --star: #f28aaa;
  --late: #ff8a80;
  --ok: #5cbf7d;
  --warn: #e0a24a;
  --myday: #f0b429;
  --important: #f28aaa;
  --planned: #4fc1b0;
  --calendar: #b59cf2;
  --p1: #ff7066;
  --p2: #ff9a14;
  --p3: #5297ff;
  --list-red: #ff7a70;
  --list-orange: #ffa040;
  --list-yellow: #f2c94c;
  --list-green: #5ccf7d;
  --list-teal: #4fc1b0;
  --list-blue: #6ea8ff;
  --list-purple: #b59cf2;
  --list-pink: #f28aaa;
  --list-grey: #a0a8b4;
  --shadow: rgb(0 0 0 / 0.6);
}

/* Each view's colour: its add box, checkboxes, and (in dark) its title. */
[data-view='myday'] { --view: var(--myday); }
[data-view='important'] { --view: var(--important); }
[data-view='planned'] { --view: var(--planned); }
[data-view='calendar'] { --view: var(--calendar); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--step-0) / 1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
.app.with-detail { grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--detail); }

/* ---- Sidebar ---------------------------------------------------------------------------- */

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rule);
  padding: 20px 12px 12px;
  overflow-y: auto;
  min-height: 0;
}
.brand {
  font: 600 1.375rem/1 var(--serif);
  letter-spacing: -0.01em;
  padding: 2px 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand svg { width: 22px; height: 22px; }
.brand .menu-close { display: none; margin-left: auto; }
.theme-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--step-0); color: var(--ink); }
.settings-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-row);
  background: none;
  text-align: left;
}
.settings-button:hover { background: var(--sunken); }
.settings-button svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.settings-dialog { width: min(420px, calc(100vw - 32px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 0 24px; }
.sheet-head h2 { margin: 0; font: 600 1.35rem/1.2 var(--serif); }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.nav + .nav { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rule); }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-row);
  background: none;
  text-align: left;
}
.nav-item:hover { background: var(--sunken); }
.nav-item[aria-current='page'] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.nav-item[aria-current='page'] svg { color: var(--accent); }
.nav-item[data-view] svg { color: var(--view); }
.nav-item[data-view='trash'] svg { color: var(--p1); }
.nav-item[data-view][aria-current='page'] { color: var(--view); background: color-mix(in srgb, var(--view) 14%, transparent); }
.nav-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: var(--step--1); color: var(--muted); font-variant-numeric: tabular-nums; }

.new-list { margin-top: 6px; }
.new-list input {
  width: 100%;
  border: 0;
  border-radius: var(--radius-row);
  padding: 8px 10px 8px 40px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23637083' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E") 10px 50% / 18px no-repeat;
}
.new-list input::placeholder { color: var(--muted); }
.new-list input:focus { background-color: var(--surface); outline: 1px solid var(--rule); }

.sync {
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--rule);
  font-size: var(--step--1);
  color: var(--muted);
  display: grid;
  gap: 8px;
}
.sync-line { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--late); }
.link-button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  text-align: left;
  font-weight: 600;
}
.link-button:hover { text-decoration: underline; }

/* ---- Main ------------------------------------------------------------------------------- */

.main { overflow-y: auto; min-height: 0; }
.main-inner { max-width: 880px; margin: 0 auto; padding: 40px 32px 80px; }

.topbar { display: none; }

.view-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.view-title {
  margin: 0;
  font: 600 var(--step-4)/1.05 var(--serif);
  letter-spacing: -0.02em;
  /* The highlighter swipe: Daybook's one bold mark. */
  background: linear-gradient(transparent 58%, var(--highlight) 58%, var(--highlight) 92%, transparent 92%) no-repeat 0 0 / 100% 100%;
  padding: 0 4px;
  margin-left: -4px;
  outline: none;
  border-radius: 2px;
}
.view-title[contenteditable='true']:hover { box-shadow: 0 0 0 1px var(--rule); }
.view-title[contenteditable='true']:focus { box-shadow: 0 0 0 2px var(--accent); }
.view-sub { color: var(--muted); font: var(--step-1)/1.4 var(--serif); margin: 0 0 28px; }
.view-menu { position: relative; }
/* Sort sits at the right end of the view's header, before the list's ⋯ menu. */
.sort-wrap { margin-left: auto; position: relative; align-self: center; }
.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  background: none;
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: var(--step--1);
  white-space: nowrap;
}
.sort-button svg { width: 17px; height: 17px; }
.sort-button:hover { background: var(--sunken); color: var(--ink); }
.sort-button.on { color: var(--view); border-color: color-mix(in srgb, var(--view) 35%, var(--rule)); font-weight: 600; }
.sort-menu { min-width: 210px; }
.sort-menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sort-menu button svg { width: 15px; height: 15px; color: var(--view); }
.sort-menu button.on { color: var(--view); font-weight: 600; }
.sort-menu button.quiet { color: var(--muted); border-top: 1px solid var(--rule); border-radius: 0 0 6px 6px; margin-top: 4px; }
.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
}
.icon-button:hover { background: var(--sunken); color: var(--ink); }
.icon-button svg { width: 20px; height: 20px; }
.menu {
  position: absolute;
  right: 0;
  top: 38px;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 12px 32px -12px var(--shadow);
  z-index: 5;
}
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: var(--sunken); }
.menu .danger { color: var(--late); }

.add {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0 14px;
}
.add:focus-within { border-color: var(--view); }
.add svg { width: 20px; height: 20px; color: var(--view); flex: none; }
.add input { flex: 1; border: 0; background: none; padding: 14px 0; outline: none; font-size: var(--step-1); }
.add input::placeholder { color: var(--muted); }
.hints:empty { display: none; }
.hints { padding: 6px 2px 0 46px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--step--1); color: var(--accent); }
.hint-help { color: var(--muted); }

.tasks { list-style: none; margin: 18px 0 0; padding: 0; }
.task {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  margin: 0 -12px;
  border-radius: var(--radius-row);
  cursor: pointer;
  border-bottom: 1px solid var(--rule);
}
.task:hover { background: var(--sunken); }
.task.selected { background: var(--accent-soft); }
.task-body { flex: 1; min-width: 0; }
.task-title { overflow-wrap: anywhere; font-weight: 600; }
.task.done .task-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--muted); }

/* Drag to reorder: the row being moved fades, and leaves a dashed gap where it will land. */
.task[draggable='true'], .nav-item[draggable='true'] { -webkit-user-drag: element; }
.dragging { opacity: 0.45; }
.task.dragging { outline: 1.5px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
li.dragging .nav-item { outline: 1.5px dashed var(--accent); outline-offset: -2px; }
/* While a task is dragged, the lists in the sidebar show they can take it. */
.task-dragging .nav-item[data-list], .task-dragging .nav-item[data-drop] { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.nav-item.drop-target { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent) !important; }
.nav-item.drop-target svg { color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: calc(100vw - 32px);
  padding: 10px 12px 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 12px 30px -10px var(--shadow);
  font-size: var(--step--1);
  animation: toast-in 160ms ease-out;
}
.toast button { border: 0; background: none; color: inherit; font-weight: 700; padding: 4px 8px; border-radius: 6px; }
.toast button:hover { background: color-mix(in srgb, var(--paper) 18%, transparent); }
@keyframes toast-in { from { transform: translate(-50%, 8px); opacity: 0; } }
.meta { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 2px; font-size: var(--step--1); color: var(--muted); }
.meta span { display: inline-flex; align-items: center; gap: 4px; }
.meta svg { width: 13px; height: 13px; }
.meta .late { color: var(--late); }
.meta .today { color: var(--view); }

.check {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--view);
  background: none;
  padding: 0;
  display: grid;
  place-items: center;
  color: transparent;
}
.check svg { width: 14px; height: 14px; }
.check:hover { color: var(--view); }
.check.on { background: var(--view); color: var(--surface); }
.check.pop { animation: pop 260ms ease-out; }
@keyframes pop { 40% { transform: scale(1.25); } }

.star { border: 0; background: none; padding: 4px; color: var(--muted); line-height: 0; }
.star svg { width: 20px; height: 20px; }
.star.on { color: var(--star); }
.star.on svg { fill: currentColor; }

.done-toggle {
  margin-top: 26px;
  border: 0;
  background: none;
  padding: 6px 0;
  color: var(--muted);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.done-toggle svg { width: 16px; height: 16px; transition: transform 150ms; }
.done-toggle[aria-expanded='true'] svg { transform: rotate(90deg); }

.empty { margin-top: 48px; color: var(--muted); max-width: 46ch; }
.empty p { margin: 0 0 6px; }
.empty .lead { font: var(--step-1)/1.4 var(--serif); color: var(--ink); }

/* Dark: like the phone. Bold sans-serif title in the view's colour, tasks on rounded cards, grey rings. */
[data-theme='dark'] .view-title { font-family: var(--sans); font-weight: 700; color: var(--view); background: none; font-size: 2.25rem; }
[data-theme='dark'] .view-sub { font-family: var(--sans); }
[data-theme='dark'] .add { border-color: transparent; }
[data-theme='dark'] .add:focus-within { border-color: var(--view); }
[data-theme='dark'] .tasks .task { background: var(--surface); border-bottom: 0; margin: 0 0 4px; border-radius: 8px; }
[data-theme='dark'] .tasks .task:hover { background: var(--sunken); }
[data-theme='dark'] .tasks .task.selected { background: color-mix(in srgb, var(--view) 20%, var(--surface)); }
[data-theme='dark'] .check:not(.on) { border-color: var(--muted); }
[data-theme='dark'] .check:not(.on):hover { border-color: var(--view); }
[data-theme='dark'] .star.on { color: var(--important); }
[data-theme='dark'] .sidebar { background: #191919; }
[data-theme='dark'] .detail { background: #252525; }

/* Theme switch, inside Settings */
.theme-switch { display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--sunken); width: fit-content; }
.theme-switch button { border: 0; background: none; padding: 3px 10px; border-radius: 6px; font-size: var(--step--1); color: var(--muted); }
.theme-switch button[aria-pressed='true'] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px var(--shadow); }

/* ---- Detail pane ------------------------------------------------------------------------- */

.detail {
  border-left: 1px solid var(--rule);
  background: var(--surface);
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.detail-inner { padding: 16px 20px 20px; display: grid; gap: 14px; }
.detail-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; }
.detail-top span { font-size: var(--step--1); color: var(--muted); }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.detail-actions .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }
.detail-actions .button svg { width: 15px; height: 15px; }
.detail-title-row { display: flex; align-items: flex-start; gap: 12px; }
.detail-title-row .check { margin-top: 6px; }
.detail-title {
  flex: 1;
  border: 0;
  background: none;
  resize: none;
  font: 600 1.375rem/1.25 var(--serif);
  padding: 2px 4px;
  margin: 0 -4px;
  border-radius: 6px;
  outline: none;
  field-sizing: content;
  min-height: 1.6em;
}
.detail-title:focus { box-shadow: 0 0 0 2px var(--accent); }

.detail-menu { display: grid; gap: 8px; }
.menu-block { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; }
.menu-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: none;
  padding: 12px 14px;
  text-align: left;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.detail-menu > .menu-row { border: 1px solid var(--rule); background: var(--paper); border-radius: 10px; }
.menu-row svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.menu-row.set, .menu-row.on { color: var(--accent); font-weight: 600; }
.menu-row.set svg, .menu-row.on svg { color: var(--accent); }
.menu-row.on, .menu-row.on svg { color: var(--myday); }
.menu-copy { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.menu-hint { color: var(--ink); font-weight: 400; font-size: 0.8125rem; line-height: 1.3; }
.menu-more { display: grid; gap: 8px; padding: 0 14px 12px; }
.menu-more[hidden] { display: none; }
.menu-more .select, .menu-more .input { width: 100%; }
.menu-more .notes { min-height: 88px; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.step { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.step .check { width: 18px; height: 18px; border-width: 1.5px; }
.step .check svg { width: 11px; height: 11px; }
.step span { flex: 1; overflow-wrap: anywhere; }
.step.done span { color: var(--muted); text-decoration: line-through; }
.step .remove { opacity: 0; }
.step:hover .remove, .step .remove:focus-visible { opacity: 1; }
.add-step { display: flex; align-items: center; gap: 10px; }
.add-step .check { width: 18px; height: 18px; border-width: 1.5px; pointer-events: none; }
.add-step input { flex: 1; width: auto; border: 0; border-bottom: 1px solid var(--rule); background: none; padding: 6px 0; outline: none; }
.add-step input:focus { border-color: var(--accent); }

.field { display: grid; gap: 6px; }
.field-label { font-size: var(--step--1); color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip-grid .chip { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 34px; text-align: center; }
.chip-grid .input { width: 100%; min-width: 0; }
#d-duration-none[hidden] { display: none; }
#d-duration-none .chip { width: 100%; }
.chip {
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: var(--step--1);
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.input, .select, .notes {
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 8px;
  padding: 7px 10px;
}
.notes { width: 100%; min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .notes:focus { outline: none; border-color: var(--accent); }
.myday-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
}
.myday-button svg { width: 18px; height: 18px; color: var(--muted); }
.myday-button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.myday-button.on svg { color: var(--on-accent); }
.detail-trash { color: var(--p1); }
.detail-title-row .detail-trash, .detail-title-row .star {
  width: 34px;
  height: 34px;
  margin-top: 2px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: none;
}
.detail-trash:hover, .detail-trash.confirm { color: var(--p1); background: color-mix(in srgb, var(--p1) 14%, transparent); }

.detail-foot {
  margin-top: auto;
  border-top: 1px solid var(--rule);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--step--1);
  color: var(--muted);
}
.delete { border: 0; background: none; color: var(--late); padding: 6px 8px; border-radius: 6px; font-weight: 600; }
.delete:hover { background: color-mix(in srgb, var(--late) 12%, transparent); }

/* ---- Connect-your-phone sheet ---------------------------------------------------------- */

.sheet {
  border: 1px solid var(--rule);
  border-radius: var(--radius-panel);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  box-shadow: 0 24px 60px -20px rgb(20 30 50 / 0.45);
}
.sheet::backdrop { background: rgb(15 20 30 / 0.45); }
/* Settings sits on the page as it is. No blue wash behind it, and no blue shadow. */
.settings-dialog { box-shadow: 0 16px 40px rgb(0 0 0 / 0.45); }
.settings-dialog::backdrop { background: transparent; }
.sheet-inner { padding: 24px; display: grid; gap: 16px; }
.sheet h2 { margin: 0; font: 600 1.5rem/1.2 var(--serif); }
.sheet p { margin: 0; color: var(--muted); }
.sheet ol { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; }
.big-value {
  font: 600 1.75rem/1.2 var(--sans);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 10px 14px;
  user-select: all;
}
.big-value.small { font-size: 1.0625rem; letter-spacing: 0; }
.sheet-actions { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
}
.button.quiet { background: none; color: var(--accent); }

/* Code screen (website opened from another computer) */
.gate { max-width: 420px; margin: 12vh auto 0; padding: 0 24px; display: grid; gap: 16px; }
.gate h1 { margin: 0; font: 600 var(--step-4)/1.05 var(--serif); }
.gate .error { color: var(--late); }

/* ---- Add box choices: due date, reminder, repeat, important ----------------------------- */

.add-options { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 0 2px; }
.opt-wrap { position: relative; }
.opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px 4px 9px;
  font-size: var(--step--1);
  color: var(--muted);
}
.opt svg { width: 15px; height: 15px; flex: none; }
.opt:hover { border-color: var(--view); color: var(--ink); }
.opt.on { border-color: var(--view); color: var(--view); background: color-mix(in srgb, var(--view) 12%, var(--surface)); font-weight: 600; }
.opt[aria-pressed='true'] svg { fill: currentColor; }
.opt-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 6;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 12px 32px -12px var(--shadow);
  display: grid;
  gap: 2px;
}
.pop-item { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 6px; display: flex; justify-content: space-between; gap: 12px; }
.pop-item:hover { background: var(--sunken); }
.pop-item.on { color: var(--view); font-weight: 600; }
.pop-item.quiet { color: var(--muted); }
.pop-sub { color: var(--muted); font-weight: 400; }
.pop-field { display: grid; gap: 4px; padding: 8px 10px; font-size: var(--step--1); color: var(--muted); }
.pop-times { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 6px 2px; }
.pop-times .chip.on { background: var(--view); border-color: var(--view); }

/* ---- List colours, My Day bar, durations, when-late ------------------------------------------ */

.lc-red { --lc: var(--list-red); }
.lc-orange { --lc: var(--list-orange); }
.lc-yellow { --lc: var(--list-yellow); }
.lc-green { --lc: var(--list-green); }
.lc-teal { --lc: var(--list-teal); }
.lc-blue { --lc: var(--list-blue); }
.lc-purple { --lc: var(--list-purple); }
.lc-pink { --lc: var(--list-pink); }
.lc-grey { --lc: var(--list-grey); }
.nav-item[class*='lc-'] svg { color: var(--lc); }
.task.coloured { box-shadow: inset 4px 0 0 var(--lc); }
.meta .list-name[class*='lc-'] { color: var(--lc); font-weight: 600; }
.meta .list-name[class*='lc-'] svg { color: var(--lc); }
.menu-label { padding: 8px 10px 4px; font-size: var(--step--1); color: var(--muted); }
.swatches { display: grid; grid-template-columns: repeat(5, 26px); gap: 6px; padding: 2px 10px 8px; }
/* ".menu button" styles every menu button; these need to win over it to show their colour. */
.menu .swatch { display: block; width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; background: var(--lc); padding: 0; }
.menu .swatch:hover { background: var(--lc); transform: scale(1.12); }
.menu .swatch.none, .menu .swatch.none:hover { background: none; border: 2px dashed var(--muted); }
.menu .swatch.on { outline: 2px solid var(--ink); outline-offset: 2px; }
.myday-bar { display: grid; gap: 8px; margin: -16px 0 16px; justify-items: start; }
.myday-bar:empty { display: none; }
.list-chip { display: inline-flex; align-items: center; gap: 6px; }
.list-chip .dot-list { width: 8px; height: 8px; border-radius: 50%; background: var(--lc); }
.chip-count { font-size: 0.72rem; opacity: 0.75; }
.when-late { display: grid; gap: 6px; margin-top: 6px; }
.when-late[hidden] { display: none; }
.small-select { padding: 3px 6px; font-size: var(--step--1); }

/* ---- Catch-up, hidden-until, recently deleted ---------------------------------------------- */

.catchup {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--view) 30%, var(--rule));
  background: color-mix(in srgb, var(--view) 8%, var(--surface));
}
.catchup-text { margin: 0; }
.link-button.quiet { color: var(--muted); font-weight: 400; }
.meta .later { color: var(--muted); font-style: italic; }
.field-hint { font-size: var(--step--1); color: var(--muted); }
.pop-item.keep { color: var(--view); border-top: 1px solid var(--rule); border-radius: 0 0 6px 6px; margin-top: 2px; }
.nav-extra { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rule); }
.trash-row { cursor: default; }
.trash-row .button.small { flex: none; }

/* ---- Priority flags ---------------------------------------------------------------------------- */

.p1 { --flag: var(--p1); }
.p2 { --flag: var(--p2); }
.p3 { --flag: var(--p3); }
.p4 { --flag: var(--muted); }
/* A priority colours the checkbox ring and lightly fills it, as in Todoist. */
.check.p1, .check.p2, .check.p3,
[data-theme='dark'] .check.p1:not(.on), [data-theme='dark'] .check.p2:not(.on), [data-theme='dark'] .check.p3:not(.on) {
  border-color: var(--flag);
  background: color-mix(in srgb, var(--flag) 14%, transparent);
}
.check.p1:hover, .check.p2:hover, .check.p3:hover { color: var(--flag); }
.check.on.p1, .check.on.p2, .check.on.p3 { background: var(--flag); }
.meta .prio { color: var(--flag); font-weight: 600; }
.meta .prio svg { fill: currentColor; }
.prio-chip { display: inline-flex; align-items: center; gap: 5px; color: var(--flag); }
.prio-chip svg { width: 14px; height: 14px; }
.chip.prio-chip.on { background: color-mix(in srgb, var(--flag) 18%, var(--surface)); border-color: var(--flag); color: var(--flag); font-weight: 600; }
.chip.prio-chip.on svg { fill: currentColor; }
.prio-item span { display: inline-flex; align-items: center; gap: 8px; }
.prio-item svg { width: 16px; height: 16px; color: var(--flag); }
.prio-item.on svg { fill: currentColor; }
.find-check.p1, .find-check.p2, .find-check.p3 { border-color: var(--flag); background: color-mix(in srgb, var(--flag) 14%, transparent); }
.tone-p1 { --tone: var(--p1); }
.tone-p2 { --tone: var(--p2); }
.tone-p3 { --tone: var(--p3); }

/* ---- Task menu (right-click a task) --------------------------------------------------------- */

.task-menu {
  position: fixed;
  z-index: 30;
  width: 270px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 18px 40px -14px var(--shadow);
  display: grid;
  gap: 1px;
}
[data-theme='dark'] .task-menu { background: #2b2b2b; }
.tm-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: none;
  padding: 7px 10px;
  border-radius: 7px;
  text-align: left;
}
.tm-item svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.tm-item:hover, .tm-item:focus-visible { background: var(--sunken); outline: none; }
.tm-text { flex: 1; }
.tm-hint { margin-left: auto; font-size: var(--step--1); color: var(--muted); font-weight: 400; }
.tm-item.current { color: var(--accent); font-weight: 600; }
.tm-item.current svg:last-child { color: var(--accent); width: 15px; height: 15px; }
.tm-item.danger, .tm-item.danger svg { color: var(--late); }
.tm-sub { padding-left: 18px; display: grid; gap: 1px; }
.tm-sep { height: 1px; background: var(--rule); margin: 5px 4px; }
.tm-label { display: flex; align-items: center; gap: 8px; padding: 6px 10px 2px; font-size: var(--step--1); font-weight: 700; }
.tm-row { display: flex; gap: 4px; padding: 2px 6px 4px; }
.tm-icon {
  width: 40px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--muted);
}
.tm-icon svg { width: 21px; height: 21px; }
.tm-icon:hover, .tm-icon:focus-visible { background: var(--sunken); outline: none; }
.tm-icon.on { border-color: var(--rule); background: var(--sunken); }
.tm-icon.today { color: var(--ok); }
.tm-icon.tomorrow { color: var(--warn); }
.tm-icon.nextweek { color: var(--calendar); }
.tm-icon.flag { color: var(--flag); }
.tm-icon.flag:not(.p4) svg { fill: currentColor; }

/* ---- Quick find (search) ------------------------------------------------------------------- */

.search-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 14px;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: left;
}
.search-button:hover { border-color: var(--accent); color: var(--ink); }
.search-button svg { width: 17px; height: 17px; flex: none; }
.search-button span { flex: 1; }
kbd {
  font: 600 0.7rem/1 var(--sans);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 3px 5px;
  color: var(--muted);
  background: var(--paper);
}
.topbar-search { margin-left: auto; }

.find { width: min(660px, calc(100vw - 24px)); margin-top: 9vh; max-height: 78vh; overflow: hidden; }
.find[open] { display: flex; flex-direction: column; }
.find-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.find-head svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.find-head input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: var(--step-1); padding: 6px 0; }
.find-head input::-webkit-search-cancel-button { display: none; }
.find-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--rule); }
.find-filters .chip { cursor: pointer; }
.find-results { overflow-y: auto; padding: 4px 8px 10px; min-height: 90px; }
.find-section { font-size: var(--step--1); font-weight: 600; color: var(--muted); padding: 12px 8px 4px; }
.find-option { display: flex; align-items: flex-start; gap: 12px; padding: 8px; border-radius: 8px; cursor: pointer; }
.find-option.active { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.find-icon { line-height: 0; padding-top: 1px; }
.find-icon svg { width: 18px; height: 18px; color: var(--muted); }
.find-check { width: 18px; height: 18px; margin-top: 2px; flex: none; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; }
.find-check.on { background: var(--muted); color: var(--surface); }
.find-check svg { width: 11px; height: 11px; }
.find-body { flex: 1; min-width: 0; display: grid; gap: 1px; }
.find-title { overflow-wrap: anywhere; }
.find-title.done { text-decoration: line-through; color: var(--muted); }
.find-snippet { font-size: var(--step--1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.find-meta { font-size: var(--step--1); color: var(--muted); }
.find-meta.late { color: var(--late); }
.find-star { line-height: 0; padding-top: 2px; }
.find-star svg { width: 16px; height: 16px; color: var(--important); fill: currentColor; }
.find mark { background: color-mix(in srgb, var(--highlight) 60%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.sheet .find-tip { padding: 12px 8px; font-size: var(--step--1); }
.find-tip b { color: var(--ink); font-weight: 600; }
.find-esc { flex: none; }

/* ---- Calendar -------------------------------------------------------------------------------- */

.main-inner.wide { max-width: 1160px; }
.cal-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; align-self: center; }
.button.small { padding: 4px 14px; font-size: var(--step--1); }
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: var(--step--1); color: var(--muted); margin: -14px 0 14px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend .sw { width: 14px; height: 10px; border-radius: 3px; background: color-mix(in srgb, var(--tone) 22%, transparent); border-left: 3px solid var(--tone); }
.cal-legend .sw.upcoming { background: none; border: 1px dashed var(--tone); }
.cal { border: 1px solid var(--rule); border-radius: var(--radius-panel); overflow: hidden; background: var(--surface); }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-row + .cal-row { border-top: 1px solid var(--rule); }
.cal-wd { padding: 8px 10px; font-size: var(--step--1); color: var(--muted); font-weight: 600; background: var(--sunken); }
.cal-cell {
  min-height: 112px;
  min-width: 0;
  padding: 6px;
  border-left: 1px solid var(--rule);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  outline-offset: -3px;
}
.cal-cell:first-child { border-left: 0; }
.cal-cell:hover { background: color-mix(in srgb, var(--sunken) 70%, transparent); }
.cal-cell.other { background: color-mix(in srgb, var(--sunken) 45%, transparent); }
.cal-cell.other .cal-num { color: var(--muted); opacity: 0.7; }
.cal-cell.weekend .cal-num { color: var(--muted); }
.cal-cell.selected { box-shadow: inset 0 0 0 2px var(--view); }
.cal-cell.drop-target { background: color-mix(in srgb, var(--view) 18%, transparent); }
.cal-num { font-size: var(--step--1); font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.cal-cell.today .cal-num { background: var(--view); color: var(--on-accent); opacity: 1; }
.cal-entries { display: grid; gap: 3px; min-width: 0; }
.tone-normal { --tone: var(--accent); }
.tone-important { --tone: var(--important); }
.tone-late { --tone: var(--late); }
.tone-done { --tone: var(--muted); }
.cal-entry {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-size: 0.75rem;
  line-height: 1.35;
  padding: 2px 6px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--tone) 16%, transparent);
  border-left: 3px solid var(--tone);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
}
.cal-entry[draggable='true'] { cursor: grab; }
.cal-entry:hover { background: color-mix(in srgb, var(--tone) 28%, transparent); }
.cal-entry .cal-title { overflow: hidden; text-overflow: ellipsis; }
.cal-entry .cal-time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.cal-entry.tone-done .cal-title { text-decoration: line-through; color: var(--muted); }
.cal-entry.upcoming { background: none; border: 1px dashed var(--tone); border-left: 3px dashed var(--tone); color: var(--muted); }
.cal-sym { color: var(--tone, var(--view)); font-weight: 700; flex: none; }
.cal-legend .cal-sym { color: var(--view); }
.cal-more { font-size: 0.72rem; color: var(--muted); padding-left: 6px; }
.cal-dots { display: none; }

.cal-day { margin-top: 28px; }
.cal-day-title { font: 600 1.25rem/1.3 var(--sans); margin: 0 0 12px; }
.task.upcoming { opacity: 0.8; }
.task.upcoming .cal-sym.big { width: 22px; text-align: center; font-size: 1.1rem; color: var(--view); }
[data-theme='dark'] .tasks .task.upcoming { background: none; border: 1px dashed var(--rule); }

/* ---- Narrow screens ----------------------------------------------------------------------- */

.scrim { position: fixed; inset: 0; background: rgb(15 20 30 / 0.4); z-index: 9; }

@media (max-width: 1100px) {
  .app.with-detail { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .detail { position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--detail), 100vw); z-index: 10; box-shadow: -20px 0 50px -30px rgb(20 30 50 / 0.5); }
}

@media (max-width: 900px) {
  .app, .app.with-detail { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    background: var(--paper);
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 200ms ease-out;
  }
  .app.menu-open .sidebar { transform: none; box-shadow: 20px 0 50px -30px var(--shadow); }
  .brand .menu-close { display: grid; }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: var(--paper); z-index: 2; }
  .topbar .brand { padding: 0; font-size: 1.125rem; }
  .detail { width: 100vw; }
}

@media (max-width: 760px) {
  :root { --step-4: 2.25rem; }
  .main-inner { padding: 24px 18px 80px; }
  .cal-cell { min-height: 56px; padding: 4px 2px; align-items: center; }
  .cal-entries { display: none; }
  .cal-dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
  .cal-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--tone); }
  .cal-dots i.upcoming { background: none; border: 1.5px solid var(--tone); }
  .cal-wd { padding: 6px 2px; text-align: center; }
  .cal-legend { margin-top: 0; }
  .opt-pop { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; }
  .find { margin-top: 12px; max-height: calc(100dvh - 24px); }
  .find-esc { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.sheet a.button { text-decoration: none; display: inline-block; }
