/*
  The Last Commit Archive: full-screen scene, HUD, bottom navigation and the ritual table.
  All selectors are namespaced (`lib-*`). Nothing here styles a bare element outside `.lib-root`.
*/

.lib-root {
  --lib-bg: #0c0814;
  --lib-glass: rgba(20, 14, 34, 0.84);
  --lib-glass-strong: rgba(16, 11, 28, 0.94);
  --lib-line: rgba(214, 190, 255, 0.28);
  --lib-text: #f1ecfb;
  --lib-muted: #b9afd0;
  --lib-gold: #ffe29a;
  --lib-accent: #b79bff;
  --lib-ok: #58d6a0;
  --lib-warn: #f0c15a;
  --lib-bad: #ff7a85;
  --lib-info: #6cb8f0;
  --lib-blocked: #b9a6ff;
  --lib-hud-h: 52px;
  --lib-nav-h: 60px;
  --lib-drawer-w: clamp(340px, 28vw, 500px);
  --lib-serif: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;

  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh; /* mobile browsers: follow the dynamic toolbar */
  overflow: hidden;
  overflow: clip; /* hidden still lets a script or scrollIntoView scroll the scene away; clip cannot be scrolled at all */
  background: var(--lib-bg);
  color: var(--lib-text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
.lib-root *, .lib-root *::before, .lib-root *::after { box-sizing: border-box; }
.lib-root a { color: var(--lib-gold); }
.lib-root :focus-visible { outline: 3px solid var(--lib-gold); outline-offset: 2px; }

.lib-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- scene */
.lib-scene { position: absolute; inset: 0; overflow: hidden; overflow: clip; isolation: isolate; }
.lib-shift { position: absolute; inset: 0; transition: right 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
.lib-viewport {
  position: absolute; inset: 0; overflow: hidden; container-type: size;
  /*
    Portrait only. Where the ghost grid ends: the second row's centre (scene.ts PORTRAIT.host.y = 38.5), half of the Host sprite
    (width 29 of the screen, 400/426 tall, so 13.6; the sprite is also capped at 15% of the height, half of which is 7.05)
    and one nameplate (about 42px). The shared caption starts just under it, and the ritual panel stops above the caption.
    tests/library.test.ts keeps these numbers in step with scene.ts.
  */
  --lib-grid-bottom: calc(38.5cqh + min(13.6cqw, 7.05cqh) + 42px);
  --lib-caption-h: 48px;
}

/* portrait default: the painting covers the viewport and ghosts use viewport percentages */
.lib-art { position: absolute; inset: 0; container-type: size; }
.lib-art-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 36%; user-select: none; pointer-events: none; }
.lib-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 46%, transparent 38%, rgba(8, 5, 16, 0.55) 100%),
    linear-gradient(180deg, rgba(8, 5, 16, 0.62) 0, rgba(8, 5, 16, 0) 14%, rgba(8, 5, 16, 0) 78%, rgba(8, 5, 16, 0.7) 100%);
}

/* landscape: the painting keeps its own 1672x941 aspect ratio and covers the viewport, centred */
@media (min-aspect-ratio: 5/4) {
  .lib-art {
    inset: auto; left: 50%; top: 50%;
    width: max(100cqw, calc(100cqh * 1672 / 941));
    aspect-ratio: 1672 / 941;
    transform: translate(-50%, -50%);
  }
}

/*
  Side drawer open (desktop): the scene is laid out again in the space left of the drawer, instead of being slid sideways.
  Sliding it by half the drawer cut the left-hand ghosts off at 16:10 and narrower, and hid the right-hand ones under the drawer.
  Now the painting keeps its aspect ratio and covers the free area, but it is never wider than the free area divided by 0.76:
  the ghosts stand between 15% and 86% of the painting's width, so all six, their nameplates and the table stay in view.
  Where that cap applies, the painting is a little shorter than the window and the background shows above and below it.
*/
@media (min-width: 1100px) and (min-aspect-ratio: 7/5) {
  .lib-root[data-drawer='open'] .lib-shift { right: var(--lib-drawer-w); }
  .lib-root[data-drawer='open'] .lib-art { width: min(max(100cqw, calc(100cqh * 1672 / 941)), calc(100cqw / 0.76)); }
  .lib-root[data-drawer='open'] .lib-panel-anchor { --art-w: min(max(100cqw, calc(100cqh * 1672 / 941)), calc(100cqw / 0.76)); }
  /* 29% of the painting is the room between the Git and Test ghosts: the 380px floor would cover their nameplates here */
  .lib-root[data-drawer='open'] .lib-panel-anchor > .lib-ritual { width: clamp(300px, calc(var(--art-w) * 0.29), 640px); }
  .lib-root[data-drawer='open'] .lib-top, .lib-root[data-drawer='open'] .lib-nav-wrap { padding-right: var(--lib-drawer-w); }
}
/* below 1300px the free area is narrower than the full navigation: short labels, so every item stays on screen without a hidden sideways scroll */
@media (min-width: 1100px) and (max-width: 1299.98px) and (min-aspect-ratio: 7/5) {
  .lib-root[data-drawer='open'] .lib-nav-long { display: none; }
  .lib-root[data-drawer='open'] .lib-nav-short { display: inline; }
  .lib-root[data-drawer='open'] .lib-nav-btn { padding: 7px 7px; gap: 4px; }
  .lib-root[data-drawer='open'] .lib-nav-wrap { padding-left: 6px; }
  .lib-root[data-drawer='open'] .lib-nav { gap: 2px; }
}

/* ---------------------------------------------------------------- HUD */
/* top overlays share one flow container: a wrapped HUD pushes the ribbon down instead of being covered by it */
.lib-top { position: absolute; z-index: 60; top: 0; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; transition: padding 0.4s; }
.lib-top > * { pointer-events: auto; }
.lib-hud {
  position: relative; width: 100%; min-height: var(--lib-hud-h);
  display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding: 8px 14px;
  background: linear-gradient(180deg, rgba(10, 6, 20, 0.88), rgba(10, 6, 20, 0.55) 70%, rgba(10, 6, 20, 0));
}
.lib-hud-status { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; min-width: 0; flex: 1 1 auto; }
.lib-brand { font: 700 20px/1 var(--lib-serif); color: var(--lib-text) !important; text-decoration: none; letter-spacing: 0.02em; white-space: nowrap; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8); }
.lib-brand small { display: block; margin-top: 3px; font: 11px/1 system-ui, sans-serif; color: var(--lib-muted); letter-spacing: 0.04em; font-weight: 400; }
.lib-hud-repo { min-width: 0; flex: 1 1 120px; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 13px ui-monospace, 'Cascadia Code', Consolas, monospace; color: var(--lib-text); padding: 4px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--lib-line); }
.lib-hud-spacer { flex: 1 1 0; }
.lib-hud-tools { display: flex; gap: 8px; align-items: center; margin-left: auto; }

.lib-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--lib-line); background: rgba(0, 0, 0, 0.45); font-size: 12.5px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; color: var(--lib-text); }
.lib-pill-ok { color: var(--lib-ok); border-color: var(--lib-ok); }
.lib-pill-warn { color: var(--lib-warn); border-color: var(--lib-warn); }
.lib-pill-bad { color: var(--lib-bad); border-color: var(--lib-bad); }
.lib-pill-live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--lib-ok); box-shadow: 0 0 8px var(--lib-ok); }
.lib-conn { font-size: 12px; color: var(--lib-muted); white-space: nowrap; }
.lib-conn::before { content: '●'; margin-right: 5px; color: var(--lib-muted); }
.lib-conn[data-state='live'] { color: var(--lib-ok); }
.lib-conn[data-state='live']::before { color: var(--lib-ok); }
.lib-conn[data-state='simulated'] { color: var(--lib-warn); }
.lib-conn[data-state='simulated']::before { color: var(--lib-warn); }

