@import url('/static/fonts/fonts.css');

:root {
  --bg-canvas: #080a09;
  --bg-sheet: rgba(14, 17, 15, 0.92);
  --bg-surface: rgba(255, 255, 255, 0.035);
  --bg-elevated: rgba(255, 255, 255, 0.06);
  --bg-glass: rgba(13, 16, 15, 0.72);
  --border-subtle: rgba(255, 255, 255, 0.065);
  --border-default: rgba(255, 255, 255, 0.12);
  --border-gold: rgba(214, 178, 110, 0.36);
  --ink: #f4efe6;
  --ink-2: #c4cbc3;
  --ink-secondary: var(--ink-2);
  --muted: #7f8980;
  --gold: #d6b26e;
  --gold-soft: rgba(214, 178, 110, 0.13);
  --sage: #82ad8e;
  --wine: #a83c4f;
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;
  --rail-w: 460px;
  /* Compat aliases */
  --bg: var(--bg-canvas);
  --bg-rail: var(--bg-sheet);
  --panel: var(--bg-sheet);
  --panel-elev: var(--bg-elevated);
  --line: var(--border-subtle);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Manrope', system-ui, sans-serif;
  --top: 0px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-canvas);
  color: var(--ink);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01' 1, 'kern' 1;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.skip-link { position: fixed; top: -80px; left: 12px; background: var(--gold); color: #111; padding: 10px 14px; z-index: 50; border-radius: var(--r-sm); }
.skip-link:focus { top: 10px; }

h1, h2, h3, p, blockquote { margin: 0; }
h1, h2, h3, blockquote { font-family: var(--serif); font-weight: 500; }
button, textarea, input { font: inherit; color: inherit; }
button {
  min-height: 36px;
  min-width: 36px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  cursor: pointer;
  transition-property: border-color, background, transform, color, box-shadow, opacity;
  transition-duration: 160ms, 160ms, 120ms, 160ms, 180ms, 160ms;
  transition-timing-function: var(--ease-spring), var(--ease-spring), var(--ease-spring), ease, ease, ease;
}
button:hover:not(:disabled) { border-color: var(--border-gold); background: #222925; }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: .42; cursor: not-allowed; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 2px solid rgba(214, 178, 110, 0.55);
  outline-offset: 2px;
}

