/* Compass UI components — built on tokens.css. */
* { box-sizing: border-box; }
/* The canvas is the bar colour: in the installed iPhone app (status bar style
   "default") iOS paints the clock/battery area with it, and overscroll at the
   top and bottom shows white next to the white top bar and tab bar. The cream
   page colour lives on #app. */
html, body { height: 100%; background: var(--surface); }
body {
  margin: 0; color: var(--ink);
  font-family: var(--font-ui); font-size: var(--fs-md);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); }
::selection { background: var(--mark); }
mark { background: var(--mark); color: inherit; border-radius: 4px; padding: 0 2px; }

button { font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; font-size: var(--fs-md); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---- Layout ---- */
/* dvh = the visible viewport: in Safari 100vh reaches under the bottom toolbar and hides the tab bar. */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 52px;
  /* White bar over the cream page, so the chrome reads apart from the content. */
  background: var(--surface); flex-shrink: 0; border-bottom: 1px solid var(--line);
  position: relative; z-index: 5;
}
.topbar .brand { font-weight: 700; font-size: var(--fs-lg); letter-spacing: 0.01em; display: flex; align-items: center; gap: 8px; }
.topbar .btn.icon { border-radius: 999px; }
.logo-mark { display: inline-flex; flex-shrink: 0; }
.logo-mark svg { display: block; }
.topbar .spacer { flex: 1; }
.main-row { flex: 1; display: flex; overflow: hidden; }
.content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ---- Buttons & inputs ----
   Crisp paper: secondary buttons and inputs are outlined on the card colour,
   so every control has a visible edge; primary is a solid accent fill. */
.btn {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: var(--fs-sm); font-weight: 500; padding: 6px 12px; cursor: pointer; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  box-shadow: var(--shadow-card); transition: background 120ms, border-color 120ms;
}
.btn:hover { background: var(--raised); border-color: color-mix(in srgb, var(--ink) 30%, var(--line-strong)); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 14%, var(--accent)); border-color: transparent; }
.btn.danger { color: var(--danger); background: var(--surface); border-color: color-mix(in srgb, var(--danger) 45%, var(--surface)); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.icon { width: 32px; height: 32px; padding: 0; justify-content: center; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--raised); border-color: transparent; }

.input, select.input {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 7px 11px; font-size: var(--fs-md); border-radius: var(--radius-sm);
}
.input:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line-strong)); }
.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 0; border-color: var(--accent); }
.input::placeholder, textarea::placeholder { color: var(--faint); }
textarea.input { resize: vertical; line-height: 1.5; }

/* ---- Search ---- */
.search-wrap { position: relative; }
.search-input { width: 260px; border-radius: 999px; padding-left: 14px; background: var(--raised); }
.search-results {
  position: absolute; top: 42px; right: 0; width: 400px; max-height: 440px; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); z-index: 60; padding: 6px;
}
.search-result {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; cursor: pointer;
  border-radius: var(--radius-sm); font-size: var(--fs-sm);
}
.search-result:hover, .search-result.active { background: var(--raised); }
.search-result .sr-title { font-size: var(--fs-md); display: flex; gap: 8px; align-items: center; }
.search-result .sr-snippet { color: var(--muted); }

/* ---- Sidebar ---- */
/* A floating warm-charcoal panel inset from the edges, its own colour apart from
   the white top bar and the cream page. It remaps the base tokens, so every
   row, button and badge inside reads its light-on-charcoal variants. */
.sidebar {
  --ink: var(--side-ink); --muted: var(--side-muted); --faint: var(--side-faint);
  --raised: var(--side-raised); --surface: var(--side-raised);
  --line: var(--side-line); --line-strong: var(--side-line);
  --accent: var(--side-active-ink); --accent-bg: var(--side-active-bg);
  color-scheme: dark; color: var(--ink);
  width: var(--sidebar-w); flex-shrink: 0; margin: 12px 0 12px 12px;
  background: var(--side-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-side);
  padding: 12px 10px 12px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar :focus-visible { outline-color: var(--side-ink); }
/* Icons and counts on the light active pill take its ink, not the panel's pale muted. */
.sidebar .tree-row.active, .sidebar .nav-btn.active { --muted: var(--side-active-ink); --faint: var(--side-active-ink); }
.nav-btn {
  display: flex; align-items: center; gap: 9px; border: none; background: transparent;
  font-size: var(--fs-md); font-weight: 500; padding: 7px 10px; cursor: pointer;
  text-align: left; border-radius: var(--radius-sm); color: var(--ink); width: 100%;
}
.nav-btn .msi { color: var(--muted); }
.nav-btn:hover { background: var(--raised); }
.nav-btn.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.nav-btn.active .msi { color: var(--accent); }
.nav-btn .count-badge {
  background: var(--danger); color: var(--on-accent); font-size: var(--fs-xs); font-weight: 600;
  padding: 1px 7px; border-radius: 999px; min-width: 18px; text-align: center; margin-left: auto;
}
.side-section {
  font-size: var(--fs-meta); color: var(--faint); font-weight: 600;
  padding: 16px 10px 4px; display: flex; align-items: center;
}
.side-section .plus { margin-left: auto; }
.plus {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 3px 6px; border-radius: var(--radius-sm); visibility: hidden;
}
.plus:hover { background: var(--raised); color: var(--ink); }
.side-section:hover .plus, .tree-row:hover .plus { visibility: visible; }

.tree-row { display: flex; align-items: center; border-radius: var(--radius-sm); }
.tree-row:hover { background: var(--raised); }
.tree-row.active { background: var(--accent-bg); }
.tree-row.active .tree-btn { color: var(--accent); }
.tree-btn {
  flex: 1; display: flex; align-items: center; gap: 7px; border: none; background: transparent;
  font-size: var(--fs-sm); padding: 6px 6px 6px 10px; cursor: pointer; text-align: left;
  color: var(--ink); min-width: 0; border-radius: var(--radius-sm);
}
.tree-btn .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-btn .cnt { color: var(--muted); font-size: var(--fs-xs); flex-shrink: 0; }
.tree-btn .chev { color: var(--muted); width: 10px; text-align: right; flex-shrink: 0; }
.tree-btn.project-btn { font-size: var(--fs-md); font-weight: 600; padding-left: 10px; }
.tree-btn .msi { font-size: 14px; color: var(--muted); flex-shrink: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.sm { width: 6px; height: 6px; }
/* Favorites: project key badge next to the color dot, so pinned lists from
   different projects stay distinguishable without relying on color alone. */
.tree-btn .proj-key {
  font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1; color: var(--muted);
  background: var(--raised); border-radius: 5px; padding: 2px 5px; flex-shrink: 0; letter-spacing: 0.02em;
}
.tree-row.active .proj-key { background: var(--side-bg); color: var(--side-ink); }
.star-btn {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  padding: 4px 6px; display: flex; visibility: hidden;
}
.tree-row:hover .star-btn, .star-btn.pinned { visibility: visible; }
.star-btn .msi { font-size: 13px; }
.add-menu { display: flex; gap: 4px; padding: 2px 10px 6px 24px; }
.add-menu .btn { font-size: var(--fs-xs); padding: 3px 6px; }
.indent-1 { padding-left: 24px !important; }
.indent-2 { padding-left: 38px !important; }

/* ---- List header (breadcrumb + tabs) ---- */
.list-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px 8px;
  flex-shrink: 0; min-height: 52px;
}
.breadcrumb { font-size: var(--fs-md); color: var(--muted); display: flex; gap: 6px; align-items: center; }
.breadcrumb .sep { opacity: 0.6; }
.breadcrumb b { color: var(--ink); font-weight: 600; }
.breadcrumb .list-gear { width: 26px; height: 26px; color: var(--muted); margin-left: 2px; }
.breadcrumb .list-gear:hover { color: var(--ink); }
.btn[disabled] { opacity: 0.35; cursor: default; }
.view-tabs { display: flex; gap: 2px; }
.view-tabs { padding: 3px; }
.view-tab {
  border: none; background: transparent; cursor: pointer; font-size: var(--fs-sm);
  padding: 5px 12px; color: var(--muted); border-radius: 999px;
}
.view-tab:hover { color: var(--ink); }
.view-tab.active { color: var(--ink); font-weight: 600; background: var(--surface); box-shadow: 0 0 0 1px var(--line), var(--shadow-card); }
.view-tab .msi { font-size: 13px; margin-right: 4px; vertical-align: -2px; }
.view-tabs .tab-sep { width: 1px; height: 16px; background: var(--line); align-self: center; margin: 0 4px; }
.view-tab.tab-add { color: var(--muted); }
.view-tab.tab-add:hover { color: var(--ink); }

/* ---- My Tasks ---- */
.mytasks {
  flex: 1; overflow-y: auto; padding: 24px 28px;
  max-width: 920px; width: 100%; margin: 0 auto;
}
.mt-actions { display: flex; justify-content: flex-end; margin-bottom: 12px; }
/* Each section is one soft card; rows inside have no borders. */
.mt-section {
  margin-bottom: 16px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-card);
  padding: 12px 6px 6px;
}
.mt-head { display: flex; align-items: baseline; gap: 8px; padding: 0 10px 6px; }
.mt-head .t { font-size: var(--fs-lg); font-weight: 600; white-space: nowrap; }
.mt-head.danger .t { color: var(--danger); }
.mt-head .c { font-size: var(--fs-sm); color: var(--faint); }
.mt-empty { font-size: var(--fs-md); color: var(--muted); padding: 6px 10px 8px; }

