/* ─────────────────────────────────────────────────────────────
   ISO 27001 Explorer — editorial archive aesthetic
   Warm paper palette · Fraunces display · IBM Plex Sans/Mono
   ───────────────────────────────────────────────────────────── */

:root {
  --bg:          #F2ECDE;
  --bg-raised:  #FBF7EC;
  --bg-panel:   #EFE8D6;
  --ink:        #14130E;
  --ink-body:   #2A2822;
  --ink-muted:  #5C5648;
  --ink-faint:  #948D7B;
  --rule:       #D4C9AE;
  --rule-soft:  #E3DAC2;
  --accent:     #B63F1E;
  --accent-ink: #7A2B14;
  --accent-soft:#F2D9CC;
  --sage:       #6B7359;
  --amber:      #BC8618;
  --ocean:      #385568;

  --chapter: #B63F1E;
  --domain:  #385568;
  --cluster: #6B7359;
  --control: #BC8618;

  --font-display: "Fraunces", "Cormorant Garamond", Georgia, serif;
  --font-sans:    "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    "IBM Plex Mono", "SF Mono", Menlo, monospace;

  --shadow-panel: 0 1px 0 rgba(20,19,14,.04),
                  -24px 0 60px -20px rgba(20,19,14,.18),
                  -1px 0 0 rgba(212,201,174,.9);
  --shadow-palette: 0 60px 120px -20px rgba(20,19,14,.35),
                    0 0 0 1px rgba(212,201,174,.8);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-body);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(182,63,30,0.04), transparent 60%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(56,85,104,0.05), transparent 60%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.08 0 0 0 0 0.08 0 0 0 0 0.05 0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App shell ─────────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 320px 1fr;
  grid-template-areas:
    "header header"
    "sidebar canvas";
  height: 100vh;
}

/* ── Header ────────────────────────────────────────────────── */

.header {
  grid-area: header;
  display: flex;
  align-items: stretch;
  border-bottom: 0.5px solid var(--rule);
  background: var(--bg-raised);
  position: relative;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 18px 28px 16px;
  border-right: 0.5px solid var(--rule);
  min-width: 320px;
}

.brand .mark {
  width: 38px;
  height: 38px;
  position: relative;
  flex-shrink: 0;
  align-self: center;
}

.brand .mark svg { display: block; }

.brand .title {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand .eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
}

.brand h1 {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 48, "wght" 500, "SOFT" 50;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.brand h1 em {
  font-style: italic;
  font-variation-settings: "opsz" 48, "wght" 400, "SOFT" 100;
  color: var(--accent-ink);
}

.header-meta {
  display: flex;
  flex: 1;
  align-items: center;
  padding: 0 28px;
  gap: 32px;
  justify-content: flex-end;
}

.counts {
  display: flex;
  align-items: baseline;
  gap: 24px;
}

.count {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.count .num {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 96, "wght" 500;
  font-size: 26px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.count .lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.cmdk-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 12px;
  border: 0.5px solid var(--rule);
  border-radius: 2px;
  background: var(--bg);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  min-width: 240px;
}

.cmdk-trigger:hover {
  border-color: var(--ink-muted);
  color: var(--ink);
  background: var(--bg-raised);
}

.cmdk-trigger .kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-panel);
  border: 0.5px solid var(--rule);
  border-radius: 2px;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
}

.cmdk-trigger svg { flex-shrink: 0; opacity: .7; }

/* ── Sidebar / Legend ──────────────────────────────────────── */

.sidebar {
  grid-area: sidebar;
  padding: 28px 28px 32px;
  border-right: 0.5px solid var(--rule);
  background: var(--bg-raised);
  overflow-y: auto;
  position: relative;
  z-index: 1;
}

.side-section { margin-bottom: 34px; }

.side-section h2 {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--ink-faint);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 0.5px solid var(--rule);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  font-size: 13px;
  color: var(--ink-body);
}

.legend-item .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-item .count-pill {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}