/* Floating chrome — full-bleed stage */
.app-topbar {
  position: fixed;
  inset: 14px 16px auto 16px;
  z-index: 30;
  height: auto;
  padding: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: transparent;
  border: 0;
  pointer-events: none;
}
.classroom-topbar {
  min-height: 0;
  border-bottom: 0;
}
.brand-lockup {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 12px 8px 8px;
  border-radius: var(--r-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.brand-logo { flex: none; display: grid; place-items: center; }
.brand-symbol {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
}
.brand-title {
  font: 600 15px/1 var(--serif);
  color: var(--gold);
  letter-spacing: 0.08em;
  display: block;
}
.brand-sub {
  font: 700 8.5px/1.2 var(--sans);
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 3px;
  opacity: 0.85;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(36vw, 340px);
}
.btn-danger.is-quiet { opacity: 0.42; }

.classroom-actions {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.classroom-actions button,
.classroom-actions .icon-btn {
  font-size: 12px;
  padding: 6px 12px;
  min-height: 32px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
}
.classroom-actions button:hover:not(:disabled),
.classroom-actions .icon-btn:hover:not(:disabled) {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
}
.classroom-actions button[aria-pressed="true"],
.classroom-actions .icon-btn[aria-pressed="true"],
.classroom-actions .icon-btn[aria-expanded="true"] {
  border-color: var(--border-gold);
  color: var(--gold);
  background: var(--gold-soft);
}
.btn-danger {
  border-color: rgba(168, 60, 79, 0.35);
  color: #f0b8c0;
  background: rgba(40, 19, 24, 0.55);
}
.btn-danger:hover:not(:disabled) { background: var(--wine); color: #fff; border-color: var(--wine); }

.aula-menu { position: relative; }
.aula-panel {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 40;
  min-width: 268px; padding: 8px;
  display: grid; gap: 2px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.03),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  pointer-events: auto;
}
.aula-panel a, .aula-panel > button {
  display: block; width: 100%; text-align: left; text-decoration: none;
  color: var(--ink); font-size: 12.5px; padding: 9px 11px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent;
}
.aula-panel a:hover, .aula-panel > button:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
  color: var(--gold);
}
.aula-panel .aula-status:first-of-type {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}
.aula-status { font-size: 11px; color: var(--muted); padding: 4px 8px; margin: 0; }
.aula-status:empty { display: none; }

.stage-grid {
  height: 100dvh;
  display: grid;
  min-height: 0;
  padding: 0;
}
.regia-grid,
.lim-grid {
  grid-template-columns: minmax(0, 1fr) var(--rail-w);
  gap: 0;
  align-items: stretch;
}

.book-arena {
  position: relative;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-canvas);
}

/* PHYSICAL BOOK — zero-chrome floating HUD over stage */
.physical-book {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  min-height: 0;
}
.book-hud-top {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  height: auto;
  width: auto;
  padding: 0;
  border: 0;
  border-bottom: 0;
  background: transparent;
  pointer-events: none;
}
.book-tools-rail {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: var(--r-lg);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms var(--ease-spring), transform 280ms var(--ease-spring);
}
.physical-book[data-state="OPEN"] .book-tools-rail,
.physical-book[data-state="SEARCHING"] .book-tools-rail {
  opacity: 1;
  pointer-events: auto;
}
.book-tools-rail .book-read-jump {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  column-gap: 4px;
  row-gap: 6px;
  width: 100%;
  box-sizing: border-box;
  padding: 6px;
  border-radius: var(--r-md);
}
.book-tools-rail .book-read-jump-lab {
  grid-column: 1;
  grid-row: 1;
}
.book-tools-rail #book-read-page {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  min-width: 0;
  max-width: 3.6rem;
}
.book-tools-rail .book-read-here {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
  justify-content: center;
  border-radius: var(--r-md);
}
.book-tools-rail .book-highlight,
.book-tools-rail .book-view {
  width: 100%;
  box-sizing: border-box;
  justify-content: flex-start;
  min-height: 34px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  font-size: 11.5px;
}
.book-tools-rail .book-highlight:hover,
.book-tools-rail .book-view:hover:not(:disabled) {
  border-color: var(--border-gold);
  color: var(--gold);
  background: var(--gold-soft);
}
.chapter-float {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: var(--r-md);
  background: var(--bg-glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--border-subtle);
  box-shadow:
    0 14px 36px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.chapter-label {
  font: 700 10px/1 var(--sans);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: .9;
}
.chapter-bar {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
}
.chapter-btn {
  position: relative;
  min-width: 28px;
  min-height: 28px;
  padding: 0 7px;
  font: 600 12px/1 var(--serif);
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--r-pill);
  transition: color 160ms ease, background 160ms var(--ease-spring), box-shadow 180ms ease;
}
.chapter-btn em {
  display: block;
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  white-space: nowrap;
  padding: 7px 11px;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-gold);
  color: var(--ink);
  font: 500 12px/1.2 var(--serif);
  font-style: normal;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5);
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms var(--ease-spring), transform 160ms var(--ease-spring);
}
.chapter-btn:hover em, .chapter-btn:focus-visible em {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.chapter-btn[aria-current="true"] {
  color: #15120c;
  background: var(--gold);
  box-shadow: 0 0 18px rgba(214, 178, 110, 0.28);
}
.book-view[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--gold);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ui-icon {
  width: 14px;
  height: 14px;
  flex: none;
  display: block;
}
.ui-label { line-height: 1.2; }
.presets-toggle .ui-chevron,
.presets-toggle svg:last-of-type { margin-left: auto; }
.book-hud-top,
.book-hud-bottom {
  transition: opacity 320ms cubic-bezier(0.22, 1, 0.36, 1);
}
.book-arena.hud-dimmed .book-hud-top,
.book-arena.hud-dimmed .book-hud-bottom {
  opacity: 0.42;
}

.book-stage {
  --open-amt: 0;
  --read-glow: 0;
  --voice: 0;
  --read-progress: 0;
  position: absolute;
  inset: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 62% 54% at 50% 44%, rgba(240, 210, 140, calc(0.08 + var(--open-amt) * 0.14 + var(--read-glow) * 0.06 + var(--voice) * 0.05)) 0%, transparent 64%),
    radial-gradient(ellipse 100% 88% at 50% 72%, rgba(28, 18, 10, calc(0.22 + var(--open-amt) * 0.28)) 0%, transparent 70%),
    radial-gradient(ellipse 90% 80% at 50% 50%, #1c1812 0%, #0b0d0c 70%, #060807 100%);
  transition: box-shadow 600ms cubic-bezier(0.22, 1, 0.36, 1), background 400ms ease;
}
body[data-stato="SPEAKING"] .book-stage {
  box-shadow:
    inset 0 0 0 1px rgba(212, 175, 106, 0.24),
    inset 0 0 68px rgba(212, 175, 106, 0.08);
}
body[data-reading="on"] .book-stage,
.book-stage.is-reading {
  --read-glow: 1;
  box-shadow:
    inset 0 0 0 1px rgba(143, 179, 153, 0.18),
    inset 0 -40px 80px rgba(212, 175, 106, 0.06),
    inset 0 0 90px rgba(240, 220, 160, 0.05);
}

/* Proscenium atmosphere — beams + footlights (no layout scale on stage) */
.stage-atmosphere {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  opacity: 0.55;
  transition: opacity 700ms cubic-bezier(0.22, 1, 0.36, 1);
}
body[data-reading="on"] .stage-atmosphere,
.physical-book.is-reading .stage-atmosphere,
body[data-stato="SPEAKING"] .stage-atmosphere,
body[data-stato="LISTENING"] .stage-atmosphere {
  opacity: 1;
}
.stage-beam {
  position: absolute;
  top: -8%;
  width: 42%;
  height: 118%;
  transform-origin: 50% 0;
  background: conic-gradient(
    from 168deg at 50% 0%,
    transparent 0deg,
    rgba(255, 226, 170, 0.07) 10deg,
    rgba(255, 236, 200, 0.14) 18deg,
    rgba(255, 226, 170, 0.06) 26deg,
    transparent 36deg
  );
  -webkit-mask-image: linear-gradient(#000 8%, transparent 78%);
  mask-image: linear-gradient(#000 8%, transparent 78%);
  mix-blend-mode: screen;
  opacity: 0.65;
}
.stage-beam--l {
  left: 18%;
  transform: translateX(-50%) rotate(-16deg);
  animation: stageBeamSweepL 11s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}
.stage-beam--r {
  left: 82%;
  transform: translateX(-50%) rotate(16deg);
  background: conic-gradient(
    from 168deg at 50% 0%,
    transparent 0deg,
    rgba(143, 179, 153, 0.05) 10deg,
    rgba(212, 190, 140, 0.12) 18deg,
    rgba(143, 179, 153, 0.05) 26deg,
    transparent 36deg
  );
  animation: stageBeamSweepR 13s cubic-bezier(0.45, 0, 0.55, 1) -2.5s infinite alternate;
}
.stage-foot {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -2%;
  height: 28%;
  background:
    radial-gradient(ellipse 48% 70% at 22% 100%, rgba(255, 214, 150, 0.14), transparent 72%),
    radial-gradient(ellipse 48% 70% at 78% 100%, rgba(255, 214, 150, 0.12), transparent 72%),
    radial-gradient(ellipse 70% 80% at 50% 110%, rgba(212, 175, 106, 0.1), transparent 70%);
  mix-blend-mode: screen;
  opacity: 0.55;
  animation: stageFootBreathe 5.6s ease-in-out infinite;
}
.stage-grain {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.55) 0 0.5px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(255,255,255,0.4) 0 0.5px, transparent 1px),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,0.35) 0 0.5px, transparent 1px);
  background-size: 120px 120px, 160px 160px, 90px 90px;
  animation: stageGrainDrift 18s linear infinite;
  mix-blend-mode: soft-light;
}
@keyframes stageBeamSweepL {
  from { transform: translateX(-50%) rotate(-22deg); }
  to { transform: translateX(-50%) rotate(-8deg); }
}
@keyframes stageBeamSweepR {
  from { transform: translateX(-50%) rotate(22deg); }
  to { transform: translateX(-50%) rotate(8deg); }
}
@keyframes stageFootBreathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.72; }
}
@keyframes stageGrainDrift {
  from { background-position: 0 0, 0 0, 0 0; }
  to { background-position: 120px 40px, -80px 60px, 40px -30px; }
}

