/* ─────────────────────────────────────────────────────────────────────────────
   IVALDI — a dusty tome.

   Every other tool in the suite is dark: a terminal, an instrument, a night
   sky. This one is a book. It keeps the suite's structure — the same nav, the
   same panel rhythm, the same monospaced labels — and inverts its material.
   Vellum instead of void, sepia ink instead of cyan, gold leaf instead of glow.

   The colour system rests on one rule that took some care: on a dark page,
   "important" means brighter, and every accent can be a light. On vellum it
   cannot — brighter than parchment is white, and white is a hole in the paper.
   So emphasis here is carried by *warmth and depth* rather than by luminance.
   Gilt (a saturated warm ochre) advances; tarnish (a desaturated cool slate)
   recedes; and the ink between them does the reading.
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  /* The page */
  --vellum:       #e9dcbe;
  --vellum-lit:   #f4ead0;
  --vellum-deep:  #ddcda9;
  --vellum-sunk:  #d3c199;

  /* The binding — panels and chrome, a shade darker than the page */
  --bind:         #e2d3b1;
  --bind-deep:    #d8c7a1;

  /* Ink */
  --ink:          #33281a;
  --ink-2:        #5d4c33;
  --muted:        #8a765480;
  --muted-solid:  #8a7654;

  /* Rules */
  --rule:         #c4ae86;
  --rule-soft:    #d5c39d;

  /* Accents */
  --gilt:         #a8781f;
  --gilt-lit:     #c99a34;
  --gilt-wash:    rgba(168, 120, 31, 0.12);
  --tarnish:      #4a5c7c;
  --tarnish-wash: rgba(74, 92, 124, 0.12);
  --ember:        #9a2b18;
  --ember-wash:   rgba(154, 43, 24, 0.1);
  --verdigris:    #3d6b57;

  --shadow-soft:  0 2px 10px rgba(74, 52, 18, 0.12);
  --shadow-lift:  0 10px 34px rgba(60, 42, 14, 0.26);

  --mono:  'JetBrains Mono', ui-monospace, monospace;
  --sans:  'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --serif: 'Cormorant Garamond', 'EB Garamond', Georgia, serif;
  --book:  'EB Garamond', 'Cormorant Garamond', Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: #2a2318; /* the desk the book is lying on */
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Suite nav ─────────────────────────────────────────────────────────────
   Same structure as every other tool, re-inked. It reads as the leather board
   the pages are bound into. */
