/* ==========================================================================
   Chaos to Done — design system
   Warm paper, ink typography, one ember accent. Hairlines over shadows.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&display=swap');

:root {
  --rail-w: 254px;
  --day-w: 348px;
  --top-h: 62px;
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --paper: #f3efe7;
  --paper-2: #ece7dc;
  --surface: #fcfaf5;
  --surface-2: #f7f2e8;
  --surface-3: #fffdf9;
  --ink: #1c1a16;
  --ink-2: #565047;
  --ink-3: #736c5f;
  --ink-4: #a89f90;
  --line: #e4ddd0;
  --line-2: #d6ccba;

  --ember: #b4552d;
  --ember-ink: #8f3f1f;
  --ember-soft: rgba(180, 85, 45, 0.09);
  --ember-line: rgba(180, 85, 45, 0.26);
  --sage: #5c7357;
  --sage-soft: rgba(92, 115, 87, 0.1);
  --sky: #3f6285;
  --sky-soft: rgba(63, 98, 133, 0.09);
  --gold: #a3782c;
  --gold-soft: rgba(163, 120, 44, 0.11);

  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --shadow-1: 0 1px 2px rgba(38, 30, 18, 0.04);
  --shadow-2: 0 8px 24px -12px rgba(38, 30, 18, 0.22), 0 1px 2px rgba(38, 30, 18, 0.05);
  --shadow-3: 0 28px 60px -24px rgba(28, 22, 12, 0.35), 0 2px 6px rgba(28, 22, 12, 0.06);
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--ember-line);

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --fast: 120ms var(--ease);
  --med: 200ms var(--ease);
}

[data-theme='dark'] {
  --paper: #14120e;
  --paper-2: #0f0d0a;
  --surface: #1a1712;
  --surface-2: #211d17;
  --surface-3: #241f18;
  --ink: #f2ede2;
  --ink-2: #bcb3a3;
  --ink-3: #8b8272;
  --ink-4: #6b6355;
  --line: #2e2921;
  --line-2: #3b3429;
  --ember: #e07a4c;
  --ember-ink: #f09367;
  --ember-soft: rgba(224, 122, 76, 0.12);
  --ember-line: rgba(224, 122, 76, 0.32);
  --sage: #8ea585;
  --sage-soft: rgba(142, 165, 133, 0.12);
  --sky: #85a6c7;
  --sky-soft: rgba(133, 166, 199, 0.12);
  --gold: #d0a45c;
  --gold-soft: rgba(208, 164, 92, 0.12);
  --shadow-2: 0 8px 24px -12px rgba(0, 0, 0, 0.7), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-3: 0 28px 60px -24px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* a faint paper grain, never a flat plastic fill */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme='dark'] body::before { opacity: 0.05; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: var(--ember-soft); color: var(--ink); }

.i { flex: none; display: block; }
.display { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; }
.mono { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ================================================================== shell */
#app {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--day-w);
}

/* ------------------------------------------------------------------- rail */
#rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  padding: 14px 10px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 14px;
}
.brand-mark {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  color: var(--ink);
  flex: none;
}
.brand-mark svg { width: 26px; height: 26px; display: block; overflow: visible; }
.brand-word { font-family: var(--display); font-size: 18.5px; line-height: 1; letter-spacing: -0.025em; font-weight: 600; white-space: nowrap; }
.brand-tag { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-left: auto; padding-left: 10px; }

.rail-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; margin: 0 -4px; padding: 0 4px; }

.nav-group { margin-bottom: 16px; }
.nav-label {
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px 6px;
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 500;
}
.nav-label .i { color: var(--ink-4); }
.nav-label button { margin-left: auto; color: var(--ink-3); opacity: 0; transition: opacity var(--fast); }
.nav-group:hover .nav-label button { opacity: 1; }
.nav-label button:hover { color: var(--ink); }

.nav-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 13.5px;
  text-align: left;
  position: relative;
  transition: background var(--fast), color var(--fast);
}
.nav-item:hover { background: rgba(28, 26, 22, 0.045); color: var(--ink); }
[data-theme='dark'] .nav-item:hover { background: rgba(255, 255, 255, 0.05); }
.nav-item.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); font-weight: 500; }
[data-theme='dark'] .nav-item.is-active { background: var(--surface-2); }
.nav-item.is-active::before {
  content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 2px;
  background: var(--ember); border-radius: 0 2px 2px 0;
}
.nav-item .i { color: var(--ink-3); }
.nav-item.is-active .i { color: var(--ember); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nav-item .count.is-hot { color: var(--ember); }

.glyph {
  width: 18px; height: 18px; border-radius: 5px;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 600; letter-spacing: 0;
  color: #fff; flex: none;
  font-family: var(--sans);
}
.glyph.ghost { background: transparent; color: var(--ink-3); border: 1px solid var(--line-2); }

.rail-foot { padding-top: 10px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ember-soft); color: var(--ember-ink);
  border: 1px solid var(--ember-line);
  display: grid; place-items: center; font-size: 10.5px; font-weight: 600;
}
.rail-foot .who { min-width: 0; flex: 1; }
.rail-foot .who b { display: block; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-foot .who span { display: block; font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--ink-3);
  transition: background var(--fast), color var(--fast);
}
.icon-btn:hover { background: rgba(28, 26, 22, 0.06); color: var(--ink); }
[data-theme='dark'] .icon-btn:hover { background: rgba(255, 255, 255, 0.07); }

/* ------------------------------------------------------------------- main */
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }

#topbar {
  height: var(--top-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 5;
}
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumb h1 { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
.crumb .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-4); }
.crumb .sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb .sub.is-over { color: var(--ember-ink); }

.capture {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px 0 11px;
  min-width: 230px;
  max-width: 430px;
  flex: 1 1 320px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--ink-3);
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
[data-theme='dark'] .capture { background: var(--surface-2); }
.capture:focus-within { border-color: var(--ember-line); box-shadow: 0 0 0 3px var(--ember-soft); background: var(--surface); }
.capture input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 13px; color: var(--ink); }
.capture input::placeholder { color: var(--ink-3); }
.capture .kbd { font-size: 10px; color: var(--ink-4); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }
.capture.is-lg { height: 42px; max-width: none; }