.stage-light {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 48% 40% at 50% 18%, rgba(255,220,150,0.12), transparent 70%),
    linear-gradient(180deg, rgba(0,0,0,0.35) 0%, transparent 18%, transparent 78%, rgba(0,0,0,0.45) 100%),
    linear-gradient(90deg, rgba(0,0,0,0.42) 0%, transparent 16%, transparent 84%, rgba(0,0,0,0.42) 100%);
}
body[data-reading="on"] .stage-light::before,
.physical-book.is-reading .stage-light::before {
  opacity: 0.9;
  background:
    radial-gradient(ellipse 44% 36% at 50% 20%, rgba(255, 232, 190, 0.22), transparent 72%),
    radial-gradient(ellipse 30% 24% at 50% 38%, rgba(143, 179, 153, 0.1), transparent 70%);
  animation: stageReadLamp 4.8s ease-in-out infinite;
}
body[data-reading="on"] .stage-light::after,
.physical-book.is-reading .stage-light::after {
  opacity: 1;
  background:
    radial-gradient(ellipse 88% 78% at 50% 50%, transparent 46%, rgba(0, 0, 0, 0.32) 100%),
    radial-gradient(ellipse 56% 48% at 50% 42%, transparent 40%, rgba(20, 28, 22, 0.18) 100%);
}
@keyframes stageReadLamp {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Thin progress rail — narration position across the open spread */
.stage-read-rail {
  pointer-events: none;
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 4.5%;
  height: 2px;
  z-index: 2;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 480ms cubic-bezier(0.22, 1, 0.36, 1), transform 480ms cubic-bezier(0.22, 1, 0.36, 1);
}
.stage-read-rail i {
  display: block;
  height: 100%;
  width: calc(var(--read-progress, 0) * 100%);
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(143, 179, 153, 0.2), rgba(212, 175, 106, 0.85), rgba(255, 232, 190, 0.95));
  box-shadow: 0 0 12px rgba(212, 175, 106, calc(0.15 + var(--voice, 0) * 0.35));
  transition: width 160ms linear;
}
body[data-reading="on"] .stage-read-rail,
.book-stage.is-reading .stage-read-rail {
  opacity: 1;
  transform: translateY(0);
}
.book-stage.is-pick-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 42% 36% at 50% 42%, rgba(255, 236, 200, 0.18), transparent 70%);
  animation: stagePickFlash 780ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes stagePickFlash {
  from { opacity: 0.85; }
  to { opacity: 0; }
}
.physical-book.is-lens .stage-light::after {
  opacity: 1;
  background:
    radial-gradient(ellipse 42% 46% at 50% 44%, transparent 28%, rgba(6, 8, 7, 0.55) 78%),
    radial-gradient(ellipse 70% 60% at 50% 42%, transparent 40%, rgba(12, 10, 8, 0.35) 100%);
}
.physical-book.is-lens .book-stage {
  box-shadow:
    inset 0 0 0 1px rgba(212, 175, 106, 0.16),
    inset 0 0 70px rgba(0, 0, 0, 0.28);
}
.physical-book.is-lens .book-view[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 16px rgba(212, 175, 106, 0.18);
}
.stage-light::before,
.stage-light::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms cubic-bezier(0.22, 1, 0.36, 1), transform 600ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
.stage-light::before {
  background: radial-gradient(ellipse 42% 36% at 50% 22%, rgba(255, 220, 150, 0.2), transparent 72%);
  transform: translate3d(0, 0, 0) scale(1);
}
.stage-light::after {
  background:
    radial-gradient(ellipse 88% 78% at 50% 50%, transparent 48%, rgba(0, 0, 0, 0.28) 100%),
    radial-gradient(ellipse 70% 60% at 50% 42%, transparent 55%, rgba(122, 36, 52, 0) 100%);
}
body[data-stato="LISTENING"] .stage-light::before {
  opacity: 1;
  background: radial-gradient(ellipse 46% 40% at 50% 24%, rgba(130, 173, 142, 0.22), transparent 70%);
  animation: stageListenPulse 2.8s ease-in-out infinite;
}
body[data-stato="LISTENING"] .stage-light::after {
  opacity: 1;
  background: radial-gradient(ellipse 90% 80% at 50% 50%, transparent 42%, rgba(130, 173, 142, 0.16) 100%);
}
body[data-stato="THINKING"] .stage-light::before {
  opacity: 1;
  background: radial-gradient(ellipse 36% 28% at 50% 30%, rgba(255, 212, 132, 0.28), transparent 72%);
  animation: stageThinkSweep 3.4s ease-in-out infinite;
}
body[data-stato="SPEAKING"] .stage-light::before {
  opacity: 0.85;
  background: radial-gradient(ellipse 44% 38% at 50% 20%, rgba(212, 175, 106, 0.22), transparent 70%);
}
body[data-esito="NON_ATTESTATO"] .stage-light::after {
  opacity: 1;
  background: radial-gradient(ellipse 90% 80% at 50% 50%, transparent 40%, rgba(122, 36, 52, 0.26) 100%);
}
@keyframes stageListenPulse {
  0%, 100% { opacity: 0.55; transform: translate3d(0, 0, 0) scale(1); }
  50% { opacity: 1; transform: translate3d(0, 0, 0) scale(1.04); }
}
@keyframes stageThinkSweep {
  0% { transform: translate3d(-28%, 0, 0); opacity: 0.45; }
  50% { opacity: 1; }
  100% { transform: translate3d(28%, 0, 0); opacity: 0.45; }
}
.book-canvas-wrap { position: absolute; inset: 0; z-index: 1; }
.book-canvas-wrap.is-interactive { cursor: pointer; }
.book-canvas-wrap canvas { display: block; width: 100% !important; height: 100% !important; cursor: inherit; }

