/* Design system — Curation-App v2 (spec §4.1) */
:root {
  --canvas: #F1F3F5;
  --surface: #FFFFFF;
  --surface-2: #F7F9FB;
  --border: #DCE0E6;
  --border-2: #C5CBD5;

  --ink: #15181D;
  --text: #2A2F37;
  --quiet: #5C6470;
  --faint: #8C95A4;

  --brand: #0E4E9C;
  --brand-50: #EAF2FB;
  --brand-100: #D2E4F6;

  --recommend: #1F7A3E;
  --recommend-50: #E8F4EC;
  --recommend-100: #C7E4D1;

  --caution: #B86F12;
  --caution-50: #FDF4E5;

  --reject: #B5322B;
  --reject-50: #FCEBEA;

  --consult: #6B45C7;
  --consult-50: #EFE9FB;
  --consult-100: #D5C4F2;

  --shadow-card: 0 1px 2px rgba(20,24,30,0.05),
                 0 6px 24px -8px rgba(20,24,30,0.10);
  --shadow-action: 0 1px 0 rgba(20,24,30,0.06),
                   0 2px 4px rgba(20,24,30,0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: 'IBM Plex Sans', 'IBM Plex Sans Devanagari', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.mono { font-family: 'IBM Plex Mono', monospace; font-size: 0.85em; letter-spacing: -0.01em; }

/* Pulsing dot used by the "Finalizing AI summary…" badge */
@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* Long JSON payloads + comment bodies must wrap, not push their parent wide.
   Without this, a single-line JSON dump stretches the memo pane and breaks
   the two-pane grid (grid items default to min-width: auto = content-size). */
pre, .body-text {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Top strip — present on every page */
.top-strip {
  background: var(--ink); color: #fff;
  padding: 8px 16px;
  display: flex; align-items: center; gap: 14px;
  font-size: 12.5px;
}
.top-strip .brand { font-weight: 700; letter-spacing: 0.02em; }
.top-strip .brand em { font-style: normal; opacity: 0.7; margin: 0 6px; }
.top-strip .crumb { color: rgba(255,255,255,0.7); }
.top-strip .crumb-current { color: #fff; font-weight: 600; }
.top-strip .user { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; }
.top-strip .user .avatar {
  width: 28px; height: 28px; border-radius: 999px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.02em;
}

/* Primary nav strip — sits under the top-strip ink bar */
.nav-strip {
  display: flex; gap: 2px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 22px;
  align-items: center;
  font-size: 13px;
}
.nav-strip a {
  position: relative;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--quiet);
  font-weight: 500;
  letter-spacing: 0.005em;
  transition: color 100ms ease;
}
.nav-strip a:hover {
  color: var(--ink);
}
.nav-strip a.is-active {
  color: var(--ink);
  font-weight: 600;
}
.nav-strip a.is-active::after {
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: -1px;
  height: 2px;
  background: var(--brand);
}
.nav-strip .nav-spacer { margin-left: auto; }
.nav-strip .nav-signout {
  color: var(--faint);
  font-size: 12px;
}
.nav-strip .nav-signout:hover { color: var(--reject); }

/* Page canvas wrapper */
.canvas { padding: 28px 36px 60px; }

/* Card frame */
.register {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* Generic button system — used by all action zones */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit;
  font-size: 13.5px; font-weight: 600;
  padding: 9px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  box-shadow: var(--shadow-action);
  transition: transform 100ms ease, box-shadow 120ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--recommend); color: #fff; border-color: #176131; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-2); }
.btn-tertiary { background: var(--surface); color: var(--caution); border-color: var(--caution); }
.btn-danger { background: var(--surface); color: var(--reject); border-color: var(--reject); }
.btn-consult { background: var(--surface); color: var(--consult); border-color: var(--consult); }
.btn .kbd {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  background: rgba(0,0,0,0.12);
  padding: 1px 5px; border-radius: 2px;
  margin-left: 6px; opacity: 0.85;
}
.btn-primary .kbd { background: rgba(255,255,255,0.22); }

/* Two-pane queue layout — must explicitly let the memo column shrink,
   otherwise long content (JSON payload, URLs) pushes the grid wider. */
.two-pane {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 600px;
}
.two-pane > * { min-width: 0; }

/* Mobile breakpoint — collapses two-pane */
@media (max-width: 768px) {
  .canvas { padding: 16px 14px 40px; }
  .register { border-radius: 6px; }
  .top-strip { padding: 8px 12px; font-size: 12px; gap: 8px; }
  .nav-strip {
    overflow-x: auto;
    padding: 0 8px;
    scrollbar-width: none;
  }
  .nav-strip::-webkit-scrollbar { display: none; }
  .nav-strip a { padding: 11px 10px; white-space: nowrap; }
  .two-pane { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════════════════════════
   ADR-0055 — folio-scales-to-volume: register spine + piles + facets.
   Same §4.1 tokens; the spine + overview are the only new visual primitives.
   ════════════════════════════════════════════════════════════════════════ */

/* Three-pane registry desk: [spine | folio] + memo. */
.desk { display: flex; height: calc(100vh - 138px); min-height: 520px; }
.desk > * { min-width: 0; }
.register-pane { display: flex; flex: none; }
.memo-pane { flex: 1 1 auto; min-width: 0; overflow-y: auto; background: var(--surface); }

.desk a[role="button"] { cursor: pointer; text-decoration: none; }
.desk a[role="button"]:focus-visible,
.folio :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── Pane 1 · the register spine (signature element) ── */
.spine { width: 222px; flex: none; background: var(--surface-2);
  border-right: 1px solid var(--border); padding: 15px 0 18px; overflow-y: auto; }
.spine-eyebrow { font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--faint); padding: 0 18px 10px; }
.spine-all { display: flex; align-items: center; gap: 9px; padding: 9px 16px;
  margin: 0 8px 4px; border-radius: 6px; font-weight: 600; color: var(--ink); font-size: 13px; }
.spine-all.on { background: var(--brand-50); }
.spine-all .ct { margin-left: auto; background: var(--brand-100); border-color: transparent; color: var(--brand); }
.spine-tab { display: block; padding: 8px 16px 9px; margin: 0 8px; border-radius: 6px; }
.spine-tab:hover { background: #EEF1F4; }
.spine-tab.on { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand); }
.spine-tab .row1 { display: flex; align-items: center; gap: 8px; }
.spine-tab .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.spine-tab .nm { font-size: 13px; font-weight: 500; color: var(--ink); }
.spine-tab.on .nm { font-weight: 600; }
.spine-tab .ct { margin-left: auto; }
.spine .ct { font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; font-weight: 600;
  color: var(--quiet); background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 8px; min-width: 26px; text-align: center; }
.spine-tab .meter { height: 3px; border-radius: 2px; background: var(--border);
  margin-top: 7px; overflow: hidden; display: flex; }
.spine-tab .meter i { display: block; height: 100%; }
.spine-tab .meter .seal { background: var(--recommend); }
.spine-tab .meter .exp { background: var(--reject); }
.spine-sep { height: 1px; background: var(--border); margin: 12px 18px; }
.spine-tab.route { background: var(--caution-50); }
.spine-tab.route .nm { color: var(--caution); font-weight: 600; }
.spine-tab.route.on { box-shadow: inset 3px 0 0 var(--caution); }

/* ── Pane 2 · the folio (list / landing) ── */
.folio { width: 372px; flex: none; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); }
.register-pane:not(.with-spine) .folio { width: 400px; }
.folio-head { padding: 14px 20px 0; border-bottom: 1px solid var(--border); }
.folio-back { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0;
  cursor: pointer; color: var(--quiet); font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 0; margin-bottom: 8px; }
.folio-back:hover { color: var(--brand); }
.folio-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.folio-title { font-size: 16px; font-weight: 600; color: var(--ink); }
.pill { background: var(--brand-50); color: var(--brand); font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; }

.folio-controls { margin-top: 11px; }
.search-wrap { position: relative; margin-bottom: 11px; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.folio .search { width: 100%; padding: 9px 12px 9px 32px; border: 1px solid var(--border-2);
  border-radius: 7px; font-family: inherit; font-size: 13px; background: var(--surface); }
.folio .search:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-50); }

.scope-row, .chips, .opts { display: flex; gap: 6px; flex-wrap: wrap; }
.scope-row { padding-bottom: 10px; }
.chips { padding-bottom: 11px; }
.chip { font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: -0.01em;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--surface);
  color: var(--quiet); cursor: pointer; white-space: nowrap; user-select: none; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
/* `.on` is the server-rendered active state; `:has()` makes the chip flip
   instantly on click (the list-only swap leaves these controls in place). */
.chip.on,
.chip:has(input:checked) { background: var(--ink); border-color: var(--ink); color: #fff; }

.refine-row { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; }
.refine summary { list-style: none; cursor: pointer; color: var(--quiet); font-size: 12px; font-weight: 600; }
.refine summary::-webkit-details-marker { display: none; }
.refine summary:hover { color: var(--brand); }
.refine[open] summary { color: var(--brand); }
.refine-drawer { display: flex; gap: 12px 20px; flex-wrap: wrap; padding: 11px 0 2px; }
.facet { display: flex; flex-direction: column; gap: 5px; }
.facet .flbl { font-size: 10px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--faint); }
.sort-sel { margin-left: auto; font-family: inherit; font-size: 12px; color: var(--text);
  border: 1px solid var(--border-2); border-radius: 6px; padding: 5px 8px; background: var(--surface); cursor: pointer; }

/* Leaf list */
.leaf-list { overflow-y: auto; flex: 1; }
.leaf { padding: 13px 20px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.leaf:hover { background: var(--surface-2); }
.leaf.on { background: var(--brand-50); box-shadow: inset 4px 0 0 var(--brand); }
.leaf .l1 { display: flex; gap: 8px; align-items: center; }
.kind-tag { font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--quiet);
  border: 1px solid var(--border); border-radius: 3px; padding: 1px 6px; }
.leaf-date { margin-left: auto; color: var(--faint); font-size: 11.5px; }
.leaf-claim { font-size: 13.5px; font-weight: 500; color: var(--ink); line-height: 1.4; margin-top: 8px; }
.leaf.on .leaf-claim { font-weight: 600; }
.leaf-enrich { margin-top: 6px; font-size: 11px; color: var(--quiet); font-style: italic;
  display: flex; align-items: center; gap: 6px; }
.leaf-enrich .d { width: 6px; height: 6px; border-radius: 999px; background: var(--caution);
  animation: pulse 1.4s ease-in-out infinite; }
.leaf-tags { margin-top: 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sent-cfo { color: var(--quiet); font-style: italic; font-size: 11.5px; }
.exp-tag { background: var(--reject-50); color: var(--reject); font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 3px; border: 1px solid var(--reject); }
.route-tag { background: var(--caution); color: #fff; font-size: 10px; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 8px; border-radius: 3px; }
.conf-tag { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--faint); }

/* Consults-you-owe pile (spec §4.4) */
.consult-pile-head { background: var(--consult); color: #fff; padding: 11px 20px; font-size: 12px;
  font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; display: flex; gap: 10px; align-items: center; }
.consult-pile-ct { background: rgba(255,255,255,0.22); padding: 2px 9px; border-radius: 999px; font-size: 11.5px; }
.consult-pile-item { padding: 13px 20px 14px; border-bottom: 1px solid var(--border);
  background: var(--consult-50); cursor: pointer; }
.consult-pile-item .from { font-size: 12px; color: var(--consult); font-weight: 600; }
.consult-pile-item .q { font-size: 13.5px; color: var(--ink); font-style: italic; margin-top: 6px; }

/* ── The piles landing (overview) ── */
.overview { padding: 16px 20px 24px; overflow-y: auto; }
.ov-eyebrow { font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--faint); margin: 6px 0 10px; }
.ov-scopes { display: flex; gap: 8px; margin-bottom: 18px; }
.scope { flex: 1; text-align: left; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; cursor: pointer; transition: transform 110ms ease, border-color 110ms ease; }
.scope:hover { transform: translateY(-1px); }
.scope.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.scope .big { font-family: 'IBM Plex Mono', monospace; font-size: 20px; font-weight: 600; line-height: 1; }
.scope .sl { font-size: 10.5px; font-weight: 600; color: var(--quiet); margin-top: 5px; }
.scope.seal .big { color: var(--recommend); }
.scope.exp .big { color: var(--reject); }
.scope.route .big { color: var(--caution); }
.ov-card { display: flex; align-items: center; gap: 14px; padding: 13px 14px; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 9px; cursor: pointer; background: var(--surface);
  transition: transform 110ms ease, border-color 110ms ease, box-shadow 110ms ease; }
.ov-card:hover { transform: translateY(-1px); border-color: var(--border-2); box-shadow: var(--shadow-card); }
.ov-card .bar { width: 5px; align-self: stretch; border-radius: 3px; flex: none; }
.ov-card-body { min-width: 0; }
.ov-card .nm { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.ov-card .sub { font-size: 11.5px; color: var(--quiet); margin-top: 3px; }
.ov-card .sub b { color: var(--recommend); font-weight: 600; }
.ov-card .sub i { font-style: normal; color: var(--reject); font-weight: 600; }
.ov-card .cnt { margin-left: auto; text-align: right; }
.ov-card .cnt .n { font-family: 'IBM Plex Mono', monospace; font-size: 24px; font-weight: 600; color: var(--ink); line-height: 1; }
.ov-card .cnt .nl { font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }

.empty-list { padding: 44px 20px; text-align: center; color: var(--quiet); font-size: 13px; }
.memo-empty { padding: 90px 40px; text-align: center; color: var(--quiet); font-size: 14px; }
.memo-empty .ar { font-size: 28px; opacity: 0.4; margin-bottom: 10px; }

/* Spine collapses to a horizontal rail; panes stack on narrow screens. */
@media (max-width: 960px) {
  .desk { flex-direction: column; height: auto; }
  .register-pane { flex-direction: column; }
  .spine { width: auto; flex-direction: row; overflow-x: auto; border-right: 0;
    border-bottom: 1px solid var(--border); padding: 10px; gap: 4px; }
  .spine-eyebrow, .spine-sep { display: none; }
  .spine-all, .spine-tab { margin: 0; white-space: nowrap; flex: none; }
  .spine-tab .meter { display: none; }
  .folio, .register-pane:not(.with-spine) .folio { width: auto; }
  .leaf-list { overflow-y: visible; }
  .memo-pane { overflow-y: visible; }
}