.task-row {
  display: flex; align-items: center; gap: 10px; padding: 0 10px; height: var(--row-h);
  cursor: pointer; border-radius: var(--radius-sm);
}
/* Hairline dividers between rows (inset shadow: no layout shift, survives hover). */
.task-row + .task-row, .inbox-item + .inbox-item { box-shadow: inset 0 1px 0 var(--divider); }
.task-row:hover, .task-row.selected { background: var(--raised); }
.task-row .key { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--faint); flex-shrink: 0; min-width: 58px; text-align: right; }
.task-row .title { font-size: var(--fs-md); flex: 1 1 auto; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Tags never take more than 40 % of a row, so a long tag list can't squeeze the title away. */
.task-row .tag-chips, .inbox-item .tag-chips { max-width: 40%; }
.task-row .due { font-size: var(--fs-sm); font-family: var(--font-mono); color: var(--muted); flex-shrink: 0; white-space: nowrap; text-align: right; }
.task-row .due:empty { display: none; }
.task-row .due.overdue, .card .due.overdue { color: var(--danger); font-weight: 500; }
.tag-chips { display: flex; gap: 4px; flex-wrap: nowrap; flex-shrink: 1; min-width: 0; overflow: hidden; }
.prio-flag { font-size: 15px; flex-shrink: 0; }
.prio-cell { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: var(--fs-sm); }
.proj-key-text { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--faint); flex-shrink: 0; }
.proj-cell { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-family: var(--font-mono); font-size: var(--fs-sm); }

.chip {
  font-size: var(--fs-xs); padding: 2px 8px; background: var(--raised); color: var(--muted);
  white-space: nowrap; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px;
}
.prio-chip { font-size: var(--fs-xs); font-weight: 600; padding: 2px 8px; white-space: nowrap; border-radius: 999px; flex-shrink: 0; }

/* Tag chips: filled with the tag's own color, text auto-contrasted so it
   stays readable regardless of which color (palette or custom) was picked. */
.tag-chip {
  font-size: var(--fs-xs); font-weight: 600; padding: 2px 9px; border-radius: 999px;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; line-height: 1.4; flex-shrink: 0;
}

/* Palette + custom color picker (Settings tag rows, drawer tag chips). */
.color-picker { display: flex; flex-direction: column; gap: 10px; }
.color-swatches { display: grid; grid-template-columns: repeat(11, 22px); gap: 5px; }
.color-swatch {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
  cursor: pointer; padding: 0; flex-shrink: 0; transition: transform 80ms;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { outline: 2px solid var(--ink); outline-offset: 1px; }
/* Rainbow "custom" swatch wrapping an invisible native color input. */
.color-swatch-custom {
  position: relative; display: block; overflow: hidden;
  background: conic-gradient(#f44 0deg, #fb3 60deg, #6d3 120deg, #3dd 180deg, #36f 240deg, #c3f 300deg, #f44 360deg);
}
.color-swatch-custom input[type='color'] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; border: 0;
}
.color-custom-row { display: flex; align-items: center; gap: 8px; }
.color-hex { width: 110px; font-family: var(--font-mono); font-size: var(--fs-sm); padding: 5px 9px; text-transform: uppercase; }
.color-picker-popover {
  display: inline-block; background: var(--surface); border-radius: var(--radius);
  padding: 14px; margin: 6px 0 8px; box-shadow: var(--shadow-pop);
}

/* ---- Board ---- */
/* Board: each column is a soft card that scrolls inside itself; cards are
   page-toned tiles on it. */
.board { flex: 1; overflow: auto; padding: 12px 24px 20px; display: flex; flex-direction: column; }
.board-cols { display: flex; gap: 12px; align-items: flex-start; min-width: max-content; flex: 1; min-height: 0; }
.board-col {
  width: var(--col-w); flex-shrink: 0; background: var(--raised); border-radius: var(--radius);
  border: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; max-height: 100%;
}
.board-col-head {
  display: flex; align-items: center; gap: 7px; padding: 6px 8px; margin-bottom: 6px;
  border-radius: var(--radius-sm); flex-shrink: 0;
}
.board-col-head .label { font-size: var(--fs-md); font-weight: 600; flex: 1; }
.board-col-head .count { font-size: var(--fs-sm); color: var(--faint); }
.board-col-head .count.over { color: var(--danger); font-weight: 600; }
.board-col-head { position: relative; }
.board-col-head.editable { cursor: pointer; }
.board-col-head.editable:hover { background: var(--raised); }
.status-popover {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: 340px;
  background: var(--surface); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow-pop); cursor: default;
  display: flex; flex-direction: column; gap: 12px; font-weight: 400;
}
.board-cards {
  display: flex; flex-direction: column; gap: 6px; min-height: 30px; padding: 2px 0 6px;
  overflow-y: auto; min-height: 0; border-radius: var(--radius);
}
.card {
  border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card);
  padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; flex-shrink: 0;
}
.card:hover { border-color: var(--line-strong); }
.card.dragging { opacity: 0.4; }
.card .key { font-size: var(--fs-meta); font-family: var(--font-mono); color: var(--faint); }
.card .title { font-size: var(--fs-md); line-height: 1.35; }
.card .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card .due { font-size: var(--fs-xs); font-family: var(--font-mono); color: var(--muted); }
.card .due.overdue { color: var(--danger); }
.board-col.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.board-col.drop-disabled { opacity: 0.35; filter: grayscale(0.6); }
.board-col.drop-disabled .board-cards { cursor: not-allowed; }
.type-icon { flex-shrink: 0; vertical-align: -2px; }
.status-icon { flex-shrink: 0; vertical-align: -3px; line-height: 1; }
.card .key { display: flex; align-items: center; gap: 4px; }

/* ---- Workflow editor (Settings) ---- */
.wf-tabs { display: flex; gap: 2px; flex-wrap: wrap; margin: 6px 0 10px; padding: 3px; }
/* Pill tabs need a raised track wherever they sit, or the active pill blends into the card. */
.view-tabs, .notes-tabs, .wf-tabs { background: var(--raised); border: 1px solid var(--line); border-radius: 999px; width: fit-content; }
.wf-tabs { border-radius: var(--radius); } /* may wrap to two rows */
.wf-section { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 10px 0 4px; }
.wf-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-md); }
.wf-checks label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
table.wf-grid { border-collapse: collapse; font-size: var(--fs-sm); }
table.wf-grid th, table.wf-grid td { border: 1px solid var(--line); padding: 4px 8px; text-align: center; }
table.wf-grid th { color: var(--muted); font-weight: 600; font-size: var(--fs-xs); background: var(--surface); }
table.wf-grid th.rowh { text-align: left; }
table.wf-grid td.self { background: var(--line); }
.wf-note { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; }
.wf-note.warn { color: var(--danger); }
.type-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.quick-add {
  border: none; background: transparent; color: var(--muted);
  font-size: var(--fs-sm); padding: 7px 8px; cursor: pointer; border-radius: var(--radius-sm); text-align: left;
}
.quick-add:hover { color: var(--ink); background: var(--raised); }
.quick-add-row { margin-top: 2px; }
.quick-add-row .quick-add { width: 100%; display: inline-flex; align-items: center; gap: 4px; }
.quick-add-row.open { display: flex; flex-direction: column; gap: 4px; }
.quick-add-error { font-size: var(--fs-xs); color: var(--danger); padding: 0 2px; }
.quick-add-error:empty { display: none; }
.quick-add-input { flex: 1; font-size: var(--fs-sm); padding: 7px 9px; background: var(--bg); }