.book-cover {
  position: absolute; inset: 14% 26%; z-index: 3;
  background: transparent !important; border: 0 !important; cursor: pointer;
  border-radius: 2px;
  transition: box-shadow 320ms ease, outline-color 320ms ease;
  outline: 1px solid transparent;
}
.physical-book[data-state="CLOSED"] .book-cover:hover,
.physical-book[data-state="CLOSED"] .book-cover:focus-visible {
  outline-color: rgba(212, 175, 106, 0.55);
  box-shadow:
    0 0 0 1px rgba(212, 175, 106, 0.28),
    0 0 28px rgba(212, 175, 106, 0.22);
}
.physical-book:not([data-state="CLOSED"]) .book-cover {
  pointer-events: none !important;
  opacity: 0;
}
.book-method {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4;
  max-width: 360px; text-align: center; padding: 24px 28px; border-radius: 12px;
  background: rgba(12, 14, 13, 0.88); backdrop-filter: blur(14px);
  border: 1px solid #6b2d39;
  box-shadow: 0 0 0 1px rgba(212,175,106,0.18), 0 24px 60px rgba(0,0,0,0.7);
  transition: opacity 420ms cubic-bezier(0.22, 1, 0.36, 1), transform 420ms cubic-bezier(0.22, 1, 0.36, 1);
}
.physical-book[data-state="NON_ATTESTATO"] .book-method:not([hidden]) {
  animation: methodIn 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes methodIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.method-kicker { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: #e28896; margin-bottom: 6px; }
.book-method strong { display: block; font: 600 28px/1.1 var(--serif); color: var(--ink); margin-bottom: 8px; }
.book-method p { font-size: 12.5px; color: var(--muted); }

.book-hud-bottom {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 5;
  height: auto;
  width: auto;
  max-width: calc(100% - 24px);
  padding: 0;
  border: 0;
  border-top: 0;
  background: transparent;
  pointer-events: none;
}
.book-dock {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: var(--r-pill);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  transition: border-color 420ms var(--ease-spring), box-shadow 420ms var(--ease-spring);
  box-shadow:
    0 20px 44px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.book-dock.is-reading {
  border-color: rgba(143, 179, 153, 0.4);
  box-shadow:
    0 20px 44px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(214, 178, 110, 0.1),
    0 0 28px rgba(143, 179, 153, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.book-turn {
  min-width: 36px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  color: var(--ink-secondary);
}
.book-prev { font-size: 18px; padding: 0 10px; }
.book-turn:hover:not(:disabled) {
  border-color: var(--border-gold);
  color: var(--gold);
  background: var(--gold-soft);
}
.book-dock-center {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.dock-sep {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 4px;
}
.book-view {
  min-height: 34px;
  border-radius: var(--r-pill);
  font-size: 12px;
  white-space: nowrap;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-secondary);
}
.book-read-jump {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink-secondary);
  font-size: 11.5px;
}
.book-read-jump-lab {
  font: 600 11px/1 var(--sans);
  color: var(--gold);
  letter-spacing: .02em;
}
#book-read-page {
  width: 3.4rem;
  height: 28px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: 700 12.5px/1 var(--sans);
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 0;
}
#book-read-page::-webkit-outer-spin-button,
#book-read-page::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#book-read-page { appearance: textfield; -moz-appearance: textfield; }
.book-read-here {
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: #e8dcc0;
  font: 600 11.5px/1 var(--sans);
  white-space: nowrap;
}
.book-read-here:hover {
  border-color: var(--border-gold);
  color: var(--gold);
  background: var(--gold-soft);
}
.book-read {
  min-height: 34px;
  border-radius: var(--r-pill);
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: #e8dcc0;
}
.book-read[data-state="paused"],
.book-read[data-state="jump"] {
  border-color: var(--border-gold);
  color: var(--gold);
  background: var(--gold-soft);
}
.book-read-stop {
  min-width: 34px;
  min-height: 34px;
  width: 34px;
  padding: 0;
  border-radius: var(--r-pill);
  font-size: 12px;
  color: #f0a0ab;
  border: 1px solid rgba(168, 60, 79, 0.28);
  background: rgba(36, 22, 26, 0.7);
  display: inline-grid;
  place-items: center;
}
.book-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.book-tabs button {
  min-height: 30px; padding: 4px 11px; font-size: 11.5px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(244, 239, 230, 0.72);
}
.book-tabs button[aria-pressed="true"] {
  background: var(--gold-soft);
  color: var(--gold);
  border-color: var(--border-gold);
  font-weight: 700;
}
.book-caption, .book-folio {
  font-size: 12px; color: #cfc7b8; text-align: center;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 0 4px; margin: 0;
}
.book-caption.is-scenic {
  color: #e8dfc8;
  animation: captionScenicIn 480ms cubic-bezier(0.22, 1, 0.36, 1) both;
  text-shadow: 0 0 18px rgba(212, 175, 106, 0.18);
}
@keyframes captionScenicIn {
  from { opacity: 0; letter-spacing: 0.04em; filter: blur(2px); }
  to { opacity: 1; letter-spacing: 0; filter: blur(0); }
}
.book-read[data-state="playing"] {
  border-color: rgba(143, 179, 153, 0.55);
  color: #c5dbc9;
  box-shadow: 0 0 18px rgba(143, 179, 153, 0.18);
  animation: readLiveGlow 2.4s ease-in-out infinite;
}
.book-highlight {
  min-height: 34px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
  border-color: #3a3324;
  color: #e8dcc0;
}
.book-highlight[data-state="on"],
.book-highlight[aria-pressed="true"] {
  border-color: rgba(212, 160, 48, 0.7);
  color: #f0d48a;
  background: #241f14;
  box-shadow: 0 0 18px rgba(212, 160, 48, 0.16);
}
.physical-book.is-highlighting .book-stage {
  box-shadow:
    inset 0 0 0 1px rgba(212, 160, 48, 0.2),
    inset 0 0 70px rgba(212, 160, 48, 0.05);
}
@keyframes readLiveGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(143, 179, 153, 0.12); }
  50% { box-shadow: 0 0 22px rgba(143, 179, 153, 0.28); }
}

/* Floating editorial sheet — top padding clears overlay classroom-actions */
.console-rail,
.lim-rail {
  height: calc(100dvh - 24px);
  min-height: 0;
  margin: 12px 12px 12px 0;
  padding-top: 52px;
  overflow: hidden;
  background: var(--bg-sheet);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  width: auto;
  max-width: none;
}
.rail-block { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); }
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.block-head h2 { font-size: 17px; color: var(--ink); letter-spacing: 0.01em; }
.mode-tag { font-size: 10.5px; color: var(--gold); padding: 2px 8px; border: 1px solid var(--border-gold); border-radius: var(--r-pill); background: var(--gold-soft); }

