/* ProjectTracker — palette and layout ported from Tracker.dc.html */

:root {
  --bg: #e9e3d6;
  --panel: #f4efe4;
  --panel-2: #efe8d9;
  --panel-3: #eae3d3;
  --card: #fbf8f1;
  --border: #d8cfba;
  --border-soft: #e2dac8;
  --border-softer: #eee4d0;
  --border-faint: #f0e8d6;
  --ink: #262117;
  --ink-soft: #3a342a;
  --ink-mid: #6b6353;
  --muted: #8a8171;
  --muted-2: #a89f8b;
  --faint: #bcb29c;
  --faintest: #c8bfa9;
  --hover: #e5dcc7;
  --sel: #e0d6bf;
  --row-sel: #e8dfca;
  --green: #5e8a55;
  --green-dark: #4e7147;
  --green-border: #b7cdb0;
  --green-bg: #eef3ea;
  --green-bg-hover: #e3ecdd;
  --red: #b5504a;
  --red-dark: #8a3d38;
  --red-border: #e6c9c4;
  --red-bg: #f7e9e6;
  --amber: #c08a3e;
  --gray: #a89f8b;
  --slate: #7d8aa0;
  --font-sans: "IBM Plex Sans", system-ui, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  font-family: var(--font-sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 12px;
}

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

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

.col::-webkit-scrollbar { width: 9px; height: 9px; }
.col::-webkit-scrollbar-thumb { background: #d0c6b0; border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
.col::-webkit-scrollbar-track { background: transparent; }

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

/* ---- frame / chrome ---- */

.frame { padding: 22px; display: flex; justify-content: center; height: 100vh; }

.app {
  width: min(1300px, 100%);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 28px rgba(38, 33, 23, .14);
  overflow: hidden;
}

.titlebar {
  display: flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 13px;
  background: var(--panel-3);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-amber { background: #dcae57; }
.dot-red { background: #c98b6b; }
.dot-green { background: #8fae7a; }
.titlebar-name { margin-left: 8px; font-size: 10.5px; color: var(--muted); }
.titlebar-count { margin-left: auto; font-size: 10px; color: var(--muted-2); }

.app-body { height: 100vh; display: flex; min-height: 0; }

/* ---- sidebar ---- */

.sidebar {
  width: 236px; flex: none;
  background: var(--panel-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
/* The whole sidebar minus its toggle bar — the part mobile folds away. */
.sidebar-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
/* Mobile-only affordance; the desktop sidebar is never collapsed. */
.sidebar-toggle { display: none; }

.sidebar-brand {
  display: flex; align-items: center; gap: 7px; flex: none;
  padding: 11px 12px 3px;
}
.brand-icon { width: 15px; height: 15px; flex: none; }
.brand-name { font-weight: 700; font-size: 12.5px; letter-spacing: -0.1px; }

.sidebar-top { padding: 9px 9px 7px; flex: none; }

.nav-row {
  display: flex; gap: 9px; align-items: center;
  padding: 7px 9px; border-radius: 6px; cursor: pointer;
}
.nav-row:hover { background: var(--hover); }
.nav-row.selected { background: var(--sel); }
.nav-row.selected:hover { background: var(--sel); }
.nav-row + .nav-row { margin-top: 3px; }
/* Only the Gutter row takes drops, and a task goes into it — highlight the row. */
.nav-row.drag-over-task { background: var(--green-bg); box-shadow: inset 0 0 0 1.5px var(--green); }
.nav-icon { width: 13px; height: 13px; border-radius: 3px; background: var(--muted); flex: none; }
.nav-icon.dashed { background: transparent; border: 1.5px dashed var(--muted-2); }
.nav-label { font-weight: 600; font-size: 12px; }
.nav-label.normal { font-weight: 500; }
.nav-count { margin-left: auto; font-size: 9px; color: var(--muted-2); }

.sidebar-heading {
  padding: 8px 13px 5px;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border-soft); flex: none;
  font-size: 9px; letter-spacing: .1em; color: var(--muted);
}
.sidebar-heading .count { color: var(--muted-2); letter-spacing: 0; }

/* ---- recurring section ----
   Sits above PROJECTS and outside .sidebar-scroll: it is small, bounded, and
   time-sensitive, so it should never scroll out of reach. */
.recur-section { flex: none; padding-bottom: 3px; }
.recur-kind-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px 4px;
}
.recur-kind-name { font-size: 9px; letter-spacing: .09em; color: var(--muted); }
.recur-kind-count { color: var(--muted-2); font-size: 9px; margin-right: auto; }
/* No count (an empty template) still needs the buttons pushed right. */
.recur-kind-name:last-of-type { margin-right: auto; }
.recur-kind-row .group-btn.ghost { visibility: hidden; }
.recur-kind-row:hover .group-btn.ghost { visibility: visible; }
.recur-section .proj-row { padding-left: 26px; }
.recur-section .group-empty { padding-left: 28px; }
.recur-add { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 12px 2px; }
.recur-add-btn {
  border: 1px dashed var(--border); background: none; color: var(--muted-2);
  border-radius: 4px; font-size: 9px; padding: 1px 6px; cursor: pointer;
  font-family: var(--font-mono);
}
.recur-add-btn:hover { color: var(--ink-mid); border-color: var(--ink-mid); background: var(--card); }

.sidebar-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.sidebar-list { padding: 2px 0; min-height: 8px; }
.sidebar-list.drag-over, .group-body.drag-over, .group-row.drag-over { background: var(--green-bg); }

.sidebar-heading-tools { display: flex; align-items: center; gap: 6px; }

/* ---- project groups ---- */
.group-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px 5px;
  cursor: pointer; border-top: 1px solid var(--border-soft);
}
.group-row:hover { background: var(--hover); }
.group-caret { width: 10px; flex: none; color: var(--muted-2); font-size: 9px; }
.group-name { font-weight: 600; font-size: 11px; color: var(--ink-mid); }
.group-count { color: var(--muted-2); font-size: 9px; margin-right: auto; }
.group-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--ink-mid);
  border-radius: 4px; font-size: 9px; padding: 1px 6px; cursor: pointer; line-height: 1.5;
  font-family: var(--font-mono); flex: none;
}
.group-btn:hover { background: var(--panel-3); }
.group-btn.ghost { border: none; background: none; color: var(--muted-2); padding: 1px 3px; visibility: hidden; }
.group-row:hover .group-btn.ghost { visibility: visible; }
.group-btn.ghost:hover { color: var(--ink); }
.sidebar-heading-tools .group-btn.ghost { visibility: visible; }
.group-body { padding: 1px 0 4px; }
.group-body .proj-row { padding-left: 26px; }
.group-body .group-empty { padding-left: 28px; }
.group-empty { padding: 6px 14px; font-size: 9px; color: var(--faint); font-style: italic; }
.proj-row[draggable="true"] { cursor: grab; }
/* A dragged project lands *before* this row — an edge. A dragged task lands
   *in* the project, so the whole row lights up instead. */
.proj-row.drag-over-project { box-shadow: inset 0 2px 0 var(--green); }
.proj-row.drag-over-task { background: var(--green-bg); box-shadow: inset 0 0 0 1.5px var(--green); }

.proj-row {
  display: flex; gap: 9px; padding: 6px 12px;
  cursor: pointer; align-items: flex-start;
  border-left: 2px solid transparent;
}
.proj-row:hover { background: #e8e0cd; }
.proj-row.selected { background: var(--hover); }
.proj-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; margin-top: 4px; }
.proj-main { min-width: 0; flex: 1; }
.proj-name { font-size: 11.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-name.dim { color: var(--muted); }
.proj-sub { font-family: var(--font-mono); font-size: 9px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-sub.blocked { color: var(--red); }
.proj-progress { font-family: var(--font-mono); font-size: 9px; color: var(--muted-2); flex: none; margin-top: 1px; }

.sidebar-footer {
  padding: 7px 8px; border-top: 1px solid var(--border-soft); flex: none;
  display: flex; align-items: stretch; gap: 5px;
}
.footer-action {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--border); background: var(--card); color: var(--ink-mid);
  border-radius: 5px; padding: 5px 6px; cursor: pointer;
  font-family: var(--font-mono); font-size: 10px;
}
.footer-action:hover { background: var(--panel-3); color: var(--ink); }
.footer-action.selected { background: var(--sel); color: var(--ink); }
.footer-icon { font-size: 11px; line-height: 1; }

/* ---- main pane shared ---- */

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--panel); }

.pane-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px 12px; border-bottom: 1px solid var(--border-soft); flex: none;
}
.pane-title { font-weight: 600; font-size: 15px; }
.header-tools { display: flex; gap: 7px; align-items: center; }

.chip {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-mid); border: 1px solid var(--border); border-radius: 5px;
  padding: 3px 9px; background: var(--card); cursor: pointer;
  appearance: none; -webkit-appearance: none;
}
button.chip, select.chip { line-height: 1.4; }
.chip:hover { background: var(--panel-3); }
.chip.static { cursor: default; color: var(--muted); }
.chip.static:hover { background: var(--card); }