/* ---- Table (list layout) ---- */
.table-wrap { flex: 1; overflow: auto; padding: 8px 24px 24px; }
table.tasks {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-md);
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-card); padding: 4px 8px 8px;
}
table.tasks th {
  text-align: left; padding: 10px 8px 8px; font-size: var(--fs-meta); color: var(--muted);
  font-weight: 600; border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none; white-space: nowrap; position: sticky; top: 0; background: var(--surface);
}
table.tasks th.r, table.tasks td.r { text-align: right; }
table.tasks td { padding: 4px 8px; height: 34px; border-bottom: 1px solid var(--divider); }
table.tasks tbody tr:last-child td { border-bottom: none; }
table.tasks tbody tr { cursor: pointer; }
table.tasks tbody tr:hover td { background: var(--raised); }
table.tasks tbody tr:hover td:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
table.tasks tbody tr:hover td:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
table.tasks td.key, table.tasks td.date { font-family: var(--font-mono); color: var(--muted); white-space: nowrap; }
table.tasks td.date.overdue { color: var(--danger); }

/* ---- Drawer: task detail (left) + comments & history chat (right) ---- */
.drawer-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 40; }
.drawer {
  position: absolute; top: 8px; right: 8px; height: calc(100% - 16px);
  width: calc(var(--drawer-w) * 2 - 60px); max-width: calc(96vw - 8px);
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  border: 1px solid var(--line); display: flex; flex-direction: row; overflow: hidden;
}
.drawer-form {
  width: var(--drawer-w); max-width: 60%; flex-shrink: 0;
  padding: 22px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px;
}
.drawer-chat {
  flex: 1; min-width: 300px; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; background: var(--bg);
}
.chat-head {
  padding: 16px 18px 10px;
  font-size: var(--fs-sm); color: var(--muted); font-weight: 600;
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
}
.chat-feed { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-card);
  padding: 10px 14px; display: flex; flex-direction: column; gap: 4px;
}
.chat-msg .cm-head { display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-xs); color: var(--muted); }
.chat-msg .cm-author { font-weight: 600; color: var(--ink); font-size: var(--fs-sm); }
.chat-msg .cm-time { margin-left: auto; font-family: var(--font-mono); }
.chat-msg .cm-del { cursor: pointer; opacity: 0; }
.chat-msg:hover .cm-del { opacity: 0.7; }
.chat-msg .md-preview { padding: 0; font-size: var(--fs-md); }
.chat-src {
  font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--raised);
  padding: 1px 7px; border-radius: 999px; color: var(--muted);
}
.chat-src.mcp { color: var(--accent); background: var(--accent-bg); }
.chat-event {
  display: flex; gap: 8px; align-items: baseline; font-size: var(--fs-xs);
  color: var(--faint); padding: 0 6px;
}
.chat-event .ce-time { margin-left: auto; font-family: var(--font-mono); flex-shrink: 0; }
.chat-day {
  text-align: center; font-size: var(--fs-xs); color: var(--faint);
  font-family: var(--font-mono); padding: 6px 0 2px;
}
.chat-composer {
  padding: 10px 14px 14px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-composer textarea {
  border: 1px solid transparent; background: var(--surface); border-radius: var(--radius);
  padding: 10px 12px; min-height: 64px; resize: vertical; line-height: 1.5; width: 100%;
}
.chat-composer textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.chat-composer .cc-actions { display: flex; align-items: center; gap: 8px; }
.chat-composer .cc-hint { font-size: var(--fs-xs); color: var(--muted); margin-left: auto; }
@media (max-width: 900px) {
  .drawer { flex-direction: column; width: calc(100vw - 16px); max-width: none; }
  .drawer-form { width: 100%; max-width: none; flex: 1; }
  .drawer-chat { border-left: none; border-top: 1px solid var(--line); max-height: 45%; }
}
.drawer .head { display: flex; align-items: center; gap: 10px; }
.drawer .title-input {
  font-size: var(--fs-title); font-weight: 600; border: none; background: transparent;
  color: var(--ink); padding: 0; width: 100%;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: var(--fs-meta); color: var(--muted); font-weight: 600; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.subtasks-head { display: flex; align-items: center; gap: 8px; }
.subtasks-head label { font-size: var(--fs-meta); color: var(--muted); font-weight: 600; }
.progress { height: 6px; background: var(--raised); border-radius: 999px; overflow: hidden; margin: 2px 0 4px; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width 160ms; }
.subtask {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: var(--fs-md);
  border-radius: var(--radius-sm); margin: 0 -8px;
}
.subtask:hover { background: var(--raised); }
.subtask .st-title { flex: 1; cursor: pointer; }
.subtask .st-title:hover { text-decoration: underline; }
.subtask .st-key { font-size: var(--fs-xs); color: var(--muted); flex-shrink: 0; }
.subtask.done .st-title { text-decoration: line-through; color: var(--muted); }
.subtask .st-status {
  font-size: var(--fs-xs); font-weight: 600; padding: 2px 8px; border-radius: 999px;
  white-space: nowrap; flex-shrink: 0;
}

/* Parent breadcrumb: which task this one is a subtask of. */
.parent-link {
  display: flex; align-items: center; gap: 6px; text-decoration: none;
  font-size: var(--fs-sm); color: var(--muted);
  background: var(--raised); border-radius: var(--radius-sm); padding: 6px 10px;
}
.parent-link:hover { background: color-mix(in srgb, var(--ink) 7%, var(--raised)); }
.parent-link .pl-key { flex-shrink: 0; font-size: var(--fs-xs); }
.parent-link .pl-title {
  color: var(--ink); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.parent-link:hover .pl-title { text-decoration: underline; }
.parent-link .pl-status { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; font-size: var(--fs-xs); font-weight: 600; }
.archived-banner {
  display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted);
  background: var(--raised); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 7px 12px;
}

/* ---- Dropdown menu (⋯) ---- */
.menu {
  position: fixed; z-index: 80; min-width: 210px; padding: 6px;
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column;
}
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  border: none; background: transparent; padding: 8px 10px; font-size: var(--fs-md);
  border-radius: var(--radius-sm); cursor: pointer; color: var(--ink);
}
.menu-item:hover { background: var(--raised); }
.menu-item .msi { color: var(--muted); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .msi { color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.gh-link { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); padding: 3px 0; }
.gh-state { font-size: var(--fs-xs); font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--raised); }
.gh-state.merged { color: var(--gh-merged); background: color-mix(in srgb, var(--gh-merged) 14%, var(--surface)); }
.gh-state.open { color: var(--gh-open); background: color-mix(in srgb, var(--gh-open) 14%, var(--surface)); }
.gh-state.closed { color: var(--danger); background: var(--danger-bg); }
.gh-state.draft { color: var(--muted); }
.gh-kind { font-size: var(--fs-xs); color: var(--muted); flex-shrink: 0; }
.gh-link a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-meta { font-size: var(--fs-xs); color: var(--muted); margin-left: auto; white-space: nowrap; flex-shrink: 0; }
.activity-row { display: flex; gap: 8px; font-size: var(--fs-sm); color: var(--muted); padding: 3px 0; align-items: baseline; }
.activity-row .src { font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--raised); padding: 1px 7px; border-radius: 999px; flex-shrink: 0; }
.md-toolbar { display: flex; gap: 2px; background: var(--raised); padding: 4px; border: 1px solid var(--line-strong); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.md-toolbar .btn { background: transparent; border-color: transparent; box-shadow: none; width: 26px; height: 26px; padding: 0; justify-content: center; }
.md-toolbar .btn:hover { background: var(--surface); }
.md-toolbar .grow { flex: 1; }
.md-body { background: var(--surface); border-radius: 0 0 var(--radius-sm) var(--radius-sm); border: 1px solid var(--line-strong); }
.md-body textarea { width: 100%; border: none; background: transparent; min-height: 110px; padding: 10px; font-size: var(--fs-md); display: block; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.md-body textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.md-preview { padding: 8px 10px; font-size: var(--fs-md); line-height: 1.55; min-height: 40px; }
.md-preview > :first-child { margin-top: 0; }
.md-preview > :last-child { margin-bottom: 0; }
.md-preview pre { background: var(--raised); padding: 10px; overflow-x: auto; border-radius: var(--radius-sm); }
.md-preview code { font-family: var(--font-mono); font-size: var(--fs-sm); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  border: 1px solid var(--line); padding: 22px; width: 360px; display: flex; flex-direction: column; gap: 14px;
}
.modal .m-title { font-size: var(--fs-title); font-weight: 600; }
.modal.wide { width: 720px; max-width: 94vw; gap: 14px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; }
.modal.wide .nt-title { font-size: var(--fs-title); font-weight: 600; padding: 8px 10px; }
.modal.wide textarea.input { width: 100%; min-height: 120px; }
.modal.wide .field-row .field { min-width: 0; }
.modal .m-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---- Notes ---- */
.notes-layout { flex: 1; display: flex; overflow: hidden; }
.notes-list {
  width: 280px; flex-shrink: 0; overflow-y: auto; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-card); margin: 12px 0 16px 24px;
}
.notes-tabs { display: flex; gap: 2px; padding: 3px; margin: 0 4px 8px; }
.note-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.note-item:hover { background: var(--raised); }
.note-item.active { background: var(--accent-bg); }
.note-item.active .n-title { color: var(--accent); }
.note-item.active .n-meta { color: var(--muted); }
.note-item .n-title { font-size: var(--fs-md); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .n-meta { font-size: var(--fs-xs); color: var(--faint); font-family: var(--font-mono); }
.note-editor { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 20px 28px; max-width: 860px; }
.note-editor .title-input { font-size: var(--fs-title); font-weight: 600; border: none; background: transparent; padding: 0 0 12px; width: 100%; color: var(--ink); }
.note-editor textarea { flex: 1; border: 1px solid var(--line); box-shadow: var(--shadow-card); background: var(--surface); padding: 16px 18px; line-height: 1.6; border-radius: var(--radius); }
.note-editor textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.note-editor .md-preview { flex: 1; overflow-y: auto; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-card); background: var(--surface); padding: 16px 18px; }
.editor-bar { display: flex; gap: 8px; align-items: center; padding-bottom: 8px; }
.save-state { font-size: var(--fs-xs); color: var(--faint); margin-left: auto; }

/* ---- Doc view ---- */
.doc-view { flex: 1; overflow-y: auto; padding: 24px 28px; max-width: 760px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; }

/* ---- Settings ---- */
/* Two tiers: groups (Personal, Workspace, …) → pages, beside one page at a time. */
.settings-shell { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.settings-nav { width: 228px; flex-shrink: 0; overflow-y: auto; padding: 4px 12px 24px 20px; display: flex; flex-direction: column; gap: 14px; }
.sn-group { display: flex; flex-direction: column; gap: 1px; }
.sn-group-label {
  font-size: var(--fs-meta); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 4px 10px 6px;
}
.sn-item {
  display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 5px 10px; border-radius: var(--radius-sm);
  color: var(--ink); font-size: var(--fs-md); text-decoration: none;
}
.sn-item .msi { color: var(--muted); }
.sn-item:hover { background: var(--raised); }
.sn-item.active { background: var(--surface); font-weight: 600; box-shadow: 0 0 0 1px var(--line), var(--shadow-card); }
.sn-item.active .msi { color: var(--accent); }
.sn-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sn-chev { display: none; margin-left: auto; }
.sn-back { display: none; align-items: center; gap: 2px; color: var(--accent); font-weight: 500; text-decoration: none; }
.settings { flex: 1; overflow-y: auto; padding: 4px 28px 40px 12px; }
.settings-page { max-width: 760px; }
.settings-head { margin: 0 0 14px; }
.settings-head h1 { font-size: var(--fs-screen); font-weight: 600; margin: 0 0 4px; }
.settings-head .hint { margin: 0; max-width: 62ch; line-height: 1.5; }
.settings h2 { font-size: var(--fs-title); margin: 28px 0 10px; }
.settings h2:first-child { margin-top: 0; }
.settings .row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: var(--fs-md); }
.settings .hint { font-size: var(--fs-sm); color: var(--muted); }
.settings .row > .grow { flex: 1 1 12em; min-width: 0; } /* long text beside its control: shrinks first, wraps last */
.settings pre { background: var(--surface); padding: 12px 14px; border-radius: var(--radius); overflow-x: auto; font-size: var(--fs-sm); }
.tpl-status { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: var(--fs-md); }
.tpl-status .cat { font-size: var(--fs-xs); color: var(--muted); width: 52px; }

/* ---- Login ---- */
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: 30px; width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-box .brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; justify-content: center; }
.login-error { color: var(--danger); font-size: var(--fs-sm); }