.blurb {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 14, "wght" 350;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-muted);
  font-style: italic;
  padding-left: 12px;
  border-left: 1.5px solid var(--accent);
  margin-top: 4px;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0.5px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: var(--ink-body);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background .12s, border-color .12s;
  width: 100%;
}

.filter-chip:hover { background: var(--bg-panel); }
.filter-chip.active {
  background: var(--bg);
  border-color: var(--rule);
}

.filter-chip .chip-code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  width: 18px;
}

.filter-chip .chip-name { flex: 1; }

.filter-chip .chip-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}

.side-footer {
  margin-top: auto;
  padding-top: 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
  line-height: 1.8;
}

.side-footer .dash {
  display: inline-block;
  width: 18px;
  border-top: 0.5px solid var(--rule);
  vertical-align: middle;
  margin: 0 8px 3px 0;
}

/* ── Canvas ────────────────────────────────────────────────── */

.canvas {
  grid-area: canvas;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(20,19,14,0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(20,19,14,0.02) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

.canvas svg {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

.canvas-overlay {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: flex;
  gap: 6px;
  z-index: 3;
  background: var(--bg-raised);
  padding: 5px;
  border: 0.5px solid var(--rule);
  border-radius: 2px;
}

.zoom-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 14px;
  border-radius: 2px;
  transition: background .12s, color .12s;
}

.zoom-btn:hover {
  background: var(--bg-panel);
  color: var(--ink);
}

.canvas-caption {
  position: absolute;
  top: 28px;
  right: 32px;
  z-index: 3;
  text-align: right;
  pointer-events: none;
}

.canvas-caption .label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

.canvas-caption .rev {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144, "wght" 400;
  font-style: italic;
  font-size: 34px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ── Tree SVG ──────────────────────────────────────────────── */

.link {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1;
  transition: stroke .2s, stroke-width .2s;
}

.link.active {
  stroke: var(--accent);
  stroke-width: 1.5;
}

.node { cursor: pointer; }

.node .node-circle {
  transition: r .15s, fill .15s, stroke-width .15s;
}

.node-chapter .node-circle { fill: var(--chapter); }
.node-domain  .node-circle { fill: var(--domain); }
.node-cluster .node-circle { fill: var(--cluster); }
.node-control .node-circle { fill: var(--bg-raised); stroke: var(--control); stroke-width: 1.5; }

.node:hover .node-circle {
  filter: drop-shadow(0 1px 2px rgba(20,19,14,.2));
}

.node-hit {
  fill: transparent;
  stroke: none;
  cursor: pointer;
}

.node.selected .node-circle {
  stroke: var(--ink);
  stroke-width: 2;
}

.node-label {
  font-family: var(--font-sans);
  font-size: 12px;
  fill: var(--ink-body);
  pointer-events: none;
  dominant-baseline: middle;
}

.node-chapter .node-label {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 48, "wght" 500;
  font-size: 16px;
  fill: var(--ink);
  letter-spacing: -0.005em;
}

.node-domain .node-label {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 32, "wght" 450;
  font-size: 14px;
  fill: var(--ink);
}

.node-cluster .node-label {
  font-size: 12px;
  fill: var(--ink-muted);
}

.node-control .node-label {
  font-size: 11.5px;
  fill: var(--ink-body);
}

.node-code {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--control);
  letter-spacing: 0.04em;
  pointer-events: none;
  dominant-baseline: middle;
  font-weight: 500;
}

.node.dimmed .node-label,
.node.dimmed .node-code { opacity: 0.22; }
.node.dimmed .node-circle { opacity: 0.3; }
.link.dimmed { opacity: 0.18; }

/* ── Detail panel ──────────────────────────────────────────── */

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  background: var(--bg-raised);
  box-shadow: var(--shadow-panel);
  transform: translateX(100%);
  transition: transform .32s cubic-bezier(.2,.7,.2,1);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel.open { transform: translateX(0); }

.panel-head {
  padding: 28px 32px 20px;
  border-bottom: 0.5px solid var(--rule);
  background:
    linear-gradient(to bottom, var(--bg-panel), var(--bg-raised));
  position: relative;
}

.panel-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 16px;
  border-radius: 2px;
  transition: background .12s, color .12s;
}
.panel-close:hover { background: var(--bg-panel); color: var(--ink); }

.panel .breadcrumb {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 14px;
  line-height: 1.6;
}

.panel .breadcrumb .sep { margin: 0 8px; color: var(--rule); }

.panel .code-block {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 6px;
}

.panel .code {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.01em;
  line-height: 1;
}

.panel .tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 3px 8px;
  background: var(--bg);
  border: 0.5px solid var(--rule);
  border-radius: 2px;
}

