@font-face { font-family: "PB UI"; src: local("PingFang SC"), local("Hiragino Sans GB"), local("Microsoft YaHei"); }
:root { --ink: #1f2126; --paper: #fbf9f3; --accent: #c8402f;
  --ui: "Source Serif 4", "PB Latin", "PB Serif", "Songti SC", Georgia, serif; --sans: -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cbbfa9; color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* bottom player bar (book controls + live caption) */
#bar { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 2px;
  width: min(860px, calc(100vw - 24px)); padding: 6px 8px; border-radius: 16px; background: rgba(251, 249, 243, .9); backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 14px 40px -16px rgba(40, 30, 10, .45), 0 0 0 1px rgba(31, 33, 38, .08); z-index: 5; }
#bar button { width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; display: grid; place-items: center; flex: none; color: #3a3c43; }
#bar button:hover { background: rgba(31, 33, 38, .06); }
#bar button:disabled { opacity: .25; cursor: default; background: none; }
#bar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#bar .cap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0 10px; font: 500 15.5px/1.3 var(--ui); }
#bar .cap b { color: var(--accent); font-weight: 700; }
#bar .cap b:empty { display: none; }
#bar .cap span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bar .dots { display: flex; gap: 5px; flex: none; }
#bar .dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(31, 33, 38, .22); }
#bar .dots i.on { background: var(--ink); }
#bar .sep { width: 1px; height: 22px; background: rgba(31, 33, 38, .12); margin: 0 4px; }
#b-play .i-stop { display: none; }
#b-play.on .i-stop { display: block; } #b-play.on .i-play { display: none; }
#b-play.on { background: var(--ink) !important; color: #fff !important; }
#b-sound.off .w { display: none; }

.top { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 16px; display: flex; gap: 8px; z-index: 5; }
.chip { border: 0; border-radius: 999px; padding: 7px 14px; font: 600 13px var(--sans); background: rgba(251, 249, 243, .9); backdrop-filter: blur(10px); box-shadow: 0 6px 20px -10px rgba(40, 30, 10, .5), 0 0 0 1px rgba(31,33,38,.08); }

#toc { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); width: min(420px, calc(100vw - 24px)); padding: 10px; border-radius: 16px; background: rgba(251, 249, 243, .96); box-shadow: 0 20px 50px -20px rgba(40, 30, 10, .55), 0 0 0 1px rgba(31,33,38,.08); z-index: 6; display: grid; gap: 2px; }
#toc button { border: 0; background: none; text-align: left; padding: 10px 12px; border-radius: 10px; font: 500 16px var(--ui); display: flex; gap: 14px; }
#toc button b { color: var(--accent); width: 18px; }
#toc .teach { border-top: 1px solid rgba(31,33,38,.1); border-radius: 0 0 10px 10px; margin-top: 4px; font: 500 14px var(--sans); color: #2a7f7a; }
#toc button.on, #toc button:hover { background: rgba(31, 33, 38, .06); }

#hint { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); font: 500 13px var(--sans); color: rgba(31, 33, 38, .65); background: rgba(251, 249, 243, .7); padding: 6px 14px; border-radius: 999px; transition: opacity .6s; pointer-events: none; white-space: nowrap; }

/* video overlays (capture / watch): title chip + large subtitle */
#chip, #subtitle { position: fixed; left: 0; right: 0; text-align: center; pointer-events: none; z-index: 4; display: none; }
body.capture #chip, body.capture #subtitle { display: block; }
#chip { top: 5vh; font: 800 max(4.2vh, 30px)/1.2 var(--ui); color: var(--ink); transition: opacity .5s; }
#chip small { display: block; font: 700 max(1.6vh, 13px) var(--sans); letter-spacing: .24em; color: var(--accent); margin-bottom: .8vh; text-transform: uppercase; }
#subtitle { bottom: 13vh; padding: 0 6%; font: 600 max(3.1vh, 26px)/1.5 var(--ui); }
#subtitle span { background: rgba(251, 249, 243, .94); color: var(--ink); padding: .28em .7em; border-radius: .5em; box-shadow: 0 10px 30px -12px rgba(40, 30, 10, .5); -webkit-box-decoration-break: clone; box-decoration-break: clone; }
body.capture #bar { bottom: 4vh; }
body.capture .top, body.capture #hint { display: none; }
@media (orientation: portrait) {
  body.capture #subtitle { bottom: 15vh; font-size: max(2.5vh, 26px); }
  body.capture #chip { top: 6vh; font-size: max(3.2vh, 28px); }
  body.capture #bar { display: none; }
  body.capture #subtitle { bottom: 8vh; }
}

body.night { background: #0d1117; }
body.night #bar, body.night .chip, body.night #toc { background: rgba(22, 26, 34, .88); color: #e8eaf0; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
body.night #bar button, body.night #toc button { color: #d8dbe4; }
body.night #bar .dots i.on { background: #fff; }

#load { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: #cbbfa9; transition: opacity .7s; }
#load i { width: 40px; height: 40px; border-radius: 50%; border: 3px solid rgba(31, 33, 38, .15); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#load.done { opacity: 0; pointer-events: none; }

@media (max-width: 640px) {
  #bar { gap: 0; padding: 4px; }
  #bar button { width: 36px; height: 38px; }
  #bar .dots, #bar .sep, #b-full { display: none; }
  #bar .cap { font-size: 14px; padding: 0 6px; }
}

body.capture *, body.capture #load { transition: none !important; animation: none !important; }
body.still #bar, body.still .top, body.still #hint, body.still #toc { display: none !important; }