/* ---- Settings cards ---- */
.settings-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-card); padding: 18px 20px; margin-bottom: 14px; }
.settings .settings-card h2 { margin: 0 0 10px; }
.settings .settings-card h2 { font-size: var(--fs-lg); }

/* A preference: text left, control right, hairlines between. */
.pref { display: flex; align-items: center; gap: 8px 24px; padding: 12px 0; border-top: 1px solid var(--divider); flex-wrap: wrap; }
.settings-card > .pref:first-child, .settings-card > h2 + .pref { border-top: none; padding-top: 4px; }
.pref-text { flex: 1 1 18em; min-width: 0; }
.pref-label { font-size: var(--fs-md); font-weight: 500; display: block; }
.pref-text .hint { margin-top: 2px; line-height: 1.45; }
.pref-control { flex-shrink: 0; display: flex; align-items: center; gap: 8px; max-width: 100%; }
.pref-control select.input { min-width: 12em; max-width: 100%; }
.about-val { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.about-val code { overflow-wrap: anywhere; font-size: var(--fs-sm); }

.segmented { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px; border-radius: var(--radius-sm); background: var(--raised); border: 1px solid var(--line); }
.segmented button {
  display: inline-flex; align-items: center; gap: 5px; border: none; background: transparent; color: var(--muted);
  font: inherit; font-size: var(--fs-sm); padding: 4px 11px; border-radius: 6px; cursor: pointer; min-height: 28px;
}
.segmented button:hover { color: var(--ink); }
.segmented button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line), var(--shadow-card); }
.segmented button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.switch { position: relative; display: inline-flex; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-track { width: 100%; height: 100%; border-radius: 999px; background: var(--line-strong); transition: background 0.15s; }
.switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / 25%); transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .switch-track, .switch-track::after { transition: none; } }

.swatch-input { width: 18px; height: 18px; padding: 0; border: 1px solid var(--line); border-radius: 3px; cursor: pointer; flex-shrink: 0; }
.user-row { padding: 8px 0; border-top: 1px solid var(--divider); }
.settings-card > .user-row:first-child { border-top: none; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--accent-bg); color: var(--accent); font-weight: 600; font-size: var(--fs-sm);
}
.shortcut-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); column-gap: 28px; }
.shortcut { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--divider); font-size: var(--fs-md); }
.keys { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }
.keys kbd {
  font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--raised); color: var(--ink); min-width: 22px; text-align: center;
  box-shadow: inset 0 -1px 0 var(--line-strong); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
}

/* Density: compact rows (Settings → Preferences). */
html[data-density='compact'] { --row-h: 30px; }

/* ---- Settings → Google Calendar ---- */
.cal-err { display: flex; align-items: flex-start; gap: 6px; color: var(--danger); font-size: var(--fs-sm); padding: 2px 0 4px; }
.cal-err .msi { flex-shrink: 0; margin-top: 1px; }
.settings .cal-err.row { font-size: var(--fs-md); align-items: center; }
.cal-list { margin: 6px 0 4px; }
.cal-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 4px 14px;
  padding: 7px 0; border-top: 1px solid var(--divider); font-size: var(--fs-md);
}
.cal-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 30%, transparent); }
.cal-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cal-label { min-width: 0; overflow-wrap: anywhere; }
.cal-check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; }
.cal-check.off { opacity: 0.6; cursor: default; }
.cal-row .cal-err { grid-column: 2 / -1; padding: 0; }
.cal-syncing { grid-column: 2 / -1; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); }
.cal-syncing .msi { color: var(--accent); animation: dp-spin 1s linear infinite; }
@media (prefers-reduced-motion: reduce) { .cal-syncing .msi { animation: none; } }
.cal-preview { margin: 12px 0 6px; }
.cal-event { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 3px 0; border-top: 1px solid var(--divider); font-size: var(--fs-md); }
.cal-time { width: 104px; flex-shrink: 0; font-size: var(--fs-sm); color: var(--muted); }
.cal-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chips { display: inline-flex; gap: 4px; flex-shrink: 0; }
.chip.cal-busy { background: var(--accent-bg); color: var(--accent); }