.panel .name {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 72, "wght" 450;
  font-size: 28px;
  line-height: 1.15;
  color: var(--ink);
  letter-spacing: -0.015em;
  margin-top: 10px;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 40px;
}

.panel-section { margin-bottom: 32px; }

.panel-section h3 {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--ink-faint);
  margin-bottom: 12px;
  padding-bottom: 7px;
  border-bottom: 0.5px solid var(--rule);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.panel-section h3 .count-i {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

.panel-section p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-body);
}

.panel-section .description {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 14, "wght" 380;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink-body);
}

.panel-section .description::first-letter {
  font-variation-settings: "opsz" 144, "wght" 500;
  font-size: 48px;
  float: left;
  line-height: 0.88;
  padding: 4px 10px 0 0;
  color: var(--accent);
}

.resources {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.resource {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 0.5px solid var(--rule-soft);
  color: var(--ink-body);
  text-decoration: none;
  transition: color .15s, padding-left .2s;
}

.resource:last-child { border-bottom: none; }

.resource:hover {
  color: var(--accent);
  padding-left: 6px;
}

.resource .r-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--ink-faint);
  transition: color .15s;
}

.resource:hover .r-icon { color: var(--accent); }

.resource .r-label { flex: 1; font-size: 13.5px; }

.resource .r-ext {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}

.empty-state {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 14, "wght" 340;
  font-style: italic;
  color: var(--ink-faint);
  font-size: 14px;
  padding: 4px 0;
}

.notes {
  padding: 16px 18px;
  background: var(--bg-panel);
  border-left: 2px solid var(--amber);
  font-size: 13.5px;
  color: var(--ink-body);
  line-height: 1.55;
}

/* ── Cmd+K palette ─────────────────────────────────────────── */

.cmdk-scrim {
  position: fixed;
  inset: 0;
  background: rgba(20,19,14,0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  opacity: 0;
  transition: opacity .2s;
}

.cmdk-scrim.open {
  display: flex;
  opacity: 1;
}

.cmdk-box {
  width: 620px;
  max-width: calc(100vw - 32px);
  background: var(--bg-raised);
  border-radius: 3px;
  box-shadow: var(--shadow-palette);
  overflow: hidden;
  transform: translateY(-8px) scale(0.99);
  transition: transform .2s cubic-bezier(.2,.7,.2,1);
}

.cmdk-scrim.open .cmdk-box {
  transform: translateY(0) scale(1);
}

.cmdk-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 0.5px solid var(--rule);
}

.cmdk-input-row svg { color: var(--ink-faint); flex-shrink: 0; }

.cmdk-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--ink);
  outline: none;
}

.cmdk-input::placeholder { color: var(--ink-faint); }

.cmdk-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  text-transform: uppercase;
}

.cmdk-results {
  max-height: 440px;
  overflow-y: auto;
  padding: 6px 0;
}

.cmdk-group {
  padding: 10px 22px 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 22px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background .08s, border-left-color .08s;
}

.cmdk-item.highlight {
  background: var(--bg-panel);
  border-left-color: var(--accent);
}

.cmdk-item .code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 500;
  width: 40px;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.cmdk-item .name {
  flex: 1;
  font-size: 13.5px;
  color: var(--ink-body);
  line-height: 1.35;
}