.lib-btn {
  all: unset; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer;
  padding: 7px 14px; min-height: 36px; border-radius: 10px; font: 600 14px/1.2 system-ui, sans-serif; color: #1a1030;
  background: linear-gradient(180deg, #ffe9a8, #f2c46b); border: 1px solid #ffeab5; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  transition: filter 0.15s, transform 0.15s;
}
.lib-btn:hover:not(:disabled) { filter: brightness(1.08); }
.lib-btn:active:not(:disabled) { transform: translateY(1px); }
.lib-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.lib-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.lib-btn-quiet { color: var(--lib-text); background: rgba(20, 14, 34, 0.7); border: 1px solid var(--lib-line); box-shadow: none; }
.lib-btn-small { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.lib-btn-danger { color: #ffd0d4; background: rgba(60, 14, 24, 0.75); border: 1px solid var(--lib-bad); box-shadow: none; }
.lib-hud .lib-btn { background: rgba(20, 14, 34, 0.72); color: var(--lib-text); border: 1px solid var(--lib-line); box-shadow: none; }
.lib-hud a.lib-btn { text-decoration: none; color: var(--lib-text); }
.lib-btn-label { white-space: nowrap; }

/* ---------------------------------------------------------------- bottom navigation */
.lib-nav-wrap { position: absolute; z-index: 55; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; padding: 0 12px 10px; pointer-events: none; transition: padding 0.4s; }
.lib-nav {
  pointer-events: auto; display: flex; gap: 4px; max-width: 100%; overflow-x: auto; padding: 5px; border-radius: 16px;
  background: var(--lib-glass); border: 1px solid var(--lib-line); backdrop-filter: blur(6px); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  scrollbar-width: none;
}
.lib-nav::-webkit-scrollbar { display: none; }
.lib-nav-btn {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 11px;
  min-height: 40px; font-size: 13px; font-weight: 600; color: var(--lib-text); white-space: nowrap; border: 1px solid transparent;
}
.lib-nav-btn:hover { background: rgba(183, 155, 255, 0.16); }
.lib-nav-btn:focus-visible { outline: 3px solid var(--lib-gold); outline-offset: -1px; }
.lib-nav-btn[aria-expanded='true'] { background: rgba(255, 226, 154, 0.16); border-color: rgba(255, 226, 154, 0.6); }
.lib-nav-icon { font-size: 15px; line-height: 1; }
.lib-nav-count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: rgba(255, 226, 154, 0.2); color: var(--lib-gold); font-size: 11.5px; text-align: center; }
.lib-nav-btn[data-empty='true'] { color: var(--lib-muted); }
.lib-nav-btn[data-empty='true'] .lib-nav-count { display: none; }

/* ---------------------------------------------------------------- ritual panel */
/* portrait: the panel sits just above the navigation and grows upward, never into the ghost grid */
.lib-panel-anchor { position: absolute; z-index: 30; left: 0; right: 0; bottom: calc(var(--lib-nav-h) + 10px); transition: bottom 0.3s ease; display: flex; justify-content: center; align-items: flex-end; padding: 0 8px; pointer-events: none; }
.lib-panel-anchor > .lib-ritual {
  pointer-events: auto; width: min(100%, 480px);
  /* never taller than 40% of the screen, and never so tall that it reaches the shared caption that sits under the ghost grid */
  max-height: max(180px, min(40cqh, calc(100cqh - var(--lib-nav-h) - 10px - var(--lib-grid-bottom) - var(--lib-caption-h) - 12px)));
}
@media (min-aspect-ratio: 5/4) {
  /*
    Landscape: the panel lives in the band between the front of the table (about 61.5% of the painting's height) and
    the navigation. Its width is a share of the painting, so the ghosts on either side of it can never be overrun.
    Taller content scrolls inside the panel instead of climbing over the table or into the navigation.
  */
  .lib-panel-anchor {
    --art-w: max(100cqw, calc(100cqh * 1672 / 941));
    --art-h: calc(var(--art-w) * 941 / 1672);
    top: calc((100cqh - var(--art-h)) / 2 + var(--art-h) * 0.585);
    bottom: calc(var(--lib-nav-h) + 20px);
    /* anchored to the bottom of the band: text above grows upward, so the buttons in the footer never move under the pointer */
    align-items: flex-end;
  }
  .lib-panel-anchor > .lib-ritual { width: clamp(380px, calc(var(--art-w) * 0.29), 640px); max-height: 100%; }
  /* before a run exists (the entry screen, the idle showcase) there is no navigation, so the panel uses the room kept for it */
  .lib-root[data-phase='ENTRY'] .lib-panel-anchor { bottom: 28px; }
}

/*
  The ritual table is two parts in one card: a body that scrolls when the text is taller than the space on the rug,
  and a footer that never scrolls (Resurrect, Discard, the report, the showcase controls).
*/
.lib-ritual {
  position: relative; display: flex; flex-direction: column; border-radius: 18px; border: 1px solid var(--lib-line);
  background: linear-gradient(180deg, rgba(34, 22, 58, 0.9), rgba(16, 11, 28, 0.93)); backdrop-filter: blur(6px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08); overflow: hidden;
}
.lib-ritual::before { content: ''; position: absolute; z-index: 2; left: 18px; right: 18px; top: 0; height: 2px; pointer-events: none; background: linear-gradient(90deg, transparent, var(--ritual-tone, var(--lib-accent)), transparent); }
.lib-ritual-scroll { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.lib-ritual-body {
  flex: 1 1 auto; min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 18px 10px;
  scrollbar-width: thin; scrollbar-color: rgba(214, 190, 255, 0.45) transparent;
}
.lib-ritual-body:focus-visible { outline-offset: -3px; }
/* a soft fade at the edge that has more to show, so a cut-off text never looks like the end of the text */
.lib-ritual-scroll::before, .lib-ritual-scroll::after { content: ''; position: absolute; left: 0; right: 10px; height: 26px; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 0.2s; }
.lib-ritual-scroll::before { top: 0; background: linear-gradient(180deg, rgba(27, 18, 47, 0.97), rgba(27, 18, 47, 0)); }
.lib-ritual-scroll::after { bottom: 0; background: linear-gradient(0deg, rgba(23, 15, 40, 0.97), rgba(23, 15, 40, 0)); }
.lib-ritual-scroll[data-more-before='true']::before, .lib-ritual-scroll[data-more-after='true']::after { opacity: 1; }
.lib-ritual-foot { flex: 0 0 auto; padding: 8px 18px 14px; }
.lib-ritual-foot > * + * { margin-top: 8px; }
.lib-ritual-scroll[data-more-after='true'] + .lib-ritual-foot, .lib-ritual-scroll[data-more-before='true'] + .lib-ritual-foot { border-top: 1px solid rgba(214, 190, 255, 0.16); }
.lib-ritual-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lib-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 13px; border-radius: 999px; border: 2px solid var(--ritual-tone, var(--lib-accent));
  color: var(--ritual-tone, var(--lib-accent)); background: rgba(0, 0, 0, 0.4); font: 700 15px/1.3 var(--lib-serif); letter-spacing: 0.01em;
}
.lib-ritual-note { margin: 8px 0 0; font-size: 14px; color: var(--lib-text); min-height: 1.4em; overflow-wrap: anywhere; }
.lib-ritual-sub { margin: 6px 0 0; font-size: 13px; color: var(--lib-muted); overflow-wrap: anywhere; }
.lib-ritual-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.lib-moment { margin: 8px 0 0; padding: 5px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; border: 1px solid var(--lib-warn); color: #ffe7a6; background: rgba(240, 193, 90, 0.12); animation: lib-moment-in 0.4s ease-out; overflow-wrap: anywhere; }
.lib-moment[data-kind='plan-ready'] { border-color: var(--lib-accent); color: #e4d8ff; background: rgba(183, 155, 255, 0.14); }
@keyframes lib-moment-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.lib-progress { display: flex; gap: 4px; margin: 10px 0 0; padding: 0; list-style: none; }
.lib-progress li { flex: 1; height: 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); }
.lib-progress li[data-state='done'] { background: var(--lib-ok); }
.lib-progress li[data-state='running'] { background: var(--lib-warn); animation: lib-pulse 1.1s ease-in-out infinite; }
.lib-progress li[data-state='failed'], .lib-progress li[data-state='blocked'] { background: var(--lib-bad); }
.lib-progress li[data-state='skipped'] { background: rgba(255, 255, 255, 0.05); }
@keyframes lib-pulse { 50% { opacity: 0.4; } }

.lib-form label { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--lib-muted); }
.lib-form-row { display: flex; gap: 8px; }
.lib-input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.78); color: var(--lib-text); font: inherit; }
.lib-input::placeholder { color: #8b81a3; }
.lib-error { color: #ffb3b9; margin: 8px 0 0; font-size: 13.5px; overflow-wrap: anywhere; }
.lib-tagline { margin: 2px 0 0; font: italic 15px/1.4 var(--lib-serif); color: var(--lib-gold); text-wrap: balance; }
.lib-title { margin: 10px 0 0; font: 700 22px/1.2 var(--lib-serif); }
.lib-caps { margin: 10px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--lib-muted); display: grid; gap: 2px; }
.lib-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.lib-dot-ok { background: var(--lib-ok); }
.lib-dot-bad { background: var(--lib-bad); }
.lib-warnline { margin: 8px 0 0; padding: 6px 10px; border-radius: 10px; font-size: 13px; border: 1px solid var(--lib-warn); background: rgba(240, 193, 90, 0.1); color: #ffe7a6; overflow-wrap: anywhere; }
.lib-warnline[data-tone='bad'] { border-color: var(--lib-bad); background: rgba(255, 122, 133, 0.1); color: #ffc4c9; }
.lib-warnline[data-tone='info'] { border-color: var(--lib-info); background: rgba(108, 184, 240, 0.1); color: #cfe8fa; }
.lib-facts { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--lib-muted); display: grid; gap: 1px; }
.lib-facts strong { color: var(--lib-text); }
.lib-why { margin: 8px 0 0; font-size: 12.5px; color: var(--lib-muted); }
.lib-clamp { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lib-facts-inline { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 0 14px; font-size: 12.5px; color: var(--lib-muted); }
.lib-facts-inline strong { color: var(--lib-text); }
.lib-ritual .lib-warnline { margin-top: 6px; padding: 4px 9px; font-size: 12.5px; }
.lib-ritual .lib-ritual-actions { margin-top: 8px; }
.lib-ritual-foot .lib-ritual-actions { margin-top: 0; }
.lib-ritual-foot .lib-warnline, .lib-ritual-foot .lib-error { margin-top: 0; }
.lib-inline-code { padding: 0 4px; border-radius: 5px; background: rgba(255, 255, 255, 0.1); font: 0.92em ui-monospace, 'Cascadia Code', Consolas, monospace; color: inherit; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- ritual lights over the glowing circle */
.lib-lights { position: absolute; z-index: 5; left: 50.4%; top: 44.2%; width: 27%; aspect-ratio: 5 / 1; transform: translate(-50%, -50%); pointer-events: none; --light: 95, 224, 208; }
.lib-lights::before, .lib-lights::after { content: ''; position: absolute; border-radius: 50%; }
.lib-lights::before { inset: -45% -10%; background: radial-gradient(ellipse at center, rgba(var(--light), 0.6) 0%, rgba(var(--light), 0.24) 38%, transparent 68%); mix-blend-mode: screen; opacity: 0.6; animation: lib-breathe 4.2s ease-in-out infinite; }
.lib-lights::after { inset: -260% 22% 30%; background: radial-gradient(ellipse at 50% 100%, rgba(var(--light), 0.38), transparent 64%); mix-blend-mode: screen; opacity: 0.4; }
.lib-lights-ring { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; opacity: 0; transform-origin: 50% 50%; }
.lib-lights-ring ellipse { fill: none; stroke: rgba(var(--light), 0.95); stroke-width: 0.55; filter: drop-shadow(0 0 5px rgba(var(--light), 0.95)); }

.lib-scene[data-stage='investigating'] .lib-lights { --light: 108, 184, 240; }
.lib-scene[data-stage='investigating'] .lib-lights::before { animation-duration: 2.2s; }
.lib-scene[data-ritual='contradiction'] .lib-lights { --light: 240, 193, 90; }
.lib-scene[data-ritual='contradiction'] .lib-lights::before { animation: lib-flicker 0.9s steps(2, end) infinite; }
.lib-scene[data-stage='awaiting'] .lib-lights { --light: 183, 155, 255; }
.lib-scene[data-stage='awaiting'] .lib-lights::before { opacity: 0.9; animation-duration: 2.6s; }
.lib-scene[data-stage='awaiting'] .lib-lights-ring { opacity: 0.9; }
.lib-scene[data-stage='repairing'] .lib-lights { --light: 255, 160, 80; }
.lib-scene[data-stage='repairing'] .lib-lights-ring { opacity: 1; }
.lib-scene[data-stage='repairing'] .lib-lights-ring ellipse { stroke-dasharray: 3 2; animation: lib-march 1.6s linear infinite; }
.lib-scene[data-stage='verifying'] .lib-lights { --light: 108, 184, 240; }
.lib-scene[data-stage='verifying'] .lib-lights-ring { opacity: 1; animation: lib-scan 1.4s ease-in-out infinite alternate; }
.lib-scene[data-stage='pass'] .lib-lights { --light: 255, 214, 102; }
.lib-scene[data-stage='pass'] .lib-lights::before { opacity: 1; animation: lib-bloom 2.4s ease-out 1 forwards; }
.lib-scene[data-stage='pass'] .lib-lights-ring { opacity: 1; }
.lib-scene[data-stage='pass-scripted'] .lib-lights { --light: 88, 214, 160; }
.lib-scene[data-stage='pass-scripted'] .lib-lights::before { opacity: 0.4; animation: none; }
.lib-scene[data-stage='pass-scripted'] .lib-lights-ring { opacity: 1; }
.lib-scene[data-stage='pass-scripted'] .lib-lights-ring ellipse { stroke-dasharray: 2.5 2.5; filter: none; }
.lib-scene[data-stage='partial'] .lib-lights { --light: 240, 193, 90; }
.lib-scene[data-stage='partial'] .lib-lights-ring { opacity: 1; }
.lib-scene[data-stage='partial'] .lib-lights-ring ellipse { stroke-dasharray: 50 50; }
.lib-scene[data-stage='fail'] .lib-lights { --light: 255, 90, 105; }
.lib-scene[data-stage='fail'] .lib-lights::before { opacity: 0.35; animation: none; }
.lib-scene[data-stage='fail'] .lib-lights-ring { opacity: 1; animation: lib-crack 0.5s ease-out 1; }
.lib-scene[data-stage='fail'] .lib-lights-ring ellipse { stroke-dasharray: 0.1 2.2; stroke-linecap: round; stroke-width: 1.1; }
.lib-scene[data-stage='blocked'] .lib-lights { --light: 185, 166, 255; }
.lib-scene[data-stage='blocked'] .lib-lights::before { opacity: 0.28; animation: none; }
.lib-scene[data-stage='blocked'] .lib-lights-ring { opacity: 1; }
.lib-scene[data-stage='blocked'] .lib-lights-ring ellipse { stroke-dasharray: 9 2 1 2; stroke-width: 0.85; filter: none; }
.lib-scene[data-stage='satisfied'] .lib-lights { --light: 127, 196, 216; }
.lib-scene[data-stage='satisfied'] .lib-lights::before { opacity: 0.3; animation: none; }
.lib-scene[data-stage='satisfied'] .lib-lights-ring { opacity: 1; }
.lib-scene[data-stage='satisfied'] .lib-lights-ring ellipse { stroke-dasharray: 1.2 1.2; filter: none; }
.lib-scene[data-stage='interrupted'] .lib-lights { --light: 150, 146, 168; }
.lib-scene[data-stage='interrupted'] .lib-lights::before { opacity: 0.2; animation: none; }
.lib-scene[data-stage='interrupted'] .lib-lights-ring { opacity: 0.9; }
.lib-scene[data-stage='interrupted'] .lib-lights-ring ellipse { stroke-dasharray: 0.6 1.6; filter: none; }
.lib-scene[data-stage='failed'] .lib-lights { --light: 255, 90, 105; }
.lib-scene[data-stage='failed'] .lib-lights::before { opacity: 0.3; animation: none; }
.lib-scene[data-moment='contradiction'] .lib-lights-ring { opacity: 1; animation: lib-flash 0.7s ease-out 3; }
.lib-scene[data-moment='contradiction'] .lib-lights-ring ellipse { stroke: rgba(240, 193, 90, 0.98); }
@keyframes lib-flicker { 0% { opacity: 0.35; } 50% { opacity: 0.95; } }
@keyframes lib-march { to { stroke-dashoffset: -5; } }
@keyframes lib-scan { from { transform: scale(0.72, 0.5); opacity: 0.55; } to { transform: scale(1.04, 1.15); opacity: 1; } }
@keyframes lib-bloom { 0% { transform: scale(0.8); opacity: 0.2; } 40% { transform: scale(1.35); opacity: 1; } 100% { transform: scale(1); opacity: 0.85; } }
@keyframes lib-crack { 0% { transform: scale(1.2, 1.6); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes lib-flash { 0% { transform: scale(0.9, 0.9); opacity: 1; } 100% { transform: scale(1.14, 1.5); opacity: 0; } }
/* ---------------------------------------------------------------- outcome treatments: border pattern, tint and wording all differ */
.lib-frame { position: absolute; inset: 0; z-index: 50; pointer-events: none; border: 0 solid transparent; transition: box-shadow 0.5s; }
.lib-scene[data-stage='pass'] .lib-frame { box-shadow: inset 0 0 90px rgba(255, 214, 102, 0.28), inset 0 0 0 4px rgba(88, 214, 160, 0.85); }
.lib-scene[data-stage='pass-scripted'] .lib-frame { box-shadow: inset 0 0 60px rgba(88, 214, 160, 0.12); border: 4px dashed rgba(88, 214, 160, 0.8); }
.lib-scene[data-stage='partial'] .lib-frame { box-shadow: inset 0 0 80px rgba(240, 193, 90, 0.2), inset 0 0 0 4px rgba(240, 193, 90, 0.8); }
.lib-scene[data-stage='fail'] .lib-frame { box-shadow: inset 0 0 120px rgba(255, 60, 80, 0.3), inset 0 0 0 4px rgba(255, 122, 133, 0.85); }
.lib-scene[data-stage='blocked'] .lib-frame { box-shadow: inset 0 0 110px rgba(120, 90, 220, 0.3); border: 4px double rgba(185, 166, 255, 0.85); background: repeating-linear-gradient(45deg, rgba(185, 166, 255, 0.05) 0 12px, transparent 12px 24px); }
.lib-scene[data-stage='satisfied'] .lib-frame { box-shadow: inset 0 0 80px rgba(127, 196, 216, 0.18); border: 4px dotted rgba(127, 196, 216, 0.85); }
.lib-scene[data-stage='interrupted'] .lib-frame { box-shadow: inset 0 0 100px rgba(120, 120, 140, 0.35); border: 4px dotted rgba(170, 166, 188, 0.8); }
.lib-scene[data-stage='failed'] .lib-frame { box-shadow: inset 0 0 110px rgba(255, 60, 80, 0.3); border: 4px solid rgba(255, 122, 133, 0.85); background: repeating-linear-gradient(-45deg, rgba(255, 122, 133, 0.06) 0 10px, transparent 10px 20px); }
.lib-scene[data-stage='interrupted'] .lib-art-img { filter: grayscale(0.85) brightness(0.8); }
.lib-scene[data-stage='blocked'] .lib-art-img { filter: saturate(0.7) hue-rotate(12deg) brightness(0.85); }
.lib-scene[data-stage='fail'] .lib-art-img, .lib-scene[data-stage='failed'] .lib-art-img { filter: saturate(0.75) brightness(0.8); }
.lib-scene[data-stale='true'] .lib-frame { border: 3px dashed var(--lib-warn); }
.lib-art-img { transition: filter 0.8s ease; }

/* ---------------------------------------------------------------- simulated ribbon (showcase) */
.lib-sim-ribbon {
  margin: 0; max-width: calc(100% - 24px);
  padding: 4px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 700; text-align: center; color: #ffe7a6;
  background: rgba(60, 44, 10, 0.9); border: 1px dashed var(--lib-warn); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.lib-stale-note { margin: 0; padding: 4px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: #ffe7a6; background: rgba(60, 44, 10, 0.92); border: 1px dashed var(--lib-warn); max-width: calc(100% - 24px); text-align: center; }
.lib-toast { max-width: calc(100% - 24px); margin: 0; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--lib-bad); background: rgba(46, 14, 22, 0.96); color: #ffd0d4; }

/* showcase deck */
.lib-deck { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; padding-top: 8px; border-top: 1px dashed var(--lib-warn); }
.lib-ritual-foot .lib-deck { margin-top: 8px; }
.lib-ritual-foot > .lib-deck:first-child { margin-top: 0; }
/* the note shares a row with Pause/Resume while a scenario is running, and takes a row of its own otherwise */
.lib-deck-note { flex: 1 1 150px; margin: 0; font-size: 11.5px; line-height: 1.35; color: #ffe7a6; }
.lib-select { padding: 7px 10px; min-height: 34px; border-radius: 9px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.85); color: var(--lib-text); font: inherit; font-size: 13px; }
/* the scenario picker takes whatever width is left on its row, so the speed picker and Play/Replay share that row with it */
.lib-deck .lib-select:not(.lib-select-speed) { flex: 1 1 150px; min-width: 0; }

/* ---------------------------------------------------------------- effects */
.lib-fx { position: absolute; inset: 0; z-index: 25; pointer-events: none; }
.lib-mote {
  position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 25%, rgba(255, 226, 154, 0.95) 45%, rgba(255, 226, 154, 0) 72%); box-shadow: 0 0 14px 4px rgba(255, 226, 154, 0.55);
  animation: lib-mote 1.1s cubic-bezier(0.3, 0.1, 0.3, 1) forwards;
}
@keyframes lib-mote {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(calc(var(--dx) * 1cqw), calc(var(--dy) * 1cqh)) scale(1.1); opacity: 0; }
}
.lib-arc { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.lib-arc path { fill: none; stroke: #ffd77a; stroke-width: 0.35; stroke-linecap: round; stroke-dasharray: 2.4 1.6; filter: drop-shadow(0 0 1.2px #f0c15a); animation: lib-arc 2.2s ease-out forwards; vector-effect: non-scaling-stroke; }
@keyframes lib-arc { 0% { opacity: 0; stroke-dashoffset: 30; } 15% { opacity: 1; } 100% { opacity: 0; stroke-dashoffset: 0; } }

.lib-sparkles { position: absolute; z-index: 24; left: 50%; top: 40%; width: 44%; height: 40%; transform: translate(-50%, -50%); pointer-events: none; }
.lib-sparkles i { position: absolute; width: 8px; height: 8px; background: #ffe29a; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: lib-twinkle 2.4s ease-in-out infinite; opacity: 0; }
.lib-sparkles i:nth-child(1) { left: 6%; top: 40%; animation-delay: 0s; }
.lib-sparkles i:nth-child(2) { left: 22%; top: 10%; animation-delay: 0.3s; }
.lib-sparkles i:nth-child(3) { left: 40%; top: 55%; animation-delay: 0.7s; }
.lib-sparkles i:nth-child(4) { left: 58%; top: 5%; animation-delay: 1.1s; }
.lib-sparkles i:nth-child(5) { left: 76%; top: 45%; animation-delay: 0.5s; }
.lib-sparkles i:nth-child(6) { left: 90%; top: 18%; animation-delay: 1.5s; }
@keyframes lib-twinkle { 0%, 100% { opacity: 0; transform: scale(0.4); } 50% { opacity: 1; transform: scale(1.5); } }

.lib-scene[data-paused='true'] *, .lib-scene[data-paused='true'] *::before, .lib-scene[data-paused='true'] *::after { animation-play-state: paused !important; transition: none !important; }
.lib-scene[data-paused='true'] .lib-mote, .lib-scene[data-paused='true'] .lib-arc { display: none; }
@media (prefers-reduced-motion: reduce) {
  .lib-root *, .lib-root *::before, .lib-root *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .lib-mote, .lib-arc, .lib-sparkles { display: none; }
}

/* ---------------------------------------------------------------- shared caption (phone layout only) */
/*
  Six floating bubbles cannot fit in a 3x2 grid on a phone: they overlap and run off the screen. So the portrait layout hides
  them and shows ONE caption under the grid: who spoke (name), what they said, and a tail toward their column. The speaker's
  nameplate and sprite are highlighted. Desktop and laptop keep their bubbles, and this caption is not shown there.
*/
.lib-speaker {
  --box-w: min(480px, calc(100cqw - 20px));
  --box-left: calc((100cqw - var(--box-w)) / 2);
  position: absolute; z-index: 28; top: calc(var(--lib-grid-bottom) + 6px); left: var(--box-left); width: var(--box-w); margin: 0;
  display: flex; align-items: baseline; gap: 8px; padding: 6px 12px 7px; border-radius: 14px; pointer-events: none;
  border: 1px solid rgba(255, 226, 154, 0.6); background: rgba(24, 16, 40, 0.95); color: #fff6dc; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  font-size: 12.5px; line-height: 1.3; animation: lib-speaker-in 0.25s ease-out;
}
.lib-speaker[hidden] { display: none; }
.lib-speaker[data-persistent='true'] { border-color: rgba(214, 190, 255, 0.75); }
.lib-speaker::before {
  content: ''; position: absolute; top: -6px; width: 10px; height: 10px; background: inherit; transform: translateX(-50%) rotate(45deg);
  left: clamp(18px, calc(var(--tail-x, 50) * 1cqw - var(--box-left)), calc(var(--box-w) - 18px));
  border-left: 1px solid rgba(255, 226, 154, 0.6); border-top: 1px solid rgba(255, 226, 154, 0.6);
}
.lib-speaker-name { flex: none; font: 700 12px/1.3 var(--lib-serif); letter-spacing: 0.02em; color: var(--lib-gold); }
.lib-speaker-name::after { content: ':'; }
.lib-speaker-text { min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.lib-speaker .lib-inline-code { padding: 0 2px; background: rgba(255, 255, 255, 0.12); }
@keyframes lib-speaker-in { from { opacity: 0; } to { opacity: 1; } }
/* landscape keeps the bubbles next to each ghost */
@media (min-aspect-ratio: 5/4) {
  .lib-speaker { display: none; }
}

/* ---------------------------------------------------------------- small screens */
/* short landscape windows (a 1366x768 laptop is about 650 px tall once the browser's own bars are subtracted): tighter panel */
@media (min-aspect-ratio: 5/4) and (max-height: 820px) {
  .lib-ritual-body { padding: 10px 16px 6px; }
  .lib-ritual-foot { padding: 6px 16px 10px; }
  .lib-badge { font-size: 14px; padding: 2px 12px; }
  .lib-ritual-note { margin-top: 5px; font-size: 13.5px; }
  .lib-ritual-sub { margin-top: 4px; font-size: 12.5px; }
  .lib-progress { margin-top: 7px; }
  .lib-title { margin-top: 6px; font-size: 20px; }
  /* the painted sign and the HUD already carry the archive's title here; the heading stays for screen readers. The room it
     takes is what lets the three capability lines (Docker, Kiro authorization, GitHub) show in full on a 1366x768 laptop. */
  [data-testid='screen-entry'] > .lib-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
  .lib-tagline { margin-top: 8px; font-size: 14px; }
  .lib-form label { margin: 6px 0 3px; }
  .lib-caps { margin-top: 5px; font-size: 12px; }
  .lib-btn { min-height: 34px; padding: 5px 13px; }
}
.lib-nav-short, .lib-sim-short { display: none; }
/* below a laptop width the HUD tools shrink to icons (their names stay as accessible labels) so the HUD stays on one row */
@media (max-width: 900px) {
  .lib-btn-label { display: none; }
  .lib-hud .lib-btn { padding: 4px 9px; min-width: 38px; min-height: 34px; }
}
@media (max-width: 640px) {
  .lib-sim-long { display: none; }
  .lib-sim-short { display: inline; }
  .lib-root { --lib-nav-h: 54px; }
  /* row 1: brand and the three tools. row 2: phase, repository, connection. */
  .lib-hud { padding: 5px 10px 2px; gap: 2px 8px; min-height: 0; }
  .lib-brand { font-size: 17px; }
  .lib-brand small { display: none; }
  .lib-btn-label { display: none; }
  .lib-hud .lib-btn { padding: 4px 9px; min-height: 34px; min-width: 38px; }
  .lib-hud-status { order: 3; flex-basis: 100%; gap: 2px 8px; flex-wrap: nowrap; overflow: hidden; }
  .lib-hud-repo { order: 2; flex: 1 1 0; min-width: 0; max-width: none; font-size: 11.5px; padding: 1px 8px; }
  .lib-hud-status .lib-pill { order: 1; font-size: 11.5px; padding: 1px 9px; }
  .lib-conn { order: 3; font-size: 11px; }
  .lib-sim-ribbon, .lib-stale-note { font-size: 11px; padding: 2px 10px; }
  .lib-nav-wrap { padding: 0 6px 8px; }
  .lib-nav { width: 100%; justify-content: space-between; gap: 0; padding: 3px; }
  .lib-nav-btn { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 0; padding: 4px 2px; min-height: 44px; font-size: 10px; position: relative; }
  .lib-nav-long { display: none; }
  .lib-nav-short { display: inline; }
  .lib-nav-count { position: absolute; top: 1px; right: 2px; font-size: 9.5px; min-width: 15px; padding: 0 3px; line-height: 1.35; }
  .lib-ritual { border-radius: 16px; }
  .lib-ritual-body { padding: 10px 12px 6px; }
  .lib-ritual-foot { padding: 6px 12px 10px; }
  .lib-ritual::before { left: 12px; right: 12px; }
  .lib-badge { font-size: 14px; padding: 2px 11px; }
  .lib-ritual-note { font-size: 13px; margin-top: 6px; }
  .lib-ritual-actions { margin-top: 8px; }
  .lib-title { font-size: 19px; }
  .lib-tagline { font-size: 13.5px; }
  .lib-form-row { flex-direction: column; }
  .lib-caps { font-size: 11.5px; margin-top: 6px; }
  .lib-why { font-size: 12px; }
}
/* A Reforge run has seven shortcuts, two of them eight-letter words. On the narrowest phones each button is about 45px wide, so the label steps down one size rather than being cut. The accessible name is unchanged. */
@media (max-width: 400px) {
  .lib-nav-btn { font-size: 9px; padding-left: 1px; padding-right: 1px; }
}
/*
  Evidence drawer. Desktop (wide landscape): non-modal side panel, the scene slides over so nothing hides behind it.
  Everything else: modal bottom sheet with a backdrop. Content styles are scoped to `.lib-drawer`.
*/

.lib-backdrop { position: absolute; inset: 0; z-index: 80; background: rgba(6, 3, 12, 0.6); animation: lib-fade 0.25s ease-out; }
@keyframes lib-fade { from { opacity: 0; } }

.lib-drawer {
  position: absolute; z-index: 90; display: flex; flex-direction: column; min-height: 0; color: var(--lib-text);
  background: linear-gradient(180deg, rgba(30, 20, 50, 0.97), rgba(14, 9, 25, 0.98)); border: 1px solid var(--lib-line);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.65); outline: none;
  /* bottom sheet by default */
  left: 0; right: 0; bottom: 0; height: min(86vh, 86dvh); max-height: calc(100dvh - 12px); border-radius: 20px 20px 0 0; border-bottom: 0;
  animation: lib-sheet-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes lib-sheet-in { from { transform: translateY(40px); opacity: 0; } }
@keyframes lib-side-in { from { transform: translateX(40px); opacity: 0; } }
.lib-drawer-grab { align-self: center; width: 44px; height: 5px; margin: 8px 0 0; border-radius: 3px; background: rgba(214, 190, 255, 0.4); flex: none; }

@media (min-width: 1100px) and (min-aspect-ratio: 7/5) {
  .lib-drawer { left: auto; top: 0; right: 0; bottom: 0; width: var(--lib-drawer-w); height: auto; max-height: none; border-radius: 0; border-top: 0; border-right: 0; animation: lib-side-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
  .lib-drawer-grab { display: none; }
}

.lib-drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px 8px 16px; flex: none; }
.lib-drawer-avatar { width: 54px; height: 46px; flex: none; object-fit: contain; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.6)); }
.lib-drawer-titles { flex: 1; min-width: 0; }
.lib-drawer-title { margin: 0; font: 700 20px/1.2 var(--lib-serif); outline: none; }
.lib-drawer-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--lib-muted); }
.lib-drawer-close { all: unset; box-sizing: border-box; cursor: pointer; width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; font-size: 20px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.6); color: var(--lib-text); }
.lib-drawer-close:hover { background: rgba(183, 155, 255, 0.2); }
.lib-drawer-close:focus-visible { outline: 3px solid var(--lib-gold); outline-offset: 1px; }
.lib-sim-tag { display: inline-block; margin-left: 8px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #ffe7a6; border: 1px dashed var(--lib-warn); vertical-align: middle; }

.lib-tabs-wrap { position: relative; flex: none; border-bottom: 1px solid var(--lib-line); }
.lib-tabs { position: relative; display: flex; gap: 4px; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: thin; }
/* ten tabs never fit one row: a fade and a chevron show which side still has tabs, so none looks like the end of the list */
.lib-tabs-wrap::before, .lib-tabs-wrap::after {
  content: ''; position: absolute; top: 0; bottom: 8px; width: 34px; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 0.2s;
  display: flex; align-items: center; font: 700 22px/1 var(--lib-serif); color: var(--lib-gold);
}
.lib-tabs-wrap::before { content: '\2039'; left: 0; justify-content: flex-start; padding-left: 6px; background: linear-gradient(90deg, rgb(27, 18, 46) 35%, rgba(27, 18, 46, 0)); }
.lib-tabs-wrap::after { content: '\203A'; right: 0; justify-content: flex-end; padding-right: 6px; background: linear-gradient(270deg, rgb(27, 18, 46) 35%, rgba(27, 18, 46, 0)); }
.lib-tabs-wrap[data-more-before='true']::before, .lib-tabs-wrap[data-more-after='true']::after { opacity: 1; }
.lib-tab { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; min-height: 34px; border-radius: 10px; font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--lib-muted); border: 1px solid transparent; }
.lib-tab:hover { color: var(--lib-text); background: rgba(183, 155, 255, 0.12); }
.lib-tab:focus-visible { outline: 3px solid var(--lib-gold); outline-offset: -1px; }
.lib-tab[aria-selected='true'] { color: var(--lib-text); background: rgba(255, 226, 154, 0.14); border-color: rgba(255, 226, 154, 0.55); }
.lib-tab img { width: 22px; height: 19px; object-fit: contain; }
.lib-tab-n { padding: 0 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); font-size: 11px; }

.lib-drawer-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 16px 28px; scroll-behavior: smooth; }
.lib-drawer-body:focus-visible { outline-offset: -3px; }

/* ---- content (scoped, so no bare element selector can collide) */
.lib-drawer h2 { margin: 18px 0 6px; font: 700 16px/1.3 var(--lib-serif); }
.lib-drawer h2:first-child { margin-top: 2px; }
.lib-drawer h3 { margin: 12px 0 4px; font-size: 14px; }
.lib-drawer p { margin: 6px 0; }
.lib-drawer ul, .lib-drawer ol { margin: 6px 0; padding-left: 20px; }
.lib-drawer ul.lib-plain, .lib-drawer ol.lib-plain { list-style: none; padding: 0; }
.lib-drawer table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13px; }
.lib-drawer th, .lib-drawer td { text-align: left; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--lib-line); vertical-align: top; }
.lib-drawer pre { margin: 6px 0; padding: 10px; border-radius: 10px; background: #0a0612; border: 1px solid var(--lib-line); overflow: auto; font-size: 12px; max-height: 420px; }
.lib-drawer details { margin: 6px 0; }
.lib-drawer summary { cursor: pointer; padding: 2px 0; color: var(--lib-gold); }
.lib-drawer summary:focus-visible { outline: 3px solid var(--lib-gold); outline-offset: 2px; border-radius: 4px; }
.lib-drawer .lib-muted { color: var(--lib-muted); }
.lib-drawer .lib-small { font-size: 12.5px; }
.lib-drawer .lib-mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12.5px; overflow-wrap: anywhere; }
.lib-drawer .lib-err { color: #ffb3b9; }
.lib-drawer .lib-diff { white-space: pre; }
.lib-drawer .lib-log { padding: 8px 12px; border-radius: 10px; background: #0a0612; border: 1px solid var(--lib-line); font: 12px/1.5 ui-monospace, Consolas, monospace; max-height: 240px; overflow: auto; overflow-wrap: anywhere; }

.lib-section { margin: 0 0 18px; scroll-margin-top: 8px; }
.lib-section[data-empty='true'] { opacity: 0.92; }
.lib-callout { margin: 8px 0; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.5); font-size: 13.5px; overflow-wrap: anywhere; }
.lib-callout[data-tone='info'] { border-color: var(--lib-info); background: rgba(108, 184, 240, 0.1); }
.lib-callout[data-tone='warn'] { border-color: var(--lib-warn); background: rgba(240, 193, 90, 0.1); }
.lib-callout[data-tone='bad'] { border-color: var(--lib-bad); background: rgba(255, 122, 133, 0.1); }

.lib-status { display: inline-block; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 800; letter-spacing: 0.04em; border: 1px solid transparent; vertical-align: 1px; }
.lib-status[data-status='OBSERVED'] { background: #173a2c; color: #6ee7b0; border-color: #2c6a50; }
.lib-status[data-status='INFERRED'] { background: #172f49; color: #8fcaff; border-color: #2b5b8c; border-style: dashed; }
.lib-status[data-status='UNRESOLVED'] { background: #45391a; color: #ffd77a; border-color: #8a7230; border-style: dotted; }
/* the key to the three statuses is one paragraph, so it costs two lines instead of three rows */
.lib-drawer .lib-legend { margin: 2px 0 8px; font-size: 12px; line-height: 1.75; color: var(--lib-muted); }

/* filter bar: search on its own row, then the status chips with the count on the same row */
.lib-filter { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 4px 0 8px; }
.lib-search { flex: 1 1 100%; min-width: 0; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.8); color: var(--lib-text); font: inherit; font-size: 14px; }
.lib-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-chip { all: unset; box-sizing: border-box; cursor: pointer; padding: 2px 9px; min-height: 26px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.03em; border: 1px solid var(--lib-line); color: var(--lib-muted); }
.lib-chip[aria-pressed='true'] { color: var(--lib-text); background: rgba(255, 226, 154, 0.16); border-color: rgba(255, 226, 154, 0.7); }
.lib-chip:focus-visible { outline: 3px solid var(--lib-gold); outline-offset: 1px; }
.lib-drawer .lib-count { font-size: 12px; color: var(--lib-muted); margin: 2px 0 6px; }
.lib-drawer .lib-filter .lib-count { margin: 0 0 0 auto; }

/* evidence rows, claims, conflicts */
.lib-rows { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.lib-row { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.45); min-width: 0; }
.lib-row-title { font-weight: 600; overflow-wrap: anywhere; }
.lib-row-summary { margin-top: 2px; font-size: 13px; color: var(--lib-muted); overflow-wrap: anywhere; }
.lib-ref { margin-top: 5px; font-size: 12.5px; }
.lib-ref summary { display: inline-block; color: var(--lib-info); }
.lib-ref dl { margin: 4px 0 0; padding: 6px 10px; display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; border-radius: 8px; background: rgba(0, 0, 0, 0.35); }
.lib-ref dt { color: var(--lib-muted); }
.lib-ref dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.lib-reflabel { font: 12px ui-monospace, Consolas, monospace; color: var(--lib-muted); overflow-wrap: anywhere; }
.lib-conflict { border-left: 3px solid var(--lib-warn); }
.lib-conflict[data-kind='HISTORY_REGRESSION'] { border-left-style: dashed; }
.lib-more { margin: 8px 0 0; }

/* stage list (Overview) */
.lib-stages { list-style: none; padding: 0; margin: 6px 0; }
.lib-stage { padding: 3px 0; }
.lib-mark { display: inline-block; width: 24px; }
.lib-stage[data-state='done'] .lib-mark { color: var(--lib-ok); }
.lib-stage[data-state='running'] .lib-mark { color: var(--lib-warn); }
.lib-stage[data-state='failed'] .lib-mark, .lib-stage[data-state='blocked'] .lib-mark { color: var(--lib-bad); }
.lib-stage[data-state='pending'], .lib-stage[data-state='skipped'] { color: var(--lib-muted); }

.lib-verdict-pill { display: inline-block; padding: 1px 12px; border-radius: 999px; border: 2px solid var(--lib-line); font-weight: 800; font-size: 15px; letter-spacing: 0.03em; }
.lib-verdict-pill[data-verdict='PASS'] { color: var(--lib-ok); border-color: var(--lib-ok); }
.lib-verdict-pill[data-verdict='PARTIAL'] { color: var(--lib-warn); border-color: var(--lib-warn); border-style: dashed; }
.lib-verdict-pill[data-verdict='FAIL'] { color: var(--lib-bad); border-color: var(--lib-bad); }
.lib-verdict-pill[data-verdict='BLOCKED'] { color: var(--lib-blocked); border-color: var(--lib-blocked); border-style: double; border-width: 4px; }
/* Not a verdict. A goal that already holds has its own outline (dotted, teal), so it is never read as PASS or BLOCKED. */
.lib-verdict-pill[data-outcome='ALREADY_SATISFIED'] { color: #7fc4d8; border-color: #7fc4d8; border-style: dotted; border-width: 3px; }
.lib-twocol { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.lib-empty { padding: 14px; border: 1px dashed var(--lib-line); border-radius: 12px; color: var(--lib-muted); text-align: center; }

@media (max-width: 640px) {
  .lib-drawer-head { padding: 8px 10px 6px 12px; }
  .lib-drawer-title { font-size: 18px; }
  .lib-drawer-body { padding: 10px 12px 24px; }
}
/*
  Remember, Diagnose and Reforge, shown inside the library drawer. Everything is scoped to `.lib-drawer` and uses the library's own
  tokens (--lib-*), so these panels look like every other drawer panel and nothing can leak onto the scene. Colour is never the only signal.
*/

/* evidence source + ghost, shown as an icon with its visible name */
.lib-drawer .ch-src { display: inline-flex; align-items: center; gap: 4px; margin-right: 4px; font-size: 11.5px; color: var(--lib-muted); vertical-align: middle; white-space: nowrap; }
.lib-drawer .ch-src img { width: 22px; height: 19px; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)); }

.lib-drawer .ch-pill { display: inline-block; margin: 0 2px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--lib-line); font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; color: var(--lib-text); vertical-align: 1px; }
.lib-drawer .ch-pill[data-tone='ok'] { color: var(--lib-ok); border-color: var(--lib-ok); }
.lib-drawer .ch-pill[data-tone='warn'] { color: var(--lib-warn); border-color: var(--lib-warn); border-style: dashed; }
.lib-drawer .ch-pill[data-tone='bad'] { color: var(--lib-bad); border-color: var(--lib-bad); border-style: dotted; }

.lib-drawer .ch-claim-text { margin: 0 0 2px; overflow-wrap: anywhere; }
.lib-drawer .ch-caveat { margin: 2px 0; color: var(--lib-warn); font-size: 12.5px; }
.lib-drawer .ch-reflist { margin: 4px 0 4px 16px; padding: 0; }
.lib-drawer .ch-reflist li { margin: 4px 0; overflow-wrap: anywhere; }
.lib-drawer .ch-reflist li[data-state='FAILED'], .lib-drawer .ch-reflist li[data-state='SKIPPED'] { color: var(--lib-bad); }
.lib-drawer .ch-quote { margin: 4px 0; padding: 4px 10px; border-left: 3px solid var(--lib-line); color: #d9d4e6; font-style: italic; overflow-wrap: anywhere; }
.lib-drawer .ch-unknown { color: var(--lib-warn); letter-spacing: 0.04em; }
.lib-drawer .ch-live { margin: 6px 0; }
.lib-drawer .ch-live li { padding: 2px 0; }
.lib-drawer .ch-source { margin: 4px 0; overflow-wrap: anywhere; }
.lib-drawer .ch-source[data-state='FAILED'], .lib-drawer .ch-source[data-state='SKIPPED'] { color: var(--lib-bad); }
.lib-drawer .ch-proposal { margin: 4px 0; overflow-wrap: anywhere; }

/* proposals */
.lib-drawer .ch-candidates { display: grid; gap: 8px; margin: 6px 0; }
.lib-drawer .ch-candidate { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.45); min-width: 0; }
.lib-drawer .ch-candidate[data-selectable='false'] { border-style: dashed; }
.lib-drawer .ch-candidate[data-selected='true'] { border: 2px solid var(--lib-gold); }
.lib-drawer .ch-candidate-head { display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.lib-drawer .ch-candidate-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lib-drawer .ch-blockers { margin: 6px 0; padding-left: 18px; color: #ffb3b9; font-size: 12.5px; }
.lib-drawer .ch-candidate-actions { margin-top: 8px; }
.lib-drawer .ch-candidate > button { margin-top: 6px; }
.lib-drawer .ch-detail { margin: 8px 0 0; }
.lib-drawer .ch-detail dt { margin-top: 10px; font-weight: 700; color: var(--lib-gold); }
.lib-drawer .ch-detail dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.lib-drawer .ch-detail ul { margin: 2px 0 2px 16px; padding: 0; }

/*
  Verifier checks. The drawer is 340 to 500px wide, so three columns (id, state, detail) left the detail about 16px wide and the
  text ran one syllable per line. Each check is a stacked entry instead: the id and its state on one line, the detail under them.
*/
.lib-drawer .ch-checks { list-style: none; margin: 6px 0; padding: 0; }
.lib-drawer .ch-checks li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: start; padding: 6px 8px; border-bottom: 1px solid var(--lib-line); font-size: 12.5px; }
.lib-drawer .ch-checks li[data-ok='false'] { background: rgba(255, 122, 133, 0.08); }
.lib-drawer .ch-check-id { min-width: 0; overflow-wrap: anywhere; }
.lib-drawer .ch-check-state { font-weight: 700; white-space: nowrap; }
.lib-drawer .ch-check-state.is-ok { color: var(--lib-ok); }
.lib-drawer .ch-check-state.is-bad { color: var(--lib-bad); }
.lib-drawer .ch-check-detail { grid-column: 1 / -1; overflow-wrap: anywhere; min-width: 0; }

/* the measured result */
.lib-drawer .ch-two-panels { align-items: start; }
.lib-drawer .ch-panel { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.45); min-width: 0; }
.lib-drawer .ch-panel h3 { margin: 4px 0; }
.lib-drawer .ch-panel[data-ok='true'] { border-color: var(--lib-ok); }
.lib-drawer .ch-panel[data-ok='false'] { border-color: var(--lib-bad); border-style: dashed; }
.lib-drawer .ch-warnings { color: #ffd77a; }

/* ritual table: the mode choice and the Reforge decision lists */
.lib-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; padding: 0; border: 0; min-width: 0; }
.lib-modes legend { grid-column: 1 / -1; padding: 0; margin-bottom: 4px; font-size: 12.5px; color: var(--lib-muted); }
.lib-mode { position: relative; display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--lib-line); background: rgba(8, 5, 16, 0.45); cursor: pointer; font-size: 12.5px; line-height: 1.35; color: var(--lib-text); min-width: 0; }
/* the real radio covers the whole card, invisible but clickable and focusable, so a click anywhere on the card chooses it */
.lib-mode input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.lib-mode strong { display: block; font-size: 13.5px; }
.lib-mode span { color: var(--lib-muted); overflow-wrap: anywhere; }
/* two shapes of border as well as two colours: Restore is solid, Reforge is double */
.lib-mode[data-mode='reforge'] { border-style: double; border-width: 4px; }
.lib-mode[data-checked='true'] { border-color: var(--lib-gold); background: rgba(255, 226, 154, 0.1); }
.lib-mode:has(input:focus-visible) { outline: 3px solid var(--lib-gold); outline-offset: 2px; }
/* Two wordings of the same rule. A short window shows the one-line blurb, so the entry panel still holds its three capability lines; a tall one shows the full rule. Both stay in the page. */
.lib-mode .lib-mode-long { display: none; }
@media (min-height: 900px) and (min-width: 561px) { .lib-mode .lib-mode-long { display: block; } .lib-mode .lib-mode-short { display: none; } }
/* A short window (a laptop) keeps only the names: the entry panel must still hold its capability lines. The wording stays in the page and in each card's title. */
@media (max-height: 820px) and (min-width: 561px) { .lib-mode .lib-mode-short { display: none; } .lib-mode { padding: 6px 10px; } .lib-modes { margin-bottom: 6px; gap: 6px; } .lib-modes legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }
@media (max-width: 560px) { .lib-modes { grid-template-columns: 1fr; } .lib-mode span { display: none; } .lib-mode[data-checked='true'] .lib-mode-short { display: block; } }
.lib-mode-tag { display: inline-block; margin-left: 8px; padding: 0 9px; border-radius: 999px; border: 3px double #f0a35e; color: #f0a35e; font-size: 11.5px; font-weight: 800; letter-spacing: 0.08em; line-height: 1.5; white-space: nowrap; vertical-align: middle; }
.lib-minilist { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 3px; font-size: 13px; }
.lib-minilist li { overflow-wrap: anywhere; }
.lib-minilist li[data-selectable='false'] { color: var(--lib-muted); }

/* ---- Intent-First: the Revival Contract, the editor and the three axes of the outcome */
.lib-drawer .lib-status[data-status='USER_REQUESTED'] { background: #3a2a4d; color: #e3c6ff; border-color: #7b5aa6; border-style: solid; }
.lib-drawer .ct-items { list-style: none; margin: 2px 0; padding: 0; display: grid; gap: 4px; }
.lib-drawer .ct-items li { overflow-wrap: anywhere; }
.lib-drawer .ct-ref[data-verified='false'] { color: var(--lib-warn); }
.lib-drawer .ct-source { margin: 2px 0 0 8px; }
.lib-drawer .ct-editor { margin-top: 12px; padding: 8px 12px; border-radius: 10px; border: 1px dashed var(--lib-line); }
.lib-drawer .ct-editor > summary { cursor: pointer; font-weight: 700; color: var(--lib-gold); }
.lib-drawer .ct-field { display: grid; gap: 3px; margin: 8px 0; border: 0; padding: 0; font-size: 13px; }
.lib-drawer .ct-field textarea, .lib-drawer .ct-field input[type='text'] { width: 100%; box-sizing: border-box; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.78); color: var(--lib-text); font: inherit; }
.lib-drawer .ct-check { display: block; margin: 4px 0; font-size: 13px; overflow-wrap: anywhere; }
.lib-drawer .ct-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.lib-drawer .ct-axes { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 8px 0; }
.lib-drawer .ct-axis { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--lib-line); }
.lib-drawer .ct-axis h3 { margin: 0 0 2px; font-size: 12px; letter-spacing: 0.06em; }
.lib-drawer .ct-axis strong { display: block; font-size: 14px; overflow-wrap: break-word; word-break: normal; hyphens: none; }
.lib-drawer .ct-axis[data-tone='ok'] { border-color: var(--lib-ok); }
.lib-drawer .ct-axis[data-tone='warn'] { border-color: var(--lib-warn); border-style: dashed; }
.lib-drawer .ct-axis[data-tone='bad'] { border-color: var(--lib-bad); border-style: dotted; }
.lib-intent { margin: 8px 0 2px; }
.lib-intent textarea { width: 100%; box-sizing: border-box; min-height: 74px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.78); color: var(--lib-text); font: inherit; resize: vertical; }
.lib-intent .lib-intent-help { display: block; margin-top: 3px; font-size: 12px; color: var(--lib-muted); }
.lib-goal { margin: 6px 0; padding: 6px 10px; border-left: 3px solid #7b5aa6; background: rgba(123, 90, 166, 0.12); overflow-wrap: anywhere; font-size: 13px; }
.lib-drawer .ct-items .ch-pill { white-space: normal; overflow-wrap: anywhere; }
.lib-drawer .ct-source { max-width: 100%; }
.lib-drawer .ct-source pre { max-width: 100%; overflow-x: auto; box-sizing: border-box; }

/* ---- requirement-first verification: the requirement-to-check matrix and its words */
.lib-drawer .ch-check-state.is-unknown { color: var(--lib-warn); }
.lib-drawer .ch-checks li[data-unknown='true'] { background: rgba(240, 193, 90, 0.08); }
.lib-drawer .rq-scroll { overflow-x: auto; margin: 4px 0 10px; border-radius: 10px; border: 1px solid var(--lib-line); }
.lib-drawer .rq-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.lib-drawer .rq-table th { text-align: left; padding: 6px 8px; font-size: 11.5px; letter-spacing: 0.04em; color: var(--lib-gold); border-bottom: 1px solid var(--lib-line); white-space: nowrap; }
.lib-drawer .rq-table td { padding: 7px 8px; vertical-align: top; border-bottom: 1px solid var(--lib-line); overflow-wrap: anywhere; min-width: 110px; }
.lib-drawer .rq-table td:first-child { min-width: 200px; }
.lib-drawer .rq-table tr:last-child td { border-bottom: 0; }
.lib-drawer .rq-table tr[data-outcome='CONTRADICTED'] { background: rgba(255, 122, 133, 0.08); }
.lib-drawer .rq-table tr[data-state='SUPERSEDED'] { opacity: 0.7; }
.lib-drawer .rq-cases > summary { cursor: pointer; font-size: 12px; }
.lib-drawer .rq-conflicts h4, .lib-drawer .ch-panel h4 { margin: 10px 0 2px; font-size: 12.5px; letter-spacing: 0.04em; }

/* The drawer is about 360px wide at laptop sizes, so a four-column table would hide its right-hand columns behind a sideways scroll.
   Each requirement is a card instead: its columns become labelled lines, and nothing is cut off. */
.lib-drawer .rq-scroll { overflow-x: visible; border: 0; }
.lib-drawer .rq-table, .lib-drawer .rq-table tbody, .lib-drawer .rq-table tr, .lib-drawer .rq-table td { display: block; width: auto; }
.lib-drawer .rq-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.lib-drawer .rq-table tr { margin: 0 0 8px; padding: 6px 10px; border: 1px solid var(--lib-line); border-radius: 10px; background: rgba(8, 5, 16, 0.45); }
.lib-drawer .rq-table tr[data-outcome='CONTRADICTED'] { border-color: var(--lib-bad); }
.lib-drawer .rq-table td, .lib-drawer .rq-table td:first-child { min-width: 0; padding: 4px 0; border-bottom: 0; }
.lib-drawer .rq-table td + td { border-top: 1px dashed var(--lib-line); }
.lib-drawer .rq-table td::before { content: attr(data-label); display: block; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--lib-gold); }

/* ---- the proposal checkpoint: open items sorted by consequence (stops approval / keeps PASS out of reach / missing evidence) */
.lib-drawer .ct-checkpoint { margin: 10px 0 14px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.55); scroll-margin-top: 8px; }
.lib-drawer .ct-checkpoint[data-state='blocked'] { border-color: var(--lib-bad); }
.lib-drawer .ct-checkpoint[data-state='open'] { border-color: var(--lib-warn); }
.lib-drawer .ct-checkpoint[data-state='clear'] { border-color: var(--lib-ok); }
.lib-drawer .ct-checkpoint h3 { margin: 0 0 4px; font: 700 15px/1.3 var(--lib-serif); }
.lib-drawer .ct-group { margin-top: 10px; }
.lib-drawer .ct-group h4 { margin: 0 0 4px; font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--lib-gold); }
.lib-drawer .ct-entry { margin: 0 0 6px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--lib-line); border-left-width: 3px; background: rgba(8, 5, 16, 0.45); font-size: 13px; overflow-wrap: anywhere; }
.lib-drawer .ct-entry[data-tone='bad'] { border-left-color: var(--lib-bad); }
.lib-drawer .ct-entry[data-tone='warn'] { border-left-color: var(--lib-warn); }
.lib-drawer .ct-entry[data-tone='info'] { border-left-color: var(--lib-info); }
.lib-drawer .ct-decision-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.lib-drawer .ct-decision .ch-quote { margin: 6px 0; }