.site-nav {
  position: relative; z-index: 900; flex-shrink: 0;
  background: linear-gradient(180deg, #34291b, #241c11);
  border-bottom: 1px solid #4a3a22;
  box-shadow: 0 2px 14px rgba(0,0,0,0.4);
}
.site-nav .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem clamp(1rem, 3vw, 2.25rem); }
.nav-logo { display: flex; align-items: center; text-decoration: none; gap: 0.75rem; }
.nav-logo img { width: 30px; height: auto; filter: invert(1) sepia(0.4); opacity: 0.85; }
.nav-logo-name { font-family: var(--serif); font-size: 1.15rem; font-weight: 500; color: #e4d3ae; letter-spacing: 0.01em; }
.nav-links { display: flex; align-items: center; gap: 1.5rem; min-width: 0; }
.suite-dropdown { position: relative; }
.suite-btn {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.18em;
  color: #a8987a; text-transform: uppercase; background: none; border: none; cursor: pointer;
  padding: 0; display: flex; align-items: center; gap: 5px; transition: color 0.2s;
}
.suite-btn:hover, .suite-btn.open { color: #e9d8b2; }
.suite-arrow { font-size: 0.55rem; display: inline-block; transition: transform 0.2s; }
.suite-btn.open .suite-arrow { transform: rotate(180deg); }
.suite-menu {
  display: none; position: absolute; top: calc(100% + 14px); right: 0;
  background: #34291b; border: 1px solid #55432a; border-radius: 6px; padding: 6px;
  min-width: 160px; z-index: 950; box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}
.suite-btn.open + .suite-menu { display: block; }
.suite-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 4px;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  text-decoration: none; color: #a8987a; transition: all 0.15s; white-space: nowrap;
}
.suite-item:hover { background: rgba(233, 216, 178, 0.07); color: #e9d8b2; }
.suite-item.current { color: var(--gilt-lit); }
.suite-sep { height: 1px; background: #55432a; margin: 4px 0; }

/* The activity line the app portals into the nav */
.iv-navstate { display: flex; align-items: center; gap: 8px; max-width: 38vw; min-width: 0; }
.iv-navstate-text {
  font-family: var(--mono); font-size: 0.65rem; letter-spacing: 0.04em; color: #96865f;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.iv-navstate-text.is-good { color: #b39a5e; }
.iv-navstate-text.is-warn { color: #c08a4a; }
.iv-navstate-text.is-bad  { color: #c06a52; }

/* ── Boot ──────────────────────────────────────────────────────────────────── */
#ivaldi-root { flex: 1; min-height: 0; position: relative; }
.iv-boot {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1rem;
  background: var(--vellum); color: var(--ink-2); font-family: var(--book);
}
.iv-boot-mark { font-size: 2.4rem; color: var(--gilt); animation: iv-breathe 2.6s ease-in-out infinite; }
.iv-boot-line { font-size: 1.05rem; font-style: italic; }
@keyframes iv-breathe { 0%, 100% { opacity: 0.35; transform: scale(0.94); } 50% { opacity: 1; transform: scale(1.04); } }

.iv-fallback, .iv-boundary {
  padding: 2rem; background: var(--vellum); color: var(--ink);
  display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-start;
}
.iv-fallback-title, .iv-boundary-title { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.iv-fallback-body, .iv-boundary-body { font-family: var(--book); color: var(--ink-2); max-width: 46ch; }

/* ── Shell ─────────────────────────────────────────────────────────────────── */
.iv-shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.iv-body { flex: 1; display: flex; min-height: 0; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.iv-sidebar {
  width: 344px; flex-shrink: 0; display: flex; flex-direction: column; min-height: 0;
  background: linear-gradient(180deg, var(--bind), var(--bind-deep));
  border-right: 1px solid var(--rule);
  box-shadow: inset -8px 0 18px -14px rgba(70, 48, 16, 0.6);
  transition: width 0.18s ease;
}
.iv-sidebar.is-collapsed { width: 38px; }

.iv-rail { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; }
.iv-rail-expand {
  width: 26px; height: 26px; border-radius: 4px; cursor: pointer;
  background: transparent; border: 1px solid var(--rule); color: var(--muted-solid);
  font-family: var(--mono); font-size: 0.7rem; line-height: 1; transition: all 0.15s;
}
.iv-rail-expand:hover { color: var(--gilt); border-color: var(--gilt); background: var(--gilt-wash); }
.iv-rail-tab {
  writing-mode: vertical-rl; text-orientation: mixed;
  padding: 12px 5px; margin-top: 2px; border: none; border-radius: 4px; cursor: pointer;
  background: transparent; color: var(--muted-solid);
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.16em; text-transform: uppercase;
  transition: all 0.15s;
}
.iv-rail-tab:hover { color: var(--ink-2); background: rgba(120, 92, 44, 0.08); }
.iv-rail-tab.is-on { color: var(--gilt); background: var(--gilt-wash); }

.iv-tabs { display: flex; align-items: stretch; border-bottom: 1px solid var(--rule); flex-shrink: 0; }
.iv-tab {
  flex: 1; padding: 0.75rem 0.5rem; background: none; border: none; cursor: pointer;
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted-solid); border-bottom: 2px solid transparent; transition: all 0.15s;
}
.iv-tab:hover { color: var(--ink-2); }
.iv-tab.is-on { color: var(--gilt); border-bottom-color: var(--gilt); background: var(--gilt-wash); }
.iv-collapse {
  flex-shrink: 0; width: 34px; background: none; border: none; cursor: pointer;
  color: var(--muted-solid); font-family: var(--mono); font-size: 0.7rem;
  border-left: 1px solid var(--rule); transition: all 0.15s;
}
.iv-collapse:hover { color: var(--gilt); background: var(--gilt-wash); }
.iv-panel-scroll { flex: 1; overflow-y: auto; min-height: 0; }

.iv-section { padding: 1rem; border-bottom: 1px solid var(--rule-soft); }
.iv-section-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.7rem; }
.iv-section-head-tight { margin-top: 1.1rem; }
.iv-section-head h3, .iv-ledger-head h3 {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted-solid);
}
.iv-count { font-family: var(--mono); font-size: 0.62rem; color: var(--muted-solid); white-space: nowrap; }

/* ── Prose ─────────────────────────────────────────────────────────────────── */
.iv-hint {
  font-family: var(--book); font-size: 0.9rem; line-height: 1.5; color: var(--ink-2);
  margin-bottom: 0.75rem;
}
.iv-hint-tight { font-size: 0.84rem; margin: 0.35rem 0 0; opacity: 0.9; }
.iv-hint a { color: var(--gilt); }
.iv-hint strong { color: var(--ink); font-weight: 600; }
.iv-label {
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted-solid); display: block;
}
.iv-mono { font-family: var(--mono); font-size: 0.76rem; }
.iv-wrap { overflow-wrap: anywhere; }
.iv-pos { color: var(--verdigris); }
.iv-neg { color: var(--ember); }

/* ── Controls ──────────────────────────────────────────────────────────────── */
.iv-btn {
  padding: 8px 14px; border-radius: 3px; border: 1px solid transparent;
  font-family: var(--mono); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.1em;
  text-transform: uppercase; cursor: pointer;
  background: rgba(120, 92, 44, 0.1); color: var(--ink);
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s; white-space: nowrap;
}
.iv-btn:hover:not(:disabled) { background: rgba(120, 92, 44, 0.18); }
.iv-btn:disabled { opacity: 0.36; cursor: not-allowed; }
.iv-btn-primary {
  background: linear-gradient(180deg, var(--gilt-lit), var(--gilt));
  color: #2a1d05; border-color: #8c6316; box-shadow: var(--shadow-soft);
}
.iv-btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #d9a83f, #b98726); }
.iv-btn-ghost { background: transparent; border-color: var(--rule); color: var(--ink-2); }
.iv-btn-ghost:hover:not(:disabled) { background: rgba(120, 92, 44, 0.08); color: var(--ink); }
/* Destructive actions stay quiet at rest and declare themselves on hover. */
.iv-btn-danger { background: transparent; color: var(--ink-2); border-color: var(--rule); }
.iv-btn-danger:hover:not(:disabled) { background: var(--ember-wash); color: var(--ember); border-color: rgba(154,43,24,0.45); }
.iv-btn-sm { padding: 6px 10px; font-size: 0.64rem; }
.iv-btn-xs { padding: 3px 8px; font-size: 0.57rem; letter-spacing: 0.06em; }
.iv-btn-block { display: block; width: 100%; margin-top: 0.6rem; }
.iv-btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-top: 0.7rem; }
.iv-btn-grid .iv-btn { width: 100%; padding-left: 6px; padding-right: 6px; text-align: center; }

.iv-icon-btn {
  width: 26px; height: 26px; flex-shrink: 0; border: none; background: transparent; cursor: pointer;
  color: var(--muted-solid); border-radius: 4px; font-size: 0.8rem; line-height: 1; transition: all 0.15s;
}
.iv-icon-btn:hover { color: var(--ember); background: var(--ember-wash); }
.iv-link { background: none; border: none; padding: 0; color: var(--gilt); font: inherit; cursor: pointer; text-decoration: underline; }

.iv-field { display: block; margin-bottom: 0.8rem; }
.iv-field > span {
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem;
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted-solid); margin-bottom: 0.35rem;
}
.iv-field > span em { font-style: normal; color: var(--gilt); text-transform: none; letter-spacing: 0.02em; }

.iv-input, .iv-select, .iv-textarea {
  width: 100%; padding: 7px 9px; border-radius: 3px;
  border: 1px solid var(--rule); background: rgba(255, 250, 235, 0.6); color: var(--ink);
  font-family: var(--sans); font-size: 0.82rem; transition: border-color 0.15s, background 0.15s;
}
.iv-input:focus, .iv-select:focus, .iv-textarea:focus {
  outline: none; border-color: var(--gilt); background: rgba(255, 252, 242, 0.9);
}
.iv-input-sm { padding: 4px 8px; font-size: 0.76rem; width: auto; min-width: 130px; }
.iv-textarea { resize: vertical; line-height: 1.5; }
.iv-mono.iv-textarea, .iv-textarea.iv-mono { font-family: var(--mono); font-size: 0.76rem; }

.iv-range { width: 100%; accent-color: var(--gilt); }

.iv-query {
  display: block; padding: 8px 10px; border-radius: 3px; border: 1px dashed var(--rule);
  background: rgba(255, 250, 235, 0.45); font-family: var(--mono); font-size: 0.74rem;
  color: var(--ink-2); overflow-wrap: anywhere; line-height: 1.5;
}

.iv-chiprow { display: flex; flex-wrap: wrap; gap: 4px; }
.iv-chip {
  padding: 4px 9px; border-radius: 3px; border: 1px solid var(--rule); background: transparent;
  color: var(--ink-2); font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.06em;
  cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 4px;
}
.iv-chip:hover { border-color: var(--gilt); color: var(--ink); }
.iv-chip.is-on { background: var(--gilt-wash); border-color: var(--gilt); color: var(--gilt); }
.iv-pip { font-size: 0.85rem; line-height: 1; text-shadow: 0 0 2px rgba(60,40,10,0.35); }

.iv-radiorow, .iv-checkrow {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-top: 0.5rem;
  font-family: var(--book); font-size: 0.86rem; color: var(--ink-2);
}
.iv-checkrow-stack { flex-direction: column; gap: 0.35rem; }
.iv-radiorow label, .iv-checkrow label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.iv-radiorow input, .iv-checkrow input { accent-color: var(--gilt); }

.iv-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.6rem; }
.iv-numfield { display: block; margin-bottom: 0.6rem; }
.iv-numfield > span {
  display: block; font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted-solid); margin-bottom: 0.25rem;
}
.iv-toggle-inline {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted-solid);
}
.iv-toggle-inline input { accent-color: var(--gilt); }
.iv-inline-form { display: flex; gap: 0.4rem; }
.iv-swatch { height: 8px; border-radius: 2px; margin-top: 6px; border: 1px solid var(--rule); }