/* ---- overview ---- */

.overview-scroll { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 15px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; }
.tile { background: var(--card); border: 1px solid var(--border-soft); border-radius: 6px; padding: 11px 13px; }
.tile-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: .09em; color: var(--muted-2); }
.tile-value { font-size: 24px; font-weight: 600; line-height: 1.2; }
.tile-value.green { color: var(--green); }
.tile-value.red { color: var(--red); }
.tile-value.amber { color: var(--amber); }

.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.overview-col { display: flex; flex-direction: column; gap: 14px; }

.card { background: var(--card); border: 1px solid var(--border-soft); border-radius: 6px; overflow: hidden; }
.card-header {
  padding: 10px 13px; border-bottom: 1px solid var(--border-softer);
  font-weight: 600; font-size: 11.5px; display: flex; justify-content: space-between;
}
.card-header .count { font-family: var(--font-mono); color: var(--muted-2); font-weight: 400; }
.card-header-link { cursor: pointer; }
.card-header-link:hover { background: var(--panel-3); }
.card-header-link:hover .count { color: var(--ink-mid); }

/* next-up aggregate view */
.nextup-heading {
  display: flex; align-items: center; gap: 7px;
  font-size: 9px; letter-spacing: .08em; color: var(--muted-2);
  padding: 11px 14px 4px;
}
.nextup-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.nextup-heading.drag-over { background: var(--green-bg); color: var(--ink-mid); }

