:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: #070b13;
  color: #eaf4ff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --panel: rgba(5, 14, 26, .88);
  --line: rgba(112, 221, 255, .24);
  --muted: #91a9c1;
  --cyan: #75e6f4;
  --violet: #c5baff;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; min-height: 100%; margin: 0; overflow: hidden; background: #070b13; }
body { min-height: 100dvh; }
button, select, a { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid #a8f1ff;
  outline-offset: 3px;
}
#stage {
  position: relative;
  width: 100%;
  width: 100vw;
  height: 100%;
  height: 100dvh;
  min-height: min(360px, 100dvh);
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(ellipse at 50% 42%, #202a3b 0%, #0b1220 46%, #070b13 78%);
}
#scene { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.scene-overlay {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  pointer-events: none;
}
.topbar, .route-links, .brand { display: flex; align-items: center; }
.topbar { justify-content: space-between; gap: 18px; }
.brand {
  min-height: 44px;
  gap: 10px;
  color: #edf7ff;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .15em;
  text-decoration: none;
  text-shadow: 0 2px 16px #000;
  pointer-events: auto;
}
.brand-mark, .loading-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid rgba(117, 230, 244, .6);
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(197,186,255,.24), rgba(117,230,244,.12));
  color: var(--cyan);
  font-size: 20px;
  font-weight: 900;
}
.route-links { flex-wrap: wrap; justify-content: flex-end; gap: 8px; pointer-events: auto; }
.route-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 18, 32, .82);
  color: #dff8ff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .09em;
  text-decoration: none;
  backdrop-filter: blur(14px);
}
.service-language-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 18, 32, .82);
  backdrop-filter: blur(14px);
}
.service-language-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #b9cce0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  cursor: pointer;
}
.service-language-switch button[aria-pressed="true"] {
  background: linear-gradient(135deg, #c5baff, #7bdde9);
  color: #111827;
}
.scene-intro { max-width: min(560px, 72vw); margin-top: auto; margin-bottom: auto; text-shadow: 0 2px 20px #000; }
.eyebrow { margin: 0 0 12px; color: #83dbe9; font: 700 9px/1.4 ui-monospace, monospace; letter-spacing: .2em; }
.scene-intro h1 { margin: 0; color: #f2f6ff; font-size: clamp(25px, 4.5vw, 52px); line-height: .98; letter-spacing: .08em; }
.subtitle { margin: 12px 0 0; color: #a8bbd1; font-size: clamp(12px, 1.5vw, 15px); line-height: 1.5; }
.control-panel {
  width: min(920px, 100%);
  align-self: center;
  padding: 15px;
  border: 1px solid rgba(117, 230, 244, .24);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 54px rgba(0, 0, 0, .38);
  backdrop-filter: blur(20px);
  pointer-events: auto;
}
.status-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .8fr); gap: 18px; align-items: center; }
.status-copy { display: flex; align-items: center; gap: 9px; min-width: 0; color: #c9f6ff; font: 800 10px/1.45 ui-monospace, monospace; letter-spacing: .08em; }
.status-indicator { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #72e6bb; box-shadow: 0 0 12px rgba(114,230,187,.7); }
.progress-wrap { display: grid; gap: 6px; }
.progress-wrap label { color: var(--muted); font: 700 8px/1.3 ui-monospace, monospace; letter-spacing: .09em; }
progress { width: 100%; height: 6px; overflow: hidden; border: 0; border-radius: 99px; background: rgba(255,255,255,.1); accent-color: var(--cyan); }
progress::-webkit-progress-bar { background: rgba(255,255,255,.1); border-radius: 99px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, #6fdce8, #b9a8ff); border-radius: 99px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, #6fdce8, #b9a8ff); border-radius: 99px; }
.controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.controls button, .quality-control, .motion-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid rgba(133, 157, 188, .3);
  border-radius: 10px;
  background: rgba(12, 23, 40, .92);
  color: #eaf4ff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .07em;
}
.controls button { cursor: pointer; }
.controls button.primary { border-color: #c5baff; background: linear-gradient(135deg, #c5baff, #7bdde9); color: #111827; }
.controls button:disabled { opacity: .48; cursor: not-allowed; }
.quality-control { justify-content: space-between; min-width: 210px; color: var(--muted); }
.quality-control select { max-width: 132px; min-height: 28px; border: 0; background: transparent; color: #f3f7ff; font-size: 9px; font-weight: 800; }
.quality-control option { background: #101827; color: #f3f7ff; }
.motion-control { cursor: pointer; color: #cdd8e8; }
.motion-control input { width: 17px; height: 17px; margin: 0; accent-color: #82e6f2; }
.notice, .error-message { margin: 10px 2px 0; color: #91a9c1; font: 10px/1.5 ui-monospace, monospace; }
.error-message { color: #ffd1d9; }
.error-message[hidden] { display: none; }
.diagnostics-panel { margin-top:9px; border-top:1px solid rgba(112,221,255,.16); }
.diagnostics-panel summary { display:flex; align-items:center; justify-content:space-between; gap:10px; min-height:44px; cursor:pointer; list-style:none; color:#cde9f5; font:800 9px/1.4 ui-monospace,monospace; letter-spacing:.09em; }
.diagnostics-panel summary::-webkit-details-marker { display:none; }
.diagnostics-panel summary::after { content:"+"; flex:0 0 auto; color:var(--cyan); font-size:16px; }
.diagnostics-panel[open] summary::after { content:"−"; }
.diagnostics-summary { margin-left:auto; color:#8ceac7; text-align:right; }
.diagnostics-content { padding:7px 0 2px; }
.wire-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; margin:0; padding:0; list-style:none; }
.wire-diagnostic { min-width:0; padding:8px; border:1px solid rgba(112,221,255,.15); border-radius:9px; background:rgba(13,25,41,.82); }
.wire-line { display:flex; align-items:flex-start; justify-content:space-between; gap:6px; }
.wire-name,.wire-state { min-width:0; font:800 8px/1.4 ui-monospace,monospace; overflow-wrap:anywhere; }
.wire-name { color:#b9cce0; }
.wire-state { color:#91a9c1; text-align:right; }
.wire-state[data-status="connecting"] { color:#f5d58b; }
.wire-state[data-status="connected"] { color:#8ceac7; }
.wire-diagnostic progress { display:block; height:4px; margin-top:8px; }
.menu-diagnostic { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:9px; padding:9px 10px; border-top:1px solid rgba(112,221,255,.16); color:#b9cce0; font:800 8px/1.4 ui-monospace,monospace; letter-spacing:.08em; }
.menu-diagnostic strong { color:#f5d58b; text-align:right; }
.menu-diagnostic strong[data-status="verified"] { color:#8ceac7; }
.menu-diagnostic strong[data-status="under-repair"] { color:#f5d58b; }
body.is-embedded .diagnostics-panel { display:none; }
.loading-screen {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #070b13;
  color: #b9f3ff;
  font: 700 10px/1.5 ui-monospace, monospace;
  letter-spacing: .14em;
  text-align: center;
  transition: opacity .25s ease, visibility .25s ease;
}
.loading-screen.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-mark { width: 54px; height: 54px; flex-basis: 54px; font-size: 27px; }
.skip-link {
  position: fixed;
  z-index: 10;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  padding: 12px 14px;
  border-radius: 9px;
  background: #e8f8ff;
  color: #07111d;
  font-weight: 800;
}
.skip-link:focus { transform: translateY(0); }
.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;
}
@media (max-width: 760px) {
  .scene-overlay { gap: 12px; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
  .topbar { align-items: flex-start; flex-direction: column; gap: 6px; }
  .route-links { justify-content: flex-start; gap: 6px; }
  .route-links a { min-height: 44px; padding: 8px 10px; font-size: 8px; }
  .scene-intro { max-width: min(520px, 94vw); margin-top: 8px; margin-bottom: auto; }
  .scene-intro h1 { font-size: clamp(25px, 8vw, 42px); }
  .control-panel { padding: 12px; border-radius: 15px; }
  .status-row { grid-template-columns: 1fr; gap: 10px; }
  .controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .controls button, .quality-control, .motion-control { width: 100%; min-width: 0; min-height: 44px; padding: 9px; font-size: 8px; }
  .quality-control { grid-column: 1 / -1; }
  .quality-control select { max-width: 52%; }
  .motion-control { grid-column: 1 / -1; justify-content: flex-start; }
  .notice, .error-message { font-size: 9px; }
  .wire-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
  .diagnostics-content { max-height:min(28vh,220px); overflow-y:auto; overscroll-behavior:contain; }
  .wire-diagnostic { padding:7px; }
}
@media (max-width: 390px) {
  .brand { font-size: 9px; letter-spacing: .1em; }
  .brand-mark { width: 32px; height: 32px; flex-basis: 32px; }
  .route-links a { font-size: 7px; padding: 7px 8px; }
  .controls { grid-template-columns: 1fr 1fr; }
  .scene-intro { margin-top: 2px; }
  .scene-intro h1 { font-size: 26px; }
  .diagnostics-panel summary { gap:6px; font-size:8px; }
  .diagnostics-summary { font-size:7px; }
  .wire-name,.wire-state { font-size:7px; }
}

body.is-embedded .topbar{display:none}
body.is-embedded .scene-overlay{gap:10px;padding:max(10px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))}
body.is-embedded .scene-intro{max-width:min(760px,100%);margin:auto 0 10px;text-align:center}
body.is-embedded .scene-intro .eyebrow{display:none}
body.is-embedded .scene-intro h1{font-size:clamp(19px,3vw,30px);letter-spacing:.06em}
body.is-embedded .scene-intro .subtitle{margin-top:7px;font-size:11px}
body.is-embedded .control-panel{width:min(820px,100%);margin:0 auto;padding:12px}
body.is-embedded .controls{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
body.is-embedded .controls #play,body.is-embedded .controls #reset{display:none}
body.is-embedded .quality-control,body.is-embedded .motion-control{grid-column:1/-1}
body.is-embedded .status-row{grid-template-columns:minmax(0,1fr) minmax(150px,.8fr)}
body.is-embedded .route-links{display:none}
@media(max-width:760px){body.is-embedded .scene-intro{max-width:100%;margin:auto 0 8px}body.is-embedded .scene-intro h1{font-size:clamp(18px,5vw,25px)}body.is-embedded .status-row{grid-template-columns:1fr;gap:8px}body.is-embedded .control-panel{padding:10px}body.is-embedded .controls button,body.is-embedded .quality-control,body.is-embedded .motion-control{min-height:44px}}
@media(max-height:560px){html.is-embedded,html.is-embedded body{height:auto;min-height:100%;overflow-x:hidden;overflow-y:auto}html.is-embedded #stage{height:max(100dvh,420px);min-height:420px}}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}


/* Audio is opt-in; captions remain visible when speech synthesis is unavailable. */
.controls button#audio-toggle[aria-pressed="true"] {
  border-color: rgba(117, 230, 244, .72);
  background: rgba(22, 75, 85, .94);
  color: #dffcff;
}
.audio-status {
  margin: 7px 2px 0;
  color: var(--muted);
  font: 9px/1.45 ui-monospace, monospace;
}
.dialogue-caption {
  min-height: 34px;
  margin: 7px 2px 0;
  padding: 8px 11px;
  border-left: 2px solid var(--cyan);
  border-radius: 7px;
  background: rgba(9, 24, 39, .78);
  color: #e2f1ff;
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
body.is-embedded .audio-status,
body.is-embedded .dialogue-caption {
  margin-top: 5px;
  font-size: 9px;
}
@media (max-width: 760px) {
  .audio-status { font-size: 8px; }
  .dialogue-caption { min-height: 32px; padding: 7px 9px; font-size: 10px; }
}

@media (max-height: 680px) {
  .scene-overlay {
    justify-content: flex-start;
    gap: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y pinch-zoom;
    pointer-events: auto;
    scrollbar-width: thin;
  }
  .topbar, .scene-intro, .control-panel { flex: 0 0 auto; }
  .scene-intro { margin: 8px 0 12px; }
  .control-panel { margin-top: auto; }
  body.is-embedded .scene-overlay {
    justify-content: flex-start;
    overflow-y: auto;
    pointer-events: auto;
  }
  body.is-embedded .scene-intro { margin: 8px 0 10px; }
}


/* The full dialogue remains readable without audio and follows the live cue without auto-scrolling. */
.transcript-panel {
  margin-top: 9px;
  border-top: 1px solid rgba(112, 221, 255, .16);
}
.transcript-panel summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  color: #cde9f5;
  font: 800 9px/1.4 ui-monospace, monospace;
  letter-spacing: .08em;
}
.transcript-panel summary::-webkit-details-marker { display: none; }
.transcript-panel summary::after {
  content: "+";
  flex: 0 0 auto;
  color: var(--cyan);
  font-size: 16px;
}
.transcript-panel[open] summary::after { content: "−"; }
.transcript-panel summary:focus-visible { outline: 2px solid #a8f1ff; outline-offset: 3px; border-radius: 5px; }
.transcript-count {
  min-width: 0;
  margin-left: auto;
  color: var(--cyan);
  font: 800 8px/1.4 ui-monospace, monospace;
  text-align: right;
  white-space: nowrap;
}
.transcript-hint {
  margin: 0 0 8px;
  color: var(--muted);
  font: 9px/1.5 ui-monospace, monospace;
}
.transcript-list {
  display: grid;
  gap: 7px;
  max-height: min(38vh, 280px);
  margin: 0;
  padding: 0 3px 3px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  scrollbar-width: thin;
  list-style: none;
}
.transcript-entry {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(112, 221, 255, .14);
  border-radius: 9px;
  background: rgba(13, 25, 41, .82);
}
.transcript-entry[aria-current="step"] {
  border-color: rgba(117, 230, 244, .78);
  background: rgba(23, 57, 73, .9);
  box-shadow: inset 2px 0 0 var(--cyan);
}
.transcript-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #9db8cc;
  font: 800 8px/1.4 ui-monospace, monospace;
}
.transcript-time { color: var(--cyan); font-variant-numeric: tabular-nums; }
.transcript-speaker { min-width: 0; text-align: right; overflow-wrap: anywhere; }
.transcript-stage {
  margin: 5px 0 3px;
  color: #b8c8f4;
  font: 800 8px/1.4 ui-monospace, monospace;
  letter-spacing: .05em;
  overflow-wrap: anywhere;
}
.transcript-text {
  margin: 0;
  color: #e2f1ff;
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
@media (max-width: 760px) {
  .transcript-list { max-height: min(38vh, 240px); }
  .transcript-entry { padding: 8px; }
  .transcript-text { font-size: 10px; }
}
@media (max-width: 390px) {
  .transcript-panel summary { gap: 6px; font-size: 8px; }
  .transcript-count { font-size: 7px; }
  .transcript-meta { font-size: 7px; }
  .transcript-stage { font-size: 7px; }
}