/* ── Presets ───────────────────────────────────────────────────────────────── */
.iv-presets { display: flex; flex-direction: column; gap: 4px; }
.iv-preset {
  text-align: left; padding: 8px 10px; border-radius: 3px; cursor: pointer;
  border: 1px solid transparent; background: rgba(255, 250, 235, 0.35);
  transition: all 0.15s; display: block; width: 100%;
}
.iv-preset:hover:not(:disabled) { border-color: var(--gilt); background: rgba(255, 250, 235, 0.7); }
.iv-preset:disabled { opacity: 0.5; cursor: not-allowed; }
.iv-preset-name {
  display: block; font-family: var(--serif); font-size: 1rem; font-weight: 600; color: var(--ink);
}
.iv-preset-blurb {
  display: block; font-family: var(--book); font-size: 0.82rem; line-height: 1.4; color: var(--ink-2);
}

/* ── Notes and progress ────────────────────────────────────────────────────── */
.iv-note {
  padding: 9px 11px; border-radius: 3px; border-left: 3px solid var(--rule);
  background: rgba(255, 250, 235, 0.5); font-family: var(--book); font-size: 0.88rem;
  color: var(--ink-2); margin: 0.6rem 0;
}
.iv-note-warn { border-left-color: var(--gilt); background: var(--gilt-wash); }
.iv-note-bad { border-left-color: var(--ember); background: var(--ember-wash); color: var(--ember); }
.iv-note p + .iv-btn, .iv-note p + .iv-btn-grid { margin-top: 0.5rem; }

.iv-progress { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.7rem; }
.iv-progress-line {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 0.68rem; color: var(--ink-2);
}
.iv-progress-bar { height: 3px; background: var(--vellum-sunk); border-radius: 2px; overflow: hidden; }
.iv-progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--gilt), var(--gilt-lit)); transition: width 0.25s; }
.iv-spinner {
  width: 11px; height: 11px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid rgba(120, 92, 44, 0.28); border-top-color: var(--gilt);
  animation: iv-spin 0.8s linear infinite;
}
@keyframes iv-spin { to { transform: rotate(360deg); } }

/* ── Facts list ────────────────────────────────────────────────────────────── */
.iv-facts { display: flex; flex-direction: column; gap: 2px; margin: 0.5rem 0; }
.iv-facts > div {
  display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
  padding: 3px 0; border-bottom: 1px dotted var(--rule-soft);
}
.iv-facts dt {
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted-solid); flex-shrink: 0;
}
.iv-facts dd { font-family: var(--book); font-size: 0.9rem; color: var(--ink); text-align: right; }
.iv-facts-row { flex-direction: row; flex-wrap: wrap; gap: 1.5rem; }
.iv-facts-row > div { flex-direction: column; align-items: flex-start; border: none; gap: 0; }
.iv-facts-row dd { text-align: left; font-size: 1.15rem; font-family: var(--serif); font-weight: 600; }
.iv-dim { font-family: var(--mono); font-size: 0.55rem; font-style: normal; font-weight: 400; color: var(--muted-solid); letter-spacing: 0.06em; }

/* ── The stage ─────────────────────────────────────────────────────────────
   The page now owns the full height between the two rails. It used to give up
   300px to a ledger docked underneath, which left it about 40% of the viewport
   and the ledger about three rows — both of them half-useful. */
.iv-stage { flex: 1; min-width: 0; position: relative; }
.iv-page { position: absolute; inset: 0; background: var(--vellum); }

/* Which question the page is answering, on the page. */
.iv-stage-top {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 20;
  display: flex; align-items: flex-start; gap: 0.9rem; pointer-events: none;
}
.iv-stage-top > * { pointer-events: auto; }

.iv-layoutswitch {
  flex-shrink: 0; display: flex; gap: 2px;
  padding: 3px; border-radius: 4px; border: 1px solid var(--rule);
  background: rgba(244, 234, 208, 0.86); box-shadow: var(--shadow-soft);
}
.iv-layoutbtn {
  padding: 4px 10px; border-radius: 2px; border: none; background: none; cursor: pointer;
  color: var(--muted-solid); transition: all 0.15s; white-space: nowrap;
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase;
}
.iv-layoutbtn:hover { color: var(--ink-2); }
.iv-layoutbtn.is-on { background: var(--gilt-wash); color: var(--gilt); }
.iv-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.iv-canvas:active { cursor: grabbing; }

.iv-page-hints {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  display: flex; gap: 1rem; align-items: center;
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.08em;
  color: var(--muted-solid); pointer-events: none; text-transform: uppercase;
}
.iv-page-hints b { color: var(--ink-2); font-weight: 500; }
.iv-hint-btn {
  pointer-events: auto; background: transparent; border: 1px solid var(--rule); border-radius: 3px;
  padding: 2px 7px; font: inherit; color: var(--muted-solid); cursor: pointer;
}
.iv-hint-btn:hover { color: var(--gilt); border-color: var(--gilt); }

