/* CheckIt library: the home page's visual system.
   Loaded after style.css and scoped to .library-page, so the classroom and
   admin pages that share style.css are untouched. The shared result styles in
   style.css are re-skinned through its own custom properties. */

/* ── Tokens ─────────────────────────────────────────── */
.library-page {
  --walnut-950: #170c06;
  --walnut-900: #24140b;
  --walnut-700: #4a2b19;
  --brass: #b98a3c;
  --brass-light: #e3bd72;
  --green: #1f4d32;
  --green-deep: #143823;
  --parchment: #f5ecd6;
  --parchment-shade: #e9d8b2;
  --ink: #2a1c12;
  --ink-soft: #5c4532;
  --phosphor: #f2e9d3;
  --screen: #183b2b;
  --screen-deep: #0d2519;
  --supported: #2d6a3b;
  --contradicted: #9b3226;
  --unclear: #8f640e;
  --focus: var(--green);
  --font-display: 'Libre Caslon Text', 'Iowan Old Style', Georgia, serif;
  --font-text: 'Source Serif 4', 'Iowan Old Style', Georgia, serif;
  --header-h: 88px;

  /* style.css variables, so analysis results read as parchment */
  --bg: #efe2c4;
  --card: #fffaf0;
  --border: #d9c59c;
  --text: var(--ink);
  --muted: #6c543e;
  --primary: var(--green);
  --primary-hover: var(--green-deep);
  --radius: 10px;
  --shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 1px 2px rgba(60,35,15,.08);

  font-family: var(--font-text);
  background: var(--walnut-950);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
}

[data-theme="dark"] .library-page {
  --parchment: #2b1b11;
  --parchment-shade: #22150d;
  --ink: #f3e8d2;
  --ink-soft: #cdb79a;
  --bg: #20140c;
  --card: #33221a;
  --border: #5a3f2a;
  --muted: #c9b294;
  --primary: #e3bd72;
  --primary-hover: #f0cf8c;
  --focus: var(--brass-light);
  --shadow: none;
}

.library-page :focus { outline: none; }
.library-page :focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}
.lib-header, .crt, .placard__actions, .scene-notice { --focus: var(--brass-light); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; left: 16px; top: -60px; z-index: 200;
  background: var(--parchment); color: var(--ink);
  padding: 10px 16px; border-radius: 8px;
  font-weight: 600; text-decoration: none;
  transition: top .15s;
}
.skip-link:focus-visible { top: 12px; }

/* ── Scenery ────────────────────────────────────────── */
.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* Painted stand-in while the 3D library loads, and the simple view's backdrop. */
.scene__backdrop {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 45% at 50% 6%, rgba(255, 216, 150, .42), transparent 70%),
    radial-gradient(ellipse 40% 50% at 12% 78%, rgba(255, 190, 110, .18), transparent 70%),
    radial-gradient(ellipse 40% 50% at 88% 70%, rgba(255, 190, 110, .14), transparent 70%),
    repeating-linear-gradient(90deg,
      #4a1d16 0 9px, #23402c 9px 15px, #5b3a1b 15px 26px, #283453 26px 32px,
      #6a2a1a 32px 41px, #1b3122 41px 49px, #3d2414 49px 54px),
    #2a170c;
  background-size: auto, auto, auto, 100% 100%, auto;
}
.scene__backdrop::after {
  /* shelves: dark rails every 46px over the spines, and a deep vignette */
  content: ''; position: absolute; inset: 0;
  background:
    repeating-linear-gradient(180deg, transparent 0 38px, #1b0e07 38px 46px),
    radial-gradient(ellipse 85% 75% at 50% 45%, rgba(40, 22, 10, .55), rgba(14, 7, 3, .94));
}
.scene__canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; opacity: 0;
  transition: opacity .9s ease;
}
.scene-ready .scene__canvas { opacity: 1; }
.scene__veil {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(15, 8, 3, .55) 0, rgba(15, 8, 3, 0) 150px),
    radial-gradient(ellipse 120% 90% at 50% 50%, transparent 60%, rgba(12, 6, 2, .45));
}
.simple-view .scene__canvas, .no-webgl .scene__canvas { display: none; }

