/* plans UI — per design_handoff_plans_ui. Light editorial theme; the document is
   the product, the app is a quiet frame around it. Tokens from the handoff. */

:root {
  --canvas: oklch(0.945 0.008 85);
  --surface: oklch(0.995 0.003 85);
  --surface-sunken: oklch(0.965 0.006 85);
  --surface-sunken-2: oklch(0.972 0.006 85);
  --rule: oklch(0.915 0.008 80);
  --rule-soft: oklch(0.935 0.008 80);
  --rule-strong: oklch(0.885 0.008 80);
  --border-control: oklch(0.90 0.008 80);
  --ink: oklch(0.24 0.015 60);
  --ink-1: oklch(0.28 0.015 60);
  --ink-2: oklch(0.33 0.015 60);
  --ink-3: oklch(0.45 0.012 70);
  --ink-4: oklch(0.565 0.012 70);
  --ink-5: oklch(0.64 0.012 70);
  --accent: oklch(0.55 0.11 250);
  --accent-deep: oklch(0.5 0.11 250);
  --accent-tint-bg: oklch(0.925 0.020 250);
  --accent-tint-soft: oklch(0.965 0.015 250);
  --accent-tint-border: oklch(0.90 0.03 250);
  --warn: oklch(0.68 0.13 60);
  --warn-bg: oklch(0.975 0.022 60);
  --warn-border: oklch(0.90 0.04 60);
  --ok: oklch(0.67 0.11 150);
  --danger: oklch(0.62 0.15 25);
  --diff-add-bg: oklch(0.955 0.030 145);
  --daemon-bg: oklch(0.955 0.018 290);
  --daemon-fg: oklch(0.45 0.05 290);
  --button-fill: oklch(0.38 0.02 60);
  --frame-shadow: 0 1px 2px oklch(0.4 0.02 60 / 0.05), 0 18px 44px -22px oklch(0.4 0.02 60 / 0.28);
  --thumb-shadow: 0 1px 1.5px oklch(0.4 0.02 60 / 0.10);
  --r-btn: 7px;
  --r-card: 11px;
  --r-row: 8px;
  --r-chip: 4px;
  --font-serif: "Newsreader", Georgia, serif;
  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  overflow: hidden;
}

/* every rule is exactly 1px */
:is(.sidebar, .topbar, .rail, .doc, .panel, table, .card, .seg, .btn, .chip, .field, input, textarea) {
  border-radius: 0;
}

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

/* focus ring, required on every interactive element */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------- app frame (full-bleed; no viewport chrome) ------- */

.app-frame {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: minmax(0, 1fr);
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
}

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

.sidebar {
  background: var(--surface-sunken);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.sidebar-head {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}
.sidebar-brand:hover .sidebar-wordmark { color: var(--accent-deep); }
.sidebar-mark {
  width: 9px;
  height: 9px;
  background: var(--accent);
  border-radius: 2px;
}
.sidebar-wordmark {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-1);
  transition: color 120ms;
}
.sidebar-kbd { margin-left: auto; }

.sidebar-search { padding: 14px 16px 8px; flex-shrink: 0; }
.field-search {
  width: 100%;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-control);
  border-radius: var(--r-btn);
  padding: 0 10px;
}
.field-search .glyph { color: var(--ink-4); font-size: 14px; line-height: 1; }
.field-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  outline: 0;
}
.field-search input::placeholder { color: var(--ink-5); }

.sidebar-scroll { flex: 1; overflow: auto; padding: 4px 8px 12px; }

.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 6px; }
.nav-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
}
.nav-eyebrow .count { color: var(--ink-5); }

.nav-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--r-row);
  cursor: pointer;
  position: relative;
}
.nav-row + .nav-row { margin-top: 1px; }
.nav-row:hover { background: var(--accent-tint-soft); }
.nav-row.active { background: var(--accent-tint-bg); }
.nav-row.active .nav-title { color: oklch(0.25 0.02 250); font-weight: 600; }
.nav-marker {
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: oklch(0.86 0.012 80);
  flex-shrink: 0;
}
.nav-row.active .nav-marker { background: var(--accent); }
.nav-row.reference .nav-marker { background: transparent; }
.nav-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
  color: var(--ink-2);
}
.nav-frac {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
}