/* ---- recurring: completion grid ----
   The popup is shown by :hover alone. Every mutation rebuilds this pane, so a
   JS-held "which square is hovered" flag would be wiped on the next keystroke. */
/* Deliberately NOT a scroll container here: `overflow-x: auto` forces
   `overflow-y` to auto as well, and the popup — which sits above its square —
   gets clipped away to nothing. Wide enough for the daily grid (26 columns,
   ~450px) to fit outright, so scrolling only kicks in below, where the popup
   is off anyway and the square's title attribute carries the detail. */
/* The generous top padding is headroom for the popup, which opens upward and
   is clipped by .overview-scroll if it runs past the top of the scroll view. */
.rq-body { padding: 34px 16px 10px; }
/* .card clips to its radius; the popup has to be able to leave the card. */
.rq-card { overflow: visible; }
.rq-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.rq-grid.daily {
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr);
  gap: 3px; width: max-content;
}
.rq-wrap { position: relative; }
.rq { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border-soft); }
.rq.filled { cursor: pointer; }
.rq.filled:hover { outline: 1.5px solid var(--ink-mid); outline-offset: 1px; }
.rq-pad { width: 14px; height: 14px; }

.rq-pop {
  display: none; position: absolute; bottom: calc(100% + 7px); left: 50%;
  transform: translateX(-50%); z-index: 20; min-width: 190px; max-width: 260px;
  background: var(--card); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 4px 14px rgba(38, 33, 23, .16); padding: 8px 0 6px;
  max-height: 168px; overflow-y: auto;
}
.rq-wrap:hover .rq-pop { display: block; }
.rq-pop-head {
  display: flex; justify-content: space-between; gap: 10px; padding: 0 11px 5px;
  font-size: 9.5px; letter-spacing: .05em; color: var(--muted);
}
.rq-pop-item { display: flex; gap: 7px; align-items: center; padding: 2px 11px; font-size: 10.5px; }
.rq-pop-item.done { color: var(--muted-2); text-decoration: line-through; }
.rq-pop-dot { width: 5px; height: 5px; border-radius: 50%; flex: none; }
.rq-pop-more { padding: 3px 11px 0; font-size: 9px; color: var(--faintest); }

.rq-legend {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  padding: 4px 16px 12px; font-size: 9px; color: var(--muted-2);
}
.rq-legend-item { display: flex; align-items: center; gap: 5px; }
.rq-key { width: 10px; height: 10px; border-radius: 2px; border: 1px solid var(--border-soft); }