/* ── Header ─────────────────────────────────────────── */
.library-page .lib-header {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 18px clamp(16px, 3vw, 40px);
  background: transparent; border: 0;
  color: var(--phosphor);
}
.brand {
  display: inline-flex; flex-direction: column; align-items: center;
  color: #f7edd8; text-decoration: none; margin-right: auto;
  padding: 2px 4px;
}
.brand__name {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.9rem, 2.6vw, 2.6rem); line-height: 1;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .55), 0 1px 0 rgba(0, 0, 0, .4);
}
.brand__flourish { width: 120px; height: 12px; color: var(--brass-light); margin-top: 6px; opacity: .9; }

.lib-nav { display: flex; gap: 10px; }
.lib-nav__link {
  position: relative;
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 46px; padding: 0 20px;
  border-radius: 999px;
  border: 1.5px solid rgba(227, 189, 114, .7);
  background: rgba(22, 12, 6, .72);
  color: #f6ecd7; text-decoration: none;
  font-family: var(--font-text); font-size: 1.02rem; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  white-space: nowrap;
  transition: background .2s, border-color .2s;
}
.lib-nav__link svg { width: 19px; height: 19px; flex: none; }
.lib-nav__link:hover { border-color: var(--brass-light); background: rgba(40, 23, 12, .85); }
.lib-nav__link[aria-current="page"] {
  background: var(--green); border-color: var(--brass-light);
  box-shadow: inset 0 0 0 1px rgba(255, 230, 170, .25), 0 6px 20px rgba(0, 0, 0, .3);
}
.lib-nav__dot {
  position: absolute; top: 7px; right: 10px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--brass-light); box-shadow: 0 0 0 2px var(--walnut-900);
}