.cmdk-item .crumb {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.cmdk-item mark {
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 0 2px;
  border-radius: 1px;
  font-weight: 500;
}

.cmdk-empty {
  padding: 40px 22px;
  text-align: center;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 14, "wght" 350;
  font-style: italic;
  color: var(--ink-faint);
  font-size: 15px;
}

.cmdk-footer {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 22px;
  border-top: 0.5px solid var(--rule);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  text-transform: uppercase;
}

.cmdk-footer .kbd {
  padding: 2px 6px;
  background: var(--bg-raised);
  border: 0.5px solid var(--rule);
  border-radius: 2px;
  color: var(--ink-muted);
  margin-right: 5px;
}

/* ── Scrollbars (slim, archival) ───────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--rule);
  border: 3px solid var(--bg-raised);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

/* ── Entrance animation ───────────────────────────────────── */
@keyframes drawIn {
  from { stroke-dasharray: 0 2000; opacity: 0; }
  to   { stroke-dasharray: 2000 0; opacity: 1; }
}
@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.link { animation: drawIn .8s ease-out both; }
.node .node-circle { animation: popIn .35s cubic-bezier(.4,1.6,.5,1) both; transform-origin: center; transform-box: fill-box; }
.node text { animation: fadeIn .5s ease-out .15s both; }

/* ── Resource rows (editable) ──────────────────────────── */

.resource-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 0.5px solid var(--rule-soft);
  padding: 0;
}
.resource-row:last-child { border-bottom: none; }

.resource-row .resource {
  flex: 1;
  border-bottom: none;
  padding: 11px 0;
}

.r-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  padding: 2px 6px;
  border-radius: 2px;
  flex-shrink: 0;
  font-weight: 500;
}
.r-tag-yaml {
  color: var(--ink-faint);
  background: var(--bg-panel);
  border: 0.5px solid var(--rule);
}
.r-tag-own {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 0.5px solid var(--accent-soft);
}

.r-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .12s;
}

.resource-row:hover .r-actions { opacity: 1; }

.r-act {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.r-act:hover {
  background: var(--bg-panel);
  color: var(--accent);
}

.add-resource-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 7px 11px 7px 9px;
  border: 0.5px dashed var(--rule);
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  border-radius: 2px;
  transition: border-color .15s, color .15s, background .15s;
}
.add-resource-btn:hover {
  border-color: var(--accent);
  border-style: solid;
  color: var(--accent);
  background: var(--bg-panel);
}

.res-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px;
  margin-top: 14px;
  background: var(--bg-panel);
  border-left: 2px solid var(--accent);
}

.res-input {
  padding: 8px 10px;
  border: 0.5px solid var(--rule);
  background: var(--bg-raised);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink);
  border-radius: 2px;
  outline: none;
}
.res-input:focus { border-color: var(--accent); }

.res-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  padding: 6px 14px;
  border: 0.5px solid var(--rule);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  border-radius: 2px;
  color: var(--ink-body);
  transition: background .12s, color .12s, border-color .12s;
}
.btn-ghost:hover { background: var(--bg-raised); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-raised);
  font-weight: 500;
}
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

/* ── Notes editor ──────────────────────────────────────── */

.notes-editor {
  width: 100%;
  min-height: 100px;
  padding: 12px 14px;
  background: var(--bg-panel);
  border: 0.5px solid var(--rule);
  border-left: 2px solid var(--amber);
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-body);
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
.notes-editor:focus {
  border-color: var(--accent);
  border-left-width: 2px;
  border-left-color: var(--accent);
}
.notes-editor::placeholder {
  color: var(--ink-faint);
  font-style: italic;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 14, "wght" 340;
}

.save-indicator {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  transition: color .2s, opacity .2s;
  min-height: 12px;
}
.save-indicator[data-state="editing"] { color: var(--ink-muted); }
.save-indicator[data-state="saving"]  { color: var(--amber); }
.save-indicator[data-state="saved"]   { color: var(--sage); }
.save-indicator[data-state="error"]   { color: var(--accent); }
.save-indicator[data-state="idle"]    { opacity: 0; }

/* ── Cmd+K snippets ────────────────────────────────────── */

.cmdk-main {
  flex: 1;
  min-width: 0;
}

.cmdk-item .cmdk-main .name {
  font-size: 13.5px;
  color: var(--ink-body);
  line-height: 1.35;
}