.preset-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.classroom-presets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.presets-toggle {
  width: 100%;
  text-align: left;
  font-size: 12.5px;
  color: var(--gold);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  flex: none;
}
.presets-panel { margin-bottom: 0; flex: none; max-height: 38vh; overflow: hidden; }
.presets-panel.is-collapsed { display: none; }
body[data-mode="answer"] .idle-only { display: none !important; }
body[data-mode="idle"] #presets-toggle { display: none !important; }
.classroom-response { position: relative; }
body[data-mode="answer"] #presets-panel:not(.is-collapsed):not([hidden]) {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  z-index: 24;
  max-height: min(42vh, 360px);
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--bg-glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--border-gold);
  box-shadow: 0 22px 56px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255,255,255,0.05);
  animation: presetsDrawerIn 280ms var(--ease-spring) both;
}
@keyframes presetsDrawerIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 980px) {
  body[data-mode="answer"] #presets-panel:not(.is-collapsed):not([hidden]) {
    position: fixed;
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(var(--mobile-composer-height, 104px) + 10px);
    top: auto;
    max-height: min(46vh, calc(100dvh - var(--mobile-composer-height, 104px) - 96px));
    z-index: 26;
  }
}
.preset.spur-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  text-align: left;
  padding: 11px 13px;
  min-height: 0;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: none;
  align-items: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms var(--ease-spring);
}
.preset.spur-card:hover:not(:disabled) {
  border-color: var(--border-gold);
  background: #181d1a;
}
.preset.selected {
  border-color: var(--border-gold);
  background: var(--gold-soft);
}
.preset.spur-card:hover .spur-arrow { color: var(--gold); transform: translateX(3px); }
.spur-num {
  font-family: var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  color: var(--gold);
  min-width: 2.2ch;
}
.spur-body { display: grid; gap: 5px; min-width: 0; }
.spur-tag {
  font: 700 10px/1 var(--sans);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.spur-q {
  font: 500 17.5px/1.35 var(--serif);
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.spur-arrow {
  color: var(--muted);
  font-size: 18px;
  transition: color .15s ease, transform .18s var(--ease-spring);
}
.curious-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.curious-pill {
  border-radius: var(--r-pill);
  font: 500 13px/1.3 var(--serif);
  color: var(--ink-secondary);
  background: transparent;
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.curious-pill:hover {
  border-color: var(--border-gold);
  color: var(--gold);
  background: var(--gold-soft);
}
.compact-hero h1, .compact-hero h2 { font-size: 18px; line-height: 1.2; margin: 2px 0 4px; }
.compact-hero p { font-size: 12px; }

.response-block {
  flex: 1; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
  background: transparent;
}
.classroom-response { gap: 10px; padding: 12px 16px 8px; }
.answer-block {
  position: relative;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 0; min-width: 0; max-width: 100%;
  flex: 1 1 auto;
  padding-left: 12px;
  overflow-x: hidden;
  box-sizing: border-box;
}
.answer-block::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 280ms ease, box-shadow 280ms ease, opacity 280ms ease;
}
body[data-stato="LISTENING"] .answer-block::before {
  background: var(--sage);
  box-shadow: 0 0 10px rgba(130, 173, 142, 0.35);
}
body[data-stato="SPEAKING"] .answer-block::before {
  background: var(--gold);
  box-shadow: 0 0 12px rgba(214, 178, 110, 0.45);
  animation: liveRail 1.6s ease-in-out infinite;
}
body[data-esito="NON_ATTESTATO"] .answer-block::before {
  background: var(--wine);
  box-shadow: 0 0 10px rgba(168, 60, 79, 0.35);
  animation: none;
}
@keyframes liveRail {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
body[data-stato="SPEAKING"] #spoken {
  color: #faf6ee;
}
.response-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.audio-action {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 30px; padding: 0 12px; border-radius: var(--r-pill);
  font-size: 12px; color: var(--gold);
  background: transparent; border: 1px solid var(--border-subtle);
}
.audio-action[data-state="playing"] {
  border-color: var(--border-gold);
  background: var(--gold-soft);
}
.audio-live,
.audio-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
  width: 12px;
  flex: none;
}
.audio-eq i {
  display: block;
  width: 2.5px;
  border-radius: 2px;
  background: var(--gold);
  height: 4px;
  animation: eqBar 0.9s ease-in-out infinite;
}
.audio-eq i:nth-child(1) { animation-delay: 0s; }
.audio-eq i:nth-child(2) { animation-delay: 0.18s; height: 7px; }
.audio-eq i:nth-child(3) { animation-delay: 0.32s; }
@keyframes eqBar {
  0%, 100% { transform: scaleY(0.45); opacity: 0.7; }
  50% { transform: scaleY(1); opacity: 1; }
}
.audio-action:not([data-state="playing"]) .audio-eq { display: none; }
.quote-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.quote-lens-hint {
  font: 500 11px/1 var(--sans);
  color: var(--gold);
  opacity: 0;
  transition: opacity 180ms ease;
  margin-left: auto;
  letter-spacing: .02em;
}
#quote.is-zoomable {
  cursor: zoom-in;
  transition: border-color 180ms ease, background 180ms ease;
}
#quote.is-zoomable:hover,
#quote.is-zoomable:focus-visible {
  outline: none;
  background: rgba(212, 175, 106, 0.04);
}
#quote.is-zoomable:hover .quote-lens-hint,
#quote.is-zoomable:focus-visible .quote-lens-hint {
  opacity: 0.9;
}
.quote-steps { display: inline-flex; align-items: center; gap: 4px; }
.quote-nav {
  min-width: 22px; min-height: 22px; padding: 0;
  border: 0; background: transparent; color: var(--muted); font-size: 14px;
}
.quote-nav:hover:not(:disabled) { color: var(--gold); }
.quote-nav:disabled { opacity: .35; }
.quote-pos { font: 600 11px/1 var(--sans); color: var(--muted); min-width: 2.6ch; text-align: center; }
.empty-source {
  padding: 2px 0 2px 14px;
  border-left: 2px solid #9e3346;
  background: transparent;
}
.empty-source p { font-size: 13.5px; color: #e8d7d9; line-height: 1.45; margin: 0; }
.class-prompt {
  display: grid; gap: 6px;
  padding: 12px 0 0;
  margin-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.07);
  border-radius: 0;
  background: transparent;
  border-left: 0; border-right: 0; border-bottom: 0;
}
.class-prompt #followup {
  font: italic 500 17.5px/1.4 var(--serif);
  color: #e8dec8;
  margin: 0;
}
body[data-view="regia"] .class-prompt #followup.is-clickable {
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 8px 4px 22px;
  margin: 0 -4px;
  position: relative;
  transition: color .15s ease, background-color .15s ease;
}
body[data-view="regia"] .class-prompt #followup.is-clickable::before {
  content: '→';
  position: absolute;
  left: 4px;
  top: 0.35em;
  color: var(--muted);
  font-style: normal;
  font-size: 0.85em;
  transition: color .15s ease, transform .18s var(--ease-spring);
}
body[data-view="regia"] .class-prompt #followup.is-clickable:hover,
body[data-view="regia"] .class-prompt #followup.is-clickable:focus-visible {
  color: var(--gold);
  background: rgba(212, 175, 106, 0.08);
  outline: none;
}
body[data-view="regia"] .class-prompt #followup.is-clickable:hover::before,
body[data-view="regia"] .class-prompt #followup.is-clickable:focus-visible::before {
  color: var(--gold);
  transform: translateX(2px);
}
.synthesis-note { display: none !important; }