/* Below this the daily grid stops fitting, so the body starts scrolling — and
   the popup, which a scroll container would clip, gives way to the title. */
@media (max-width: 780px) {
  .rq-body { overflow-x: auto; }
  .rq-wrap:hover .rq-pop { display: none; }
}

.chip.selected { background: var(--panel-3); color: var(--ink); border-color: var(--border); }

/* ---- tags ---- */
.tag-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 15px; border-bottom: 1px solid var(--border-softer);
}
.tag-row-label { font-size: 9px; letter-spacing: .09em; color: var(--muted-2); margin-right: 2px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border); border-radius: 10px; padding: 1px 4px 1px 8px;
  font-size: 10px; font-family: var(--font-mono); background: var(--card);
}
.tag-chip.static { padding: 1px 8px; }
.tag-chip-x {
  border: none; background: none; cursor: pointer; color: inherit;
  opacity: .5; font-size: 9px; padding: 0 2px; line-height: 1;
}
.tag-chip-x:hover { opacity: 1; }
.tag-input {
  border: 1px dashed var(--border); background: none; border-radius: 10px;
  padding: 2px 9px; font-size: 10px; font-family: var(--font-mono);
  color: var(--ink); width: 90px; outline: none;
}
.tag-input:focus { border-style: solid; border-color: var(--ink-mid); }

/* ---- settings ---- */
.set-layout { flex: 1; display: flex; min-height: 0; }
.set-rail {
  width: 190px; flex: none; border-right: 1px solid var(--border-soft);
  overflow-y: auto; padding: 8px 0;
}
.set-rail-row { padding: 8px 15px; cursor: pointer; border-left: 2px solid transparent; }
.set-rail-row:hover { background: var(--hover); }
.set-rail-row.selected { background: var(--sel); border-left-color: var(--ink-mid); }
.set-rail-name { font-size: 11.5px; font-weight: 600; }
.set-rail-note { font-size: 9px; color: var(--muted-2); margin-top: 1px; }

.set-body { flex: 1; overflow-y: auto; min-width: 0; }
.set-panel { padding: 18px 20px; }
.set-panel-head { margin-bottom: 12px; }
.set-panel-title { font-size: 14px; font-weight: 600; }
.set-panel-note { font-size: 10.5px; color: var(--muted); margin-top: 3px; max-width: 60ch; line-height: 1.5; }

.set-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--border-softer);
}
.set-row.off .set-row-name { color: var(--muted-2); }
.set-row-main { flex: 1; min-width: 140px; }
.set-row-name { font-size: 12px; font-weight: 600; }
.set-row-sub { font-size: 9px; color: var(--muted-2); margin-top: 2px; }
.set-locked { font-size: 9px; color: var(--faint); font-style: italic; }
.set-note { margin-top: 14px; font-size: 10px; color: var(--muted-2); line-height: 1.6; }
.set-note code { font-family: var(--font-mono); font-size: 9.5px; }
.set-add { margin-top: 14px; }

.tag-swatches { display: flex; gap: 3px; }
.tag-swatch {
  width: 14px; height: 14px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; padding: 0;
}
.tag-swatch.selected { border-color: var(--ink); }
.tag-swatch:hover { outline: 1px solid var(--border); outline-offset: 1px; }

/* The templates panel was written for a modal; give it the padding the
   panel wrapper would otherwise have supplied. */
.set-body .tmpl-layout { padding: 18px 20px; min-height: 0; }
.set-body .tmpl-steps-input { min-height: 220px; }

.acc-body { padding: 5px 0 10px; }
.acc-project { font-family: var(--font-mono); font-size: 9px; letter-spacing: .06em; color: var(--muted-2); padding: 7px 13px 2px; }
.acc-item { padding: 2px 13px; font-size: 11px; display: flex; gap: 8px; align-items: center; }
.acc-check { color: var(--green); }
.acc-date { font-family: var(--font-mono); margin-left: auto; color: var(--faintest); font-size: 9.5px; }

/* ---- recurring: overview card ----
   auto-fit rather than a fixed count, so one to four enabled granularities all
   lay out without a media query. */