/* Setup modal */
.cal-modal .hint { font-size: var(--fs-sm); color: var(--muted); }
.cal-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; font-size: var(--fs-md); line-height: 1.5; }
.cal-steps ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.cal-copy { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; }
.cal-copy code {
  flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; padding: 6px 10px; font-size: var(--fs-sm);
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.cal-copy .btn { flex-shrink: 0; }
.cal-warn {
  display: flex; align-items: flex-start; gap: 10px; margin: 8px 0 2px; padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--surface)); border-radius: var(--radius-sm);
  background: var(--danger-bg); font-size: var(--fs-sm); line-height: 1.5;
}
.cal-warn .msi { color: var(--danger); flex-shrink: 0; }
.cal-paste { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100;
  display: flex; align-items: center; gap: 8px; max-width: min(560px, 92vw);
  background: var(--ink); color: var(--surface); padding: 10px 16px;
  border-radius: var(--radius); box-shadow: var(--shadow-pop); font-size: var(--fs-md);
}
.toast.error { background: var(--danger); color: var(--surface); }

/* ---- Misc ---- */
.empty-view { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.kbd {
  font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--raised);
  box-shadow: inset 0 -1px 0 var(--line-strong); border-radius: 5px; padding: 1px 5px; color: var(--muted);
}

/* ---- Inbox (capture + triage) ---- */
.inbox {
  flex: 1; overflow-y: auto; padding: 24px 28px;
  max-width: 920px; width: 100%; margin: 0 auto;
}
.inbox-head { margin-bottom: 14px; }
.inbox-title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-screen); font-weight: 600; }
.inbox-title .c { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; }
.inbox-hint { font-size: var(--fs-sm); color: var(--muted); margin-top: 4px; line-height: 1.5; }
.inbox-capture {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; margin-bottom: 16px;
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-card);
}
.inbox-capture:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.inbox-capture .cap-icon { color: var(--muted); margin-top: 7px; }
textarea.capture-input {
  flex: 1; resize: none; border: none; background: transparent; padding: 6px 2px;
  font-size: var(--fs-md); line-height: 1.45; min-height: 30px; box-shadow: none;
}
.capture-input:focus { outline: none; box-shadow: none; }
.inbox-list { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-card); padding: 6px; }
.inbox-list:empty { display: none; }
.inbox-item {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px;
  cursor: pointer; border-radius: var(--radius-sm);
}
.inbox-item:hover, .inbox-item.selected { background: var(--raised); }
.inbox-item.selected { box-shadow: inset 3px 0 0 var(--accent), inset 0 1px 0 var(--divider); }
.inbox-item.flash { animation: inbox-flash 1.8s ease-out; }
@keyframes inbox-flash { 0% { background: var(--accent-bg); } 100% { background: transparent; } }
.inbox-item .key { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--faint); flex-shrink: 0; width: 66px; }
.inbox-item .body { flex: 1; min-width: 120px; display: flex; align-items: baseline; gap: 8px; overflow: hidden; }
.inbox-item .title { font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-item .preview { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 3; }
.inbox-item .planned { display: inline-flex; align-items: center; gap: 3px; font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--muted); flex-shrink: 0; }
.inbox-item .due:empty { display: none; }
.inbox-item .age { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--faint); width: 34px; text-align: right; flex-shrink: 0; }
.inbox-item .actions { display: flex; gap: 2px; flex-shrink: 0; opacity: 0; transition: opacity 0.12s; }
.inbox-item:hover .actions, .inbox-item.selected .actions, .inbox-item:focus-within .actions { opacity: 1; }
.inbox-item .ia { width: 26px; height: 26px; color: var(--muted); }
.inbox-item .ia:hover { color: var(--ink); }
.inbox-item .ia.danger:hover { color: var(--danger); }
.inbox-empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 48px 0; color: var(--muted);
}
.inbox-empty .t { font-size: var(--fs-lg); font-weight: 600; color: var(--ink); }
.inbox-empty .s { font-size: var(--fs-md); }

/* Global quick capture (I) — anchored near the top like a command palette. */
.capture-overlay { align-items: flex-start; padding-top: 14vh; }
.capture-modal { width: 560px; max-width: 94vw; gap: 10px; }
.capture-modal .cap-row { display: flex; align-items: flex-start; gap: 10px; }
.capture-modal .cap-icon { color: var(--muted); margin-top: 8px; }
.capture-modal .capture-input { border: 1px solid transparent; background: var(--raised); border-radius: var(--radius-sm); padding: 9px 11px; }
.capture-modal .capture-input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.capture-modal .cap-foot { display: flex; align-items: center; gap: 8px; }
.capture-modal .cap-foot .hint { font-size: var(--fs-sm); color: var(--muted); }
.capture-modal .cap-foot a { color: var(--ink); }

/* ---- Habits ---- */
.habits { flex: 1; overflow-y: auto; padding: 20px 24px 32px; max-width: 760px; width: 100%; margin: 0 auto; }
.habits-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.habits-title { font-size: var(--fs-screen); font-weight: 600; }
.habits-date { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.habit-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-card);
  padding: 6px; margin-bottom: 12px; display: flex; flex-direction: column;
}
/* Hairline between rows, on the front layer (it covers the row itself); survives hover. */
.habit-row + .habit-row .swipe-front { box-shadow: inset 0 1px 0 var(--divider); }
.habit-group + .habit-row .swipe-front { box-shadow: none; }
.habit-card.quiet { padding: 16px 18px; color: var(--muted); }
.habit-group { font-size: var(--fs-meta); font-weight: 600; color: var(--faint); padding: 6px 10px 4px; }
.habit-more { margin-bottom: 12px; }
.habit-more > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--muted); border-radius: var(--radius-sm);
}
.habit-more > summary::-webkit-details-marker { display: none; }
.habit-more > summary::before { content: '›'; font-size: 16px; transition: transform 120ms; }
.habit-more[open] > summary::before { transform: rotate(90deg); }
.habit-more > summary .c { color: var(--faint); font-weight: 500; }
.habit-more > summary:hover { background: var(--raised); }
.habits-hint { display: flex; align-items: center; gap: 6px; justify-content: center; color: var(--faint); font-size: var(--fs-sm); padding: 8px 0 4px; }
.habits-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 56px 16px; text-align: center; color: var(--muted); }
.habits-empty .msi { color: var(--accent); }
.habits-empty .t { font-size: var(--fs-title); font-weight: 600; color: var(--ink); }
.habits-empty .s { font-size: var(--fs-md); max-width: 360px; line-height: 1.5; margin-bottom: 6px; }