/* the requester's decision on one clause: a labelled reason on its own line, then the two choices; wraps instead of clipping */
.lib-drawer .rq-decide { margin-top: 6px; display: grid; gap: 6px; }
.lib-drawer .rq-decide-note { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--lib-text); }
.lib-drawer .rq-decide input, .lib-drawer .rq-decide select { min-width: 0; max-width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--lib-line); background: rgba(8, 5, 16, 0.85); color: var(--lib-text); font: inherit; font-size: 13px; }
.lib-drawer .rq-decide input { width: 100%; border: 1px solid var(--lib-warn); background: rgba(255, 255, 255, 0.06); }
.lib-drawer .rq-decide input:focus { outline: 2px solid var(--lib-warn); outline-offset: 1px; }
.lib-drawer .rq-decide input::placeholder { color: var(--lib-muted); opacity: 1; }
/* A choice that still needs a reason looks unavailable, but stays pressable so the press can say why nothing was recorded. */
.lib-drawer .rq-decide button[aria-disabled='true'] { opacity: 0.55; }
.lib-drawer .rq-decide-done { margin: 0; color: var(--lib-ok, #7fd49b); }
.lib-drawer .rq-decide-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.lib-drawer .rq-decide-or { font-size: 12px; color: var(--lib-muted); }
.lib-drawer .rq-decide-hint { margin: 0; }

/* on the ritual table: a decision the requester still owes, said before the request is repeated */
.lib-checkpoint-note { margin: 0 0 8px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--lib-warn); background: rgba(240, 193, 90, 0.1); font-size: 13px; overflow-wrap: anywhere; }
.lib-checkpoint-note p { margin: 0 0 6px; }
/*
  Page base only. Every component style lives under a namespaced class (`lib-*`, `ghost-*`) in
  library/library.css, library/drawer.css and ghosts/ghosts.css, so no bare element selector can collide.
*/
html, body, #root { height: 100%; margin: 0; }
body { background: #0c0814; overflow: hidden; }
/*
  Cast layer: the six ghosts as interactive characters inside the library scene.
  Every selector starts with `ghost-` or lives under `.lib-`, so nothing here can leak into other UI.
  Positions come from scene.ts through inline custom properties (--lx/--ly/--lw landscape, --px/--py/--pw portrait).
*/

.ghost-root-wrap {
  position: absolute;
  left: var(--px);
  top: var(--py);
  /* sized by width, but never taller than a row of the grid allows, so squarer portrait screens cannot make rows collide */
  width: min(var(--pw), calc(100cqh * 0.15));
  aspect-ratio: var(--ghost-ratio);
  transform: translate(-50%, -50%);
  z-index: calc(20 + var(--z, 0));
}
@media (min-aspect-ratio: 5/4) {
  .ghost-root-wrap { left: var(--lx); top: var(--ly); width: var(--lw); }
}
.ghost-root { position: relative; width: 100%; height: 100%; }
.ghost-sum-short { display: none; }
@media (max-aspect-ratio: 124/100) {
  .ghost-sum-long { display: none; }
  .ghost-sum-short { display: inline; }
  /* the word stays in the DOM (and in the accessible name of the button); only its glyph shows on a phone */
  .ghost-name { gap: 4px; }
  .ghost-chip { font-size: 0; padding: 0 5px; line-height: 1.5; }
  .ghost-chip::before { font-size: 10.5px; margin: 0; }
  .ghost-label { max-width: 128%; padding: 2px 6px 3px; }
}

/* the button is a static box: only the sprite inside it floats, so it is a stable click and tap target */
.ghost-card {
  all: unset;
  box-sizing: border-box;
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border-radius: 18px;
  -webkit-tap-highlight-color: transparent;
}
.ghost-card:focus-visible { outline: 3px solid #ffe29a; outline-offset: 6px; box-shadow: 0 0 0 7px rgba(255, 226, 154, 0.22); }
.ghost-card[aria-expanded='true'] .ghost-label { border-color: #ffe29a; background: rgba(48, 30, 70, 0.94); }

.ghost-enter, .ghost-outer, .ghost-inner { display: block; width: 100%; height: 100%; }
.ghost-outer, .ghost-inner { will-change: transform; }
.ghost-sprite {
  display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.55));
  transition: filter 0.4s ease, transform 0.25s ease;
}
/* soft dark halo so pale ghosts stay readable on the painting */
.ghost-enter::before { content: ''; position: absolute; inset: -14% -18% -8%; z-index: -1; background: radial-gradient(ellipse at 50% 58%, rgba(14, 10, 22, 0.55) 0%, rgba(14, 10, 22, 0.26) 52%, transparent 74%); pointer-events: none; }
.ghost-card:hover .ghost-sprite, .ghost-card:focus-visible .ghost-sprite { transform: scale(1.06); }

/* nameplate: name, status chip (word, not just colour) and the evidence counts */
.ghost-label {
  position: absolute; top: calc(100% - 2px); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 100%; max-width: 190%; padding: 3px 10px 4px;
  border: 1px solid rgba(214, 190, 255, 0.3); border-radius: 12px;
  background: rgba(18, 12, 30, 0.82); backdrop-filter: blur(3px);
  color: #efe9fb; text-align: center; white-space: nowrap; line-height: 1.25;
  transition: border-color 0.25s, background 0.25s;
}
.ghost-card:hover .ghost-label { border-color: rgba(255, 226, 154, 0.7); }
.ghost-name { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: clamp(11px, 0.8vw + 3px, 14px); }
.ghost-name strong { font-weight: 700; letter-spacing: 0.02em; }
.ghost-chip { padding: 0 7px; border-radius: 999px; font-size: clamp(9.5px, 0.55vw + 3px, 11px); border: 1px solid rgba(214, 190, 255, 0.28); background: rgba(0, 0, 0, 0.45); color: #c9bfe0; }
.ghost-summary { font-size: clamp(10px, 0.55vw + 3px, 11.5px); color: #c9bfe0; }
.ghost-bump { display: inline-block; animation: ghost-bump 0.55s ease-out; }
@keyframes ghost-bump { 0% { transform: scale(1.35); color: #ffe29a; } 100% { transform: scale(1); } }

/* every state has its own glyph as well as its own word, so no status is told apart by colour alone */
.ghost-chip::before { content: var(--chip-icon, '●'); margin-right: 4px; font-size: 0.9em; }
.chip-idle { --chip-icon: '●'; }
.chip-working { --chip-icon: '🛠'; color: #8fd0ff; border-color: #6cb8f0; }
.chip-discover { --chip-icon: '🔎'; color: #fff; }
.chip-explain { --chip-icon: '💬'; color: #fff; }
.chip-conflict { --chip-icon: '⚡'; color: #ffd77a; border-color: #f0c15a; }
.chip-success { --chip-icon: '✔'; color: #7ee8b5; border-color: #58d6a0; }
.chip-failure { --chip-icon: '✕'; color: #ff9aa2; border-color: #ff7a85; }
.chip-blocked { --chip-icon: '⛔'; color: #d3c6ff; border-color: #b9a6ff; border-style: dashed; }

/* state glow, driven only by data-state */
.ghost-card[data-state='success'] .ghost-sprite { filter: drop-shadow(0 0 14px rgba(255, 214, 102, 0.85)) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5)); }
.ghost-card[data-state='failure'] .ghost-sprite { filter: saturate(0.7) brightness(0.86) drop-shadow(0 0 8px rgba(255, 90, 105, 0.45)) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5)); }
.ghost-card[data-state='blocked'] .ghost-sprite { filter: grayscale(0.65) brightness(0.8) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5)); }
.ghost-card[data-state='working'] .ghost-sprite { filter: drop-shadow(0 0 12px rgba(90, 169, 230, 0.7)) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5)); }
.ghost-card[data-state='conflict'] .ghost-sprite { filter: drop-shadow(0 0 11px rgba(240, 193, 90, 0.8)) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5)); }
.ghost-card[data-state='discover'] .ghost-sprite, .ghost-card[data-state='explain'] .ghost-sprite { filter: drop-shadow(0 0 9px rgba(255, 255, 255, 0.5)) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5)); }

/* speech bubble, taken from real event text; empty bubbles stay in the DOM (tests read them) but are invisible */
.ghost-caption {
  position: absolute; left: calc(50% + var(--bs, 0%)); bottom: calc(100% - 4px); transform: translateX(-50%);
  z-index: 3; margin: 0; width: max-content; max-width: clamp(120px, 10.5vw, 210px); padding: 4px 9px 5px;
  border-radius: 12px; border: 1px solid rgba(255, 226, 154, 0.55);
  background: rgba(24, 16, 40, 0.94); color: #fff6dc; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  font-size: clamp(10.5px, 0.5vw + 4px, 12.5px); line-height: 1.3; text-align: center;
  transition: opacity 0.35s ease, transform 0.35s ease; pointer-events: none;
}
/* the clamp lives on an inner span so the padding of the bubble can never let a third line peek through */
.ghost-caption-text { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ghost-caption::after { content: ''; position: absolute; left: calc(50% - var(--bs, 0%)); top: 100%; width: 10px; height: 10px; background: inherit; border-right: 1px solid rgba(255, 226, 154, 0.55); border-bottom: 1px solid rgba(255, 226, 154, 0.55); transform: translate(-50%, -5px) rotate(45deg); }
.ghost-caption.is-empty { opacity: 0; transform: translateX(-50%) translateY(6px); }
@media (max-aspect-ratio: 124/100) { .ghost-caption { left: 50%; max-width: 165%; } .ghost-caption::after { left: 50%; } }
.ghost-caption[data-persistent='true'] { border-color: rgba(214, 190, 255, 0.7); }
/*
  Phone layout (everything that is not the landscape arrangement): the six bubbles overlap each other and run off the
  screen, so they are not shown. They stay in the DOM with the same text. One shared caption under the grid (library.css)
  says what the last speaker said, and the speaker is highlighted here.
*/
@media not (min-aspect-ratio: 5/4) {
  .ghost-caption { display: none; }
  .ghost-root-wrap[data-speaking='true'] .ghost-label { border-color: #ffe29a; background: rgba(48, 30, 70, 0.95); box-shadow: 0 0 0 2px rgba(255, 226, 154, 0.35); }
  .ghost-root-wrap[data-speaking='true'] .ghost-card .ghost-sprite { filter: drop-shadow(0 0 12px rgba(255, 226, 154, 0.85)) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.55)); }
}
/* the Host's hat tip reaches the top of its box, so its bubble sits a little higher than the others */
.ghost-root-host .ghost-caption { bottom: calc(100% + 6px); }
.ghost-caption .lib-inline-code { padding: 0 2px; background: rgba(255, 255, 255, 0.12); }

/* ---------------------------------------------------------------- outcome reactions on the whole cast */
.lib-scene[data-stage='interrupted'] .ghost-sprite { filter: grayscale(1) opacity(0.72) !important; }
.lib-scene[data-stale='true'] .ghost-sprite { filter: saturate(0.5) brightness(0.85) !important; }

/* ---------------------------------------------------------------- motion off */
.lib-scene[data-paused='true'] .ghost-sprite, .lib-scene[data-paused='true'] .ghost-bump { transition: none; animation: none; }
@media (prefers-reduced-motion: reduce) {
  .ghost-sprite, .ghost-label, .ghost-caption { transition: none; }
  .ghost-bump { animation: none; }
}
/* The Caffeine shell around the RC3 UI. Colors follow the RC3 library palette (library.css). */
/* The RC3 stylesheet sets body { overflow: hidden } for its full-screen scene, so the Caffeine pages scroll inside their own
   frame: without this, a page taller than the window had no scrollbar. */
.lv-root {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: radial-gradient(ellipse at top, #1d1430 0%, #0c0814 70%);
  color: #f1ecfb;
  font-family: "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}
.lv-header,
.lv-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(214, 190, 255, 0.15);
  background: rgba(16, 11, 28, 0.94);
}
.lv-brand {
  color: #ffe29a;
  font-size: 20px;
  text-decoration: none;
  letter-spacing: 0.04em;
}
.lv-tag {
  color: rgba(214, 190, 255, 0.6);
  font-size: 13px;
}
.lv-who {
  margin-left: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 14px;
}
.lv-body {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 18px;
}
.lv-card {
  background: rgba(20, 14, 34, 0.84);
  border: 1px solid rgba(214, 190, 255, 0.28);
  border-radius: 10px;
  padding: 18px 22px;
  line-height: 1.5;
}
.lv-card h2 {
  margin: 0 0 8px;
  font-size: 19px;
  color: #ffe29a;
  font-weight: normal;
}
.lv-btn {
  font: inherit;
  font-size: 15px;
  background: #4b3a78;
  color: #f1ecfb;
  border: 1px solid #b79bff;
  border-radius: 6px;
  padding: 7px 16px;
  cursor: pointer;
}
.lv-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.lv-btn:focus-visible,
.lv-form select:focus-visible,
.lv-form input:focus-visible,
.lv-form textarea:focus-visible {
  outline: 2px solid #ffe29a;
  outline-offset: 2px;
}
.lv-btn-quiet {
  background: transparent;
  border-color: rgba(214, 190, 255, 0.35);
  font-size: 13px;
  padding: 4px 10px;
}
.lv-form {
  display: grid;
  gap: 8px;
}
.lv-form label {
  font-size: 14px;
  color: rgba(214, 190, 255, 0.85);
}
.lv-form select,
.lv-form input,
.lv-form textarea {
  font: inherit;
  font-size: 15px;
  background: #140e22;
  color: #f1ecfb;
  border: 1px solid rgba(214, 190, 255, 0.3);
  border-radius: 6px;
  padding: 7px 10px;
}
.lv-form textarea {
  min-height: 90px;
}
.lv-row {
  display: flex;
  gap: 8px;
}
.lv-row select {
  flex: 1;
}
.lv-modes {
  border: 1px solid rgba(214, 190, 255, 0.2);
  border-radius: 6px;
  display: grid;
  gap: 8px;
  padding: 10px 12px;
}
.lv-small {
  font-size: 13px;
  color: rgba(214, 190, 255, 0.7);
}
.lv-small a,
.lv-card a {
  color: #ffe29a;
}
.lv-error {
  color: #ff9aa2;
}
.lv-note {
  color: #ffe29a;
}
.lv-status {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 14px;
}
.lv-status li::before {
  content: "●";
  margin-right: 8px;
  color: #7bd88f;
}
.lv-status li[data-ok="false"]::before {
  color: #ff7a85;
}
.lv-jobs {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}
.lv-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
}
.lv-flow li[data-state="later"] {
  color: rgba(214, 190, 255, 0.4);
}
.lv-flow li[data-state="now"] {
  color: #ffe29a;
  font-weight: bold;
}
.lv-flow li[data-state="done"]::before {
  content: "✓ ";
  color: #7bd88f;
}
.lv-flow li[data-end="FAILED"],
.lv-flow li[data-end="BLOCKED"] {
  color: #ff9aa2;
}
.lv-strip-repo {
  font-family: ui-monospace, monospace;
  font-size: 13px;
}
.lv-job {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: #0c0814;
}
.lv-job .lv-strip {
  flex: none;
  color: #f1ecfb;
  font-family: "Palatino Linotype", Palatino, Georgia, serif;
}
/* RC3's run screen fills what is left under the job strip. */
.lv-job > .lib-root {
  flex: 1;
  height: auto;
  min-height: 0;
}

/* Public repository path */
.lv-source {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0 0.4rem;
  border-radius: 0.6rem;
  border: 1px solid currentColor;
  opacity: 0.8;
}
.lv-source[data-source="public"] {
  color: #2f7d4f;
}
.lv-languages ul {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}
.lv-languages li[data-status="COMING_SOON"] {
  opacity: 0.65;
}

/* V1 Revival Archive */
.lv-publine {
  padding: 0.25rem 1rem;
}
.lv-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Guest preview (#/sample): the strip says on every screen that this is a scripted sample. */
.lv-sample-strip {
  border-bottom: 2px solid #ffb347;
  gap: 8px 16px;
  padding: 10px 24px;
}
.lv-sample-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #ffb347;
  color: #1a1024;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.lv-sample-strip > .lv-small {
  flex: 1 1 420px;
  font-size: 13px;
  line-height: 1.4;
}
.lv-sample-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.lv-sample-controls select {
  background: rgba(16, 11, 28, 0.94);
  color: #f1ecfb;
  border: 1px solid rgba(214, 190, 255, 0.3);
  border-radius: 6px;
  padding: 4px 6px;
}
.lv-sample .lv-root {
  height: auto;
  flex: 1;
}
@media (max-width: 700px) {
  .lv-sample-strip {
    padding: 8px 12px;
    gap: 6px 10px;
  }
  .lv-sample-strip > .lv-brand {
    display: none;
  }
  .lv-sample-strip > .lv-small {
    font-size: 11px;
    line-height: 1.3;
  }
  .lv-sample-controls .lv-btn {
    padding: 4px 8px;
    font-size: 12px;
  }
}
