html, body { margin: 0; height: 100%; background: #05070b; color: #eaf0f8; font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif; overflow: hidden; }
#app { display: grid; grid-template-columns: 1fr 400px; grid-template-rows: 1fr auto; height: 100vh; height: 100dvh; }
button, input, select, label, #film, .ln { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#app.nopanel { grid-template-columns: 1fr 0; }
#app.nopanel #panel { display: none; }
#stagewrap { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; background: #05070b; }
#film { max-width: 100%; max-height: 100%; aspect-ratio: 16 / 9; display: block; }
#err { position: absolute; left: 12px; top: 12px; right: 12px; color: #ff8a8a; font: 14px/1.4 Consolas, monospace; white-space: pre-wrap; pointer-events: none; }
#panel { border-left: 1px solid #1c2636; display: flex; flex-direction: column; min-height: 0; background: #080c13; }
#panelhead { padding: 14px 20px 10px; font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: #8d9bb0; border-bottom: 1px solid #1c2636; }
#lines { flex: 1; overflow-y: auto; padding: 30vh 20px 50vh; scrollbar-width: thin; scrollbar-color: #26334a transparent; }
#lines h3 { margin: 26px 0 10px; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: #ffcf6b; font-weight: 600; }
#lines .ln { margin: 0 0 4px; padding: 7px 12px; border-radius: 8px; font-size: 18px; line-height: 1.42; color: #5d6a7e; cursor: pointer; border-left: 3px solid transparent; transition: color .3s, background .3s, border-color .3s; }
#lines .ln:hover { color: #b9c5d8; }
#lines .ln.past { color: #7f8ca1; }
#lines .ln.cur { color: #ffffff; background: rgba(255, 207, 107, 0.10); border-left-color: #ffcf6b; }
#bar { grid-column: 1 / 3; display: flex; align-items: center; gap: 12px; padding: 9px 16px; background: #0a0f18; border-top: 1px solid #1c2636; font-size: 14px; color: #b9c5d8; flex-wrap: nowrap; }
#bar button, #bar select { background: #162033; color: #eaf0f8; border: 1px solid #2a3a55; border-radius: 7px; padding: 7px 13px; font: inherit; cursor: pointer; white-space: nowrap; }
#bar button:hover { background: #1f2d47; }
#play { min-width: 74px; font-weight: 600; }
#time { font-variant-numeric: tabular-nums; min-width: 96px; white-space: nowrap; }
#seek { flex: 1; min-width: 120px; accent-color: #ffcf6b; }
#chips { display: flex; gap: 4px; }
#chips button { padding: 5px 9px; min-width: 30px; font-size: 13px; }
#chips button.on { background: #ffcf6b; color: #1a1305; border-color: #ffcf6b; }
#bar label { white-space: nowrap; cursor: pointer; }
#rec.on { background: #7a1f24; border-color: #ff5a5f; }
body.clean #app { grid-template-columns: 1fr 0; grid-template-rows: 1fr 0; }
body.clean #panel, body.clean #bar { display: none; }
#sheet { display: none; }
body.sheet { overflow: auto; }
body.sheet #app { display: none; }
body.sheet #sheet { display: grid; gap: 0; }
body.sheet #sheet canvas { display: block; }

/* A phone or narrow window held upright: the film on top at full width, the narration under it, the controls in rows. */
@media (max-width: 900px) and (orientation: portrait) {
  #app, #app.nopanel { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  #stagewrap { display: block; }
  #film { width: 100%; height: auto; max-height: none; }
  #panel { border-left: 0; border-top: 1px solid #1c2636; }
  #panelhead { padding: 9px 16px 7px; font-size: 12px; }
  #lines { padding: 12vh 10px 30vh; }
  #lines .ln { font-size: 17px; }
  #bar { grid-column: 1; flex-wrap: wrap; gap: 8px 10px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  #bar button, #bar select { padding: 9px 13px; }
  #seek { flex: 1 1 30%; min-width: 80px; }
  #chips { order: 9; flex: 1 1 100%; gap: 3px; }
  #chips button { flex: 1; min-width: 0; padding: 9px 0; }
  #rec, #lpanel { display: none; }
}
/* A phone held sideways: the film fills the screen; one row of controls. */
@media (max-height: 520px) and (orientation: landscape) {
  #app, #app.nopanel { grid-template-columns: 1fr 0; }
  #panel, #chips, #rec, #lpanel { display: none; }
  #bar { gap: 9px; padding: 5px calc(10px + env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); font-size: 13px; }
  #bar button, #bar select { padding: 6px 11px; }
  #time { min-width: 84px; }
}
