:root {
  color-scheme: dark;
  --accent: #ff982f;
  --surface: #242426;
  --guide: 50%;
  --start: 50dvh;
  --end: 50dvh;
  --margin: 3vw;
  --x: 1;
  --y: 1;
  font: 15px/1.4 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: black; color: white; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; background: transparent; border: 0; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid #82c3ff; outline-offset: 2px; }
#stage {
  position: fixed; inset: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: none;
  transform: scale(var(--x),var(--y)); overflow-anchor: none;
}
#stage:focus { outline: none; }
#stage::-webkit-scrollbar { display: none; }
#text {
  white-space: pre-wrap; overflow-wrap: anywhere; padding: 22px max(20px,var(--margin)) var(--end);
  font-size: 32px; line-height: 1.5; letter-spacing: 1px;
}
body.cued #text { padding-top: var(--start); }
mark { background: transparent; color: #ff9b52; font-weight: 700; }
#guide { position: fixed; left: 0; right: 0; top: var(--guide); height: 2px; background: #ffd700; pointer-events: none; }
#handle { position: absolute; top: 1px; left: 0; transform: translateY(-50%); border-radius: 0 20px 20px 0; height: 38px; width: 24px; padding: 0; background: #ffd700; color: #201b00; cursor: ns-resize; pointer-events: auto; touch-action: none; font-weight: 700; }
#transport, #tools, .panel { position: fixed; z-index: 1; color: #fafafa; }
#transport { bottom: calc(88px + env(safe-area-inset-bottom)); right: max(20px,env(safe-area-inset-right)); display: flex; gap: 8px; }
#play, #restart { height: 46px; border-radius: 24px; }
#play { padding: 0 22px; background: var(--accent); color: #211508; font-weight: 700; }
#restart { width: 46px; background: var(--surface); }
#tools { left: 50%; bottom: calc(15px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; border-radius: 32px; padding: 5px; gap: 3px; background: #29292cef; border: 1px solid #47474a; }
#tools button, #restart { display: grid; place-items: center; }
#tools button { height: 44px; width: 44px; border-radius: 50%; }
#tools button:hover, #tools button[aria-expanded=true] { background: #46464b; }
#tools b { font-size: 19px; }
#tools #close { width: auto; padding-inline: 12px; border-radius: 22px; font-size: 13px; white-space: nowrap; }
.panel { left: 50%; bottom: calc(78px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(345px,calc(100vw - 24px)); max-height: calc(100dvh - 100px - env(safe-area-inset-bottom)); overflow-y: auto; padding: 18px; border-radius: 16px; background: var(--surface); border: 1px solid #454549; box-shadow: 0 10px 35px #0007; z-index: 2; }
.panel h2 { margin: 0 0 16px; font-size: 17px; }
fieldset { margin: 10px 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 8px; }
.range { display: grid; grid-template-columns: 95px minmax(0,1fr) 30px; align-items: center; gap: 8px; margin: 10px 0; min-height: 32px; }
input { accent-color: var(--accent); }
input[type=range] { width: 100%; cursor: pointer; }
output { text-align: right; font-variant-numeric: tabular-nums; color: #d0d0d4; }
.toggle { display: flex; justify-content: space-between; align-items: center; min-height: 39px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; }
.swatches, .segments { display: flex; gap: 5px; }
.swatches button { flex: 1; height: 28px; border-radius: 6px; border: 1px solid #858589; }
.swatches [aria-pressed=true] { outline: 2px solid white; outline-offset: 1px; }
.segments button { flex: 1; padding: 6px; border-radius: 7px; background: #37373b; }
.segments [aria-pressed=true] { background: #59595e; }
@media (max-width: 820px) {
  #transport { bottom: calc(80px + env(safe-area-inset-bottom)); right: max(12px,env(safe-area-inset-right)); }
  .panel {
    bottom: calc(138px + env(safe-area-inset-bottom));
    max-height: calc(100dvh - 150px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

body:has(#readerSignIn:not([hidden])) { overflow:auto; }
body:has(#readerSignIn:not([hidden])) > :not(#readerSignIn) { display:none; }