.sidebar-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
}
.sidebar-foot .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}
.sidebar-foot .state-warn { color: var(--warn); }
.sidebar-foot .dot.warn { background: var(--warn); }

/* ------- topbar ------- */

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
  background: var(--surface);
}
.topbar .filename {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .divider {
  width: 1px;
  height: 14px;
  background: var(--rule-strong);
}
.topbar .meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  white-space: nowrap;
}
.topbar .spacer { flex: 1; }

/* segmented control */
.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-sunken);
  border-radius: var(--r-btn);
}
.seg button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 6px 14px;
  border-radius: 5px;
  cursor: pointer;
}
.seg button.on {
  background: var(--surface);
  color: var(--ink-1);
  box-shadow: var(--thumb-shadow);
}

/* ------- buttons / chips / fields ------- */

.btn {
  font: inherit;
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: var(--r-btn);
  border: 1px solid var(--border-control);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink-4); }
.btn.solid {
  background: var(--button-fill);
  border-color: var(--button-fill);
  color: oklch(0.99 0 0);
}
.btn.solid:hover { background: oklch(0.32 0.02 60); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--r-chip);
  border: 1px solid var(--border-control);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  background: var(--surface);
  white-space: nowrap;
}
.chip .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-4); }
.chip.state { background: var(--accent-tint-bg); border-color: var(--accent-tint-border); color: var(--accent-deep); }
.chip.state .dot { background: var(--accent); }

.chip-filter {
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: var(--r-btn);
  border: 1px solid var(--border-control);
  background: var(--surface);
  color: var(--ink-3);
  cursor: pointer;
}
.chip-filter.on {
  background: var(--button-fill);
  border-color: var(--button-fill);
  color: oklch(0.99 0 0);
}

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  border: 1px solid var(--border-control);
  border-bottom-width: 2px;
  border-radius: var(--r-chip);
  padding: 1px 5px;
  white-space: nowrap;
}

/* ------- overview (1b) ------- */

.overview-wrap { padding: 26px 40px 0; }
.overview-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.overview-title {
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 4px;
}
.overview-sentence { font-family: var(--font-sans); font-size: 13px; color: var(--ink-4); margin: 0; }
.overview-filters { display: flex; gap: 6px; }

.plan-grid { margin-top: 20px; }
.grid-head {
  display: grid;
  grid-template-columns: 1fr 190px 118px 76px;
  gap: 20px;
  padding: 0 40px 8px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
}
.grid-head .rh { text-align: right; }

.plan-row {
  display: grid;
  grid-template-columns: 1fr 190px 118px 76px;
  gap: 20px;
  align-items: center;
  padding: 13px 40px;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  position: relative;
}
.plan-row:hover { background: oklch(0.978 0.004 85); }
.plan-row .marker {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
}
.plan-row.current .marker { background: var(--accent); }
.plan-row:hover .marker { background: oklch(0.86 0.012 80); }

.p-row-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink-1);
}
.plan-row:hover .p-row-title { color: var(--ink); }
.p-row-slug { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-5); }

.p-progress {
  display: flex;
  align-items: center;
  gap: 9px;
}
.p-track {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--rule);
  overflow: hidden;
}
.p-fill { display: block; height: 100%; background: var(--accent); }
.p-fill.done { background: var(--ok); }
.p-frac { font-family: var(--font-mono); font-size: 11px; color: var(--ink-4); white-space: nowrap; }
.p-none { font-family: var(--font-mono); font-size: 11px; color: var(--ink-5); }

.p-date, .p-words { font-family: var(--font-mono); font-size: 11px; color: var(--ink-4); text-align: right; }

/* ------- plan view (1a) ------- */

.plan-layout {
  display: grid;
  grid-template-columns: 1fr 236px;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}
.plan-layout > * { min-height: 0; }