/* Clears both the interaction hints and the axis title the derived layouts
   draw onto the canvas at the same edge. */
.iv-page-caveat {
  position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%);
  max-width: 62ch; text-align: center; font-family: var(--book); font-size: 0.86rem;
  color: var(--ink-2); background: rgba(244, 234, 208, 0.85); border: 1px solid var(--rule);
  border-radius: 3px; padding: 6px 12px; box-shadow: var(--shadow-soft);
}

.iv-running-head {
  flex: 1; min-width: 0; padding-top: 5px;
  display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; justify-content: center;
  font-family: var(--book); font-size: 0.92rem; color: var(--ink-2);
  pointer-events: none; text-align: center;
}
.iv-running-title { font-family: var(--mono); font-size: 0.72rem; color: var(--ink); letter-spacing: 0.02em; }
.iv-running-sep { color: var(--muted-solid); }
.iv-running-gilt { color: var(--gilt); font-weight: 500; }
.iv-running-quiet { color: var(--muted-solid); font-size: 0.84rem; }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.iv-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 2rem; pointer-events: none;
}
.iv-empty-card {
  pointer-events: auto; max-width: 46ch; text-align: center;
  background: rgba(247, 239, 218, 0.9); border: 1px solid var(--rule); border-radius: 4px;
  padding: 2rem 2.2rem; box-shadow: var(--shadow-lift);
}
.iv-empty-mark { font-size: 2rem; color: var(--gilt); margin-bottom: 0.5rem; }
.iv-empty-card h2 { font-family: var(--serif); font-size: 1.7rem; font-weight: 600; margin-bottom: 0.6rem; }
.iv-empty-card p { font-family: var(--book); font-size: 0.98rem; color: var(--ink-2); margin-bottom: 0.8rem; }

/* ── Legend ────────────────────────────────────────────────────────────────── */
.iv-legend { flex-shrink: 0; max-width: 330px; }
.iv-legend-toggle {
  display: flex; align-items: center; gap: 6px; margin-left: auto;
  padding: 5px 10px; border-radius: 3px; border: 1px solid var(--rule);
  background: rgba(244, 234, 208, 0.86); color: var(--ink-2); cursor: pointer;
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase;
  box-shadow: var(--shadow-soft);
}
.iv-legend-toggle:hover { color: var(--gilt); border-color: var(--gilt); }
.iv-legend-body {
  margin-top: 6px; padding: 12px 14px; border-radius: 4px; border: 1px solid var(--rule);
  background: rgba(247, 239, 218, 0.95); box-shadow: var(--shadow-lift);
  max-height: 70vh; overflow-y: auto;
}
.iv-legend-group + .iv-legend-group { margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px dotted var(--rule-soft); }
.iv-legend-group h4 {
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted-solid); margin-bottom: 0.35rem;
}
.iv-legend-group p { font-family: var(--book); font-size: 0.86rem; color: var(--ink-2); }
.iv-legend-ramp {
  display: flex; align-items: center; gap: 6px; margin-top: 6px;
  font-family: var(--mono); font-size: 0.55rem; text-transform: uppercase; color: var(--muted-solid);
}
.iv-ramp { flex: 1; height: 8px; border-radius: 2px; border: 1px solid var(--rule); }
.iv-legend-shapes { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.iv-legend-shape {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--book); font-size: 0.82rem; color: var(--ink-2);
}
.iv-sigil { fill: rgba(120, 92, 44, 0.5); stroke: var(--ink-2); stroke-width: 1; }
.iv-legend-marks { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.iv-legend-marks li {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--book); font-size: 0.84rem; color: var(--ink-2);
}
.iv-mark { width: 15px; height: 15px; flex-shrink: 0; border-radius: 50%; }
.iv-mark-ring { border: 1.5px solid var(--gilt); }
.iv-mark-strike { background: linear-gradient(45deg, transparent 44%, var(--ember) 44%, var(--ember) 56%, transparent 56%); }
.iv-mark-arc { border: 3px solid transparent; border-top-color: #7ba2c4; border-right-color: #c0704f; border-radius: 50%; }
.iv-mark-seal { background: var(--ember); box-shadow: 0 0 0 1.5px rgba(247, 239, 218, 0.85); width: 10px; height: 10px; margin: 0 2px; }
.iv-mark-thread { background: repeating-linear-gradient(90deg, var(--gilt) 0 4px, transparent 4px 8px); height: 2px; border-radius: 0; }

/* ── The right rail ────────────────────────────────────────────────────────
   Master-detail. The ledger is always mounted; the codex is absolutely
   positioned over it, so going back to the list restores its scroll position
   and its filters rather than rebuilding them. */
.iv-dock {
  position: relative; flex-shrink: 0; display: flex; flex-direction: column; min-height: 0;
  background: linear-gradient(180deg, var(--bind), var(--bind-deep));
  border-left: 1px solid var(--rule);
  box-shadow: inset 8px 0 18px -14px rgba(70, 48, 16, 0.6);
}
.iv-dock-grip {
  position: absolute; left: -3px; top: 0; bottom: 0; width: 7px; z-index: 40;
  cursor: col-resize; background: transparent; transition: background 0.15s;
}
.iv-dock-grip:hover { background: rgba(168, 120, 31, 0.35); }
body.iv-resizing { cursor: col-resize; user-select: none; }
body.iv-resizing .iv-canvas { pointer-events: none; }

/* ── The ledger ────────────────────────────────────────────────────────────── */
.iv-ledger { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.iv-ledger-head {
  display: flex; align-items: baseline; gap: 0.7rem; padding: 0.75rem 0.9rem 0.5rem;
}
.iv-ledger-head .iv-count { margin-left: auto; }
.iv-ledger-controls {
  display: flex; gap: 0.35rem; align-items: center; padding: 0 0.9rem 0.6rem;
}
.iv-ledger-controls .iv-input { flex: 1; min-width: 0; }
.iv-select-sm { padding: 4px 6px; font-size: 0.72rem; width: auto; flex-shrink: 0; max-width: 46%; }

.iv-facets { border-top: 1px solid var(--rule-soft); border-bottom: 1px solid var(--rule-soft); }
.iv-facets > summary {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.9rem; cursor: pointer;
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted-solid); list-style: none;
}
.iv-facets > summary::-webkit-details-marker { display: none; }
.iv-facets > summary::before { content: '▸'; font-size: 0.55rem; }
.iv-facets[open] > summary::before { content: '▾'; }
.iv-facets > summary:hover { color: var(--ink-2); }
.iv-facets > summary em { font-style: normal; color: var(--gilt); }
.iv-facets > summary .iv-btn { margin-left: auto; }
.iv-facet-body { padding: 0 0.9rem 0.7rem; }
.iv-facet { margin-bottom: 0.6rem; }
.iv-facet .iv-label { margin-bottom: 0.25rem; }
.iv-checkline {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  font-family: var(--book); font-size: 0.86rem; color: var(--ink-2);
}
.iv-checkline input { accent-color: var(--gilt); }

.iv-ledger-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 0 0.5rem; }
.iv-ledger-foot {
  padding: 0.5rem 0.9rem 0.7rem; border-top: 1px solid var(--rule-soft);
  font-family: var(--book); font-size: 0.78rem; color: var(--muted-solid);
}
.iv-ledger-foot .iv-btn-grid { margin-top: 0; margin-bottom: 0.45rem; }
.iv-ledger-foot p { line-height: 1.4; }
.iv-empty-line { padding: 1.5rem; text-align: center; font-family: var(--book); color: var(--muted-solid); }

