/* Compass UI components — built on tokens.css. */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); 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: 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: 1px; }

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

/* ---- Layout ---- */
#app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 48px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex-shrink: 0;
}
.topbar .brand { font-weight: 700; font-size: var(--fs-lg); letter-spacing: 0.02em; display: flex; align-items: center; gap: 8px; }
.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 ---- */
.btn {
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  font-size: var(--fs-sm); padding: 5px 10px; cursor: pointer; border-radius: 4px;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.btn:hover { border-color: var(--line-strong); background: var(--bg); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.icon { width: 32px; height: 32px; padding: 0; justify-content: center; }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { border-color: transparent; background: var(--line); }

.input, select.input {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  padding: 6px 10px; font-size: var(--fs-md); border-radius: 4px;
}
textarea.input { resize: vertical; line-height: 1.5; }

/* ---- Search ---- */
.search-wrap { position: relative; }
.search-input { width: 240px; }
.search-results {
  position: absolute; top: 38px; right: 0; width: 380px; max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,0.18); z-index: 60; padding: 4px;
}
.search-result {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; cursor: pointer;
  border-radius: 4px; font-size: var(--fs-sm);
}
.search-result:hover, .search-result.active { background: var(--line); }
.search-result .sr-title { font-size: var(--fs-md); display: flex; gap: 8px; align-items: center; }
.search-result .sr-snippet { color: var(--muted); }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; border-right: 1px solid var(--line);
  background: var(--surface); padding: 14px 8px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-btn {
  display: flex; align-items: center; gap: 8px; border: none; background: transparent;
  font-size: var(--fs-md); font-weight: 600; padding: 6px 10px; cursor: pointer;
  text-align: left; border-radius: 4px; color: var(--ink); width: 100%;
}
.nav-btn:hover { background: var(--bg); }
.nav-btn.active { background: var(--line); }
.nav-btn .count-badge {
  background: var(--danger); color: #fff; font-size: var(--fs-xs); font-weight: 600;
  padding: 1px 6px; border-radius: 9px; min-width: 16px; text-align: center; margin-left: auto;
}
.side-section {
  font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase;
  padding: 14px 10px 4px; display: flex; align-items: center; letter-spacing: 0.04em;
}
.side-section .plus { margin-left: auto; }
.plus {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px 6px; border-radius: 3px; visibility: hidden;
}
.plus:hover { background: var(--line); color: var(--ink); }
.side-section:hover .plus, .tree-row:hover .plus { visibility: visible; }

.tree-row { display: flex; align-items: center; border-radius: 4px; }
.tree-row:hover { background: var(--bg); }
.tree-row.active { background: var(--line); }
.tree-btn {
  flex: 1; display: flex; align-items: center; gap: 6px; border: none; background: transparent;
  font-size: var(--fs-sm); padding: 5px 6px 5px 10px; cursor: pointer; text-align: left;
  color: var(--ink); min-width: 0; border-radius: 4px;
}
.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; }
.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: 10px 24px;
  border-bottom: 1px solid var(--line); flex-shrink: 0; min-height: 49px;
}
.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-tab {
  border: none; background: transparent; cursor: pointer; font-size: var(--fs-md);
  padding: 6px 10px; color: var(--muted); border-bottom: 2px solid transparent;
}
.view-tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.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: 8px; }
.mt-section { margin-bottom: 28px; }
.mt-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.mt-head .t { font-size: var(--fs-md); font-weight: 600; white-space: nowrap; }
.mt-head.danger .t { color: var(--danger); }
.mt-head .c { font-size: var(--fs-sm); color: var(--muted); }
.mt-empty { font-size: var(--fs-md); color: var(--muted); padding: 8px 0; }