.doc {
  min-width: 0;
  overflow: auto;
  padding: 44px 32px 80px;
  mask-image: linear-gradient(to bottom, black calc(100% - 64px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 64px), transparent 100%);
}
.doc-inner { max-width: 672px; margin: 0 auto; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  margin: 0 0 10px;
}

.doc h1.d-title {
  font-family: var(--font-serif);
  font-size: 38px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-wrap: balance;
  color: var(--ink);
  margin: 0 0 6px;
}

.pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 26px 0 34px; }

.content {
  font-family: var(--font-serif);
  font-size: 18.5px;
  line-height: 1.62;
  color: var(--ink-2);
}
.content > :first-child { margin-top: 0; }
.content p { margin: 0 0 18px; }
.content h2, .content h3, .content h4 {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-1);
}
.content h2 {
  font-size: 13px;
  font-weight: 600;
  margin: 30px 0 10px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--rule);
}
.content h3 { font-size: 12px; font-weight: 600; margin: 24px 0 8px; }
.content h4 { font-size: 11.5px; font-weight: 600; margin: 20px 0 6px; }
.content ul, .content ol { margin: 0 0 18px; padding-left: 26px; }
.content li { margin: 4px 0; }
.content blockquote {
  margin: 0 0 18px;
  padding: 2px 16px;
  border-left: 3px solid var(--rule-strong);
  color: var(--ink-3);
}
.content pre {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  background: var(--surface-sunken);
  border: 1px solid var(--rule);
  border-radius: var(--r-card);
  padding: 14px 16px;
  overflow: auto;
  margin: 0 0 18px;
}
.content code {
  font-family: var(--font-mono);
  font-size: 15.5px;
  background: var(--surface-sunken);
  border-radius: var(--r-chip);
  padding: 1px 5px;
}
.content pre code { font-size: 13px; background: none; padding: 0; border-radius: 0; }
.content table { border-collapse: collapse; width: 100%; margin: 0 0 18px; }
.content th, .content td { border: 1px solid var(--rule); padding: 7px 12px; text-align: left; }
.content th { background: var(--surface-sunken); font-size: 13px; }
.content hr { border: 0; border-top: 1px solid var(--rule-strong); margin: 26px 0; }

/* inline todos — the important detail */
.content ul.task-list { list-style: none; padding-left: 0; }
.content li.todo-row {
  list-style: none;
  padding: 8px 10px;
  margin: 0 -10px;
  border-radius: var(--r-row);
  display: flex;
  align-items: flex-start;
  gap: 11px;
  position: relative;
}
.content li.todo-row:hover { background: var(--accent-tint-soft); box-shadow: inset 0 0 0 1px var(--accent-tint-border); }
.content li.todo-row .todo-chip {
  display: none;
  position: absolute;
  top: -9px;
  left: 34px;
  z-index: 2;
}
.content li.todo-row:hover .todo-chip { display: inline-flex; }
.content li.todo-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  margin: 3px 0 0;
  border: 1.5px solid var(--ink-4);
  border-radius: 5px;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  background: var(--surface);
}
.content li.todo-row input[type="checkbox"]:hover { border-color: var(--accent); }
.content li.todo-row input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.content li.todo-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 1.9px 1.9px 0;
  transform: rotate(45deg);
  animation: checkdraw 120ms ease-out;
}
@keyframes checkdraw { from { opacity: 0; transform: rotate(45deg) scale(0.6); } }
.content li.todo-row .todo-label { color: var(--ink-2); flex: 1; min-width: 0; }
.content li.todo-row.done .todo-label { color: var(--ink-4); }
.content li.todo-row input[type="checkbox"]:disabled { cursor: default; opacity: 0.6; }
.content li.todo-row.readonly input[type="checkbox"] { opacity: 0.6; }

/* ------- right rail ------- */

.rail {
  border-left: 1px solid var(--rule);
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  min-height: 0;
  overflow: auto;
}
.rail-section { min-height: 0; display: flex; flex-direction: column; }
.rail-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  margin-bottom: 10px;
}

.progress-count {
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
}
.progress-count .of { font-family: var(--font-mono); font-size: 14px; color: var(--ink-4); font-weight: 400; }
.progress-status { font-size: 12.5px; color: var(--ink-4); margin-top: 4px; }