.opera-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 0;
  flex: none;
}
.opera-hero {
  display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center;
  padding: 10px 4px 12px;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
}
.opera-hero img {
  width: 56px; height: 68px; object-fit: cover; border-radius: var(--r-sm); background: #000;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 10px 24px rgba(0,0,0,.4);
}
.opera-hero h2 { font-size: 17px; line-height: 1.2; color: var(--ink); margin: 2px 0; letter-spacing: 0.01em; }
.opera-hero p { font-size: 12px; color: var(--muted); line-height: 1.4; }
.opera-prompt { font-size: 12px; color: var(--muted); }

.scene-panel {
  display: flex; flex-direction: column; gap: 10px;
  flex: 1 1 auto;
  min-height: 0; min-width: 0; max-width: 100%;
  overflow: hidden;
  overflow-x: hidden;
  box-sizing: border-box;
}
.kicker { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  font: 600 11.5px/1.2 var(--sans);
  color: var(--sage);
  padding: 0; background: transparent; border: 0; border-radius: 0;
}
.badge::before {
  content: '';
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; flex: none;
}
.badge[data-kind="LETTURA_INTERPRETATIVA"],
.badge[data-kind="THINKING"] { color: var(--gold); }
.badge[data-kind="NON_ATTESTATO"] { color: #c45a6c; }
.badge[data-kind="DIALOGO_APERTO"] { color: var(--sage); }
.badge[data-kind="LISTENING"] { color: var(--sage); }
.rail-question {
  font: 500 14px/1.35 var(--sans);
  color: var(--muted);
  margin: 0;
}
.rail-spoken {
  font: 500 20px/1.48 var(--serif);
  color: var(--ink);
  width: 100%;
  max-width: 100%;
  margin: 0;
  flex: 0 1 auto;
  min-height: 0;
  min-width: 0;
  max-height: min(42vh, 320px);
  overflow: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  text-wrap: pretty;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 106, 0.28) transparent;
  mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 18px), transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 18px), transparent 100%);
}
.rail-spoken::-webkit-scrollbar,
.chat-thread::-webkit-scrollbar { width: 6px; }
.rail-spoken::-webkit-scrollbar-thumb,
.chat-thread::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 106, 0.28);
  border-radius: 99px;
}
.chat-thread {
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 106, 0.28) transparent;
  mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 14px), transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 14px), transparent 100%);
}
.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  padding: 10px 14px 8px !important;
  border-bottom: 0 !important;
}
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 40%;
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  overflow-x: hidden;
  flex: none;
  scroll-behavior: smooth;
  box-sizing: border-box;
}
.chat-bubble.author.compact .chat-voice {
  display: block;
  overflow: visible;
  white-space: pre-wrap;
}
.chat-turn { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.chat-turn.is-current { flex: 1 1 auto; min-height: 0; overflow: hidden; }
.chat-bubble.user {
  align-self: flex-end;
  max-width: 92%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 14px 14px 4px 14px;
  padding: 9px 13px;
  font: 500 13.5px/1.4 var(--sans);
  color: var(--ink);
}
.chat-bubble.user:empty { display: none; }
.chat-bubble.author {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}
.chat-bubble.author.compact {
  align-self: flex-start;
  max-width: 95%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px 14px 14px 4px;
  padding: 9px 12px;
  font: 500 14.5px/1.4 var(--serif);
  color: var(--ink-secondary);
}
.chat-cite-links { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.chat-cite-links span,
.chat-cite-links .chat-cite {
  font: 600 10px/1 var(--sans);
  color: var(--gold);
  border: 1px solid #3a3324;
  border-radius: 99px;
  padding: 3px 7px;
  background: transparent;
  cursor: pointer;
}
.chat-cite-links .chat-cite:hover,
.chat-cite-links .chat-cite:focus-visible {
  border-color: var(--gold);
  background: rgba(212, 175, 106, 0.1);
  outline: none;
}
.chat-turn.is-past {
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
  border-radius: 10px;
  padding: 2px;
}
.chat-turn.is-past:hover {
  background: rgba(212, 175, 106, 0.04);
}
.thinking-hint {
  font: italic 500 15px/1.35 var(--serif);
  color: var(--muted);
  margin: 0;
}
.thinking-hint.is-rotating {
  animation: thinkFade 2.2s ease both;
}
@keyframes thinkFade {
  0% { opacity: 0; transform: translateY(4px); }
  18% { opacity: 1; transform: translateY(0); }
  78% { opacity: 1; }
  100% { opacity: 0.72; }
}
.mic-timer {
  flex: none;
  font: 700 11px/1 var(--sans);
  font-variant-numeric: tabular-nums;
  color: #f28b99;
  min-width: 2.6ch;
}
.btn-cancel-mic {
  flex: none;
  width: 30px; height: 30px; min-height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #4a3338;
  background: #24161a;
  color: #f0a0ab;
}
.rail-quote {
  position: relative;
  border: 1px solid var(--border-subtle);
  border-left: 2px solid var(--gold);
  padding: 12px 14px 12px 16px;
  background: rgba(214, 178, 110, 0.045);
  border-radius: 0 10px 10px 0;
  flex: 0 1 auto;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}
.rail-quote::before { display: none; }
.rail-quote cite {
  display: block; font: 600 11.5px var(--sans); color: var(--gold); font-style: normal;
  letter-spacing: .03em; margin: 0;
}
.rail-quote blockquote {
  font-size: 14.5px; line-height: 1.45; color: var(--ink);
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}
#quote.is-zoomable:hover,
#quote.is-zoomable:focus-visible {
  background: rgba(214, 178, 110, 0.07);
  border-color: var(--border-gold);
}
.followup-line { color: #d5cebf; }
.class-prompt {
  flex: none;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.response-meta,
#spoken,
#quote,
#no-quote,
.class-prompt #followup {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.input-dock, .composer-dock {
  margin: 0 !important;
  padding: 10px 14px 12px !important;
  border: 0 !important;
  border-top: 1px solid var(--border-subtle) !important;
  background: transparent !important;
  display: grid;
  gap: 4px;
  flex: none;
  position: relative;
}
.composer { display: grid; gap: 6px; background: transparent; border: 0; padding: 0; border-radius: 0; }
.composer-bar {
  display: flex; align-items: center; gap: 6px;
  height: 48px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 4px;
  transition: border-color 240ms var(--ease-spring), box-shadow 240ms var(--ease-spring);
}
.composer-bar:focus-within {
  border-color: var(--border-gold);
  box-shadow: 0 0 0 3px rgba(214, 178, 110, 0.1), 0 10px 28px rgba(0, 0, 0, 0.28);
}
.composer-bar.listening {
  border-color: var(--gold);
  box-shadow:
    0 0 0 1px rgba(214, 178, 110, calc(0.16 + var(--mic-amp, 0) * 0.4)),
    0 0 28px rgba(214, 178, 110, calc(var(--mic-amp, 0) * 0.32)),
    inset 0 0 22px rgba(168, 60, 79, calc(0.06 + var(--mic-amp, 0) * 0.2));
}
.composer-bar.listening #question::placeholder { color: var(--gold); }
.composer-mic {
  position: relative;
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  color: var(--ink-secondary);
  padding: 0;
}
.composer-mic svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.composer-mic.recording {
  background: #2c161c; border-color: var(--wine); color: #f28b99;
}
.listen-wave {
  display: none; position: absolute; inset: auto 4px 3px;
  height: 8px; gap: 2px; align-items: end; justify-content: center;
}
.composer-mic.recording .listen-wave { display: flex; }
.listen-wave i {
  width: 2px; height: 3px; background: #f28b99; border-radius: 1px;
  transition: height 90ms ease-out;
}
.composer-bar #question {
  flex: 1; min-width: 0;
  height: 34px;
  border: 0; outline: none;
  background: transparent;
  color: #f2ece1;
  font: 500 13.5px/1.35 var(--sans);
  padding: 0 4px;
}
.composer-bar #question::placeholder { color: #6d776f; }
.btn-ask {
  height: 36px; flex: none;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 0;
  background: var(--gold);
  color: #14110b;
  font: 700 12.5px/1 var(--sans);
  box-shadow: 0 6px 16px rgba(214, 178, 110, 0.18);
  transition: background 150ms ease, transform 120ms var(--ease-spring), box-shadow 150ms ease;
}
.mic-timer, .spur-num, .quote-pos {
  font-variant-numeric: tabular-nums lining-nums;
}
#followup, #quote-text, .spur-q {
  text-wrap: pretty;
}
.opera-card, .scene-panel {
  transition: opacity 280ms cubic-bezier(0.22, 1, 0.36, 1), transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}