/* A habit row is a swipe container: the action layer sits under the front. */
.swipe-row {
  position: relative; border-radius: var(--radius-sm); overflow: hidden;
  touch-action: pan-y; -webkit-user-select: none; user-select: none; --swipe-p: 0;
}
.swipe-under {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); background: var(--raised);
}
.swipe-act { display: inline-flex; align-items: center; gap: 6px; opacity: calc(0.35 + var(--swipe-p) * 0.65); }
.swipe-row[data-dir='right'] .swipe-act.left, .swipe-row[data-dir='left'] .swipe-act.right { visibility: hidden; }
.swipe-row[data-dir='right'] .swipe-under { background: color-mix(in srgb, var(--accent) calc(var(--swipe-p) * 100%), var(--raised)); }
.swipe-row[data-dir='right'].armed .swipe-under { color: var(--on-accent); }
.swipe-row.armed[data-dir='left'] .swipe-under { color: var(--ink); background: color-mix(in srgb, var(--ink) 12%, var(--raised)); }
.swipe-front {
  position: relative; background: var(--surface); display: grid; align-items: center; column-gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto; grid-template-areas: 'tile main strip ctrl menu';
  padding: 8px 6px 8px 10px; min-height: 56px; border-radius: var(--radius-sm); cursor: pointer;
}
.habit-row:hover .swipe-front, .habit-row.selected .swipe-front { background: var(--raised); }
.habit-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.habit-tile { grid-area: tile; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; flex-shrink: 0; }
.habit-main { grid-area: main; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.habit-name { font-size: var(--fs-md); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-meta { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-meta.done { color: var(--accent); }
.habit-row.done .habit-name { color: var(--muted); }
.habit-progress { height: 4px; background: var(--divider); border-radius: 999px; overflow: hidden; margin-top: 3px; max-width: 220px; }
.habit-row:hover .habit-progress { background: var(--line); }
.habit-progress > span { display: block; height: 100%; border-radius: 999px; transition: width 200ms; }
.habit-milestone {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; align-self: flex-start;
  font-size: var(--fs-meta); font-weight: 600; color: var(--accent); background: var(--accent-bg);
  padding: 2px 8px; border-radius: 999px;
}
.week-strip { grid-area: strip; display: inline-flex; gap: 4px; }
.ws-day { width: 13px; height: 13px; border-radius: 4px; box-sizing: border-box; }
.ws-day.done, .ws-day.clean { background: var(--c); }
.ws-day.clean { opacity: 0.45; }
.ws-day.partial { background: color-mix(in srgb, var(--c) 40%, transparent); }
.ws-day.skipped { border: 1.5px dashed var(--line-strong); }
.ws-day.missed, .ws-day.open { border: 1.5px solid var(--line-strong); }
.ws-day.slipped { background: var(--danger); border-radius: 50%; } /* shape, not only colour */
.ws-day.off { background: var(--divider); }
.habit-row:hover .ws-day.off, .habit-row.selected .ws-day.off { background: var(--line); }
.ws-day.today { outline: 1.5px solid var(--ink); outline-offset: 1.5px; }
.log-btn {
  grid-area: ctrl; width: 38px; height: 38px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--accent); background: transparent; color: var(--accent); cursor: pointer; transition: background 120ms, color 120ms;
}
.log-btn:hover { background: var(--accent-bg); }
.log-btn.done { background: var(--accent); color: var(--on-accent); }
.row-menu { grid-area: menu; }
.count-badge.neutral, .nav-btn .count-badge.neutral { background: var(--raised); color: var(--muted); }
.count-badge[hidden] { display: none; }
.sidebar .count-badge.neutral { background: var(--side-line); color: var(--side-ink); }

.amount-pop {
  position: fixed; z-index: 90; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow-pop); padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
.ap-title { font-size: var(--fs-sm); font-weight: 600; }
.ap-title span { color: var(--muted); font-weight: 400; }
.ap-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  border: none; background: var(--raised); color: var(--ink); border-radius: 999px; padding: 7px 12px;
  font-size: var(--fs-sm); font-weight: 500; cursor: pointer;
}
.chip-btn:hover { background: var(--accent-bg); color: var(--accent); }
.ap-row { display: flex; gap: 8px; }
.ap-row .input { flex: 1; min-width: 0; }

.notify-card {
  display: flex; align-items: center; gap: 12px; background: var(--accent-bg); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--accent-bg)); box-shadow: var(--shadow-card);
  border-radius: var(--radius); padding: 12px 12px 12px 16px; margin-bottom: 12px;
}
.notify-card > .msi { color: var(--accent); }
.notify-card .nc-text { flex: 1; min-width: 0; }
.notify-card .nc-title { font-weight: 600; font-size: var(--fs-md); }
.notify-card .nc-body { font-size: var(--fs-sm); color: var(--muted); }

/* ---- Habit form, icon picker, habit drawer ---- */
.habit-modal { width: 560px; }
.habit-form { display: flex; flex-direction: column; gap: 14px; }
.segmented { display: inline-flex; background: var(--raised); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; width: fit-content; max-width: 100%; }
.seg {
  border: none; background: transparent; color: var(--muted); font-size: var(--fs-sm); font-weight: 500;
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
}
.seg:hover { color: var(--ink); }
.seg.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line), var(--shadow-card); }
.hf-top { display: flex; gap: 12px; align-items: flex-start; }
.hf-icon { border: none; background: transparent; padding: 0; cursor: pointer; border-radius: 12px; }
.hf-icon .habit-tile { border-radius: 12px; }
.hf-titles { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hf-name { font-size: var(--fs-lg); font-weight: 600; }
.hf-desc { resize: vertical; }
.modal.wide textarea.input.hf-desc { min-height: 0; }
.hf-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.hf-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.hf-row .input { width: 96px; }
.hf-suffix { color: var(--muted); font-size: var(--fs-sm); }
.hf-days { display: flex; gap: 6px; margin-top: 6px; }
.day-toggle {
  width: 34px; height: 34px; border-radius: 999px; border: none; background: var(--raised); color: var(--muted);
  font-weight: 600; cursor: pointer;
}
.day-toggle.active { background: var(--accent); color: var(--on-accent); }
.hf-times { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.time-chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--accent-bg); color: var(--accent);
  border-radius: 999px; padding: 4px 6px 4px 10px; font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 500;
}
.time-chip button { border: none; background: transparent; color: inherit; cursor: pointer; display: inline-flex; padding: 0 2px; }
.hf-time { width: 112px; }
.hf-note { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: var(--fs-sm); background: var(--raised); border: 1px solid var(--divider); border-radius: var(--radius-sm); padding: 10px 12px; }
.hf-note .msi { color: var(--accent); }
.habit-modal .m-actions .hint { margin-right: auto; font-size: var(--fs-sm); color: var(--faint); }

.icon-pop {
  position: fixed; z-index: 95; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-pop);
  padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: min(420px, 70vh);
}
.icon-grid { overflow-y: auto; }
.icon-cat { font-size: var(--fs-meta); font-weight: 600; color: var(--faint); padding: 8px 4px 4px; }
.icon-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; }
.icon-cell {
  height: 40px; border: none; background: transparent; color: var(--ink); border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-cell:hover { background: var(--raised); }
.icon-cell.active { background: var(--accent-bg); color: var(--accent); }
.icon-empty { color: var(--muted); padding: 16px 4px; font-size: var(--fs-sm); }

.habit-drawer { flex-direction: column; }
.hd-top { display: flex; align-items: center; gap: 12px; padding: 16px 20px 12px 24px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.hd-body { flex: 1; min-height: 0; display: flex; }
.hd-body > .drawer-form, .hd-body > .habit-side { overflow-y: auto; }
.hd-name { font-size: var(--fs-title); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-side { padding: 16px; gap: 14px; overflow-y: auto; }
.habit-side .chat-head { padding: 4px 2px 0; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.stat-tile { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-card); padding: 12px 14px; }
.st-label { font-size: var(--fs-meta); color: var(--muted); font-weight: 600; }
.st-value { font-size: 24px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.st-sub { font-size: var(--fs-meta); color: var(--faint); }
.habit-cal { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-card); padding: 10px 12px 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: var(--fs-md); margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: var(--fs-meta); color: var(--faint); font-weight: 600; padding-bottom: 2px; }
.cal-cell {
  aspect-ratio: 1; border: none; border-radius: var(--radius-sm); background: var(--raised); box-shadow: inset 0 0 0 1px var(--divider); color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; padding: 0;
  font-size: var(--fs-meta); font-variant-numeric: tabular-nums;
}
.cal-cell.pad { background: transparent; box-shadow: none; cursor: default; }
.cal-cell:disabled { cursor: default; opacity: 0.55; }
.cal-cell .msi { font-size: 14px; }
.cal-cell.done { background: var(--c); color: var(--surface); }
.cal-cell.partial { background: color-mix(in srgb, var(--c) 35%, var(--surface)); color: var(--ink); }
.cal-cell.clean { background: color-mix(in srgb, var(--c) 30%, var(--surface)); color: var(--ink); }
.cal-cell.slipped { background: var(--danger); color: var(--surface); }
.cal-cell.skipped { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.cal-cell.missed { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); color: var(--faint); }
.cal-cell.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.habit-feed { display: flex; flex-direction: column; gap: 6px; }

.notify-panel { display: flex; flex-direction: column; gap: 8px; }
.notify-panel .row .msi { color: var(--accent); }
.device-list { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.device-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--raised); border: 1px solid var(--divider); }
.device-row > .msi { color: var(--muted); }
.device-row .dv-main { flex: 1; min-width: 0; }
.device-row .chip { margin-left: 8px; background: var(--accent-bg); color: var(--accent); }

/* ---- Habit templates ---- */
.tpl-section { border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised); }
.tpl-section > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--muted);
}
.tpl-section > summary::-webkit-details-marker { display: none; }
.tpl-section > summary .msi { color: var(--accent); }
.tpl-section[open] > summary { padding-bottom: 6px; }
.tpl-section .tpl-gallery { padding: 0 10px 10px; }
.tpl-gallery { display: flex; flex-direction: column; gap: 10px; }
.tpl-tabs { max-width: 100%; }
.tpl-tabs .seg { padding: 5px 11px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 6px; }
.tpl-card {
  display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card); padding: 8px 10px; color: var(--ink);
}
.tpl-card:hover { border-color: var(--line-strong); background: var(--surface); }
.tpl-card .habit-tile { border-radius: 9px; flex-shrink: 0; }
.tpl-text { display: flex; flex-direction: column; min-width: 0; }
.tpl-name { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-meta { font-size: var(--fs-meta); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habits-empty-tpl { width: 100%; max-width: 640px; margin: 4px 0 8px; }

.hf-help { font-size: var(--fs-meta); color: var(--muted); }
.slip-modal { width: 360px; }
.slip-sub { font-size: var(--fs-sm); color: var(--muted); line-height: 1.45; }
.slip-field { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-meta); font-weight: 600; color: var(--muted); }
.cal-count { font-size: var(--fs-meta); font-weight: 700; line-height: 1; }

/* ---- Habit reorder mode ---- */
.head-actions { display: flex; align-items: center; gap: 8px; }
.reorder-hint { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); margin: 0 2px 12px; }
.reorder-list { display: flex; flex-direction: column; }
.reorder-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 6px 8px 10px; min-height: 56px;
  border-radius: var(--radius-sm); background: var(--surface);
}
.reorder-row + .reorder-row { box-shadow: inset 0 1px 0 var(--divider); }
.reorder-row .habit-main { flex: 1; min-width: 0; }
.reorder-row.dragging {
  position: relative; z-index: 2; background: var(--raised);
  box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-pop);
}
.reorder-handle {
  width: 44px; height: 44px; flex-shrink: 0; border: none; background: transparent; color: var(--muted);
  border-radius: var(--radius-sm); cursor: grab; touch-action: none; display: inline-flex; align-items: center; justify-content: center;
}
.reorder-handle:hover { background: var(--raised); color: var(--ink); }
.reorder-row.dragging .reorder-handle { cursor: grabbing; color: var(--accent); }
.reorder-empty { display: none; color: var(--faint); font-size: var(--fs-sm); padding: 14px 10px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm); text-align: center; }
.reorder-card.empty .reorder-empty { display: block; }