.seg-bar { display: flex; gap: 2.5px; margin-top: 12px; }
.seg-bar .s { flex: 1; height: 16px; border-radius: 2px; background: oklch(0.90 0.010 80); }
.seg-bar .s.on { background: var(--accent); }
.seg-bar.continuous { height: 5px; border-radius: 3px; background: var(--rule); overflow: hidden; }
.seg-bar.continuous .fill { height: 100%; background: var(--accent); }

.outline { display: flex; flex-direction: column; gap: 1px; overflow: auto; }
.outline .o {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.outline .o::before { content: ""; width: 3px; height: 12px; border-radius: 2px; background: transparent; flex-shrink: 0; }
.outline .o:hover { background: var(--accent-tint-soft); }
.outline .o.current { background: var(--accent-tint-bg); color: var(--ink-1); }
.outline .o.current::before { background: var(--accent); }
.outline .o.lvl2 { padding-left: 18px; }
.outline .o.lvl3 { padding-left: 28px; }

.rail-foot {
  margin-top: auto;
  border-top: 1px solid var(--rule);
  padding-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
}
.rail-foot .k { color: var(--ink-5); }
.rail-foot .v { text-align: right; color: var(--ink-3); }

/* ------- editor (1d) ------- */

.editor-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.editor-base {
  display: flex;
  flex: 1;
  min-height: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 23px;
}
.editor-gutter {
  width: 44px;
  flex-shrink: 0;
  background: var(--surface-sunken-2);
  border-right: 1px solid var(--rule);
  text-align: right;
  padding: 16px 10px 0 0;
  color: var(--ink-5);
  user-select: none;
  overflow: hidden;
  position: relative;
}
.editor-gutter-inner { will-change: transform; }
.editor-gutter .ln { display: block; }
.editor-gutter .ln.mod { color: var(--ok); font-weight: 500; }
.editor-preview {
  position: absolute;
  inset: 0;
  overflow: auto;
  background: var(--surface);
  padding: 16px 22px;
  border-left: 2px solid var(--accent);
}
.editor-preview .content { font-size: 16px; }
.editor-host {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: auto;
}
.editor-textarea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 23px;
  color: var(--ink-2);
  resize: none;
  caret-color: var(--accent);
  white-space: pre;
  overflow: auto;
}
.editor-status {
  height: 30px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  background: var(--surface);
  flex-shrink: 0;
}
.editor-status .spacer { flex: 1; }
.editor-status .lang { color: var(--ink-3); }

/* diff highlight overlay */
.diff-marks {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.diff-marks .dm {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--diff-add-bg);
  border-radius: 3px;
}

/* ------- conflict banner (1d) ------- */

.conflict-banner {
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-border);
  padding: 14px 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.conflict-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--warn);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.conflict-title { font-size: 13px; font-weight: 500; color: var(--ink-1); margin: 0 0 3px; }
.conflict-body { font-size: 12.5px; color: var(--ink-3); margin: 0 0 10px; }
.conflict-body code { color: var(--ink-2); }
.conflict-actions { display: flex; gap: 8px; }

/* ------- history panel ------- */

.history-wrap { padding: 26px 40px; height: 100%; overflow: auto; mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%); }
.history-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.history-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
}
.history-count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-4); }