.opera-card[hidden], .scene-panel[hidden] {
  display: none !important;
}
.scene-panel:not([hidden]) {
  animation: sceneEnter 340ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.scene-panel.is-entering .answer-block {
  animation: enterBlock 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.scene-panel.is-entering #quote {
  animation: enterBlock 300ms cubic-bezier(0.22, 1, 0.36, 1) 70ms both;
}
.scene-panel.is-entering #quote::before {
  animation: quoteRule 340ms cubic-bezier(0.22, 1, 0.36, 1) 70ms both;
}
.scene-panel.is-entering .class-prompt {
  animation: enterBlock 300ms cubic-bezier(0.22, 1, 0.36, 1) 140ms both;
}
@keyframes sceneEnter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes enterBlock {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes quoteRule {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
#quote.citation-swap {
  animation: citationSwap 160ms ease both;
}
@keyframes citationSwap {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (min-width: 981px) {
  body[data-esito="NON_ATTESTATO"] #no-quote {
    display: none !important;
  }
}
body[data-view="lim"][data-stato="SPEAKING"] .app-topbar,
body[data-view="lim"][data-stato="SPEAKING"] .lim-topbar,
body[data-view="lim"][data-stato="SPEAKING"] .book-hud-top,
body[data-view="lim"][data-stato="SPEAKING"] .book-hud-bottom,
body[data-view="lim"][data-stato="SPEAKING"] .book-tools-rail {
  opacity: 0.42;
  transition: opacity 280ms ease;
}
body[data-view="lim"][data-stato="SPEAKING"] .app-topbar:hover,
body[data-view="lim"][data-stato="SPEAKING"] .lim-topbar:hover,
body[data-view="lim"][data-stato="SPEAKING"] .book-hud-top:hover,
body[data-view="lim"][data-stato="SPEAKING"] .book-hud-bottom:hover,
body[data-view="lim"][data-stato="SPEAKING"] .book-tools-rail:hover {
  opacity: 1;
}
body[data-view="lim"][data-stato="SPEAKING"] .lim-rail #spoken {
  font-size: clamp(22px, 2.1vw, 26px);
  line-height: 1.42;
  color: #f7f1e5;
}
.btn-ask:hover:not(:disabled) {
  background: #e2c07a;
  box-shadow: 0 8px 22px rgba(214, 178, 110, 0.28);
}
.btn-ask:active:not(:disabled) { transform: scale(0.97); }
.composer-hint {
  margin: 0;
  text-align: center;
  font-size: 10.5px;
  color: #6e7870;
  line-height: 1.3;
  opacity: 0;
  transition: opacity 200ms ease;
}
.composer-dock:focus-within .composer-hint,
.composer-bar.listening ~ .composer-hint,
.composer-dock:has(.composer-mic.recording) .composer-hint {
  opacity: 0.85;
}
.notice {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  z-index: 30;
  margin: 0;
  max-width: min(92%, 360px);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.35;
  color: #f4d0d6;
  background: rgba(28, 14, 18, 0.94);
  border: 1px solid rgba(158, 51, 70, 0.45);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  text-align: center;
  pointer-events: none;
  white-space: normal;
}
.notice:empty,
.notice[hidden] { display: none; }