/* A ledger entry. Three lines: what it is, what it is worth, what to watch for.
   The verdict is a left edge rather than a row tint, so a page of them still
   reads as a list instead of a heat map competing with the actual one. */
.iv-row {
  display: flex; align-items: stretch; gap: 2px; margin: 3px 0; border-radius: 3px;
  background: rgba(255, 250, 235, 0.4); border: 1px solid transparent; transition: all 0.12s;
}
.iv-row:hover { background: rgba(255, 250, 235, 0.8); border-color: var(--rule); }
.iv-row.is-selected { border-color: var(--gilt); background: var(--gilt-wash); }
.iv-row-body {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
  padding: 7px 4px 7px 9px; background: none; border: none; cursor: pointer; text-align: left;
  border-left: 3px solid transparent; border-radius: 3px 0 0 3px;
}
.iv-row-gilt .iv-row-body { border-left-color: rgba(168, 120, 31, 0.85); }
.iv-row-gilt-faint .iv-row-body { border-left-color: rgba(168, 120, 31, 0.35); }
.iv-row-tarnish .iv-row-body { border-left-color: rgba(74, 92, 124, 0.75); }
.iv-row-tarnish-faint .iv-row-body { border-left-color: rgba(74, 92, 124, 0.32); }
.iv-row-top { display: flex; align-items: baseline; gap: 0.5rem; }
.iv-row-name {
  flex: 1; min-width: 0; font-family: var(--serif); font-size: 1.05rem; font-weight: 600;
  color: var(--ink); line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.iv-row-gap { font-family: var(--mono); font-size: 0.78rem; flex-shrink: 0; }
.iv-row-mid { display: flex; align-items: baseline; justify-content: space-between; gap: 0.2rem 0.6rem; flex-wrap: wrap; }
.iv-row-price { font-family: var(--mono); font-size: 0.74rem; color: var(--ink-2); flex-shrink: 0; }
.iv-row-price b { color: var(--ink); font-weight: 500; }
.iv-row-stats {
  font-family: var(--mono); font-size: 0.58rem; color: var(--muted-solid);
  text-align: right; line-height: 1.5;
}
.iv-row-flags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 1px; }
.iv-row-mark {
  flex-shrink: 0; width: 30px; border: none; background: none; cursor: pointer;
  color: var(--muted-solid); font-size: 0.7rem; border-radius: 0 3px 3px 0; transition: all 0.15s;
}
.iv-row-mark:hover { color: var(--ember); background: var(--ember-wash); }
.iv-row-mark.is-on { color: var(--ember); }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.iv-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.iv-table thead th {
  position: sticky; top: 0; z-index: 2; text-align: left; white-space: nowrap;
  padding: 6px 10px; background: var(--bind-deep); border-bottom: 1px solid var(--rule);
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted-solid); cursor: pointer; user-select: none;
}
.iv-table thead th:hover { color: var(--ink-2); }
.iv-table thead th.is-sorted { color: var(--gilt); }
.iv-table td { padding: 5px 10px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
.iv-table tbody tr { cursor: pointer; transition: background 0.12s; }
.iv-table tbody tr:hover { background: rgba(255, 250, 235, 0.55); }
.iv-table tbody tr.is-selected { background: var(--gilt-wash); box-shadow: inset 3px 0 0 var(--gilt); }
.iv-num { text-align: right; font-family: var(--mono); font-size: 0.75rem; white-space: nowrap; }
.iv-row-name { display: block; font-family: var(--serif); font-size: 1rem; font-weight: 600; color: var(--ink); line-height: 1.2; }
.iv-row-type { display: block; font-family: var(--book); font-size: 0.78rem; color: var(--muted-solid); line-height: 1.2; }
/* A whole row tinted by its verdict would fight the wash on the page for
   attention. A left edge says the same thing and stays out of the way. */
.iv-row-gilt { box-shadow: inset 3px 0 0 rgba(168, 120, 31, 0.75); }
.iv-row-gilt-faint { box-shadow: inset 3px 0 0 rgba(168, 120, 31, 0.32); }
.iv-row-tarnish { box-shadow: inset 3px 0 0 rgba(74, 92, 124, 0.7); }
.iv-row-tarnish-faint { box-shadow: inset 3px 0 0 rgba(74, 92, 124, 0.3); }
.iv-table-tight td, .iv-table-tight th { padding: 3px 7px; font-size: 0.76rem; }
.iv-table-tight a { color: var(--ink); text-decoration: none; }
.iv-table-tight a:hover { color: var(--gilt); text-decoration: underline; }
.iv-table-tight em { color: var(--muted-solid); font-size: 0.68rem; }

.iv-flagcell { display: flex; gap: 3px; justify-content: flex-end; flex-wrap: wrap; }
.iv-tag {
  padding: 1px 6px; border-radius: 2px; font-family: var(--mono); font-size: 0.54rem;
  letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; cursor: help;
}
.iv-tag-good { background: var(--gilt-wash); color: var(--gilt); border: 1px solid rgba(168,120,31,0.4); }
.iv-tag-warn { background: var(--ember-wash); color: var(--ember); border: 1px solid rgba(154,43,24,0.35); }
.iv-tag-note { background: rgba(120, 92, 44, 0.1); color: var(--ink-2); border: 1px solid var(--rule); }

/* ── The codex ─────────────────────────────────────────────────────────────
   Covers the ledger inside the rail rather than sitting beside it. */
.iv-codex {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; min-height: 0;
  background: linear-gradient(180deg, var(--bind), var(--bind-deep));
  animation: iv-slide-in 0.16s ease;
}
@keyframes iv-slide-in { from { transform: translateX(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.iv-codex-head {
  display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 0.5rem 0.7rem;
  padding: 0.7rem 1rem 0.85rem; border-bottom: 1px solid var(--rule);
}
.iv-codex-back {
  grid-column: 1 / -1; justify-self: start; padding: 2px 0; background: none; border: none;
  cursor: pointer; color: var(--muted-solid);
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase;
}
.iv-codex-back:hover { color: var(--gilt); }
.iv-codex-headline { grid-column: 1 / 3; min-width: 0; }
.iv-codex-actions { grid-column: 3; display: flex; align-items: center; gap: 4px; }
.iv-mark-btn {
  padding: 3px 8px; border-radius: 3px; border: 1px solid var(--rule); background: transparent;
  color: var(--muted-solid); cursor: pointer; white-space: nowrap;
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.08em; text-transform: uppercase;
  transition: all 0.15s;
}
.iv-mark-btn:hover { color: var(--ember); border-color: rgba(154,43,24,0.45); }
.iv-mark-btn.is-on { color: var(--ember); border-color: rgba(154,43,24,0.5); background: var(--ember-wash); }
.iv-codex-name { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; line-height: 1.15; }
.iv-codex-type { font-family: var(--book); font-size: 0.88rem; color: var(--ink-2); font-style: italic; }
.iv-mana { font-family: var(--mono); font-size: 0.72rem; font-style: normal; color: var(--muted-solid); }
.iv-codex-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 0 1rem 1.5rem; }
.iv-codex-section { padding-top: 0.6rem; }

.iv-cardart {
  margin: 0.9rem 0; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--rule); box-shadow: var(--shadow-lift);
  background: var(--vellum-sunk);
}
.iv-cardart img { display: block; width: 100%; height: auto; }

/* The art crop, as an illuminated capital would sit at the head of a page:
   enough to know which card this is, not enough to displace the reading. */
.iv-cardbanner {
  margin: 0.85rem 0; height: 104px; border-radius: 4px; overflow: hidden;
  border: 1px solid var(--rule); box-shadow: var(--shadow-soft); position: relative;
}
.iv-cardbanner img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 32%; }
/* A wash of the page colour over the art, so a saturated illustration does not
   fight the parchment it is printed on. */
.iv-cardbanner::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(233, 220, 190, 0.16), rgba(233, 220, 190, 0.36));
  mix-blend-mode: multiply;
}