.history-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 11px 20px;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
}
.history-row:hover { background: oklch(0.978 0.004 85); }
.history-row.selected { background: var(--accent-tint-soft); }
.history-row.current { background: var(--accent-tint-soft); }
.history-revcol { display: flex; flex-direction: column; gap: 1px; }
.history-rev { font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.history-row.current .history-rev { color: var(--accent-deep); }
.history-when { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-5); }
.history-mid { display: flex; align-items: center; gap: 8px; min-width: 0; }
.history-summary { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-delta { display: flex; gap: 8px; font-family: var(--font-mono); font-size: 10px; white-space: nowrap; }
.history-delta .add { color: var(--ok); }
.history-delta .rem { color: var(--danger); }

.history-foot { display: flex; gap: 8px; margin-top: 16px; position: sticky; bottom: 0; background: var(--surface); padding-top: 10px; border-top: 1px solid var(--rule); }

/* ------- dialogs / palette ------- */

.dialog {
  border: 1px solid var(--rule-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--frame-shadow);
  padding: 22px 26px;
  width: min(520px, 92vw);
}
.dialog::backdrop { background: oklch(0.24 0.015 60 / 0.35); }
.dialog-title { font-family: var(--font-serif); font-size: 20px; font-weight: 500; color: var(--ink); margin: 0 0 4px; }
.dialog-note { font-size: 12.5px; color: var(--ink-4); margin: 0 0 12px; }
.dialog input[type="text"], .dialog input[type="password"] {
  width: 100%;
  border: 1px solid var(--border-control);
  border-radius: var(--r-btn);
  padding: 8px 12px;
  font: inherit;
  color: var(--ink-2);
  background: var(--surface);
  outline: 0;
  margin-bottom: 14px;
}
.dialog input:focus { border-color: var(--accent); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

.palette { padding: 0; overflow: hidden; width: min(560px, 92vw); }
.palette-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
}
.palette-glyph { color: var(--ink-4); font-size: 15px; }
.palette-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 14px;
  color: var(--ink-1);
  background: transparent;
}
.palette-results { max-height: 380px; overflow: auto; padding: 6px; }
.palette-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.palette-item.sel { background: var(--accent-tint-bg); }
.palette-item .pi-title { font-family: var(--font-serif); font-size: 15px; font-weight: 500; color: var(--ink-1); }
.palette-item .pi-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-4); }
.palette-item .pi-snippet { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.palette-foot {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
}

/* ------- gate ------- */

.gate-screen {
  position: fixed;
  inset: 0;
  background: var(--canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.gate-card {
  width: min(400px, 90vw);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  box-shadow: var(--frame-shadow);
  padding: 34px 34px 30px;
}
.gate-wordmark { font-family: var(--font-serif); font-size: 30px; font-weight: 500; color: var(--ink); margin: 0 0 4px; }
.gate-sub { font-family: var(--font-mono); font-size: 11px; color: var(--ink-4); margin: 0 0 22px; }
.gate-form { display: flex; align-items: stretch; }
.gate-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border-control);
  border-left-width: 2px;
  border-left-color: var(--accent);
  border-radius: var(--r-btn) 0 0 var(--r-btn);
  padding: 9px 12px;
  font: inherit;
  color: var(--ink-2);
  outline: 0;
}
.gate-form input:focus { border-color: var(--accent); }
.gate-form .btn { border-radius: 0 var(--r-btn) var(--r-btn) 0; }
.gate-error { color: var(--danger); font-size: 12.5px; margin: 12px 0 0; }

/* ------- shared bits ------- */

.banner { display: flex; gap: 10px; padding: 10px 14px; border: 1px solid var(--border-control); border-radius: var(--r-btn); font-size: 12.5px; }
.banner.err { color: var(--danger); border-color: var(--danger); }

.toolbar-row { display: flex; align-items: center; gap: 10px; }

.diff-view { font-family: var(--font-mono); font-size: 12px; line-height: 1.6; max-height: 60vh; overflow: auto; }
.diff-view .d { padding: 0 10px; white-space: pre-wrap; }
.diff-view .d.add { background: var(--diff-add-bg); }
.diff-view .d.rem { background: oklch(0.95 0.03 25); }
.diff-view .d.meta { color: var(--ink-4); background: var(--surface-sunken); }

.diff-body { max-height: 60vh; overflow: auto; }
.diff-head {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  margin: 14px 0 6px;
}
.diff-head:first-child { margin-top: 0; }
.diff-view { font-family: var(--font-mono); font-size: 12px; line-height: 1.6; }
.diff-view .d { padding: 0 10px; white-space: pre-wrap; }
.diff-view .d.add { background: var(--diff-add-bg); }
.diff-view .d.rem { background: oklch(0.95 0.03 25); }

.hidden { display: none !important; }