.library-page .header-actions { gap: 8px; margin-left: 4px; }
.library-page .header-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1.5px solid rgba(227, 189, 114, .55);
  background: rgba(22, 12, 6, .72); color: #f1e4c8;
}
.library-page .header-btn--labeled { width: auto; border-radius: 999px; padding: 0 14px; font-family: var(--font-text); font-size: .9rem; }
.library-page .header-btn:hover { background: rgba(44, 26, 14, .9); color: #fff6e2; border-color: var(--brass-light); }
.library-page .header-btn--labeled:hover { color: #fff6e2; }
.library-page .header-btn svg { width: 19px; height: 19px; }
.library-page .header-btn[aria-pressed="true"] { background: var(--green); border-color: var(--brass-light); }
.library-page .lang-select {
  height: 42px; border-radius: 999px; padding: 0 30px 0 14px;
  border: 1.5px solid rgba(227, 189, 114, .55);
  background-color: rgba(22, 12, 6, .72); color: #f1e4c8;
  font-family: var(--font-text); font-size: .9rem;
}
.library-page .lang-select option { color: #1a1a1a; }
.library-page .account-btn--signed-in { background: var(--brass-light); color: var(--walnut-900); border-color: var(--brass-light); }
.library-page .account-btn--signed-in:hover { background: #f0cf8c; color: var(--walnut-900); }

/* ── Shared buttons ─────────────────────────────────── */
.lib-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 28px;
  border-radius: 999px;
  font-family: var(--font-text); font-size: 1.1rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: background .18s, border-color .18s, color .18s, transform .12s;
  line-height: 1.1;
}
.lib-btn svg { width: 20px; height: 20px; flex: none; }
.lib-btn--primary {
  background: linear-gradient(180deg, #275d3d, var(--green) 55%, var(--green-deep));
  color: #f8f0dc;
  border: 1.5px solid var(--brass);
  box-shadow: inset 0 0 0 2px rgba(255, 230, 170, .14), 0 6px 16px rgba(20, 50, 30, .3);
}
.lib-btn--primary:hover:not(:disabled) { background: linear-gradient(180deg, #2d6946, #225638 55%, #183f28); border-color: var(--brass-light); }
.lib-btn--primary:active:not(:disabled) { transform: translateY(1px); }
.lib-btn--ghost {
  background: rgba(255, 251, 240, .7); color: var(--ink);
  border: 1.5px solid rgba(70, 45, 25, .55);
}
.lib-btn--ghost:hover { background: #fffaf0; border-color: var(--ink); }
[data-theme="dark"] .lib-btn--ghost { background: rgba(255, 240, 210, .06); color: var(--ink); border-color: rgba(227, 189, 114, .7); }
[data-theme="dark"] .lib-btn--ghost:hover { background: rgba(255, 240, 210, .12); border-color: var(--brass-light); }
[data-theme="dark"] .placard__actions .lib-btn--ghost { --focus: var(--brass-light); }
[data-theme="dark"] .reading-sheet__close { background: rgba(255, 240, 210, .08); color: var(--ink); border-color: rgba(227, 189, 114, .6); }
.lib-btn--screen {
  min-height: 46px; padding: 0 22px; font-size: 1rem;
  background: rgba(13, 37, 25, .55); color: var(--phosphor);
  border: 1.5px solid rgba(227, 189, 114, .8);
}
.lib-btn--screen:hover { background: rgba(31, 77, 50, .85); }
.library-page .lib-btn:disabled { opacity: .6; cursor: not-allowed; }

.rule-ornament { display: block; width: 220px; max-width: 70%; height: 14px; margin: 10px auto 0; color: var(--brass); }

/* ── Rooms ──────────────────────────────────────────── */
.rooms { position: relative; z-index: 2; }
.rooms:focus { outline: none; }
.room { position: fixed; inset: 0; pointer-events: none; transition: opacity .22s ease; }
.room > * { pointer-events: auto; }
.room--leaving, .room--arriving { opacity: 0; }
[data-travelling] .room { pointer-events: none; }
[data-travelling] .room > * { pointer-events: none; }

/* Paper surface shared by the placard, the desk panel and the reading sheet */
.placard, .parchment, .reading-sheet {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 255, 255, .5), transparent 55%),
    radial-gradient(ellipse at 85% 95%, rgba(190, 150, 90, .2), transparent 60%),
    linear-gradient(180deg, #f9f2e0, var(--parchment) 45%, #efe1c1);
  color: var(--ink);
  border: 1.5px solid #b18a48;
  box-shadow:
    inset 0 0 0 5px rgba(249, 242, 224, .9),
    inset 0 0 0 6.5px rgba(177, 138, 72, .65),
    0 24px 60px rgba(10, 5, 2, .5), 0 3px 10px rgba(10, 5, 2, .3);
}
[data-theme="dark"] .placard, [data-theme="dark"] .parchment, [data-theme="dark"] .reading-sheet {
  background: linear-gradient(180deg, #34211565, transparent), linear-gradient(180deg, #2f1e13, #24170e);
  box-shadow: inset 0 0 0 5px rgba(43, 27, 17, .95), inset 0 0 0 6.5px rgba(185, 138, 60, .55), 0 24px 60px rgba(0, 0, 0, .6);
}

/* A. Entrance */
.placard {
  position: absolute; left: 50%; bottom: max(3.5vh, 20px);
  transform: translateX(-50%);
  width: min(840px, calc(100vw - 32px));
  padding: 26px clamp(24px, 5vw, 56px) 26px;
  border-radius: 20px;
  text-align: center;
}
.placard__title {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1.12; letter-spacing: -0.015em;
  color: var(--ink);
}
.placard__lede {
  margin: 12px auto 0; max-width: 64ch;
  font-size: clamp(1rem, 1.15vw, 1.08rem); line-height: 1.55;
  color: var(--ink-soft);
}
.placard__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 20px; }
.placard__actions .lib-btn { min-width: 250px; }
.placard__actions .lib-btn--ghost { --focus: var(--green); }

/* B. Desk */
.parchment {
  position: absolute;
  top: calc(var(--header-h) + 8px); bottom: 22px;
  right: clamp(16px, 3vw, 48px);
  width: clamp(440px, 45vw, 680px);
  border-radius: 14px;
  display: flex;
}
.parchment__inner {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 34px clamp(22px, 3vw, 44px) 40px;
  scrollbar-width: thin; scrollbar-color: #b18a48 transparent;
  scroll-padding-top: 16px;
}
.parchment__title {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2rem, 2.7vw, 2.6rem); line-height: 1.1;
  text-align: center; letter-spacing: -0.015em;
}
.claim-form { margin-top: 22px; }
.library-page .input-tabs { border-bottom: 1px solid rgba(120, 88, 48, .35); margin-bottom: 14px; gap: 6px; }
.library-page .input-tab {
  font-family: var(--font-text); font-size: 1rem; font-weight: 600;
  color: var(--ink-soft); padding: 10px 14px; min-height: 44px;
  border-bottom-width: 3px;
}
.library-page .input-tab--active { color: var(--green); border-bottom-color: var(--green); }
[data-theme="dark"] .library-page .input-tab--active { color: var(--brass-light); border-bottom-color: var(--brass-light); }
.library-page .claim-textarea, .library-page .url-input {
  background: rgba(255, 252, 244, .92);
  border: 1.5px solid #c8b083;
  border-radius: 12px;
  font-family: var(--font-text); font-size: 1.12rem; line-height: 1.55;
  color: var(--ink); padding: 14px 16px;
  box-shadow: inset 0 2px 4px rgba(90, 60, 25, .08);
}
.library-page .claim-textarea { min-height: 128px; }
.library-page .claim-textarea::placeholder, .library-page .url-input::placeholder { color: #8c7558; }
.library-page .claim-textarea:focus, .library-page .url-input:focus {
  border-color: var(--green); background: #fffdf7;
  box-shadow: 0 0 0 3px rgba(31, 77, 50, .18), inset 0 2px 4px rgba(90, 60, 25, .06);
}
[data-theme="dark"] .library-page .claim-textarea, [data-theme="dark"] .library-page .url-input { background: #1d120b; border-color: #5a3f2a; color: var(--ink); }
.library-page .helper-text, .library-page .char-counter { font-size: .92rem; color: var(--muted); }
.library-page .char-counter--over { color: var(--contradicted); }
.library-page .field-error { font-size: .98rem; color: var(--contradicted); font-weight: 600; }

.options { border: 0; margin: 22px 0 0; padding: 0; min-width: 0; }
.options__legend { font-family: var(--font-display); font-size: 1.18rem; font-weight: 700; color: var(--ink); margin-bottom: 10px; padding: 0; }
.options__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.option {
  position: relative;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; min-height: 64px;
  border: 1.5px solid rgba(120, 88, 48, .3);
  border-radius: 12px;
  background: rgba(255, 252, 244, .55);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.option:hover { border-color: rgba(31, 77, 50, .6); }
.option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.option__box {
  flex: none; width: 24px; height: 24px; margin-top: 1px;
  border-radius: 6px; border: 2px solid #8a6d48; background: #fffaf0;
  display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.option__box::after {
  content: ''; width: 11px; height: 6px; margin-top: -3px;
  border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff;
  transform: rotate(-45deg) scale(0); transition: transform .12s;
}
.option input:checked + .option__box { background: var(--green); border-color: var(--green); }
.option input:checked + .option__box::after { transform: rotate(-45deg) scale(1); }
.option:has(input:checked) { border-color: rgba(31, 77, 50, .75); background: rgba(31, 77, 50, .07); }
.option input:focus-visible + .option__box { outline: 3px solid var(--focus); outline-offset: 3px; }
.option__text { display: flex; flex-direction: column; gap: 2px; }
.option__name { font-weight: 600; font-size: 1.02rem; color: var(--ink); line-height: 1.3; }
.option__hint { font-size: .9rem; color: var(--muted); line-height: 1.35; }
[data-theme="dark"] .option { background: rgba(0, 0, 0, .18); border-color: #5a3f2a; }
[data-theme="dark"] .option__box { background: #1d120b; border-color: #a58a62; }
[data-theme="dark"] .option input:checked + .option__box { background: var(--brass); border-color: var(--brass); }

.library-page .controls { margin-top: 20px; display: block; }
.library-page .btn-primary { font-family: var(--font-text); }
.lib-btn--wide { width: 100%; min-height: 58px; font-family: var(--font-display); font-size: 1.32rem; font-weight: 700; }
.library-page #check-btn { border-radius: 999px; }

.library-page .library { margin-top: 14px; text-align: center; }
.library-page .library__toggle { font-family: var(--font-text); font-size: .98rem; color: var(--green); min-height: 44px; }
[data-theme="dark"] .library-page .library__toggle { color: var(--brass-light); }
.library-page .library__panel { text-align: left; }

.library-page .predict-panel, .library-page .status, .library-page .error-banner, .library-page .shared-banner { border-radius: 12px; }
.library-page .status { font-style: italic; font-size: 1rem; color: var(--ink-soft); background: rgba(255, 252, 244, .7); }
.library-page .spinner { border-color: rgba(185, 138, 60, .35); border-top-color: var(--green); }
.library-page .error-banner { background: #fbeee6; border-color: #e3b6a3; color: #8a2a1f; font-size: 1rem; }
[data-theme="dark"] .library-page .error-banner { background: #3a1c14; border-color: #7a3a2a; color: #f4c1b0; }
.library-page .predict-btn { font-family: var(--font-text); font-size: 1rem; min-height: 44px; background: #fffaf0; }

/* Speech bubble */
.speech {
  position: absolute; left: clamp(24px, 10vw, 200px); top: calc(var(--header-h) + 40px);
  max-width: 240px; margin: 0;
  padding: 16px 22px;
  background: #fbf4e2; color: var(--ink);
  border: 1.5px solid #b18a48; border-radius: 26px;
  font-family: var(--font-display); font-size: 1.22rem; line-height: 1.25; text-align: center;
  box-shadow: 0 10px 26px rgba(10, 5, 2, .35);
  pointer-events: none;
  transition: opacity .25s;
}
.speech::after {
  content: ''; position: absolute; left: 34px; bottom: -11px;
  width: 20px; height: 20px; background: inherit;
  border-right: 1.5px solid #b18a48; border-bottom: 1.5px solid #b18a48;
  transform: rotate(45deg) skew(8deg, 8deg); border-bottom-right-radius: 4px;
}
.speech--anchored { left: var(--bubble-x); top: var(--bubble-y); transform: translate(calc(-100% + 44px), -100%); }
.speech--anchored::after { left: auto; right: 30px; transform: rotate(45deg) skew(8deg, 8deg); }
.simple-view .speech, .no-webgl .speech { display: none; }

/* Reading results inside the parchment */
.reading { display: flex; flex-direction: column; gap: 12px; }
.library-page #results { margin-top: 22px; }
.library-page .section { box-shadow: var(--shadow); }
.library-page .section-title {
  font-family: var(--font-display); font-size: 1.12rem; font-weight: 700;
  text-transform: none; letter-spacing: 0; color: var(--ink);
}
.library-page .claim-text-display, .library-page .verdict-explanation, .library-page .evidence-summary,
.library-page .breakdown-value, .library-page .context-lens__paragraph, .library-page .reflection-list li {
  font-size: 1.02rem; line-height: 1.62;
}
.library-page .evidence-source { color: var(--green); text-decoration: underline; text-underline-offset: 2px; }
[data-theme="dark"] .library-page .evidence-source { color: var(--brass-light); }
.library-page .verdict-badge { font-family: var(--font-text); }
.library-page .btn-share { font-family: var(--font-text); font-size: .95rem; min-height: 40px; background: #fffaf0; border-color: #c8b083; color: var(--ink); }
[data-theme="dark"] .library-page .btn-share { background: #2b1b11; color: var(--ink); }
.library-page .reading { user-select: text; }

/* C. Computer */
.crt {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(var(--header-h) + 8px); bottom: 22px;
  width: min(820px, calc(100vw - 32px));
  padding: 22px;
  border-radius: 38px;
  background: linear-gradient(160deg, #e9dfc6, #d6c9a8 60%, #c4b691);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6), inset 0 -6px 14px rgba(110, 90, 50, .35), 0 30px 70px rgba(10, 5, 2, .55);
  display: flex;
}
.crt__glass {
  position: relative; flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  border-radius: 26px / 30px;
  padding: clamp(18px, 3vh, 30px) clamp(18px, 3vw, 34px) 18px;
  color: var(--phosphor);
  background:
    repeating-linear-gradient(180deg, rgba(0, 0, 0, .07) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse 80% 70% at 45% 35%, #2b5a42, var(--screen) 55%, var(--screen-deep));
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .35), inset 0 0 40px rgba(0, 0, 0, .55), inset 0 0 8px rgba(160, 255, 200, .08);
  overflow: hidden;
}
.crt__glass::before {
  /* the glass's glare, kept out of the text's way at the top-left corner */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 45% 30% at 18% 8%, rgba(255, 255, 255, .1), transparent 70%);
}
.crt--on-glass {
  position: fixed; transform: none;
  left: var(--glass-x); top: var(--glass-y);
  width: var(--glass-w); height: var(--glass-h);
  bottom: auto; padding: 0;
  background: none; box-shadow: none; border-radius: 6% / 8%;
}
.crt--on-glass .crt__glass {
  border-radius: 6% / 8%;
  padding: clamp(14px, 2.4vh, 26px) clamp(16px, 2.2vw, 30px) 14px;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, .55);
  background:
    repeating-linear-gradient(180deg, rgba(0, 0, 0, .06) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse 80% 70% at 45% 35%, rgba(43, 90, 66, .97), rgba(24, 59, 43, .98) 55%, rgba(13, 37, 25, .99));
}
.crt__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crt__title {
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(1.5rem, 2.4vw, 2.3rem); line-height: 1.1;
  color: #f7efdc;
}
.crt__title svg { width: 38px; height: 30px; color: var(--phosphor); flex: none; }
.crt__source { font-size: .98rem; color: #d9cfb4; border-bottom: 1px solid rgba(227, 189, 114, .6); padding-bottom: 2px; }
.crt__tools { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.crt--on-glass .crt__title { font-size: clamp(1.4rem, 1.9vw, 2rem); }
.crt--on-glass .crt-search { min-height: 42px; }
.crt--on-glass .chip, .crt--on-glass .crt-sort select { min-height: 36px; padding-left: 13px; padding-right: 13px; font-size: .92rem; }
.crt--on-glass .crt-sort select { padding-right: 30px; }
.crt--on-glass .crt__foot { padding-top: 8px; }
.crt--on-glass .lib-btn--screen { min-height: 40px; }
.crt-search {
  display: flex; align-items: center; gap: 10px;
  min-height: 46px; padding: 0 16px;
  border-radius: 999px; border: 1.5px solid rgba(227, 189, 114, .8);
  background: rgba(8, 25, 16, .5);
}
.crt-search svg { width: 20px; height: 20px; color: #e8dcc0; flex: none; }
.crt-search input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
  color: var(--phosphor); font-family: var(--font-text); font-size: 1.05rem;
}
.crt-search input::placeholder { color: #b9ae94; }
.crt-search:focus-within { outline: 3px solid var(--brass-light); outline-offset: 2px; }
.crt__filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; justify-content: space-between; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 40px; padding: 0 18px;
  border-radius: 999px; border: 1.5px solid rgba(227, 189, 114, .7);
  background: rgba(8, 25, 16, .45); color: var(--phosphor);
  font-family: var(--font-text); font-size: .98rem; cursor: pointer;
}
.chip:hover { background: rgba(31, 77, 50, .7); }
.chip[aria-pressed="true"] { background: var(--phosphor); color: var(--screen-deep); border-color: var(--phosphor); font-weight: 600; }
.crt-sort select {
  min-height: 40px; border-radius: 999px; padding: 0 34px 0 14px;
  border: 1.5px solid rgba(227, 189, 114, .7);
  background: rgba(8, 25, 16, .45) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23efe6cf' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--phosphor); font-family: var(--font-text); font-size: .95rem;
  -webkit-appearance: none; appearance: none;
}
.crt-sort select option { color: #1a1a1a; }
.crt__body {
  flex: 1; min-height: 0; overflow-y: auto; margin-top: 12px; padding: 2px 4px 4px 2px;
  scrollbar-width: thin; scrollbar-color: rgba(227, 189, 114, .7) transparent;
}
.crt__foot { display: flex; justify-content: center; padding-top: 12px; }
.crt-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; font-size: .95rem; color: #d9cfb4; flex-wrap: wrap; }
.crt-bar__clear { display: inline-flex; gap: 14px; }
.crt-link {
  background: none; border: 0; padding: 4px 2px; min-height: 32px;
  color: var(--phosphor); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.crt-link--danger { color: #ffc2b0; font-weight: 600; }
.crt-state { padding: 18px 4px; font-size: 1.05rem; color: var(--phosphor); display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.crt-state__lead { font-family: var(--font-display); font-size: 1.25rem; }
.crt-state--error p { color: #ffd2c4; }
.crt-cursor { display: inline-block; width: .6em; height: 1.05em; background: var(--phosphor); margin-right: 10px; vertical-align: -2px; animation: crt-blink 1.1s steps(1) infinite; }
@keyframes crt-blink { 50% { opacity: 0; } }
.crt-note { margin-top: 14px; font-size: .95rem; color: #d9cfb4; }

.saved-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; }
.saved-item { display: flex; align-items: stretch; gap: 0; border-radius: 10px; background: #f4ecd8; box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.saved-item__open {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 8px 12px 16px; min-height: 60px;
  background: none; border: 0; border-radius: 10px 0 0 10px; text-align: left; cursor: pointer;
  color: var(--ink); font-family: var(--font-text);
  --focus: var(--green);
}
.saved-item__open:hover { background: #fbf6e9; }
.saved-item__icon { width: 24px; height: 24px; flex: none; color: #4a3828; }
.saved-item__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.saved-item__claim { font-size: 1.05rem; line-height: 1.35; color: #24180f; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.saved-item__meta { display: flex; gap: 10px; font-size: .86rem; color: #6c543e; }
.saved-item__kind { font-weight: 600; color: #4a3828; }
.saved-item__delete {
  flex: none; width: 48px; border: 0; border-left: 1px solid rgba(80, 55, 30, .18);
  background: none; border-radius: 0 10px 10px 0; color: #6c543e; font-size: 1.5rem; cursor: pointer;
  --focus: var(--green);
}
.saved-item__delete:hover { background: #f8e2d8; color: var(--contradicted); }

.verdict-tag {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  font-family: var(--font-text); font-size: .9rem; font-weight: 600; white-space: nowrap;
}
.verdict-tag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.verdict-tag--supported { background: #d7ecd6; color: #1f5a2c; }
.verdict-tag--contradicted { background: #f6d6cf; color: #8a2519; }
.verdict-tag--unclear { background: #f4e2b4; color: #6f4c06; }

/* Reading view for a saved claim */
.reading-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: rgba(14, 7, 3, .62);
}
.reading-sheet {
  width: min(880px, 100%); max-height: 100%;
  display: flex; flex-direction: column;
  border-radius: 16px; overflow: hidden;
}
.reading-sheet__head {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 26px clamp(20px, 4vw, 44px) 18px;
  border-bottom: 1px solid rgba(140, 105, 60, .35);
}
.reading-sheet__heading { flex: 1; min-width: 0; }
.reading-sheet__meta { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: .95rem; }
.reading-sheet__title { margin-top: 10px; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.35rem, 2.3vw, 1.9rem); line-height: 1.25; color: var(--ink); }
.reading-sheet__close {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  border: 1.5px solid rgba(70, 45, 25, .45); background: rgba(255, 251, 240, .8);
  color: var(--ink); font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.reading-sheet__close:hover { background: #fffaf0; border-color: var(--ink); }
.reading-sheet__scroll { overflow-y: auto; padding: 22px clamp(20px, 4vw, 44px) 30px; overscroll-behavior: contain; }
.reading-sheet__foot { display: flex; justify-content: center; margin-top: 22px; }
.reading-open { overflow: hidden; }

.scene-notice {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 18px; border-radius: 12px;
  background: var(--walnut-900); color: var(--phosphor);
  border: 1px solid var(--brass); font-size: .98rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}

/* Auth modal, in the house style */
.library-page .auth-modal { font-family: var(--font-text); border-radius: 16px; background: var(--parchment); border-color: #b18a48; }
.library-page .auth-modal__title { font-family: var(--font-display); }

/* ── Simple view: no camera, same rooms laid out as a plain page ── */
.simple-view .parchment, .no-webgl .parchment {
  left: 50%; right: auto; transform: translateX(-50%);
  width: min(760px, calc(100vw - 32px));
}
.simple-view .placard, .no-webgl .placard { bottom: auto; top: 50%; transform: translate(-50%, -40%); }
.simple-view .room { transition: none; }

@media (max-width: 1240px) {
  .lib-nav { gap: 6px; }
  .lib-nav__link { padding: 0 14px; font-size: .95rem; }
  .library-page .header-btn--labeled .header-btn__label { display: none; }
  .library-page .header-btn--labeled { width: 42px; padding: 0; border-radius: 50%; }
}
@media (max-width: 1060px) {
  .lib-nav__link svg { display: none; }
  .library-page .lang-select { padding: 0 24px 0 10px; background-position: right 7px center; }
}

/* ── Compact screens: the page scrolls; scenery stays fixed behind ── */
@media (max-width: 899px), (max-height: 559px) {
  .library-page { --header-h: 68px; }
  .library-page .lib-header {
    padding: 10px 12px; gap: 8px;
    background: linear-gradient(180deg, rgba(18, 10, 5, .96), rgba(18, 10, 5, .9) 78%, rgba(18, 10, 5, 0));
  }
  .brand__name { font-size: 1.7rem; }
  .brand__flourish { width: 84px; margin-top: 3px; }
  .library-page .header-btn { width: 40px; height: 40px; }
  .library-page .header-btn--labeled .header-btn__label { display: none; }
  .library-page .header-btn--labeled { width: 40px; padding: 0; border-radius: 50%; }
  .library-page .lang-select { padding: 0 10px; font-size: .85rem; background-image: none; }
  .lib-nav__link svg { display: block; }

  .lib-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    gap: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(18, 10, 5, .94);
    border-top: 1px solid rgba(227, 189, 114, .45);
  }
  .lib-nav__link {
    flex: 1; flex-direction: column; justify-content: center; gap: 3px;
    min-height: 56px; padding: 4px 4px;
    border: 0; border-radius: 12px; background: none; box-shadow: none;
    font-size: .8rem; line-height: 1.15; text-align: center;
  }
  .lib-nav__link:hover { background: rgba(255, 255, 255, .05); }
  .lib-nav__link[aria-current="page"] { background: var(--green); box-shadow: none; }
  .lib-nav__dot { top: 6px; right: calc(50% - 22px); }

  .room { position: relative; inset: auto; min-height: 100svh; pointer-events: auto; }
  .room[hidden] { display: none; }
  .room--entrance { display: flex; align-items: flex-end; padding: 0 12px calc(84px + env(safe-area-inset-bottom)); }
  .placard { position: relative; left: auto; bottom: auto; transform: none; width: 100%; padding: 24px 20px 22px; border-radius: 16px; }
  .placard__actions .lib-btn { min-width: 0; width: 100%; }

  .room--desk { padding: 34svh 10px calc(84px + env(safe-area-inset-bottom)); }
  .parchment, .simple-view .parchment, .no-webgl .parchment {
    position: relative; inset: auto; transform: none; left: auto; right: auto;
    width: 100%; max-width: 720px; margin: 0 auto; display: block;
  }
  .parchment__inner { overflow: visible; padding: 26px 18px 30px; }
  .speech, .speech--anchored { top: calc(var(--header-h) + 10px); left: auto; right: 12px; max-width: 170px; font-size: 1rem; padding: 10px 14px; transform: none; }
  .speech::after, .speech--anchored::after { left: 22px; right: auto; }

  .room--computer { padding: 30svh 10px calc(84px + env(safe-area-inset-bottom)); }
  .crt, .crt--on-glass {
    position: relative; inset: auto; transform: none; left: auto; top: auto; bottom: auto;
    width: 100%; height: auto; max-width: 760px; margin: 0 auto; padding: 14px; border-radius: 28px;
    background: linear-gradient(160deg, #e9dfc6, #d6c9a8 60%, #c4b691);
  }
  .crt__glass { min-height: 60svh; border-radius: 20px; }
  .crt__body { overflow: visible; }
  .reading-overlay { padding: 0; }
  .reading-sheet { border-radius: 0; height: 100%; max-height: none; }
  .simple-view .placard, .no-webgl .placard { top: auto; transform: none; }
  .simple-view .room--desk, .no-webgl .room--desk, .simple-view .room--computer, .no-webgl .room--computer { padding-top: calc(var(--header-h) + 16px); }
}

@media (max-width: 520px) {
  .saved-item__open { gap: 6px 10px; padding-left: 12px; flex-wrap: wrap; }
  .saved-item__text { flex: 1 1 calc(100% - 40px); }
  .saved-item__open .verdict-tag { margin-left: 34px; }
  .chip { padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .library-page *, .library-page *::before, .library-page *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .room { transition: opacity .12s linear !important; }
  .scene__canvas { transition: none; }
}