.topbar-actions { display: flex; align-items: center; gap: 2px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 12.5px; font-weight: 500;
  white-space: nowrap;
  transition: background var(--fast), border-color var(--fast), color var(--fast), transform var(--fast);
}
.btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.btn:active { transform: translateY(0.5px); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--ember-ink); border-color: var(--ember-ink); color: #fff; }
[data-theme='dark'] .btn-primary { background: var(--ember); border-color: var(--ember); color: #16120d; }
[data-theme='dark'] .btn-primary:hover { background: var(--ember-ink); border-color: var(--ember-ink); color: #16120d; }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { background: rgba(28, 26, 22, 0.05); }
[data-theme='dark'] .btn-quiet:hover { background: rgba(255, 255, 255, 0.06); }
.btn-sm { height: 27px; padding: 0 9px; font-size: 11.5px; border-radius: 7px; }
.btn-danger:hover { color: #9b2c1e; border-color: rgba(155, 44, 30, 0.4); background: rgba(155, 44, 30, 0.06); }
.btn-icon { width: 32px; padding: 0; }

/* ------------------------------------------------------------------ view */
#view { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; position: relative; }
.view-pad { padding: 26px 30px 90px; max-width: 1180px; }
.view-pad.narrow { max-width: 760px; }

.view-head { display: flex; align-items: flex-end; gap: 18px; margin-bottom: 22px; }
.view-head .titles { min-width: 0; flex: 1; }
.eyebrow { font-size: 10.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; margin-bottom: 7px; }
.view-title { font-family: var(--display); font-size: 34px; line-height: 1.08; letter-spacing: -0.02em; font-weight: 600; }
.view-title em { font-style: italic; color: var(--ember-ink); }
.view-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.view-head .tools { display: flex; align-items: center; gap: 6px; padding-bottom: 3px; }

.section { margin-top: 26px; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 0 2px; }
.section-head .name { font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }
.section-head .n { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.section-head .line { flex: 1; height: 1px; background: var(--line); }
.section-head button.mini { font-size: 11px; color: var(--ink-3); }
.section-head button.mini:hover { color: var(--ink); }

/* --------------------------------------------------------------- day budget */
.daystrip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-3);
  overflow: hidden;
  margin-bottom: 24px;
}
[data-theme='dark'] .daystrip { background: var(--surface-2); }
.stat { padding: 13px 15px 14px; border-right: 1px solid var(--line); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat .k { font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.stat .v { font-family: var(--display); font-size: 24px; line-height: 1.15; margin-top: 3px; letter-spacing: -0.01em; font-weight: 600; }
.stat .v small { font-family: var(--sans); font-size: 11px; color: var(--ink-3); letter-spacing: 0; }
.stat .bar { height: 3px; border-radius: 2px; background: var(--line); margin-top: 8px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--ember); border-radius: 2px; transition: width var(--med); }
.stat .bar i.warn { background: #a33220; }
.stat .bar i.ok { background: var(--sage); }

/* ------------------------------------------------------------------- task */
.task-list { display: flex; flex-direction: column; }
.task {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 9px 10px 9px 8px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  position: relative;
  cursor: pointer;
  transition: background var(--fast), border-color var(--fast);
}
.task:hover { background: var(--surface-2); border-color: var(--line); }
.task.is-open { background: var(--surface-2); border-color: var(--line-2); }
.task.is-done .task-title { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; text-decoration-color: var(--ink-4); }
.task.is-done { opacity: 0.72; }
.task.is-dragging { opacity: 0.4; }

.checkbox {
  width: 17px; height: 17px; margin: 2px 0 0 2px;
  border: 1.4px solid var(--line-2);
  border-radius: 50%;
  display: grid; place-items: center;
  color: transparent;
  background: transparent;
  transition: border-color var(--fast), background var(--fast), color var(--fast);
  flex: none;
}
.checkbox .i { width: 10px; height: 10px; stroke-width: 2.6; }
.task:hover .checkbox { border-color: var(--ember); color: var(--ember); }
.checkbox:hover { background: var(--ember-soft); }
.task.is-done .checkbox { background: var(--sage); border-color: var(--sage); color: #fff; }
[data-theme='dark'] .task.is-done .checkbox { color: #14120e; }

.task-body { min-width: 0; }
.task-title { font-size: 13.5px; line-height: 1.4; color: var(--ink); letter-spacing: -0.005em; overflow-wrap: anywhere; }
.task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 9px; margin-top: 4px; font-size: 11.5px; color: var(--ink-3); }
.task-meta .m { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.task-meta .m .i { width: 12px; height: 12px; }
.task-meta .m.hot { color: var(--ember-ink); }
.task-meta .m.cool { color: var(--sky); }
.task-meta .pdot { width: 6px; height: 6px; border-radius: 2px; }
.task-meta .tag { color: var(--ink-3); }
.task-meta .note-kept { color: var(--sage); display: inline-flex; align-items: center; gap: 3px; }
.task-right { display: flex; align-items: center; gap: 8px; padding-top: 1px; }
.est { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.prio { width: 3px; height: 14px; border-radius: 2px; }
.prio.p1 { background: var(--ember); }
.prio.p2 { background: var(--gold); }
.prio.p3 { background: var(--line-2); }
.prio.p4 { background: transparent; }
.task-actions { display: flex; align-items: center; gap: 1px; opacity: 0; transition: opacity var(--fast); }
.task:hover .task-actions { opacity: 1; }
.task-actions .icon-btn { width: 24px; height: 24px; }
.task-actions .icon-btn .i { width: 14px; height: 14px; }

.sub-progress { display: inline-flex; align-items: center; gap: 4px; }
.sub-progress i { width: 26px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; display: block; }
.sub-progress i b { display: block; height: 100%; background: var(--sage); }

/* add row */
.add-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-3);
  font-size: 13px;
  border: 1px dashed transparent;
  width: 100%; text-align: left;
}
.add-row:hover { color: var(--ink); background: var(--surface-2); border-color: var(--line-2); }
.add-row .plus { width: 17px; height: 17px; display: grid; place-items: center; margin-left: 1px; }

/* empty */
.empty {
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  padding: 34px 28px;
  text-align: center;
  color: var(--ink-3);
  background: linear-gradient(180deg, var(--surface-3), var(--surface));
}
.empty .mark { font-family: var(--display); font-size: 30px; color: var(--ember); line-height: 1; margin-bottom: 10px; font-weight: 600; }
.empty h3 { font-family: var(--display); font-weight: 600; font-size: 21px; color: var(--ink); margin-bottom: 5px; }
.empty p { font-size: 12.5px; max-width: 360px; margin: 0 auto 14px; }

/* ------------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px;
  border-radius: 5px;
  font-size: 11px;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip .i { width: 11px; height: 11px; }
.chip.date { color: var(--sky); border-color: color-mix(in srgb, var(--sky) 25%, var(--line)); background: var(--sky-soft); }
.chip.time { color: var(--sky); background: var(--sky-soft); border-color: transparent; }
.chip.priority { color: var(--ember-ink); background: var(--ember-soft); border-color: transparent; }
.chip.estimate { color: var(--ink-2); }
.chip.tag { color: var(--sage); background: var(--sage-soft); border-color: transparent; }
.chip.project { color: var(--ink-2); }
.chip.recur { color: var(--gold); background: var(--gold-soft); border-color: transparent; }
.chip.ghost { background: transparent; color: var(--ink-3); }
.chip button { color: inherit; opacity: 0.6; display: grid; place-items: center; }
.chip button:hover { opacity: 1; }

/* --------------------------------------------------------------- day pane */
#daypane {
  border-left: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px 20px;
}
.day-head { display: flex; align-items: baseline; gap: 8px; padding: 2px 2px 12px; }
.day-head .dow { font-family: var(--display); font-size: 19px; font-weight: 600; }
.day-head .date { font-size: 11.5px; color: var(--ink-3); margin-left: auto; font-variant-numeric: tabular-nums; }

.focus-card {
  border: 1px solid var(--line-2);
  background: var(--surface-3);
  border-radius: var(--r-md);
  padding: 13px 14px 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-1);
}
[data-theme='dark'] .focus-card { background: var(--surface); }
.focus-top { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
.focus-top .k { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.focus-top .chip { margin-left: auto; height: 18px; font-size: 10px; }
.focus-main { display: flex; align-items: center; gap: 13px; }
.ring { position: relative; width: 54px; height: 54px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .t { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 500; letter-spacing: -0.02em; }
.focus-info { min-width: 0; flex: 1; }
.focus-info .what { font-size: 12.5px; line-height: 1.35; color: var(--ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.focus-info .sub { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.focus-btns { display: flex; gap: 6px; margin-top: 11px; }
.focus-btns .btn { flex: 1; height: 29px; font-size: 11.5px; }

.timeline { position: relative; }
.tl-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  min-height: 34px;
  position: relative;
}
.tl-row .h { font-size: 10px; color: var(--ink-4); text-align: right; padding-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.tl-row .slot { border-top: 1px solid var(--line); position: relative; }
.tl-row:last-child .slot { border-bottom: 1px solid var(--line); }
.tl-row.half .slot { border-top-style: dotted; border-top-color: color-mix(in srgb, var(--line) 60%, transparent); }

.tl-block {
  position: absolute; left: 0; right: 0;
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  border-left: 2px solid var(--ink-4);
  background: var(--surface-3);
  color: var(--ink-2);
  box-shadow: var(--shadow-1);
  z-index: 2;
}
.tl-block .bt { display: block; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-block .bm { color: var(--ink-3); font-size: 10px; font-variant-numeric: tabular-nums; }
.tl-block.is-event { border-left-color: var(--sky); background: color-mix(in srgb, var(--sky) 8%, var(--surface-3)); }
.tl-block.is-task { border-left-color: var(--ember); background: color-mix(in srgb, var(--ember) 8%, var(--surface-3)); }
.tl-block.done { opacity: 0.55; }
.tl-now { position: absolute; left: 0; right: 0; height: 1px; background: var(--ember); z-index: 3; }
.tl-now::before { content: ''; position: absolute; left: -3px; top: -2.5px; width: 6px; height: 6px; border-radius: 50%; background: var(--ember); }

.mini-cal { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 9px; }
.wd {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 0 5px;
  text-align: center;
  transition: background var(--fast), border-color var(--fast);
}
.wd .n { font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.wd .d { font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.wd .pip { width: 3px; height: 3px; border-radius: 50%; background: var(--ember); margin: 3px auto 0; opacity: 0; }
.wd.has .pip { opacity: 1; }
.wd:hover { background: var(--surface-3); border-color: var(--line); }
.wd.is-today { background: var(--ink); color: var(--paper); }
[data-theme='dark'] .wd.is-today { background: var(--ember); color: #16120d; }
.wd.is-today .n { color: inherit; opacity: 0.65; }
.wd.is-today .pip { background: currentColor; }
.wd.is-sel { border-color: var(--ember-line); }

.countdown-mini { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.cd-mini { display: flex; align-items: baseline; gap: 8px; font-size: 11.5px; color: var(--ink-2); }
.cd-mini .num { font-family: var(--display); font-size: 15px; color: var(--ink); min-width: 22px; font-variant-numeric: tabular-nums; font-weight: 600; }
.cd-mini .u { font-size: 10px; color: var(--ink-3); }
.cd-mini .bar { flex: 1; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.cd-mini .bar i { display: block; height: 100%; background: var(--ember); opacity: 0.7; }

/* ------------------------------------------------------------- matrix view */
.matrix-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.quad {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-3);
  min-height: 250px;
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: border-color var(--fast), background var(--fast);
}
[data-theme='dark'] .quad { background: var(--surface-2); }
.quad.drag-over { border-color: var(--ember); background: var(--ember-soft); }
.quad-head { padding: 13px 14px 10px; display: flex; align-items: flex-start; gap: 9px; border-bottom: 1px solid var(--line); }
.quad-num { font-family: var(--display); font-size: 22px; line-height: 1; color: var(--ink-4); font-variant-numeric: tabular-nums; font-weight: 600; }
.quad-name { font-size: 12.5px; font-weight: 500; letter-spacing: -0.005em; }
.quad-hint { font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }
.quad-count { margin-left: auto; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.quad-body { padding: 6px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.quad[data-q='do'] { border-top: 2px solid var(--ember); }
.quad[data-q='schedule'] { border-top: 2px solid var(--sky); }
.quad[data-q='delegate'] { border-top: 2px solid var(--gold); }
.quad[data-q='drop'] { border-top: 2px solid var(--line-2); }
.q-task {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 8px; border-radius: 7px;
  cursor: pointer; border: 1px solid transparent;
  transition: background var(--fast);
}
.q-task:hover { background: var(--surface-2); border-color: var(--line); }
[data-theme='dark'] .q-task:hover { background: var(--surface-3); }
.q-task .task-title { font-size: 12.5px; }
.q-task .dot { width: 5px; height: 5px; border-radius: 50%; margin-top: 6px; flex: none; }
.q-empty { padding: 16px 12px; font-size: 11.5px; color: var(--ink-4); text-align: center; border: 1px dashed var(--line); border-radius: 7px; margin: 4px; }
.matrix-legend { display: flex; align-items: center; gap: 14px; margin-top: 12px; font-size: 11px; color: var(--ink-3); flex-wrap: wrap; }
.matrix-legend .k { display: inline-flex; align-items: center; gap: 5px; }
.matrix-legend .sw { width: 8px; height: 8px; border-radius: 2px; }

/* ------------------------------------------------------------ habits view */
.habit-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(7, 34px) 74px;
  gap: 6px;
  align-items: center;
  padding: 10px 10px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  border-bottom-color: var(--line);
}
.habit-row:hover { background: var(--surface-2); }
.habit-row.head { border-bottom: 1px solid var(--line-2); padding-top: 0; padding-bottom: 6px; }
.habit-row.head .d { font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); text-align: center; }
.habit-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.habit-glyph { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; flex: none; }
.habit-name .t { font-size: 13px; }
.habit-name .g { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; }
.habit-day {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  display: grid; place-items: center;
  color: transparent;
  transition: background var(--fast), border-color var(--fast), transform var(--fast);
}
[data-theme='dark'] .habit-day { background: var(--surface-2); }
.habit-day .i { width: 13px; height: 13px; stroke-width: 2.4; }
.habit-day:hover { border-color: var(--ember-line); background: var(--ember-soft); color: var(--ember); }
.habit-day.on { background: var(--sage); border-color: var(--sage); color: #fff; }
[data-theme='dark'] .habit-day.on { color: #14120e; }
.habit-day.future { opacity: 0.35; pointer-events: none; }
.streak { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.streak .i { width: 12px; height: 12px; color: var(--ember); }
.heatmap { display: flex; gap: 3px; margin-top: 14px; overflow-x: auto; padding-bottom: 4px; }
.heat-col { display: flex; flex-direction: column; gap: 3px; }
.heat-cell { width: 10px; height: 10px; border-radius: 2px; background: var(--line); }
.heat-cell.l1 { background: color-mix(in srgb, var(--sage) 30%, var(--line)); }
.heat-cell.l2 { background: color-mix(in srgb, var(--sage) 65%, var(--line)); }
.heat-cell.l3 { background: var(--sage); }

/* --------------------------------------------------------- countdown cards */
.cd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.cd-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 16px 14px;
  background: var(--surface-3);
  position: relative;
  overflow: hidden;
  min-height: 148px;
  display: flex; flex-direction: column;
}
[data-theme='dark'] .cd-card { background: var(--surface-2); }
.cd-card .kind { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.cd-card .big { font-family: var(--display); font-size: 44px; line-height: 1; letter-spacing: -0.03em; margin: 10px 0 2px; font-variant-numeric: lining-nums; font-weight: 600; }
.cd-card .big span { font-size: 12px; font-family: var(--sans); color: var(--ink-3); letter-spacing: 0; margin-left: 5px; }
.cd-card .name { font-size: 13px; margin-top: auto; }
.cd-card .when { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.cd-card .track { height: 2px; background: var(--line); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.cd-card .track i { display: block; height: 100%; background: var(--ember); opacity: 0.75; }
.cd-card .del { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity var(--fast); }
.cd-card:hover .del { opacity: 1; }

/* countdown hero */
.cd-hero {
  display: flex; align-items: center; gap: 26px;
  border: 1px solid var(--line); border-top: 2px solid var(--ember);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
  padding: 24px 26px;
  margin-bottom: 6px;
}
.cd-hero-main { flex: 1; min-width: 0; }
.cd-hero .kind { font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.cd-hero .big { font-family: var(--display); font-size: 64px; line-height: 0.98; letter-spacing: -0.035em; margin: 10px 0 4px; font-variant-numeric: lining-nums; font-weight: 600; }
.cd-hero .big span { font-family: var(--sans); font-size: 12px; letter-spacing: 0; color: var(--ink-3); margin-left: 8px; }
.cd-hero .name { font-size: 17px; letter-spacing: -0.01em; }
.cd-hero .when { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.cd-hero .track { height: 3px; background: var(--line); border-radius: 2px; margin-top: 16px; max-width: 420px; overflow: hidden; }
.cd-hero .track i { display: block; height: 100%; background: var(--ember); opacity: 0.8; border-radius: 2px; }
.cd-hero-side { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; }
.cd-add {
  border: 1px dashed var(--line-2); border-radius: var(--r-md);
  min-height: 148px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--ink-3); font-size: 12px;
  transition: border-color var(--fast), color var(--fast), background var(--fast);
}
.cd-add:hover { border-color: var(--ember-line); color: var(--ember-ink); background: var(--ember-soft); }

/* --------------------------------------------------------------- notes view */
.notes-wrap { display: grid; grid-template-columns: 284px minmax(0, 1fr); height: 100%; min-height: 0; }
.notes-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); }
[data-theme='dark'] .notes-list { background: var(--surface); }
.notes-list-head { padding: 12px 14px 8px; }
.notes-list-head .row { display: flex; align-items: center; gap: 6px; }
.nb-filter { display: flex; gap: 5px; flex-wrap: wrap; padding: 0 12px 9px; }
.nb-pill { font-size: 10.5px; padding: 3px 7px; border-radius: 5px; color: var(--ink-3); border: 1px solid transparent; }
.nb-pill:hover { background: var(--surface-3); color: var(--ink); }
.nb-pill.on { background: var(--surface-3); border-color: var(--line-2); color: var(--ink); box-shadow: var(--shadow-1); }
.note-items { overflow-y: auto; flex: 1; padding: 0 6px 12px; }
.note-item { padding: 9px 10px; border-radius: 7px; cursor: pointer; border: 1px solid transparent; }
.note-item:hover { background: var(--surface-3); border-color: var(--line); }
[data-theme='dark'] .note-item:hover { background: var(--surface-2); }
.note-item.on { background: var(--surface-3); border-color: var(--line-2); box-shadow: var(--shadow-1); }
[data-theme='dark'] .note-item.on { background: var(--surface-2); }
.note-item .nt { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.note-item .np { font-size: 11px; color: var(--ink-3); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.note-item .nm { font-size: 10px; color: var(--ink-4); margin-top: 4px; display: flex; gap: 7px; align-items: center; }
.note-item .pin { color: var(--ember); }

.note-editor { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); }
.ne-bar { display: flex; align-items: center; gap: 6px; padding: 10px 18px; border-bottom: 1px solid var(--line); flex: none; }
.ne-bar .path { font-size: 11px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.ne-scroll { flex: 1; overflow-y: auto; padding: 26px 34px 80px; }
.ne-title { font-family: var(--display); font-size: 31px; line-height: 1.15; letter-spacing: -0.02em; border: 0; background: none; outline: none; width: 100%; padding: 0; font-weight: 600; }
.ne-meta { display: flex; align-items: center; gap: 8px; margin: 10px 0 18px; font-size: 11px; color: var(--ink-3); flex-wrap: wrap; }
.ne-body { width: 100%; min-height: 46vh; border: 0; background: none; outline: none; resize: none; font-size: 14px; line-height: 1.72; color: var(--ink-2); padding: 0; font-family: var(--sans); }
.ne-body::placeholder { color: var(--ink-4); }
.ne-preview { max-width: 68ch; }
.ne-backlinks { margin-top: 34px; border-top: 1px solid var(--line); padding-top: 14px; }
.ne-backlinks .k { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 7px; }
.backlink { display: flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: 6px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.backlink:hover { background: var(--surface-2); color: var(--ink); }

/* markdown prose */
.prose { font-size: 14px; line-height: 1.72; color: var(--ink-2); max-width: 68ch; }
.prose h1, .prose h2, .prose h3, .prose h4 { color: var(--ink); font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; margin: 1.5em 0 0.45em; line-height: 1.2; }
.prose h1 { font-size: 26px; margin-top: 0; }
.prose h2 { font-size: 21px; }
.prose h3 { font-size: 17px; font-family: var(--sans); font-weight: 500; letter-spacing: -0.01em; }
.prose h4 { font-size: 14px; font-family: var(--sans); font-weight: 600; }
.prose p { margin: 0.55em 0; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose em { font-style: italic; }
.prose ul, .prose ol { margin: 0.5em 0; padding-left: 1.25em; }
.prose li { margin: 0.2em 0; }
.prose li::marker { color: var(--ink-4); }
.prose blockquote { margin: 0.9em 0; padding: 2px 0 2px 14px; border-left: 2px solid var(--ember-line); color: var(--ink-2); font-family: var(--display); font-size: 16px; font-style: italic; font-weight: 400; }
.prose code { font-family: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); padding: 1.5px 5px; border-radius: 4px; color: var(--ember-ink); border: 1px solid var(--line); }
.prose pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 0.8em 0; }
.prose pre code { background: none; border: 0; padding: 0; color: var(--ink-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.prose a { color: var(--ember-ink); text-decoration: underline; text-decoration-color: var(--ember-line); text-underline-offset: 2px; }
.prose .wikilink { background: var(--sage-soft); color: var(--sage); padding: 0 3px; border-radius: 3px; text-decoration: none; font-size: 0.95em; }
.prose .wikilink:hover { background: color-mix(in srgb, var(--sage) 22%, transparent); }
.prose .md-table { overflow-x: auto; margin: 0.9em 0; }
.prose table { border-collapse: collapse; font-size: 12.5px; width: 100%; }
.prose th, .prose td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.prose th { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }
.prose .md-task { list-style: none; margin-left: -1.2em; display: flex; gap: 7px; align-items: flex-start; }
.prose .md-check { width: 13px; height: 13px; border: 1.3px solid var(--line-2); border-radius: 3px; display: inline-grid; place-items: center; font-size: 9px; color: var(--ink-3); margin-top: 4px; flex: none; }
.prose .md-task.is-done .md-check { background: var(--sage); border-color: var(--sage); color: #fff; }
.prose .md-task.is-done span:last-child { color: var(--ink-3); text-decoration: line-through; }
.prose .md-empty { color: var(--ink-4); font-style: italic; }

/* ------------------------------------------------------------ calendar view */
.cal-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.cal-range { font-family: var(--display); font-size: 22px; letter-spacing: -0.01em; font-weight: 600; }
.cal-toolbar .spacer { flex: 1; }
.cal-grid {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-3);
  overflow: hidden;
  display: grid;
  grid-template-columns: 58px repeat(7, minmax(0, 1fr));
}
[data-theme='dark'] .cal-grid { background: var(--surface-2); }
.cal-corner { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.cal-dow { padding: 9px 6px 7px; text-align: center; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.cal-dow:last-child { border-right: 0; }
.cal-dow .n { font-size: 9.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); }
.cal-dow .d { font-size: 15px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.cal-dow.is-today .d { color: var(--ember-ink); font-weight: 600; }
.cal-dow.is-weekend .n, .cal-dow.is-weekend .d { color: var(--ink-3); }
.cal-time { border-right: 1px solid var(--line); }
.cal-hour { height: 46px; border-bottom: 1px solid var(--line); position: relative; }
.cal-hour .lbl { position: absolute; top: -6px; right: 7px; font-size: 9.5px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.cal-col { border-right: 1px solid var(--line); position: relative; }
.cal-col:last-child { border-right: 0; }
.cal-slot { height: 23px; border-bottom: 1px dotted color-mix(in srgb, var(--line) 65%, transparent); }
.cal-slot.full { height: 46px; border-bottom: 1px solid var(--line); }
.cal-col.is-today { background: color-mix(in srgb, var(--ember) 2.5%, transparent); }
.cal-ev {
  position: absolute; left: 3px; right: 3px;
  border-radius: 5px; padding: 4px 6px;
  font-size: 10.5px; line-height: 1.25; overflow: hidden;
  border-left: 2px solid var(--sky);
  background: color-mix(in srgb, var(--sky) 9%, var(--surface-3));
  color: var(--ink-2); cursor: pointer; z-index: 2;
}
.cal-ev .t { font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev .m { font-size: 9.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cal-ev.is-task { border-left-color: var(--ember); background: color-mix(in srgb, var(--ember) 8%, var(--surface-3)); cursor: grab; }
.cal-ev.is-task.done { opacity: 0.5; }
.cal-ev.drag-over { outline: 1.5px dashed var(--ember); }
.cal-now { position: absolute; left: 0; right: 0; height: 1px; background: var(--ember); z-index: 4; pointer-events: none; }
.cal-now::before { content: ''; position: absolute; left: -2.5px; top: -2.5px; width: 6px; height: 6px; border-radius: 50%; background: var(--ember); }
.cal-hint { font-size: 11px; color: var(--ink-3); margin-top: 10px; display: flex; align-items: center; gap: 6px; }

/* ------------------------------------------------------------------ drawer */
#scrim {
  position: fixed; inset: 0; background: rgba(28, 22, 14, 0.24);
  backdrop-filter: blur(1.5px); z-index: 40; opacity: 0; pointer-events: none; transition: opacity var(--med);
}
#scrim.on { opacity: 1; pointer-events: auto; }
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw);
  background: var(--surface); border-left: 1px solid var(--line-2);
  z-index: 41; transform: translateX(102%); transition: transform 260ms var(--ease);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-3);
}
#drawer.on { transform: none; }
.dr-head { display: flex; align-items: center; gap: 6px; padding: 13px 16px; border-bottom: 1px solid var(--line); flex: none; }
.dr-head .spacer { flex: 1; }
.dr-scroll { flex: 1; overflow-y: auto; padding: 20px 22px 30px; }
.dr-title { width: 100%; border: 0; background: none; outline: none; font-family: var(--display); font-size: 27px; line-height: 1.2; letter-spacing: -0.02em; color: var(--ink); resize: none; overflow: hidden; font-weight: 600; }
.dr-title.is-done { color: var(--ink-3); }
.qa-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* Phone: a spelled-out priority label needs the full width, so stack the pair. */
@media (max-width: 560px) { .qa-pair { grid-template-columns: 1fr; } }

.dr-props { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 18px; }
.prop {
  display: inline-flex; align-items: center; gap: 6px;
  height: 27px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface-3);
  font-size: 11.5px; color: var(--ink-2);
  transition: border-color var(--fast), background var(--fast);
}
[data-theme='dark'] .prop { background: var(--surface-2); }
.prop:hover { border-color: var(--line-2); background: var(--surface-2); }
.prop .i { width: 13px; height: 13px; color: var(--ink-3); }
.prop.set { color: var(--ink); border-color: var(--line-2); }
.prop.set .i { color: var(--ember); }
.prop select, .prop input { border: 0; background: none; outline: none; font-size: 11.5px; color: inherit; padding: 0; max-width: 150px; }
.prop input[type='number'] { width: 42px; }

.dr-section { margin-top: 20px; }
.dr-label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.dr-label .spacer { flex: 1; }
.dr-label button { font-size: 10px; letter-spacing: 0.04em; color: var(--ink-3); text-transform: none; }
.dr-label button:hover { color: var(--ember-ink); }
.dr-notes { width: 100%; min-height: 190px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 13px; background: var(--surface-3); outline: none; resize: vertical; font-size: 13px; line-height: 1.65; color: var(--ink-2); font-family: var(--sans); }
[data-theme='dark'] .dr-notes { background: var(--surface-2); }
.dr-notes:focus { border-color: var(--ember-line); box-shadow: 0 0 0 3px var(--ember-soft); }
.dr-notes::placeholder { color: var(--ink-4); }
.subtask { display: flex; align-items: center; gap: 8px; padding: 5px 2px; }
.subtask input[type='text'] { flex: 1; border: 0; background: none; outline: none; font-size: 12.5px; color: var(--ink-2); }
.subtask.done input[type='text'] { color: var(--ink-3); text-decoration: line-through; }
.link-row { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; margin-bottom: 5px; font-size: 12px; cursor: pointer; background: var(--surface-3); }
[data-theme='dark'] .link-row { background: var(--surface-2); }
.link-row:hover { border-color: var(--line-2); }
.link-row .i { color: var(--sage); width: 14px; height: 14px; }
.link-row .keep { font-size: 9.5px; color: var(--sage); border: 1px solid color-mix(in srgb, var(--sage) 35%, transparent); padding: 1px 4px; border-radius: 4px; margin-left: auto; }
.dr-foot { display: flex; align-items: center; gap: 6px; padding: 11px 16px; border-top: 1px solid var(--line); flex: none; }
.dr-foot .note { font-size: 10.5px; color: var(--ink-3); flex: 1; }

/* ------------------------------------------------------------- modal / palette */
#modal-root { position: fixed; inset: 0; z-index: 60; display: none; }
#modal-root.on { display: block; }
#palette-root { position: fixed; inset: 0; z-index: 70; }
.modal-scrim { position: absolute; inset: 0; background: rgba(28, 22, 14, 0.3); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 20px; }
.modal {
  width: min(640px, 96vw); max-height: 88vh;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; overflow: hidden;
  animation: pop 180ms var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.99); } }
.modal-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.modal-head h2 { font-family: var(--display); font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.modal-head .sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; background: var(--surface-2); }
.modal-foot .spacer { flex: 1; }

/* settings tabs: one job per pane, saved independently */
.set-tabs {
  display: flex; gap: 2px; margin: -2px 0 16px; flex-wrap: wrap;
  overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line);
}
.set-tabs::-webkit-scrollbar { display: none; }
.set-tab .t-short { display: none; }
.set-tab {
  flex: none; padding: 8px 11px; font-size: 12px; font-weight: 500;
  color: var(--ink-3); background: none; border: 0; border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap; margin-bottom: -1px;
}
.set-tab:hover { color: var(--ink); }
.set-tab.is-on { color: var(--ink); border-bottom-color: var(--ember); font-weight: 600; }
@media (max-width: 560px) {
  .one-foot-hint { display: none; }
}
@media (max-width: 560px) {
  .set-tab { padding: 8px 9px; }
  .set-tab .t-full { display: none; }
  .set-tab .t-short { display: inline; }
}
.set-pane { padding-bottom: 4px; }
.set-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.set-note { margin: -6px 0 18px; line-height: 1.55; }
.set-check {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; margin-bottom: 16px; cursor: pointer;
}
.set-check input { margin-top: 2px; }
.set-check b { font-size: 12.5px; font-weight: 500; display: block; }
.set-check .tiny { display: block; margin-top: 3px; line-height: 1.5; }
.set-keys { line-height: 1.9; }

.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 5px; }
.input, textarea.input, select.input {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface-3); outline: none; font-size: 13px;
}
[data-theme='dark'] .input, [data-theme='dark'] textarea.input, [data-theme='dark'] select.input { background: var(--surface-2); }
textarea.input { height: auto; min-height: 170px; padding: 11px; line-height: 1.6; resize: vertical; font-size: 13px; }
.input:focus { border-color: var(--ember-line); box-shadow: 0 0 0 3px var(--ember-soft); }

.bd-parse { display: flex; flex-direction: column; gap: 1px; margin-top: 4px; }
.bd-line { display: flex; align-items: flex-start; gap: 9px; padding: 8px 9px; border-radius: 7px; border: 1px solid transparent; }
.bd-line:hover { background: var(--surface-2); border-color: var(--line); }
.bd-line .checkbox { margin-top: 2px; }
.bd-line .txt { flex: 1; min-width: 0; }
.bd-line .txt .t { font-size: 13px; }
.bd-line .txt .c { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.bd-line .raw { font-size: 10.5px; color: var(--ink-4); text-decoration: line-through; margin-top: 2px; }

.palette { width: min(620px, 94vw); margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-md); box-shadow: var(--shadow-3); overflow: hidden; animation: pop 160ms var(--ease); }
.palette input { width: 100%; height: 52px; padding: 0 18px; border: 0; border-bottom: 1px solid var(--line); background: none; outline: none; font-size: 15px; }
.pal-results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.pal-group { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-4); padding: 8px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.pal-item .i { color: var(--ink-3); }
.pal-item .hint { margin-left: auto; font-size: 10px; color: var(--ink-4); }
.pal-item.sel { background: var(--surface-2); color: var(--ink); }
[data-theme='dark'] .pal-item.sel { background: var(--surface-2); }

/* ------------------------------------------------------------------- toast */
#toast-root { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--paper);
  padding: 9px 12px 9px 14px; border-radius: 9px;
  font-size: 12.5px; box-shadow: var(--shadow-2);
  animation: toastIn 180ms var(--ease);
  pointer-events: auto; max-width: 92vw;
}
[data-theme='dark'] .toast { background: var(--ember); color: #16120d; }
.toast .i { color: var(--ember); }
[data-theme='dark'] .toast .i { color: #16120d; }
.toast button { color: inherit; opacity: 0.75; font-size: 11.5px; border: 1px solid currentColor; border-radius: 5px; padding: 2px 6px; }
.toast button:hover { opacity: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* --------------------------------------------------------------- misc bits */
.kbd { font-family: var(--sans); }
.hr { height: 1px; background: var(--line); margin: 18px 0; }
.muted { color: var(--ink-3); }
.tiny { font-size: 11px; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

.mobile-nav { display: none; }

/* --------------------------------------------------------------- additions */
.mobile-only { display: none; }

/* SQLite sync status */
.sync-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 8px; margin-right: 3px;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--ink-3);
  font-size: 10px; letter-spacing: 0.02em; white-space: nowrap;
}
.sync-pill i { width: 5px; height: 5px; border-radius: 50%; background: var(--sage); flex: none; }
.sync-pill:hover { border-color: var(--line-2); color: var(--ink-2); }
.sync-pill.is-saving i { background: var(--gold); animation: syncPulse 1.1s ease-in-out infinite; }
.sync-pill.is-error { color: var(--ember-ink); border-color: var(--ember-line); background: var(--ember-soft); }
.sync-pill.is-error i { background: var(--ember); }
.sync-pill.is-idle i { background: var(--ink-4); }
@keyframes syncPulse { 50% { opacity: 0.25; } }

/* Matrix actions */
.q-task .q-act {
  margin-left: auto; align-self: center; flex: none;
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 7px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--surface-3);
  color: var(--ink-3); font-size: 10px; white-space: nowrap;
  opacity: 0.55; transition: opacity var(--fast), color var(--fast), border-color var(--fast), background var(--fast);
}
.q-task:hover .q-act { opacity: 1; }
.q-task .q-act:hover { color: var(--ember-ink); border-color: var(--ember-line); background: var(--ember-soft); }
.q-sprint {
  margin-left: auto; flex: none;
  display: inline-flex; align-items: center; gap: 4px;
  height: 23px; padding: 0 8px; border-radius: 6px;
  border: 1px solid transparent; background: var(--gold-soft); color: var(--gold);
  font-size: 10px; letter-spacing: 0.02em; white-space: nowrap;
  transition: background var(--fast), color var(--fast);
}
.q-sprint:hover { background: var(--gold); color: #fff; }
.q-sprint + .quad-count { margin-left: 8px; }

/* Sprint progress */
.sprint-dots { display: flex; gap: 4px; margin-top: 9px; flex-wrap: wrap; }
.sprint-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); display: block; }
.sprint-dots i.done { background: var(--sage); }
.sprint-dots i.now { background: var(--ember); box-shadow: 0 0 0 2px var(--ember-soft); }

/* AI brain dump */
.ai-toggle {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); cursor: pointer;
  transition: border-color var(--fast), background var(--fast);
}
.ai-toggle:hover { border-color: var(--line-2); }
.ai-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ai-switch { width: 32px; height: 18px; border-radius: 999px; background: var(--line-2); position: relative; flex: none; transition: background var(--fast); }
.ai-switch i { position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface-3); box-shadow: var(--shadow-1); transition: transform var(--med); }
.ai-toggle input:checked + .ai-switch { background: var(--ember); }
.ai-toggle input:checked + .ai-switch i { transform: translateX(14px); }
.ai-toggle input:focus-visible + .ai-switch { box-shadow: var(--ring); }
.ai-copy { min-width: 0; flex: 1; }
.ai-copy b { display: block; font-size: 12.5px; font-weight: 500; }
.ai-copy em { display: block; font-style: normal; font-size: 10.5px; color: var(--ink-3); margin-top: 1px; line-height: 1.35; }
.ai-state { font-size: 10px; color: var(--ink-3); border: 1px solid var(--line); padding: 2px 7px; border-radius: 999px; white-space: nowrap; flex: none; }
.ai-state.ok { color: var(--sage); border-color: color-mix(in srgb, var(--sage) 35%, transparent); background: var(--sage-soft); }
.ai-state.err { color: var(--ember-ink); border-color: var(--ember-line); background: var(--ember-soft); }
.bd-ai-panel {
  border: 1px dashed var(--ember-line); background: var(--ember-soft);
  border-radius: 9px; padding: 8px 11px; margin: 0 0 10px;
  font-size: 11px; line-height: 1.55; color: var(--ink-2);
}
.bd-error {
  margin-top: 10px; padding: 9px 11px;
  border: 1px solid var(--ember-line); background: var(--ember-soft); color: var(--ember-ink);
  border-radius: 8px; font-size: 11.5px; line-height: 1.5; overflow-wrap: anywhere;
}
.spin {
  display: inline-block; width: 12px; height: 12px; margin-right: 3px; vertical-align: -2px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Voice capture */
.bd-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 14px; }
.bd-tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 12px 9px; margin-bottom: -1px; font: inherit; font-size: 12.5px; color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.bd-tab:hover { color: var(--ink-2); }
.bd-tab.on { color: var(--ink); border-bottom-color: var(--ember); }
.bd-tab svg { opacity: 0.85; }
.rec-card {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 12px; padding: 14px; margin-bottom: 12px;
}
.rec-main { display: flex; align-items: center; gap: 14px; }
.rec-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--ember-line); background: var(--ember-soft);
  color: var(--ember-ink); font: inherit; font-size: 13px; cursor: pointer; flex: none;
  transition: background var(--fast), border-color var(--fast), opacity var(--fast);
}
.rec-btn:hover { background: color-mix(in srgb, var(--ember-soft) 70%, #fff); border-color: var(--ember); }
.rec-btn:disabled { opacity: 0.55; cursor: default; }
.rec-copy { min-width: 0; flex: 1; }
.rec-line { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; }
.rec-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); display: block; flex: none; }
.rec-dot.live { background: var(--ember); animation: recPulse 1.2s ease-in-out infinite; }
.rec-dot.busy { background: var(--ember); animation: recPulse 1.2s ease-in-out infinite; }
.rec-dot.err { background: var(--ember); }
.rec-time { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 400; letter-spacing: 0.01em; }
.rec-actions { display: flex; gap: 8px; margin-top: 12px; }
.rec-actions .btn[hidden] { display: none; }
.dropzone {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  border: 1.5px dashed var(--line-2); border-radius: 12px; cursor: pointer;
  transition: border-color var(--fast), background var(--fast);
}
.dropzone:hover, .dropzone.drag { border-color: var(--ember); background: var(--ember-soft); }
.dropzone.has-file { border-style: solid; border-color: color-mix(in srgb, var(--sage) 45%, transparent); background: var(--sage-soft); }
.dz-ico {
  width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--line); color: var(--ink-3); background: var(--surface);
}
.dz-copy { min-width: 0; flex: 1; }
.dz-copy b { display: block; font-size: 12.5px; font-weight: 500; }
.dz-copy span { display: block; font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.voice-status {
  display: flex; align-items: center; gap: 6px; min-height: 17px;
  margin-top: 10px; font-size: 11.5px; color: var(--ink-3); line-height: 1.45;
}
@keyframes recPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Calendar sync status */
.cal-sync {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
  margin-bottom: 16px;
}
.cal-sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-4); flex: none; }
.cal-sync-dot.ok { background: var(--sage); }
.cal-sync-dot.err { background: var(--ember); }
.cal-sync-copy { flex: 1; min-width: 0; }
.cal-sync-copy b { display: block; font-size: 12.5px; font-weight: 500; }
.cal-sync-copy span { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 2px; line-height: 1.4; overflow-wrap: anywhere; }
.cal-sync .btn { flex: none; }

/* Calendar credential form */
.cal-config {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  background: var(--surface-2); margin-bottom: 16px;
}
.cal-why { margin: 0 0 12px; line-height: 1.55; }
.cal-hint { display: block; margin-top: 6px; line-height: 1.55; }
.cal-hint .ex { display: block; margin-top: 3px; }
.cal-hint .ex b { font-weight: 600; color: var(--ink-2); }
.cal-hint code {
  font-size: 10.5px; overflow-wrap: anywhere; word-break: break-word;
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 4px;
}
.cal-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cal-form-grid .field, .cal-fields .field { margin-bottom: 10px; }
@media (max-width: 560px) { .cal-form-grid { grid-template-columns: 1fr; gap: 0; } }
.cal-fields[hidden] { display: none; }
.cal-fields { padding-top: 2px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 54px; }
.pw-toggle {
  position: absolute; right: 4px; top: 4px; height: 28px; padding: 0 8px;
  border: 0; border-radius: 6px; background: transparent; color: var(--ink-3);
  font-size: 10px; letter-spacing: .04em; text-transform: uppercase; cursor: pointer;
}
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--ember-ink); background: var(--surface); }
.cal-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 2px; }
.cal-actions .tiny { margin-left: auto; }
.cal-feedback { min-height: 17px; margin-top: 7px; font-size: 10.5px; line-height: 1.45; color: var(--ink-3); overflow-wrap: anywhere; }
.cal-feedback.ok { color: var(--sage-ink, var(--sage)); }
.cal-feedback.err { color: var(--ember-ink); }

/* ------------------------------------------------ AI harness credentials */
.ai-intro {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px;
  border: 1px solid var(--ember-line); background: var(--ember-soft);
  border-radius: var(--r-sm); margin-bottom: 12px;
}
.ai-intro b { font-size: 12.5px; font-weight: 600; }
.ai-intro-icon {
  flex: none; width: 26px; height: 26px; border-radius: 7px; display: grid;
  place-items: center; background: var(--surface-3); border: 1px solid var(--ember-line);
  color: var(--ember-ink);
}
.ai-active-row {
  display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px;
  align-items: center; margin: 4px 0 12px;
}
.ai-active-row label {
  font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3);
}
.ai-active-note { grid-column: 2; line-height: 1.45; }
.ai-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 8px; }
.ai-card {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--r-md); overflow: hidden;
}
.ai-card.is-active { border-color: var(--ember-line); }
.ai-head { display: flex; align-items: center; gap: 9px; padding: 9px 11px; }
.ai-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none; display: grid;
  place-items: center; background: var(--surface-3); border: 1px solid var(--line);
  color: var(--ember-ink);
}
.ai-headtext { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.ai-headtext b { font-size: 12.5px; font-weight: 600; }
.ai-headtext .tiny { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-chip {
  flex: none; font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 999px; border: 1px solid var(--line-2);
  color: var(--ink-4);
}
.ai-chip.ok { color: var(--sage); border-color: rgba(92, 115, 87, 0.4); background: var(--sage-soft); }
.ai-chip.warn { color: var(--gold); border-color: rgba(163, 120, 44, 0.4); background: var(--gold-soft); }
.ai-chip.err { color: var(--ember-ink); border-color: var(--ember-line); background: var(--ember-soft); }
.ai-body { padding: 2px 11px 11px; border-top: 1px solid var(--line); background: var(--surface); }
.ai-body .field { margin-top: 10px; }
.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ai-fields[hidden] { display: none; }
.ai-hint { display: block; margin-top: 4px; line-height: 1.45; }
.ai-hint code { font-size: 10px; }
.ai-enable {
  display: flex; gap: 8px; align-items: center; margin-top: 11px;
  font-size: 12px; color: var(--ink-2); cursor: pointer;
}
.ai-enable input { width: 15px; height: 15px; accent-color: var(--ember); flex: none; }
.ai-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 11px; }
.ai-note { margin-top: 8px; line-height: 1.5; }
.ai-note a { color: var(--ember-ink); }
.ai-vault {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 12px 2px 0; border-top: 1px dashed var(--line);
  margin: 0 0 24px; line-height: 1.55;
}
.ai-vault svg { color: var(--sage); flex: none; }
.ai-vault .vault-line { display: flex; gap: 6px; align-items: center; }
.ai-vault .vault-path {
  display: block; flex-basis: 100%; margin: 3px 0 0 18px;
  font-size: 10.5px; overflow-wrap: anywhere; word-break: break-word;
}
.ai-loading { padding: 10px 0; }

/* role sections: one collapsible block per purpose */
.ai-roles { display: flex; flex-direction: column; gap: 9px; margin-bottom: 8px; }
.ai-sec {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2, var(--surface)); padding: 0 13px;
}
.ai-sec > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0; cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.ai-sec > summary::-webkit-details-marker { display: none; }
.ai-sec > summary::before {
  content: ''; width: 6px; height: 6px; flex: none;
  border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(-45deg); transition: transform 0.15s ease;
}
.ai-sec[open] > summary::before { transform: rotate(45deg); }
.ai-sec-name { font-weight: 600; }
.ai-sec-model {
  margin-left: auto; max-width: 48%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.ai-sec[open] > summary { border-bottom: 1px solid var(--line); }
.ai-sec-sum { padding: 10px 0 0; line-height: 1.5; }
.ai-sec-body { padding: 12px 0 14px; }
.ai-sec-empty { padding: 10px 0 14px; line-height: 1.5; }
.model-row { display: flex; gap: 6px; align-items: center; }
.model-row .input { flex: 1; min-width: 0; }
.ai-sec .cal-feedback { padding-bottom: 10px; }
.ai-sec .ai-actions { margin-top: 10px; }

@media (max-width: 560px) {
  .ai-grid { grid-template-columns: 1fr; }
  .ai-active-row { grid-template-columns: 1fr; }
  .ai-active-note { grid-column: 1; }
}

/* Cloudflare tunnel card */
.tunnel-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  background: var(--surface-2); margin-bottom: 16px;
}
.tunnel-main { display: flex; align-items: flex-start; gap: 12px; }
.tunnel-details { flex: 1; min-width: 0; }
.tunnel-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tunnel-head b { font-size: 12.5px; font-weight: 500; }
.tunnel-uptime { margin-left: auto; font-size: 10px; color: var(--ink-3); }
.tunnel-url {
  margin-top: 8px; padding: 7px 9px; border: 1px dashed var(--line-2); border-radius: 7px;
  font-size: 11px; color: var(--ink-2); background: var(--surface);
  overflow-wrap: anywhere; line-height: 1.5;
}
.tunnel-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }
.tunnel-qr { margin-top: 0; padding: 8px; border-radius: 8px; background: #fff; flex: none; }
.tunnel-qr img { display: block; width: 136px; height: 136px; }

.daystrip.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.prio-dot { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.prio-dot.p1 { background: var(--ember); }
.prio-dot.p2 { background: var(--gold); }
.task-list > .task:not(:last-of-type)::after {
  content: ''; position: absolute; left: 40px; right: 12px; bottom: -1px; height: 1px;
  background: color-mix(in srgb, var(--line) 55%, transparent); pointer-events: none;
}
.cal-time .cal-hour:first-child .lbl { top: 2px; }
.cal-ev.short { padding: 2px 5px; display: flex; align-items: center; }
.cal-ev.short .t { font-size: 9.5px; line-height: 1.2; }
.heat-cell { width: 12px; height: 12px; }
.timeline { position: relative; }
.tl-layer { pointer-events: none; }
.tl-block { pointer-events: auto; cursor: pointer; transition: box-shadow var(--fast), transform var(--fast); }
.tl-block.short { padding: 2px 7px; display: flex; align-items: center; }
.tl-block.short .bt { font-size: 10px; line-height: 1.2; }
.tl-block:hover { box-shadow: var(--shadow-2); }
.tl-grid .tl-row.half .slot { border-bottom: 1px dotted color-mix(in srgb, var(--line) 55%, transparent); }
.tl-grid .tl-row.half .slot { border-top: 0; }
.prop.hot { border-color: var(--ember-line); color: var(--ember-ink); background: var(--ember-soft); }
.prop.hot .i { color: var(--ember); }
.q-task:active { cursor: grabbing; }
.task[draggable='true'] { cursor: grab; }
.cal-slot { cursor: cell; }
.cal-slot:hover { background: color-mix(in srgb, var(--ember) 4%, transparent); }
.notes-wrap { height: calc(100vh - var(--top-h)); }
.note-editor { overflow: hidden; }
.ne-scroll { scrollbar-gutter: stable; }
.dr-props .chip { cursor: pointer; }
.chip.hot { color: var(--ember-ink); background: var(--ember-soft); border-color: transparent; }
.daystrip .stat .v { white-space: nowrap; }
.palette-scrim { position: fixed; inset: 0; background: rgba(28, 22, 14, 0.28); backdrop-filter: blur(2px); display: block; }
.pal-scrim-inner { width: 100%; height: 100%; }
@media (max-width: 900px) {
  .mobile-only { display: grid; }
  .notes-wrap { height: calc(100vh - var(--top-h) - 62px); }
  .ne-bar .path { display: none; }
  .ne-extra { display: none; }
  .ne-scroll { padding-bottom: 120px; }
  .cd-hero { flex-direction: column; align-items: flex-start; gap: 16px; }
  .cd-hero-side { flex-direction: row; }
  .q-task .q-act { opacity: 1; }
}

/* --------------------------------------------------------------- responsive */
@media (max-width: 1320px) {
  :root { --day-w: 312px; }
  .view-pad { padding: 24px 24px 90px; }
}
@media (max-width: 1160px) {
  #app { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  #daypane { display: none; }
  .capture { max-width: 340px; }
}
#app.no-day { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
#app.no-day #daypane { display: none; }
@media (max-width: 900px) {
  :root { --top-h: 56px; }
  #app { grid-template-columns: minmax(0, 1fr); }
  #rail {
    position: fixed; top: 0; bottom: 0; left: 0; width: 272px; z-index: 45;
    transform: translateX(-102%); transition: transform 240ms var(--ease);
    box-shadow: var(--shadow-3);
  }
  #rail.on { transform: none; }
  #topbar { padding: 0 14px; gap: 8px; }
  .capture { display: none; }
  .view-pad { padding: 18px 15px 110px; }
  .view-head { margin-bottom: 16px; }
  .view-title { font-size: 27px; }
  .daystrip { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(1), .stat:nth-child(2) { border-bottom: 1px solid var(--line); }
  .matrix-grid { grid-template-columns: 1fr; }
  .notes-wrap { grid-template-columns: minmax(0, 1fr); }
  .notes-list { display: none; }
  .notes-wrap.show-list .notes-list { display: flex; }
  .notes-wrap.show-list .note-editor { display: none; }
  .ne-scroll { padding: 20px 18px 100px; }
  .ne-title { font-size: 25px; }
  .cal-grid { grid-template-columns: 40px repeat(7, minmax(86px, 1fr)); overflow-x: auto; }
  .cal-grid > * { min-width: 0; }
  .cal-wrap { overflow-x: auto; }
  .habit-row { grid-template-columns: minmax(0, 1fr) repeat(7, 27px) 52px; gap: 3px; }
  .habit-day { width: 25px; height: 25px; }
  .cd-grid { grid-template-columns: 1fr 1fr; }
  #drawer { width: 100%; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .mobile-nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 9.5px; color: var(--ink-3); padding: 4px 10px; border-radius: 8px; }
  .mobile-nav button.on { color: var(--ember-ink); }
  .mobile-nav button .i { width: 19px; height: 19px; }
}
@media (max-width: 560px) {
  .stat { padding: 11px 12px; }
  .stat .v { font-size: 21px; }
  .cd-grid { grid-template-columns: 1fr; }
  .task { grid-template-columns: 22px minmax(0, 1fr) auto; padding-right: 6px; }
  .task-right .prio { display: none; }
  .view-head { flex-wrap: wrap; }
  .view-head .titles { flex: 1 1 100%; }
  .view-head .tools { width: 100%; padding-top: 12px; padding-bottom: 0; }
  .view-head .tools .btn { flex: 1; height: 36px; }
  .view-head .tools .btn span { display: inline; }
  .ai-copy em { display: none; }
  #bd-foot-note { display: none; }
  .bd-tabs .bd-tab { flex: 1; justify-content: center; }
  .rec-main { flex-wrap: wrap; gap: 10px; }
  .rec-btn { height: 40px; padding: 0 14px; }
  .rec-time { margin-left: auto; }
  .dropzone { flex-wrap: wrap; }
  .dz-copy { flex: 1 1 calc(100% - 46px); }
  #bd-pick { order: 3; margin-left: auto; }
  .rec-actions .btn { flex: 1; }
  .cal-sync { flex-wrap: wrap; }
  .cal-sync .btn { width: 100%; }
  .cal-actions .btn { flex: 1; }
  .cal-actions .tiny { flex: 1 1 100%; margin-left: 0; }
  .tunnel-main { flex-wrap: wrap; }
  .tunnel-details { flex: 1 1 100%; }
  .tunnel-actions .btn { flex: 1; }
}

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

/* print: a clean paper day plan */
@media print {
  #rail, #daypane, #topbar, .mobile-nav, #toast-root { display: none !important; }
  #app { grid-template-columns: 1fr; height: auto; }
  body { overflow: visible; background: #fff; }
  #view { overflow: visible; }
}

/* --------------------------------------------------------------------------
   Passcode gate
   -------------------------------------------------------------------------- */
#auth-root[hidden] { display: none; }
#auth-root {
  position: fixed; inset: 0; z-index: 140; overflow: auto;
  background: var(--paper); color: var(--ink);
}
#auth-root.is-leaving { opacity: 0; transition: opacity 160ms ease; }
.auth-scrim {
  min-height: 100%;
  display: grid; place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  background-image: radial-gradient(circle at 18% 12%, var(--surface-2), transparent 38%),
                    radial-gradient(circle at 82% 88%, var(--ember-soft), transparent 32%);
}
.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 30px 30px 24px;
}
.auth-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 50%;
  color: var(--ember); font-size: 18px; margin-bottom: 20px;
}
.auth-kicker {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--ink-3); margin-bottom: 8px;
}
.auth-card h1 {
  font-family: var(--display); font-size: 34px; font-weight: 600; line-height: 1.05;
  letter-spacing: -.015em; margin: 0 0 10px;
}
.auth-copy { font-size: 12.5px; line-height: 1.65; color: var(--ink-2); margin: 0 0 20px; }
.auth-label {
  display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); margin: 13px 0 6px;
}
.auth-input {
  width: 100%; height: 40px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface-3); color: var(--ink); padding: 0 12px;
  font-family: var(--sans); font-size: 14px; outline: none;
}
.auth-input:focus { border-color: var(--ember); box-shadow: 0 0 0 3px var(--ember-soft); }
.auth-submit { width: 100%; margin-top: 18px; justify-content: center; }
.auth-error { min-height: 18px; margin-top: 10px; color: var(--ember-ink); font-size: 11px; line-height: 1.45; }
.auth-foot { margin: 14px 0 0; font-size: 10px; line-height: 1.6; color: var(--ink-3); }