/* ---- Phone shell: bottom tab bar, sheets ---- */
.install-sheet { max-width: 520px; margin: 0 auto; }
.install-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 12px; }
.install-head > div { flex: 1; min-width: 0; }
.install-icon { width: 48px; height: 48px; border-radius: 11px; box-shadow: var(--shadow-card); }
.install-title { font-size: var(--fs-title); font-weight: 600; }
.install-sub { font-size: var(--fs-sm); color: var(--muted); }
.install-lead { margin: 0 4px 12px; font-size: var(--fs-md); line-height: 1.5; }
.install-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.install-step {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card);
}
.is-num { width: 22px; height: 22px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: var(--fs-meta); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.is-icon { color: var(--accent); display: inline-flex; flex-shrink: 0; }
.is-text { display: flex; flex-direction: column; min-width: 0; }
.is-title { font-weight: 600; font-size: var(--fs-md); }
.is-body { font-size: var(--fs-sm); color: var(--muted); line-height: 1.4; }
.install-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--raised); border: 1px solid var(--divider); font-size: var(--fs-sm); color: var(--muted); }
.install-go { width: 100%; justify-content: center; padding: 11px 14px; }
.tabbar { display: none; }
.sheet-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 70; display: flex; align-items: flex-end; }
.sheet {
  width: 100%; background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-top: 1px solid var(--line);
  padding: 8px 12px calc(14px + env(safe-area-inset-bottom)); max-height: 80vh; max-height: 80dvh; overflow-y: auto; box-shadow: var(--shadow-pop);
}
.sheet-grip { width: 36px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 4px auto 10px; }
.sheet-section { font-size: var(--fs-meta); font-weight: 600; color: var(--faint); padding: 6px 8px; }
.sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%; border: none; background: transparent; color: var(--ink);
  font-size: var(--fs-lg); padding: 12px 10px; border-radius: var(--radius-sm); cursor: pointer; text-align: left;
}
.sheet-item:hover { background: var(--raised); }
.sheet-item .msi { color: var(--muted); }
.sheet-sep { height: 1px; background: var(--line); margin: 6px 8px; }
.sheet-empty { color: var(--muted); padding: 8px 10px; font-size: var(--fs-sm); }

@media (max-width: 720px) {
  .sidebar { display: none; }
  .topbar { height: auto; min-height: 52px; padding: env(safe-area-inset-top) 12px 0; }
  .topbar .search-wrap { display: none; }
  .tabbar {
    display: flex; flex-shrink: 0; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; border: none; background: transparent;
    color: var(--muted); font-size: var(--fs-meta); font-weight: 500; padding: 2px 0; cursor: pointer;
  }
  .tab-icon { position: relative; display: inline-flex; padding: 4px 18px; border-radius: 999px; }
  .tab.active { color: var(--accent); font-weight: 600; }
  .tab.active .tab-icon { background: var(--accent-bg); }
  .tab-badge {
    position: absolute; top: -2px; right: 6px; min-width: 18px; padding: 1px 5px; border-radius: 999px;
    background: var(--raised); color: var(--muted); font-size: 11px; font-weight: 600; text-align: center; line-height: 16px;
  }
  .tab-badge.danger { background: var(--danger); color: var(--surface); }
  .tab-badge[hidden] { display: none; }
  .mytasks, .inbox, .habits { padding: 12px 12px 20px; }
  .habits-head .btn.primary { padding: 9px 14px; }
  .swipe-front {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas: 'tile main ctrl menu' 'tile strip ctrl menu';
    row-gap: 6px; min-height: 64px;
  }
  .week-strip { justify-self: start; }
  .log-btn { width: 44px; height: 44px; }
  .drawer { top: 0; right: 0; width: 100vw; height: 100%; max-width: none; border-radius: 0; }
  .modal.wide, .modal { width: calc(100vw - 24px); max-width: none; }
  .task-row .tag-chips, .task-row .key, .task-row .type-icon { display: none; }
  .tpl-grid { grid-template-columns: 1fr 1fr; }
  .tpl-card { padding: 8px; gap: 8px; }
  .tpl-meta, .tpl-name { white-space: normal; }
  /* Habit drawer on a phone: one scrolling page — header, stats + calendar, then the form. */
  .habit-drawer { overflow-y: auto; }
  .hd-top { position: sticky; top: 0; z-index: 2; background: var(--surface); padding: calc(10px + env(safe-area-inset-top)) 12px 10px 16px; }
  .hd-body { flex-direction: column; flex: none; }
  .hd-body > .drawer-form, .hd-body > .habit-side { overflow: visible; max-height: none; width: 100%; max-width: none; flex: none; }
  .hd-body > .habit-side { order: -1; border: none; padding: 12px; }
  .hd-body > .drawer-form { padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
  .task-row .title { min-width: 0; }
  .mt-section { padding: 10px 4px 6px; }
  .inbox-item .preview, .inbox-item .age, .inbox-item .key { display: none; }
  .inbox-item { padding: 0 6px; gap: 8px; }
  .inbox-item .actions { opacity: 1; }
  /* Settings on a phone: tighter gutters, and every row wraps instead of running off-screen. */
  .settings { padding: 4px 12px 24px; max-width: none; }
  /* Settings menu: /settings is the menu, a page replaces it and shows "‹ Settings". */
  .settings-shell.at-root .settings, .settings-shell.has-page .settings-nav { display: none; }
  .settings-shell.at-root .settings-nav { width: auto; flex: 1; padding: 4px 12px 24px; }
  .settings-nav .sn-item { min-height: 44px; background: var(--surface); border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--divider); font-weight: 400; }
  .sn-group .sn-item:nth-child(2) { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
  .sn-group .sn-item:last-child { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); border-bottom: none; }
  .sn-group { gap: 0; }
  .settings-nav .sn-item.active .msi { color: var(--muted); }
  .settings-nav .sn-item .sn-chev { color: var(--faint); }
  .sn-chev { display: inline-block; color: var(--faint); }
  .list-header .sn-crumb { display: none; }
  .list-header:has(+ .settings-shell.has-page) .sn-back { display: inline-flex; }
  .list-header:has(+ .settings-shell.has-page) .sn-crumb-root { display: none; }
  .pref-control { width: 100%; }
  .settings-card { padding: 14px; }
  .settings .row, .settings .type-row, .settings .tpl-status { flex-wrap: wrap; }
  .settings .stretch { flex: 1 1 0; min-width: 0; } /* name inputs give up width so their row stays one line */
  /* Google Calendar: the name takes the first line, the ticks stack beneath it. */
  .cal-row { grid-template-columns: auto minmax(0, 1fr); }
  .cal-row .cal-check, .cal-row .cal-err, .cal-row .cal-syncing { grid-column: 2; }
  .cal-event { flex-wrap: wrap; gap: 3px 10px; padding: 6px 0; }
  .cal-title { order: 1; flex: 1 0 100%; }
  .cal-time { order: 2; width: auto; }
  .cal-time.none { display: none; }
  .cal-chips { order: 3; }
  .cal-copy { flex-wrap: wrap; }
  .cal-copy code { flex-basis: 100%; }
}