.iv-verdict {
  padding: 0.9rem; border-radius: 4px; border: 1px solid var(--rule);
  background: rgba(255, 250, 235, 0.55);
}
.iv-verdict-gilt { border-color: var(--gilt); background: linear-gradient(180deg, rgba(201,154,52,0.16), rgba(255,250,235,0.6)); }
.iv-verdict-gilt-faint { border-color: rgba(168,120,31,0.5); }
.iv-verdict-tarnish { border-color: rgba(74,92,124,0.6); background: linear-gradient(180deg, rgba(74,92,124,0.13), rgba(255,250,235,0.6)); }
.iv-verdict-tarnish-faint { border-color: rgba(74,92,124,0.35); }
.iv-verdict-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 0.6rem; }
.iv-verdict-arrow { font-size: 1.2rem; color: var(--muted-solid); padding-bottom: 0.35rem; }
.iv-price { display: block; font-family: var(--serif); font-size: 1.75rem; font-weight: 700; line-height: 1.05; }
.iv-price-alt { font-family: var(--mono); font-size: 0.7rem; color: var(--muted-solid); }
.iv-verdict-badge {
  display: inline-block; margin-top: 0.6rem; padding: 3px 10px; border-radius: 2px;
  background: rgba(120, 92, 44, 0.12); border: 1px solid var(--rule);
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase;
}
.iv-verdict-note { font-family: var(--book); font-size: 0.86rem; color: var(--ink-2); margin-top: 0.5rem; }
.iv-verdict-line { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; margin-bottom: 0.6rem; }
.iv-conf { margin-top: 0.7rem; }
.iv-conf-head { display: flex; justify-content: space-between; align-items: baseline; }
.iv-codex-links { display: flex; gap: 0.8rem; margin-top: 0.7rem; }
.iv-codex-links a {
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--gilt);
}

.iv-flags { display: flex; flex-direction: column; gap: 5px; margin-top: 0.7rem; }
.iv-flag {
  padding: 7px 10px; border-radius: 3px; border-left: 3px solid var(--rule);
  background: rgba(255, 250, 235, 0.45);
}
.iv-flag strong {
  display: block; font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.12em;
  text-transform: uppercase; margin-bottom: 2px;
}
.iv-flag span { font-family: var(--book); font-size: 0.85rem; color: var(--ink-2); }
.iv-flag-good { border-left-color: var(--gilt); background: var(--gilt-wash); }
.iv-flag-good strong { color: var(--gilt); }
.iv-flag-warn { border-left-color: var(--ember); background: var(--ember-wash); }
.iv-flag-warn strong { color: var(--ember); }
.iv-flag-note strong { color: var(--ink-2); }

.iv-codex-tabs { display: flex; gap: 2px; margin: 0.9rem 0 0.3rem; border-bottom: 1px solid var(--rule); }
.iv-codex-tab {
  flex: 1; padding: 6px 4px; background: none; border: none; cursor: pointer;
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted-solid); border-bottom: 2px solid transparent; transition: all 0.15s;
}
.iv-codex-tab:hover { color: var(--ink-2); }
.iv-codex-tab.is-on { color: var(--gilt); border-bottom-color: var(--gilt); }

.iv-estimates { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 0.8rem; }
.iv-estimate {
  padding: 8px 10px; border-radius: 3px; border: 1px solid var(--rule-soft);
  background: rgba(255, 250, 235, 0.4);
}
.iv-estimate strong { display: block; font-family: var(--serif); font-size: 1.3rem; font-weight: 700; }
.iv-estimate small { font-family: var(--book); font-size: 0.78rem; color: var(--muted-solid); line-height: 1.3; display: block; }

