:root {
  color-scheme: dark;
  --background: #0c1018;
  --panel: #151c29;
  --border: #2b3648;
  --text: #f0f3f8;
  --muted: #a7b0c0;
  --accent: #e9bd76;
  --ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font: 16px/1.5 var(--ui);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--text); }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button, .view-link {
  font: inherit; color: inherit; background: none; border: 0; cursor: pointer;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.top, .controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: .65rem; padding: .55rem clamp(.6rem, 2.6vw, 2rem);
  background: var(--background);
}
.top { min-height: 58px; border-bottom: 1px solid var(--border); }
.identity, .tools, .switch, .paging { display: flex; align-items: center; gap: .55rem; }
.identity { white-space: nowrap; }
.brand { font-weight: 700; letter-spacing: .08em; }
.version { color: var(--accent); font-weight: 650; }
.switch {
  padding: 3px; gap: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); white-space: nowrap;
}
.view-link, .tool-button {
  display: inline-flex; justify-content: center; align-items: center;
  min-height: 35px; padding: .35rem .65rem; border-radius: 5px; font-size: .86rem;
}
.view-link[aria-current], .tool-button[aria-pressed="true"] {
  background: var(--accent); color: #141924; font-weight: 650;
}
.view-link:hover:not([aria-current]), .tool-button:hover:not([aria-pressed="true"]) { background: #253045; }
.tool-button:disabled { opacity: .32; cursor: default; }
.tool-button:disabled:hover { background: none; }

.presentation { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.viewer { position: relative; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.frame {
  min-height: 0; min-width: 0; display: grid; place-items: center; container-type: size;
  padding: clamp(4px, 1vw, 14px); background: #080b10;
}
.slide {
  position: relative; width: min(100cqw, calc(100cqh * var(--slide-ratio)));
  max-width: 100%; aspect-ratio: var(--slide-ratio);
  overflow: hidden; touch-action: pan-y; user-select: none;
  box-shadow: 0 0 0 1px #323743;
}
.slide-image { display: block; width: 100%; height: 100%; }
.slide-video, .video-start { position: absolute; }
.slide-video { display: block; object-fit: fill; background: #000; }
.video-start {
  display: grid; place-items: center; padding: 0;
}
.video-start span {
  display: grid; place-items: center; background: #080c16d9; color: #fff;
  border: 1px solid #ffffffa6; border-radius: 50%;
  width: clamp(1.5rem, 4.2vw, 3.6rem); height: clamp(1.5rem, 4.2vw, 3.6rem);
  font-size: clamp(.68rem, 1.5vw, 1.1rem); padding-left: .14em;
}
.video-start:hover span { background: #e9bd76; color: #141924; }
.page-script {
  border-top: 1px solid var(--border); margin: 0; padding: .8rem clamp(1rem, 4vw, 3rem);
  max-height: min(28vh, 220px); overflow-y: auto; background: var(--panel);
  font-size: clamp(.87rem, 1.6vw, 1.05rem);
}
.controls { border-top: 1px solid var(--border); }
.paging { gap: .25rem; }
.paging output { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 4.6em; text-align: center; font-size: .87rem; }
.arrow { font-size: 1.12rem; padding-inline: .7rem; }
.current-title { color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .84rem; }

.toc {
  position: absolute; z-index: 3; inset: 0 auto 0 0; overflow: auto;
  width: min(310px, 88vw); background: var(--panel); border-right: 1px solid var(--border);
  box-shadow: 12px 0 40px #0007; padding: .9rem;
}
.toc h2 { margin: 0 0 .6rem; font-size: 1rem; }
.toc button {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  gap: .6rem; padding: .65rem .5rem; border-radius: 5px; text-align: left; font-size: .9rem;
}
.toc small { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.toc button:hover, .toc button[aria-current] { background: #253045; }
.toc button[aria-current] { color: var(--accent); }

.manuscript .top { position: sticky; top: 0; z-index: 1; }
.script-main { max-width: 1000px; margin: auto; padding: clamp(1rem, 4vw, 2.5rem); }
.script-main h1 { font-size: clamp(1.6rem, 3.6vw, 2.35rem); line-height: 1.25; margin: 0 0 .55rem; }
.script-main > p { margin: 0 0 .95rem; color: var(--muted); }
.timing { display: flex; flex-wrap: wrap; gap: 6px 13px; padding: 0; margin: 0 0 1.8rem; list-style: none; }
.timing a { display: inline-block; padding: .35rem 0; font-size: .88rem; color: var(--accent); }
.timing a:hover, .script-row a:hover { text-decoration: underline; }
.script-section, .script-row { scroll-margin-top: 76px; }
.script-section h2 {
  display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
  border-bottom: 1px solid var(--border); padding: 0 0 .55rem; margin: 1.8rem 0 .1rem; font-size: 1.2rem;
}
.script-section h2 small { color: var(--accent); white-space: nowrap; font-size: .82rem; font-weight: 500; }
.script-row {
  display: grid; grid-template-columns: minmax(105px, 26%) minmax(0, 1fr);
  gap: clamp(.7rem, 2vw, 1.3rem); padding: .85rem 0;
  align-items: start; border-bottom: 1px solid var(--border);
}
.script-row img { display: block; width: 100%; height: auto; }
.script-row h3 { margin: 0; font-size: .97rem; }
.script-row h3 span { color: var(--accent); margin-right: .42rem; font-variant-numeric: tabular-nums; }
.script-row p { margin: .3rem 0 0; font-size: .95rem; line-height: 1.65; }

@media (max-width: 580px) {
  .top, .controls { gap: .3rem; }
  .identity, .tools { gap: .35rem; }
  .brand { font-size: .83rem; letter-spacing: .02em; }
  .version { font-size: .78rem; }
  .view-link, .tool-button { padding-inline: .4rem; }
  .current-title { display: none; }
  .script-row p { font-size: .88rem; }
}
@media print {
  @page { margin: 13mm; }
  :root { color-scheme: light; }
  body { color: #000; background: #fff; }
  .manuscript .top { position: static; padding: 0 0 5mm; color: #000; background: #fff; }
  .manuscript .tools { display: none; }
  .script-main { padding: 5mm 0 0; max-width: none; }
  .script-main h1 { font-size: 18pt; }
  .script-main > p, .timing a, .version, .script-section h2 small, .script-row h3 span { color: #222; }
  .timing { margin-bottom: 3mm; }
  .script-section h2 { break-after: avoid; border-color: #aaa; margin-top: 5mm; font-size: 13pt; }
  .script-row { break-inside: avoid; grid-template-columns: 27mm 1fr; border-color: #ccc; padding: 3mm 0; gap: 4mm; }
  .script-row h3, .script-row p { font-size: 10pt; }
}