/* ---- Your day (AI daily plan) ---- */
.dayplan { padding: 12px 10px 8px; }
.dayplan .mt-head { padding: 0 4px 8px; }
.dp-head { display: flex; align-items: flex-start; gap: 12px; padding: 0 4px 12px; }
.dp-head-text { flex: 1; min-width: 0; }
.dp-summary { font-size: var(--fs-md); color: var(--ink); line-height: 1.45; }
.dp-made { font-size: var(--fs-meta); color: var(--muted); margin-top: 3px; }
.dp-cal-warn { display: flex; align-items: flex-start; gap: 6px; margin-top: 6px; font-size: var(--fs-meta); color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.dp-cal-warn:hover { color: var(--ink); }
.dp-cal-warn .msi { color: var(--danger); flex-shrink: 0; margin-top: 1px; }
.dp-empty { display: flex; align-items: center; gap: 10px; padding: 4px 4px 6px; color: var(--muted); font-size: var(--fs-md); flex-wrap: wrap; }
.dp-empty > .msi { color: var(--accent); }
.dp-planning { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--fs-md); padding: 0 4px 10px; }
.dp-planning .msi { animation: dp-spin 1s linear infinite; color: var(--accent); }
@keyframes dp-spin { to { transform: rotate(360deg); } }
.dp-skel { display: flex; flex-direction: column; gap: 6px; padding: 0 4px 6px 62px; }
.dp-skel-row { border-radius: var(--radius-sm); background: var(--raised); animation: dp-pulse 1.4s ease-in-out infinite; }
@keyframes dp-pulse { 50% { opacity: .5; } }

/* Top 3 */
.dp-top3 { display: flex; flex-direction: column; gap: 6px; padding: 0 0 12px; }
.dp-card {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}
.dp-card:hover { background: var(--raised); }
.dp-card:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dp-replan .modal:focus { outline: none; } /* focusable only so its keys stay in the sheet */
.dp-rank {
  width: 26px; height: 26px; border-radius: 999px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-bg); color: var(--accent); font-weight: 700; font-size: var(--fs-sm); font-family: var(--font-mono);
}
.dp-card .dp-why, .dp-why { font-size: var(--fs-sm); color: var(--muted); }
.dp-card .dp-why { margin-top: 2px; }
.dp-check { width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line-strong); flex-shrink: 0; }
.dp-check.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.dp-card.done .dp-name { color: var(--muted); }

/* Timeline: a flow of rows (time column + block), so blocks never overlap. */
.dp-timeline { display: flex; flex-direction: column; }
.dp-row { position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: stretch; }
.dp-row + .dp-row:not(.gap) { margin-top: 4px; }
.dp-time { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); padding: 8px 8px 0 4px; text-align: right; }
.dp-gap {
  display: flex; align-items: center; padding-left: 12px; font-size: var(--fs-meta); color: var(--faint);
  border-left: 2px dotted var(--line-strong); margin-left: 10px;
}
.dp-block.swipe-row { border-radius: var(--radius-sm); }
.dp-block .swipe-front {
  display: flex; grid-template-columns: none; grid-template-areas: none; align-items: center; gap: 10px;
  min-height: inherit; height: 100%; padding: 6px 10px; border: 1px solid var(--line); background: var(--surface);
}
.dp-block:hover .swipe-front { background: var(--raised); }
.dp-edge { align-self: stretch; width: 3px; border-radius: 3px; flex-shrink: 0; margin: -2px 0; }
.dp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dp-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.dp-name { font-size: var(--fs-md); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dp-key { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--muted); flex-shrink: 0; }
.dp-meta { display: flex; align-items: center; gap: 8px; font-size: var(--fs-meta); color: var(--muted); white-space: nowrap; overflow: hidden; }
.dp-meta .dp-why { overflow: hidden; text-overflow: ellipsis; }
.dp-energy { display: inline-flex; align-items: center; gap: 3px; }
.dp-tag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-meta); color: var(--muted); flex-shrink: 0; }
.dp-tag.done { color: var(--accent); font-weight: 600; }
.dp-block.kind-event .swipe-front, .dp-block.kind-lunch .swipe-front { background: var(--raised); color: var(--muted); }
.dp-block.kind-event .dp-name, .dp-block.kind-lunch .dp-name { color: var(--muted); }
.dp-block.kind-break .swipe-front { border-style: dashed; border-color: var(--line-strong); background: transparent; color: var(--muted); }
/* Dim what is on the front, not the front itself: an opaque front keeps the swipe labels underneath hidden. */
.dp-block.past .swipe-front > * { opacity: .55; }
.dp-block.done .dp-name, .dp-card.done .dp-name { color: var(--muted); }
.struck .dp-name { text-decoration: line-through; color: var(--muted); }
.dp-now { position: absolute; left: 44px; right: 0; height: 0; border-top: 2px solid var(--danger); z-index: 1; pointer-events: none; }
.dp-now-label {
  position: absolute; left: -44px; top: -9px; padding: 0 4px; border-radius: 4px;
  font-family: var(--font-mono); font-size: var(--fs-meta); font-weight: 600; color: var(--danger); background: var(--surface);
}
.dp-more { margin: 10px 0 0; }
.dp-more-list { display: flex; flex-direction: column; padding: 2px 4px 4px 22px; }
.dp-more-item { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; font-size: var(--fs-md); min-width: 0; }
.dp-more-item + .dp-more-item { box-shadow: inset 0 1px 0 var(--divider); }
.dp-more-item .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-more-item .dp-meta { flex-shrink: 0; }
.dp-more-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dp-more-why { font-size: var(--fs-meta); color: var(--muted); }

@media (max-width: 720px) {
  .dayplan { padding: 10px 6px 6px; }
  .dp-row { grid-template-columns: 44px minmax(0, 1fr); }
  .dp-now { left: 36px; }
  .dp-now-label { left: -36px; }
  .dp-skel { padding-left: 50px; }
  .dp-head { flex-wrap: wrap; }
}
.dp-block.opens .swipe-front { cursor: pointer; }
.dp-block:not(.opens) .swipe-front { cursor: default; }
.dp-block:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dp-label { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.dp-instruction { resize: vertical; min-height: 72px; font: inherit; color: var(--ink); }
.dp-sheet-foot { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-meta); color: var(--faint); margin-top: 6px; }
.dp-count { font-family: var(--font-mono); }
/* Settings → AI */
.ai-panel { display: flex; flex-direction: column; gap: 6px; }
.ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 18px; margin: 6px 0; }
.ai-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ai-label { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.ai-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-model { display: flex; flex-direction: column; gap: 4px; }
.ai-time { width: 7.5em; }
.ai-minutes { width: 5em; }
.ai-notes { width: 100%; resize: vertical; font: inherit; color: var(--ink); }
.ai-key { font-family: var(--font-mono); font-size: var(--fs-sm); }
.ai-privacy { display: flex; align-items: flex-start; gap: 6px; margin-top: 4px; }
.ai-privacy .msi { flex-shrink: 0; margin-top: 2px; }