.task-row {
  display: flex; align-items: center; gap: 10px; padding: 0 10px; height: var(--row-h);
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.task-row:hover { background: var(--surface); }
.task-row .key { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--muted); flex-shrink: 0; width: 66px; }
.task-row .title { font-size: var(--fs-md); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .due { font-size: var(--fs-sm); font-family: var(--font-mono); color: var(--muted); flex-shrink: 0; width: 88px; white-space: nowrap; text-align: right; }
.task-row .due.overdue { color: var(--danger); }
.tag-chips { display: flex; gap: 4px; flex-wrap: wrap; flex-shrink: 0; }

.chip {
  font-size: var(--fs-xs); padding: 1px 6px; border: 1px solid var(--line);
  white-space: nowrap; border-radius: 3px; display: inline-flex; align-items: center; gap: 5px;
}
.prio-chip { font-size: var(--fs-xs); font-weight: 600; padding: 2px 7px; white-space: nowrap; border-radius: 3px; 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 8px; border-radius: 10px;
  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: 5px; border: 1px solid var(--line);
  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: 4px 8px; text-transform: uppercase; }
.color-picker-popover {
  display: inline-block; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
  padding: 12px; margin: 6px 0 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.16);
}

/* ---- Board ---- */
.board { flex: 1; overflow: auto; padding: 20px 24px; }
.board-cols { display: flex; gap: 16px; align-items: flex-start; min-width: max-content; }
.board-col { width: var(--col-w); flex-shrink: 0; }
.board-col-head {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border-bottom: 2px solid var(--line); margin-bottom: 8px;
}
.board-col-head .label { font-size: var(--fs-sm); font-weight: 600; flex: 1; }
.board-col-head .count { font-size: var(--fs-sm); color: var(--muted); }
.board-col-head .count.over { color: var(--danger); font-weight: 600; }
.board-col-head { position: relative; }
.board-col-head.editable { cursor: pointer; border-radius: 4px 4px 0 0; }
.board-col-head.editable:hover { background: var(--surface); }
.status-popover {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: 340px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: 0 10px 28px rgba(0,0,0,0.18); cursor: default;
  display: flex; flex-direction: column; gap: 12px; font-weight: 400;
}
.board-cards { display: flex; flex-direction: column; gap: 8px; min-height: 30px; padding-bottom: 8px; }
.card {
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
}
.card:hover { border-color: var(--line-strong); }
.card.dragging { opacity: 0.4; }
.card .key { font-size: var(--fs-sm); font-family: var(--font-mono); color: var(--muted); }
.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 .board-cards { outline: 2px dashed var(--line-strong); outline-offset: 2px; border-radius: var(--radius); }
.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; }
.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: 1px dashed var(--line); background: transparent; color: var(--muted);
  font-size: var(--fs-sm); padding: 6px; cursor: pointer; border-radius: var(--radius); text-align: left;
}
.quick-add:hover { color: var(--ink); border-color: var(--line-strong); }
.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: 6px 8px; background: var(--surface); }

/* ---- Table (list layout) ---- */
.table-wrap { flex: 1; overflow: auto; padding: 8px 24px 24px; }
table.tasks { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
table.tasks th {
  text-align: left; padding: 6px 8px; font-size: var(--fs-xs); color: var(--muted);
  font-weight: 600; text-transform: uppercase; border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none; white-space: nowrap; position: sticky; top: 0; background: var(--bg);
}
table.tasks th.r, table.tasks td.r { text-align: right; }
table.tasks td { padding: 4px 8px; border-bottom: 1px solid var(--line); height: 32px; }
table.tasks tbody tr { cursor: pointer; }
table.tasks tbody tr:hover { background: var(--surface); }
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: 0; right: 0; height: 100%;
  width: calc(var(--drawer-w) * 2 - 60px); max-width: 96vw;
  background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: row; overflow: hidden;
}
.drawer-form {
  width: var(--drawer-w); max-width: 60%; flex-shrink: 0;
  padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px;
}
.drawer-chat {
  flex: 1; min-width: 300px; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; background: var(--bg);
}
.chat-head {
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.04em; 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: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; 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); border: 1px solid var(--line);
  padding: 0 5px; border-radius: 3px; color: var(--muted);
}
.chat-src.mcp { color: var(--accent); border-color: var(--accent); }
.chat-event {
  display: flex; gap: 8px; align-items: baseline; font-size: var(--fs-xs);
  color: var(--muted); padding: 0 4px;
}
.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(--muted);
  font-family: var(--font-mono); padding: 6px 0 2px;
}
.chat-composer {
  border-top: 1px solid var(--line); padding: 12px 16px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 8px; background: var(--surface);
}
.chat-composer textarea {
  border: 1px solid var(--line); background: var(--bg); border-radius: 6px;
  padding: 8px 10px; min-height: 60px; resize: vertical; line-height: 1.5; width: 100%;
}
.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: 96vw; }
  .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-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.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-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 2px 0 4px; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width 160ms; }