.iv-ledger-rows { display: flex; flex-direction: column; margin: 0.8rem 0 0; }
.iv-ledger-row {
  display: flex; justify-content: space-between; padding: 3px 0;
  font-family: var(--book); font-size: 0.88rem; color: var(--ink-2);
  border-bottom: 1px dotted var(--rule-soft);
}
.iv-ledger-row.is-total {
  border-bottom: none; border-top: 1px solid var(--rule); margin-top: 3px; padding-top: 5px;
  color: var(--ink); font-weight: 600;
}

.iv-contributors { display: flex; flex-direction: column; gap: 3px; }
.iv-contributors-wide { max-height: 280px; overflow-y: auto; }
.iv-contributor {
  display: block; width: 100%; text-align: left; padding: 5px 8px; border-radius: 3px;
  border: 1px solid transparent; background: rgba(255, 250, 235, 0.4); cursor: pointer;
  transition: all 0.15s;
}
.iv-contributor:hover { border-color: var(--gilt); background: rgba(255, 250, 235, 0.8); }
.iv-contributor-name { display: block; font-family: var(--serif); font-size: 0.98rem; font-weight: 600; line-height: 1.2; }
.iv-contributor-meta { display: block; font-family: var(--mono); font-size: 0.62rem; color: var(--muted-solid); }

.iv-contributions { display: flex; flex-direction: column; }
.iv-contribution {
  display: flex; justify-content: space-between; padding: 3px 0;
  font-family: var(--book); font-size: 0.86rem; color: var(--ink-2);
  border-bottom: 1px dotted var(--rule-soft);
}

.iv-bar {
  display: block; height: 4px; border-radius: 2px; overflow: hidden;
  background: rgba(120, 92, 44, 0.16); margin-top: 3px;
}
.iv-bar > span { display: block; height: 100%; border-radius: 2px; }
.iv-bar-gilt > span { background: linear-gradient(90deg, var(--gilt), var(--gilt-lit)); }
.iv-bar-quill > span { background: var(--muted-solid); }
.iv-bar-ember > span { background: linear-gradient(90deg, #b8703c, var(--ember)); }

.iv-meter { margin-top: 0.9rem; }
.iv-meter-head { display: flex; justify-content: space-between; align-items: baseline; }

/* Whether the verdict survives its own settings. Bordered rather than tinted:
   it is a caveat on the number above it, not a third estimate. */
.iv-sens {
  margin-top: 0.9rem; padding: 8px 10px; border-radius: 3px;
  border: 1px dashed var(--rule); background: rgba(255, 250, 235, 0.4);
}
.iv-sens.is-robust { border-color: rgba(168, 120, 31, 0.5); }
.iv-sens.is-fragile { border-color: rgba(154, 43, 24, 0.45); background: var(--ember-wash); }
.iv-sens-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.iv-sens .iv-hint { margin-bottom: 0; }

/* The printing strip */
.iv-strip { margin: 0.7rem 0 1rem; }
.iv-strip-track {
  position: relative; height: 26px; border-bottom: 1px solid var(--rule);
  background: linear-gradient(90deg, rgba(120,92,44,0.05), rgba(120,92,44,0.12));
  border-radius: 2px;
}
.iv-strip-mark {
  position: absolute; bottom: 3px; transform: translateX(-50%);
  border-radius: 50%; border: 1px solid rgba(70, 50, 20, 0.5); cursor: help; padding: 0;
  background: var(--gilt); transition: transform 0.12s;
}
.iv-strip-mark:hover { transform: translateX(-50%) scale(1.35); z-index: 2; }
.iv-strip-mark.is-minor { background: rgba(138, 118, 84, 0.55); }
.iv-strip-mark.is-future { background: var(--ember); }
.iv-strip-axis {
  display: flex; justify-content: space-between; margin-top: 3px;
  font-family: var(--mono); font-size: 0.55rem; color: var(--muted-solid);
}

/* The power rubric */
.iv-rubric { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 0.6rem; }
.iv-crit-head { display: flex; align-items: baseline; gap: 0.5rem; }
.iv-crit-label { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; flex: 1; }
.iv-crit-weight { font-family: var(--mono); font-size: 0.58rem; color: var(--muted-solid); }
.iv-crit-value { font-family: var(--mono); font-size: 0.85rem; color: var(--gilt); }
.iv-crit-blurb { font-family: var(--book); font-size: 0.82rem; color: var(--muted-solid); margin: 3px 0 5px; }
.iv-sub { border-top: 1px dotted var(--rule-soft); }
.iv-sub-head {
  display: flex; align-items: baseline; gap: 6px; width: 100%; padding: 4px 0;
  background: none; border: none; cursor: pointer; text-align: left; color: var(--ink-2);
}
.iv-sub-head:hover { color: var(--ink); }
.iv-caret { font-size: 0.6rem; color: var(--muted-solid); }
.iv-sub-label { font-family: var(--book); font-size: 0.9rem; flex: 1; }
.iv-sub-ev { font-family: var(--mono); font-size: 0.56rem; color: var(--muted-solid); }
.iv-sub-value { font-family: var(--mono); font-size: 0.78rem; }
.iv-sub-rationale {
  font-family: var(--book); font-size: 0.86rem; line-height: 1.45; color: var(--ink-2);
  padding: 0 0 8px 14px; border-left: 2px solid var(--rule-soft); margin-left: 3px;
}

.iv-power-head { display: flex; align-items: baseline; gap: 0.5rem; }
.iv-power-value { font-family: var(--serif); font-size: 2.2rem; font-weight: 700; color: var(--gilt); }
.iv-power-head .iv-label { display: inline; }

.iv-oracle {
  font-family: var(--book); font-size: 0.92rem; line-height: 1.5; white-space: pre-wrap;
  padding: 10px 12px; border-radius: 3px; border: 1px solid var(--rule-soft);
  background: rgba(255, 250, 235, 0.5); color: var(--ink); margin-bottom: 0.8rem;
}
.iv-legalities { display: flex; flex-wrap: wrap; gap: 4px; }
.iv-legal {
  padding: 2px 7px; border-radius: 2px; border: 1px solid var(--rule);
  font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted-solid);
}
.iv-legal.is-legal { color: var(--verdigris); border-color: rgba(61,107,87,0.4); background: rgba(61,107,87,0.08); }
.iv-legal.is-banned, .iv-legal.is-restricted { color: var(--ember); border-color: rgba(154,43,24,0.4); background: var(--ember-wash); }
.iv-legal em { font-style: normal; opacity: 0.7; }

/* ── Modals ────────────────────────────────────────────────────────────────── */
.iv-modal-backdrop {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 2rem; background: rgba(38, 28, 12, 0.55); backdrop-filter: blur(3px);
}
.iv-modal {
  width: 100%; max-width: 540px; max-height: 88vh; display: flex; flex-direction: column;
  background: var(--vellum-lit); border: 1px solid var(--rule); border-radius: 5px;
  box-shadow: 0 24px 70px rgba(20, 12, 2, 0.55);
}
.iv-modal-wide { max-width: 780px; }
.iv-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--rule);
}
.iv-modal-title { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; line-height: 1.1; }
.iv-modal-sub { font-family: var(--book); font-size: 0.95rem; color: var(--ink-2); font-style: italic; }
.iv-modal-body { padding: 1.1rem 1.2rem 1.4rem; overflow-y: auto; }
.iv-step-line {
  font-family: var(--book); font-size: 0.95rem; line-height: 1.5; color: var(--ink-2);
  padding-bottom: 0.9rem; margin-bottom: 0.9rem; border-bottom: 1px dotted var(--rule);
}
.iv-slider-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
.iv-result { margin-top: 0.5rem; }
.iv-result-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  padding-bottom: 0.7rem; margin-bottom: 0.7rem; border-bottom: 1px solid var(--rule-soft);
}
.iv-result-total { display: block; font-family: var(--serif); font-size: 2.1rem; font-weight: 700; line-height: 1; }
.iv-result-vs { text-align: right; }
.iv-result-vs strong { font-family: var(--serif); font-size: 1.4rem; font-weight: 700; }
.iv-form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.1rem; }