.recur-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.recur-col { border-right: 1px solid var(--border-softer); padding-bottom: 8px; min-width: 0; }
.recur-col:last-child { border-right: none; }
.recur-col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px 3px; font-size: 9px; letter-spacing: .09em; color: var(--muted);
}
.recur-col-link {
  border: none; background: none; cursor: pointer; font-family: var(--font-mono);
  font-size: 9px; color: var(--muted-2); padding: 0;
}
.recur-col-link:hover { color: var(--ink-mid); }
.recur-period { font-size: 9px; color: var(--faintest); padding: 5px 13px 1px; }
.recur-clear { padding: 4px 13px; font-size: 11px; color: var(--green); }
.recur-start {
  margin: 3px 13px; border: 1px dashed var(--border); background: none; cursor: pointer;
  border-radius: 4px; font-size: 10px; padding: 3px 7px; color: var(--muted-2);
  font-family: var(--font-mono);
}
.recur-start:hover { color: var(--ink-mid); border-color: var(--ink-mid); }
.recur-col .next-row { border-bottom: none; padding: 3px 13px; }

.next-row {
  padding: 6px 13px; font-size: 11px; display: flex; gap: 8px; align-items: center;
  border-bottom: 1px solid var(--border-faint); cursor: pointer;
}
.next-row:hover { background: #f6efdd; }
.next-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.next-project { font-weight: 500; flex: none; }
.next-task { color: var(--ink-mid); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-task.blocked { color: var(--red); }

.rollup-card { background: var(--card); border: 1px solid var(--border-soft); border-radius: 6px; padding: 11px 13px; }
.rollup-title { font-weight: 600; font-size: 11.5px; margin-bottom: 9px; }
.rollup-bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; margin-bottom: 9px; background: var(--border-soft); }
.rollup-legend { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px 8px; }
.legend-item { font-size: 10px; color: var(--ink-mid); display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; }

.empty-note { font-size: 11px; color: var(--faint); font-style: italic; padding: 8px 13px; }

/* ---- project view ---- */

.project-header { padding: 13px 20px 14px; border-bottom: 1px solid var(--border-soft); flex: none; }
.project-title-row { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.project-name { font-weight: 600; font-size: 15.5px; cursor: text; }
.project-name-input {
  font-weight: 600; font-size: 15.5px; background: var(--card);
  border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; outline: none;
}
.framework-badge { font-family: var(--font-mono); font-size: 9.5px; color: var(--muted-2); }
.header-right { margin-left: auto; display: flex; gap: 7px; align-items: center; flex: none; }

select.status-select {
  margin-left: 4px; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .02em;
  color: var(--ink-mid); background: var(--card); border: 1px solid var(--border);
  border-radius: 5px; padding: 3px 6px; cursor: pointer;
}

.blurb-row { margin-top: 9px; display: flex; gap: 9px; align-items: flex-start; }
.field-label { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .08em; color: var(--faint); padding-top: 4px; flex: none; }
.blurb-input {
  flex: 1; resize: none; background: transparent; border: none; outline: none;
  font-size: 11.5px; line-height: 1.5; color: var(--ink-soft); padding: 0; overflow: hidden; height: 54px;
}

.block-banner {
  margin-top: 7px; display: flex; gap: 8px; align-items: center;
  background: var(--red-bg); border: 1px solid var(--red-border); border-radius: 5px; padding: 4px 9px;
}
.block-banner .field-label { color: var(--red); padding-top: 0; letter-spacing: .06em; }
.block-reason-input { flex: 1; background: transparent; border: none; outline: none; font-size: 11px; color: var(--red-dark); }

.project-body { flex: 1; display: flex; min-height: 0; }

/* task list column */
.task-list { width: min(366px, 45%); flex: none; border-right: 1px solid var(--border-soft); overflow-y: auto; }

.quick-todo-wrap {
  padding: 9px 14px 7px; border-bottom: 1px solid var(--border-faint);
  display: flex; gap: 7px; align-items: center;
}
.quick-todo {
  flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--border-soft);
  border-radius: 5px; padding: 6px 9px; font-size: 11.5px; outline: none;
}
.quick-todo-wrap .chip { flex: none; }
/* On the overview it's a card of its own, not the head of a list. */
.overview-capture {
  border: 1px solid var(--border-soft); border-radius: 6px; background: var(--panel-2);
  padding: 8px 10px; flex: none;
}

.group-heading { font-family: var(--font-mono); font-size: 9px; letter-spacing: .08em; color: var(--muted-2); padding: 9px 14px 4px; }
.group-heading.blocked { color: var(--red); }
.group-heading.done { padding-top: 11px; }

.task-row {
  display: flex; gap: 9px; align-items: center;
  padding: 5px 14px; cursor: pointer; font-size: 11.5px;
}
.task-row:hover { background: #efe7d4; }
.task-row.selected { background: var(--row-sel); }
.task-row[draggable="true"] { cursor: grab; }
/* Drop lands above the row it's over, so the hint sits on that edge. */
.task-row.drag-over { box-shadow: inset 0 2px 0 var(--green); }
.task-list.drag-over { background: var(--green-bg); }
.task-grip {
  flex: none; width: 8px; margin-left: -4px; color: var(--faintest);
  font-size: 9px; line-height: 1; cursor: grab; visibility: hidden;
}
.task-row:hover .task-grip { visibility: visible; }
.task-row-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-row-name.active { font-weight: 600; color: var(--amber); }
.task-row-name.done { color: var(--muted); text-decoration: line-through; text-decoration-color: #cabfa9; }
.task-badge { font-family: var(--font-mono); font-size: 9px; color: var(--muted-2); flex: none; }
.task-badge.done { color: var(--faintest); }

.cb { width: 12px; height: 12px; border-radius: 3px; flex: none; display: flex; align-items: center; justify-content: center; }
.cb-active { border: 1.5px solid var(--amber); }
.cb-active-inner { width: 5px; height: 5px; background: var(--amber); border-radius: 1px; }
.cb-blocked { border: 1.5px solid var(--red); color: var(--red); font-size: 9px; }
.cb-todo { border: 1.5px solid var(--faintest); }
.cb-done { background: var(--green); color: #fff; font-size: 9px; }
.cb-obsolete { border: 1.5px solid var(--faint); color: var(--faint); font-size: 10px; }
.cb-click { cursor: pointer; }
.cb-click:hover { outline: 1.5px solid var(--green-border); outline-offset: 1px; }

.task-del {
  flex: none; border: none; background: none; cursor: pointer;
  color: var(--faint); font-size: 10px; line-height: 1; padding: 0 2px; visibility: hidden;
}
.task-row:hover .task-del { visibility: visible; }
.task-del:hover { color: var(--red); }

/* detail column */
.detail { flex: 1; min-width: 0; overflow-y: auto; background: var(--card); display: flex; flex-direction: column; }
.detail-inner { flex: 1; display: flex; flex-direction: column; }
.detail-header { padding: 15px 20px 13px; border-bottom: 1px solid var(--border-softer); flex: none; }
.detail-context { font-family: var(--font-mono); font-size: 9px; letter-spacing: .07em; color: var(--muted-2); }
.detail-name { font-weight: 600; font-size: 16px; margin: 5px 0 9px; line-height: 1.25; cursor: text; }
/* Sized to sit in the same line box as the title it replaces, so opening the
   editor doesn't shove the badges below it. */
.detail-name-input {
  font-weight: 600; font-size: 16px; line-height: 1.25;
  margin: 3px 0 7px; width: 100%; box-sizing: border-box;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 5px; padding: 2px 6px; outline: none;
}
.detail-badges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.badge { font-family: var(--font-mono); font-size: 10px; border-radius: 4px; padding: 2px 9px; }
.badge-status { color: #fff; }
.badge-step { border: 1px solid var(--border); color: var(--muted); }
.badge-btn { cursor: pointer; border: 1px solid var(--border); color: var(--muted); background: transparent; }
.badge-btn:hover { background: var(--panel-3); }
.badge-btn.done { border-color: var(--green-border); color: var(--green-dark); background: var(--green-bg); }
.badge-btn.done:hover { background: var(--green-bg-hover); }
.badge-btn.block { border-color: var(--red-border); color: var(--red); }
.badge-btn.block:hover { background: var(--red-bg); }

.detail-body { padding: 15px 20px; flex: 1; }
.updates-heading { font-family: var(--font-mono); font-size: 9px; letter-spacing: .08em; color: var(--muted-2); margin-bottom: 11px; }
.update-input-row { margin-bottom: 15px; display: flex; gap: 8px; }
.update-input {
  flex: 1; background: #fff; border: 1px solid var(--border-soft);
  border-radius: 5px; padding: 7px 10px; font-size: 11.5px; outline: none;
}

.update-entry { display: flex; gap: 11px; margin-bottom: 14px; }
.update-rail { flex: none; display: flex; flex-direction: column; align-items: center; }
.update-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 3px; }
.update-line { flex: 1; width: 1px; background: #e7dfcd; margin-top: 3px; }
.update-text { font-size: 11.5px; line-height: 1.5; color: var(--ink-soft); }
.update-date { font-family: var(--font-mono); font-size: 9px; color: var(--faintest); margin-top: 3px; }

.detail-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 12px; }

/* ---- modal ---- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(38, 33, 23, .25);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 32px rgba(38, 33, 23, .25);
  width: 520px; max-width: 92vw; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-box.narrow { width: 340px; }
.modal-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border-soft);
  font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: space-between;
}
.modal-close { cursor: pointer; color: var(--muted-2); font-size: 14px; background: none; border: none; padding: 0 2px; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 12px 16px; overflow-y: auto; }

.picker-row {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: 6px; cursor: pointer; font-size: 12px;
}
.picker-row:hover { background: var(--hover); }
.picker-row .count { margin-left: auto; font-family: var(--font-mono); font-size: 9.5px; color: var(--muted-2); }
.picker-divider { border-top: 1px solid var(--border-soft); margin: 6px 0; }

.tmpl-layout { display: flex; gap: 14px; min-height: 260px; }
.tmpl-list { width: 160px; flex: none; border-right: 1px solid var(--border-soft); padding-right: 10px; }
.tmpl-editor { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.tmpl-name-input {
  background: var(--card); border: 1px solid var(--border-soft); border-radius: 5px;
  padding: 6px 9px; font-size: 12px; font-weight: 600; outline: none;
}
.tmpl-steps-input {
  flex: 1; min-height: 170px; resize: vertical; background: var(--card);
  border: 1px solid var(--border-soft); border-radius: 5px; padding: 8px 10px;
  font-size: 11.5px; line-height: 1.6; outline: none; font-family: var(--font-mono);
}
.tmpl-hint { font-size: 10px; color: var(--muted-2); }
.tmpl-buttons { display: flex; gap: 7px; justify-content: flex-end; }
.paste-input {
  width: 100%; min-height: 180px; resize: vertical; box-sizing: border-box;
  background: var(--card); border: 1px solid var(--border-soft); border-radius: 5px;
  padding: 8px 10px; font-size: 11.5px; line-height: 1.6; outline: none; font-family: var(--font-mono);
}
.chip.danger { color: var(--red); border-color: var(--red-border); }
.chip.danger:hover { background: var(--red-bg); }

/* ---- in-app confirm / prompt dialog ---- */
.dialog-box { width: 360px; }
.dialog-inner { padding: 16px 18px; display: flex; flex-direction: column; gap: 11px; }
.dialog-title { font-weight: 600; font-size: 14px; }
.dialog-message { font-size: 12px; line-height: 1.5; color: var(--ink-soft); }
.dialog-field-label { font-size: 8.5px; letter-spacing: .08em; color: var(--muted); }
.dialog-input {
  background: var(--card); border: 1px solid var(--border-soft); border-radius: 5px;
  padding: 7px 10px; font-size: 12px; outline: none;
}
.dialog-input:focus { border-color: var(--border); }
.dialog-inner .tmpl-buttons { margin-top: 3px; }

/* ---- misc ---- */

.badge-btn.del { border-color: var(--red-border); color: var(--red); }
.badge-btn.del:hover { background: var(--red-bg); }

.save-error {
  position: fixed; bottom: 16px; right: 16px; z-index: 20;
  background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red-dark);
  border-radius: 6px; padding: 8px 12px; font-size: 11px;
}
.hidden { display: none; }

/* ---- butter bar ---- */
.butter-bar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: var(--panel);
  border-radius: 7px; padding: 9px 12px 9px 15px; font-size: 11.5px;
  box-shadow: 0 6px 24px rgba(38, 33, 23, .32);
  max-width: min(560px, 92vw); animation: butter-in .18s ease-out;
}
.butter-close {
  border: none; background: none; color: var(--faint); cursor: pointer;
  font-size: 11px; padding: 0 2px; line-height: 1;
}
.butter-close:hover { color: var(--panel); }
@keyframes butter-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---- remote mode: login, offline fallback, fatal errors ---- */

.offline-banner {
  position: fixed; bottom: 16px; left: 16px; z-index: 20;
  background: #f7f0e0; border: 1px solid #e0cfa3; color: #8a6d2e;
  border-radius: 6px; padding: 8px 12px; font-size: 11px; max-width: 320px;
}

.login-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel);
}
.login-card {
  display: flex; flex-direction: column; gap: 9px; width: 250px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 22px 24px 24px;
}
.login-title { margin: 0; font-size: 15px; color: var(--ink); }
.login-hint { font-size: 11px; color: var(--ink-mid); margin-bottom: 6px; }
.login-input {
  border: 1px solid var(--border); border-radius: 5px; background: var(--panel);
  padding: 7px 9px; font-size: 12px; color: var(--ink); outline: none;
}
.login-input:focus { border-color: var(--ink-mid); }
.login-error {
  background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red-dark);
  border-radius: 5px; padding: 6px 9px; font-size: 11px;
}
.login-submit {
  margin-top: 4px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--ink); color: var(--panel); padding: 7px 0;
  font-size: 12px; cursor: pointer;
}
.login-submit:disabled { opacity: .6; cursor: default; }