.subtask {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px; font-size: var(--fs-md);
  border-radius: 4px; margin: 0 -6px;
}
.subtask:hover { background: var(--bg); }
.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); }
.archived-banner {
  display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted);
  background: var(--bg); border: 1px dashed var(--line-strong); border-radius: 4px; padding: 6px 10px;
}

/* ---- Dropdown menu (⋯) ---- */
.menu {
  position: fixed; z-index: 80; min-width: 200px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0,0,0,0.18); display: flex; flex-direction: column;
}
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: none; background: transparent; padding: 7px 10px; font-size: var(--fs-md);
  border-radius: 4px; cursor: pointer; color: var(--ink);
}
.menu-item:hover { background: var(--line); }
.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: 1px 7px; border-radius: 8px; border: 1px solid var(--line); }
.gh-state.merged { color: #8656E0; border-color: #8656E0; }
.gh-state.open { color: #1FA463; border-color: #1FA463; }
.gh-state.closed { color: var(--danger); border-color: var(--danger); }
.gh-state.draft { color: var(--muted); }
.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); border: 1px solid var(--line); padding: 0 5px; border-radius: 3px; flex-shrink: 0; }
.md-toolbar { display: flex; gap: 2px; border: 1px solid var(--line); border-bottom: none; padding: 4px; border-radius: 4px 4px 0 0; }
.md-toolbar .btn { border: none; width: 26px; height: 26px; padding: 0; justify-content: center; }
.md-toolbar .grow { flex: 1; }
.md-body { border: 1px solid var(--line); border-radius: 0 0 4px 4px; }
.md-body textarea { width: 100%; border: none; background: var(--bg); min-height: 110px; padding: 8px; font-size: var(--fs-md); display: block; border-radius: 0 0 4px 4px; }
.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(--bg); padding: 8px; overflow-x: auto; border-radius: 4px; }
.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: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; width: 340px; display: flex; flex-direction: column; gap: 12px;
}
.modal .m-title { font-size: var(--fs-lg); font-weight: 600; }
.modal.wide { width: 720px; max-width: 94vw; gap: 14px; max-height: 92vh; 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; border-right: 1px solid var(--line); overflow-y: auto; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.notes-tabs { display: flex; gap: 2px; padding: 0 4px 8px; }
.note-item { display: flex; flex-direction: column; gap: 2px; padding: 7px 10px; border-radius: 4px; cursor: pointer; }
.note-item:hover { background: var(--bg); }
.note-item.active { background: var(--line); }
.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(--muted); 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); background: var(--surface); padding: 12px; line-height: 1.6; border-radius: var(--radius); }
.note-editor .md-preview { flex: 1; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px; }
.editor-bar { display: flex; gap: 8px; align-items: center; padding-bottom: 8px; }
.save-state { font-size: var(--fs-xs); color: var(--muted); 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 ---- */
.settings { flex: 1; overflow-y: auto; padding: 24px 28px; max-width: 760px; }
.settings h2 { font-size: var(--fs-lg); margin: 26px 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 pre { background: var(--surface); border: 1px solid var(--line); padding: 10px; 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: 1px solid var(--line); border-radius: var(--radius); padding: 28px; width: 320px; 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); }

/* ---- 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); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; 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-title); 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 12px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.inbox-capture:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--line); }
.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; }
.inbox-item {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 8px;
  border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 4px;
}
.inbox-item:hover, .inbox-item.selected { background: var(--surface); }
.inbox-item.selected { box-shadow: inset 2px 0 0 var(--ink); }
.inbox-item.flash { animation: inbox-flash 1.8s ease-out; }
@keyframes inbox-flash { 0% { background: var(--line); } 100% { background: transparent; } }
.inbox-item .key { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--muted); flex-shrink: 0; width: 66px; }
.inbox-item .body { flex: 1; min-width: 0; 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(--muted); 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 var(--line); border-radius: 4px; padding: 8px 10px; }
.capture-modal .capture-input:focus { border-color: var(--ink); }
.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); }