.tunnel-auto {
  display: flex; align-items: center; gap: 7px; margin-top: 9px;
  font-size: 10.5px; color: var(--ink-2); cursor: pointer;
}
.tunnel-auto input { accent-color: var(--ember); margin: 0; }

@media (max-width: 640px) {
  .auth-card { padding: 24px 20px 20px; border-radius: var(--r-md); }
  .auth-card h1 { font-size: 30px; }
}

/* --------------------------------------------------------- today's main task */
.one-card {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  padding: 14px 16px 13px; margin: 0 0 16px;
}
.one-card.is-empty { border-style: dashed; background: var(--surface-2); }
.one-card.is-done { opacity: .7; }
.one-card-top { display: flex; align-items: center; gap: 8px; }
.one-kicker { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ember-ink); font-weight: 600; }
.one-date { margin-left: auto; font-size: 10px; color: var(--ink-3); }
.one-card-title { font-family: var(--display); font-size: 24px; line-height: 1.08; letter-spacing: -.015em; margin-top: 5px; font-weight: 600; }
.one-card.is-empty .one-card-title { font-size: 20px; }
/* Finished for the day: read it as done at a glance, keep the next-pick action live. */
.one-card.is-done { opacity: 0.8; }
.one-card.is-done .one-card-title {
  color: var(--ink-3);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--ink-4);
}
.one-card.is-done .one-card-mark { color: var(--sage); }
.one-card .one-done {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--sage); font-weight: 600; margin-right: 4px;
}
.one-card-why { font-size: 11.5px; line-height: 1.5; color: var(--ink-2); margin-top: 4px; }
.one-card-main { display: flex; align-items: flex-start; gap: 10px; }
.one-card-mark {
  width: 25px; height: 25px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--ember-line); border-radius: 50%; color: var(--ember);
  font-size: 12px; margin-top: 8px;
}
.one-card-copy { min-width: 0; }
.one-card-foot { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 10px; }
.one-time { font-size: 10.5px; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.one-north { font-size: 10px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.one-done { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--sage); }
.one-question { font-family: var(--display); font-size: 25px; line-height: 1.15; letter-spacing: -.01em; color: var(--ink); font-weight: 600; }
.one-question em { color: var(--ember-ink); font-style: italic; }
.one-context { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }
.one-label { display: block; margin: 16px 0 6px; font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.one-label span { text-transform: none; letter-spacing: 0; color: var(--ink-4); }
.one-sugs { display: flex; flex-direction: column; gap: 7px; }
.one-sug {
  display: block; width: 100%; text-align: left; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-3);
  transition: border-color var(--fast), background var(--fast);
}
.one-sug:hover, .one-sug:focus-visible { border-color: var(--ember-line); background: var(--ember-soft); }
.one-sug-top { display: flex; align-items: baseline; gap: 8px; }
.one-sug-title { font-size: 13px; line-height: 1.3; color: var(--ink); font-weight: 500; }
.one-chip { margin-left: auto; flex: none; font-size: 9px; letter-spacing: .06em; color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 99px; padding: 2px 6px; }
.one-sug-why { display: block; font-size: 10.5px; color: var(--ink-2); margin-top: 3px; }
.one-sug-meta { display: block; font-size: 9.5px; color: var(--ink-3); margin-top: 3px; }
.one-none { font-size: 11.5px; color: var(--ink-3); border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px; }
.one-custom { margin-top: 2px; }
.one-options { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.one-check { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--ink-2); cursor: pointer; }
.one-check input { accent-color: var(--ember); margin: 0; }
.one-length { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--ink-3); }
.one-length .input { width: 88px; height: 30px; padding: 0 6px; }
@media (max-width: 560px) {
  .one-card { padding: 12px 13px; }
  .one-card-title { font-size: 21px; }
  .one-north { max-width: 100%; flex: 1 1 100%; order: 5; }
  .one-card-foot .btn { flex: 1; }
  .one-question { font-size: 22px; }
}

/* Image capture in the brain-dump modal */
.bd-img-preview { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); padding: 8px; overflow: hidden; }
.bd-img-preview img { display: block; max-width: 100%; max-height: 260px; margin: 0 auto; border-radius: 5px; object-fit: contain; }
@media (max-width: 560px) {
  .bd-tabs .bd-tab { padding-left: 6px; padding-right: 6px; }
  .bd-img-preview img { max-height: 190px; }
}
.bd-img-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.bd-img-actions .btn { min-width: 150px; }
@media (max-width: 560px) { .bd-img-actions .btn { width: 100%; } }
#bd-img-extract:disabled { opacity: .42; cursor: not-allowed; }