.fatal-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel);
}
.fatal-card {
  max-width: 420px; background: var(--red-bg); border: 1px solid var(--red-border);
  border-radius: 8px; padding: 20px 24px; color: var(--red-dark);
}
.fatal-card h2 { margin: 0 0 8px; font-size: 14px; }
.fatal-card p { margin: 6px 0 0; font-size: 12px; line-height: 1.5; }

/* ---- mobile (single column) ---- */
@media (max-width: 640px) {
  .app-body { flex-direction: column; height: 100vh; }
  /*
   * The sidebar is a drawer hanging off the toggle bar: never taller than
   * half the screen, and its list scrolls inside itself so flicking through
   * projects doesn't move the tracker underneath.
   */
  .sidebar {
    width: 100%; flex: none; max-height: 50vh;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .sidebar.collapsed { max-height: none; }
  .sidebar.collapsed .sidebar-body { display: none; }

  .sidebar-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 10px 13px; border: none; border-bottom: 1px solid var(--border-soft);
    background: var(--panel-2); color: var(--ink-mid);
    font-family: inherit; font-size: 12px; font-weight: 600;
    text-align: left; cursor: pointer;
  }
  .sidebar.collapsed .sidebar-toggle { border-bottom: none; }
  .sidebar-toggle:active { background: var(--hover); }
  .sidebar-toggle-caret { font-size: 10px; color: var(--muted-2); flex: none; width: 10px; }
  .sidebar-toggle-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar-toggle-count { margin-left: auto; font-size: 9px; color: var(--muted-2); flex: none; }

  /* The heading duplicates the toggle bar's count on mobile — but RECURRING
     labels a real section rather than restating the count, so it stays. */
  .sidebar-heading { display: none; }
  .sidebar-heading.recur { display: flex; }
  .recur-kind-row .group-btn.ghost { visibility: visible; }
  .recur-cols { grid-template-columns: 1fr; }
  /* Stack the settings rail above its panel, like the task list/detail split. */
  .set-layout { flex-direction: column; }
  .set-rail { width: 100%; flex: none; border-right: none; border-bottom: 1px solid var(--border-soft); }
  .set-body .tmpl-layout { flex-direction: column; padding: 12px 13px; }
  .set-body .tmpl-list { width: 100%; border-right: none; padding-right: 0; }
  .recur-col { border-right: none; border-bottom: 1px solid var(--border-softer); }
  .recur-col:last-child { border-bottom: none; }

  .main { flex: 1; min-height: 0; }
  .pane-header { padding: 11px 13px; flex-wrap: wrap; gap: 7px; }
  .header-tools { flex-wrap: wrap; }
  .overview-scroll { padding: 12px 13px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .overview-grid { grid-template-columns: 1fr; }
  .project-header { padding: 11px 13px; }
  .project-title-row { flex-wrap: wrap; }
  .header-right { margin-left: 0; flex-wrap: wrap; }
  /* Stack task list over detail. */
  .project-body { flex-direction: column; }
  .task-list { width: 100%; flex: none; max-height: 45vh; border-right: none; border-bottom: 1px solid var(--border-soft); }
  .task-del { visibility: visible; }
  .group-btn.ghost { visibility: visible; }
  .modal-box { max-height: 88vh; }
}