.cmdk-snippet {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 3px;
  line-height: 1.4;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cmdk-hit-field {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 1px 5px;
  background: var(--bg);
  border: 0.5px solid var(--rule);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── User identification modal ─────────────────────────── */

.user-scrim {
  position: fixed;
  inset: 0;
  background: rgba(20,19,14,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .25s ease-out both;
}

.user-box {
  background: var(--bg-raised);
  width: 460px;
  max-width: calc(100vw - 32px);
  padding: 32px 36px 28px;
  border-radius: 3px;
  box-shadow: var(--shadow-palette);
  animation: fadeIn .3s ease-out both;
}

.user-box h2 {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 72, "wght" 450;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 8px;
}

.user-box h2::before {
  content: "·";
  color: var(--accent);
  margin-right: 10px;
}

.user-box .sub {
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.55;
  margin-bottom: 18px;
}

.user-input {
  width: 100%;
  padding: 12px 14px;
  border: 0.5px solid var(--rule);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--ink);
  border-radius: 2px;
  outline: none;
  transition: border-color .15s;
}
.user-input:focus { border-color: var(--accent); }

.user-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ── User chip in header ───────────────────────────────── */

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border: 0.5px solid var(--rule);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--ink-body);
  cursor: pointer;
  border-radius: 2px;
  transition: border-color .15s, background .15s;
}
.user-chip:hover { border-color: var(--ink-muted); background: var(--bg-raised); }

.user-chip .user-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sage);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(107,115,89,0.15);
}

.user-chip-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 0.5px solid var(--rule);
  background: var(--bg);
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--ink-muted); color: var(--ink); background: var(--bg-raised); }

/* ── Activity drawer ───────────────────────────────────── */

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 480px;
  background: var(--bg-raised);
  box-shadow:
    1px 0 0 rgba(212,201,174,.9),
    24px 0 60px -20px rgba(20,19,14,.18);
  transform: translateX(-102%);
  transition: transform .32s cubic-bezier(.2,.7,.2,1);
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 24px 18px;
  border-bottom: 0.5px solid var(--rule);
  background: linear-gradient(to bottom, var(--bg-panel), var(--bg-raised));
}

.drawer-title { display: flex; flex-direction: column; gap: 2px; }
.drawer-title .eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.drawer-title h2 {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 48, "wght" 500;
  font-size: 20px;
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.drawer-body { flex: 1; overflow-y: auto; padding: 18px 24px 32px; }

/* ── History list (used in panel + drawer) ─────────────── */

.history-list {
  display: flex;
  flex-direction: column;
}

.hist-item {
  padding: 14px 0;
  border-bottom: 0.5px solid var(--rule-soft);
}
.hist-item:first-child { padding-top: 6px; }
.hist-item:last-child { border-bottom: none; }

.hist-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12.5px;
}

.hist-user {
  font-weight: 500;
  color: var(--ink);
}

.hist-action {
  color: var(--ink-muted);
}

.hist-ctrl {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  padding: 1px 5px;
  border: 0.5px solid var(--accent-soft);
  border-radius: 2px;
  letter-spacing: 0.02em;
}

.hist-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  padding: 1px 5px;
  background: var(--bg-panel);
  border: 0.5px solid var(--rule);
  border-radius: 2px;
}

.hist-time {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  text-transform: uppercase;
}

.hist-diff {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  line-height: 1.5;
}

.hist-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 2px 2px 0;
}
.hist-before { background: rgba(182,63,30,0.04); border-left-color: var(--accent-soft); color: var(--ink-muted); }
.hist-after  { background: rgba(107,115,89,0.08); border-left-color: var(--sage); color: var(--ink-body); }

.hist-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex-shrink: 0;
  padding: 2px 5px 1px;
  background: var(--bg-raised);
  color: var(--ink-faint);
  border-radius: 1px;
  align-self: flex-start;
  line-height: 1;
  margin-top: 1px;
}

.hist-resource-ref {
  font-size: 12.5px;
  color: var(--ink-body);
  padding: 3px 0 0 4px;
}

.hist-resource-ref .hist-url {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  margin-left: 6px;
}