.iv-coefs { display: flex; flex-direction: column; gap: 5px; }
.iv-coef { display: grid; grid-template-columns: 12rem 1fr 4rem; align-items: center; gap: 0.6rem; }
.iv-coef-label { font-family: var(--book); font-size: 0.9rem; color: var(--ink-2); }
.iv-coef-track {
  position: relative; height: 12px; border-radius: 2px;
  background: rgba(120, 92, 44, 0.1); border-left: 1px solid var(--rule);
}
.iv-coef-track::before {
  content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px;
  width: 1px; background: var(--rule);
}
.iv-coef-fill { position: absolute; top: 1px; bottom: 1px; border-radius: 1px; }
.iv-coef-fill.is-pos { background: linear-gradient(90deg, var(--gilt), var(--gilt-lit)); }
.iv-coef-fill.is-neg { background: linear-gradient(270deg, var(--tarnish), #64789c); }
.iv-coef-value { text-align: right; }

.iv-plot { width: 100%; height: auto; margin: 0.5rem 0; }
.iv-plot-axis { stroke: var(--rule); stroke-width: 1; }
.iv-plot-band { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 4 5; opacity: 0.7; }
.iv-plot-dot { fill: rgba(120, 92, 44, 0.5); }
.iv-plot-dot.is-under { fill: var(--gilt); }
.iv-plot-dot.is-over { fill: var(--tarnish); }
.iv-plot-label { font-family: var(--mono); font-size: 8px; fill: var(--muted-solid); text-anchor: middle; }
.iv-plot-label.is-left { text-anchor: start; }
.iv-coefs + .iv-hint { margin-top: 0.7rem; }

/* ── Scrollbars, so the panels do not look like a browser default ─────────── */
.iv-panel-scroll::-webkit-scrollbar,
.iv-codex-scroll::-webkit-scrollbar,
.iv-ledger-scroll::-webkit-scrollbar,
.iv-modal-body::-webkit-scrollbar,
.iv-legend-body::-webkit-scrollbar,
.iv-contributors-wide::-webkit-scrollbar { width: 9px; height: 9px; }
.iv-panel-scroll::-webkit-scrollbar-track,
.iv-codex-scroll::-webkit-scrollbar-track,
.iv-ledger-scroll::-webkit-scrollbar-track,
.iv-modal-body::-webkit-scrollbar-track,
.iv-legend-body::-webkit-scrollbar-track,
.iv-contributors-wide::-webkit-scrollbar-track { background: transparent; }
.iv-panel-scroll::-webkit-scrollbar-thumb,
.iv-codex-scroll::-webkit-scrollbar-thumb,
.iv-ledger-scroll::-webkit-scrollbar-thumb,
.iv-modal-body::-webkit-scrollbar-thumb,
.iv-legend-body::-webkit-scrollbar-thumb,
.iv-contributors-wide::-webkit-scrollbar-thumb {
  background: rgba(120, 92, 44, 0.3); border-radius: 5px; border: 2px solid transparent;
  background-clip: content-box;
}
.iv-panel-scroll::-webkit-scrollbar-thumb:hover,
.iv-codex-scroll::-webkit-scrollbar-thumb:hover,
.iv-ledger-scroll::-webkit-scrollbar-thumb:hover { background: rgba(120, 92, 44, 0.5); background-clip: content-box; }

/* ── Narrow viewports ──────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .iv-sidebar { width: 300px; }
}
@media (max-width: 980px) {
  /* Below this the three-column split stops working: the page needs room to be
     a page. Both panels float over it and the grip goes away — there is no
     width left worth trading. */
  .iv-sidebar { position: absolute; left: 0; top: 0; bottom: 0; z-index: 55; }
  .iv-sidebar:not(.is-collapsed) { box-shadow: 14px 0 40px rgba(60, 42, 14, 0.35); }
  .iv-dock {
    position: absolute; right: 0; top: 0; bottom: 0; z-index: 60;
    width: min(420px, 92vw) !important;
    box-shadow: -14px 0 40px rgba(60, 42, 14, 0.35);
  }
  .iv-dock-grip { display: none; }
  .iv-running-head { font-size: 0.82rem; }
}
@media (max-width: 700px) {
  .nav-logo-name { display: none; }
  .iv-navstate { max-width: 46vw; }
  /* The sidebar stops sitting beside the page and starts covering it. It opens
     nearly full width, because a 300px panel on a 620px screen leaves neither
     the controls nor the page enough room to be usable. */
  .iv-sidebar { position: absolute; left: 0; top: 0; bottom: 0; z-index: 55; }
  .iv-sidebar:not(.is-collapsed) {
    width: min(360px, 88vw);
    box-shadow: 14px 0 40px rgba(60, 42, 14, 0.45);
  }
  .iv-page-hints { display: none; }
  .iv-running-head { font-size: 0.76rem; }
  .iv-legend { max-width: 60vw; }
  .iv-page-caveat { font-size: 0.78rem; bottom: 12px; max-width: 92%; }
}