/* Projector typography on LIM rail */
.lim-rail {
  padding: 52px 20px 16px;
  overflow: hidden;
}
.lim-rail .rail-question { font: 500 15px/1.3 var(--sans); color: var(--muted); }
.lim-rail .rail-spoken {
  font: 500 clamp(22px, 2.05vw, 26px)/1.4 var(--serif);
  color: #f3ede0;
  -webkit-line-clamp: 8;
}
.lim-rail .rail-quote blockquote { font-size: 17px; line-height: 1.4; -webkit-line-clamp: 5; }
.lim-rail .class-prompt #followup { font: italic 500 18px/1.3 var(--serif); color: #e8dec8; }

.fallback-spread { display: flex; justify-content: center; align-items: center; height: 100%; gap: 4px; padding: 40px; }
.fallback-spread img { max-height: 100%; max-width: 48%; object-fit: contain; }
.fallback-cover {
  position: absolute; inset: 12% 28%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  text-align: center; color: #f1dfb1;
  background:
    linear-gradient(105deg, rgba(0,0,0,.22), transparent 28%),
    linear-gradient(180deg, #5a2430 0%, #3b121a 55%, #2a0c12 100%);
  border: 1px solid #9c6a56; border-radius: 4px;
  box-shadow: inset 0 0 0 10px #4a1c24, inset 0 0 0 11px rgba(185,149,102,.55), 0 28px 48px rgba(0,0,0,.55);
}
.fallback-cover .fb-author { font: 600 15px/1.2 Manrope, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #e5c687; }
.fallback-cover .fb-title { font: 500 clamp(28px, 3.2vw, 42px)/1.08 "Cormorant Garamond", Georgia, serif; color: #f5ead2; }
.fallback-cover .fb-edition { font: 500 12px/1.3 Manrope, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: rgba(229,198,135,.85); }

@media (max-width: 1100px) {
  .chapter-float { max-width: calc(100vw - 40px); overflow-x: auto; }
  .book-dock { max-width: calc(100vw - 40px); flex-wrap: wrap; justify-content: center; }
}
@media (max-width: 980px) {
  html, body { height: auto; overflow: auto; }
  .stage-grid { height: auto; grid-template-columns: 1fr; }
  .book-arena { height: 62vh; min-height: 420px; }
  .console-rail, .lim-rail {
    margin: 0;
    padding-top: 0;
    height: auto;
    border-radius: 0;
    box-shadow: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .stage-light::before,
  .stage-light::after,
  .stage-beam,
  .stage-foot,
  .stage-grain,
  .stage-read-rail,
  .book-stage,
  .book-stage.is-pick-flash::after,
  .opera-card,
  .scene-panel,
  .book-method,
  .book-caption.is-scenic,
  .book-read[data-state="playing"],
  button {
    transition: opacity 180ms linear !important;
    animation: none !important;
    filter: none !important;
  }
  .stage-beam--l { transform: translateX(-50%) rotate(-14deg); }
  .stage-beam--r { transform: translateX(-50%) rotate(14deg); }
  .stage-read-rail { transform: none; opacity: 1; }
  button:active:not(:disabled) { transform: none !important; }
}
