/* 全興工業｜STAR 學員版動畫 — 深藍鋼色舞台、紙白文案、少量暖橙 */
:root {
  --bg: #0a121b; --stage: #0c1521; --steel-1: #121c28; --steel-2: #1a2634; --steel-3: #26364a; --line: #2c3b4f;
  --on-dark: #e7edf4; --muted-dark: #9fb0c3; --paper: #f3eee4; --paper-2: #e9e2d4; --paper-line: #d4cab8; --ink: #17212c; --ink-2: #4a5462;
  --accent: #e8893a; --accent-ink: #1a1208; --accent-soft: rgba(232,137,58,.16);
  --ok: #4f9f7e; --wait: #c9912e; --bad: #c9523b; --cool: #4f8fc4; --coord: #7577cc;
  --sS: #6fb0ea; --sT: #d7b56d; --sA: #e8893a; --sR: #62c497;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", "Noto Sans CJK TC", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 10px; --gutter: 16px;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper: #ece6da; --paper-2: #e1d9c9; --paper-line: #cbc0ac; }
}
:root[data-theme="dark"] { --paper: #ece6da; --paper-2: #e1d9c9; --paper-line: #cbc0ac; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--on-dark); font-family: var(--font); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 6px; font-weight: 700; }
.skip:focus { top: 8px; }
.ic { width: 18px; height: 18px; flex: none; }
kbd { font-family: var(--mono); font-size: 12px; background: var(--steel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; color: var(--on-dark); }

/* 版面 */
.app { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh; }
.top { display: flex; align-items: center; gap: 14px; padding: 8px var(--gutter); background: linear-gradient(180deg, #111b27, #0d1620); border-bottom: 1px solid var(--line); min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand > div { min-width: 0; }
.kicker { font-size: 11.5px; color: var(--muted-dark); letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.star-steps { display: flex; gap: 4px; flex: none; }
.star-chip { display: flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--steel-1); border-radius: 999px; padding: 3px 10px 3px 4px; color: var(--muted-dark); font-size: 12.5px; }
.star-chip b { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--steel-3); color: var(--on-dark); font-size: 12px; }
.star-chip.on { color: var(--on-dark); border-color: currentColor; }
.star-chip.s-S.on b { background: var(--sS); color: #0b1620; } .star-chip.s-T.on b { background: var(--sT); color: #1a1406; }
.star-chip.s-A.on b { background: var(--sA); color: #1a1208; } .star-chip.s-R.on b { background: var(--sR); color: #07160f; }
.star-chip.s-S.on { color: var(--sS); } .star-chip.s-T.on { color: var(--sT); } .star-chip.s-A.on { color: var(--sA); } .star-chip.s-R.on { color: var(--sR); }
.tools { display: flex; gap: 4px; flex: none; }
.tbtn { display: flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 9px; color: var(--on-dark); font-size: 13px; white-space: nowrap; }
.tbtn:hover { background: var(--steel-2); border-color: var(--line); }
.tbtn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

.main { display: grid; grid-template-columns: minmax(0, 1fr) clamp(330px, 29vw, 440px); min-height: 0; }
.stage { position: relative; overflow: hidden; background: var(--stage); min-height: 260px; isolation: isolate; }
#gl, #scene2d, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#gl[hidden], #scene2d[hidden] { display: none; }
#overlay { pointer-events: none; z-index: 3; font-family: var(--font); }
#gl.whip, #scene2d.whip { animation: whip .85s ease-out; }
@keyframes whip { 0% { filter: blur(10px) brightness(1.1); } 100% { filter: none; } }
.vignette { position: absolute; inset: 0; pointer-events: none; z-index: 2; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(4,8,12,.55) 100%); }
.fade { position: absolute; inset: 0; background: #05090e; opacity: 0; pointer-events: none; z-index: 6; }
.fade.go-dim { animation: fadeDim 1.1s ease-out; }
.fade.go-cut { animation: fadeCut .32s ease-out; }
@keyframes fadeDim { 0% { opacity: 1; } 30% { opacity: .85; } 100% { opacity: 0; } }
@keyframes fadeCut { 0% { opacity: .9; } 100% { opacity: 0; } }
.wipe { position: absolute; top: 0; bottom: 0; width: 38%; left: -45%; z-index: 6; pointer-events: none; background: linear-gradient(90deg, rgba(20,30,42,0), #1e2a38 18%, #3a4a5e 50%, #1e2a38 82%, rgba(20,30,42,0)); box-shadow: 0 0 40px rgba(0,0,0,.6); }
.wipe.go { animation: wipe .95s cubic-bezier(.6,.05,.3,1); }
@keyframes wipe { 0% { left: -45%; } 100% { left: 110%; } }

.hud { position: absolute; left: 12px; top: 12px; z-index: 4; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 24px); padding: 6px 8px; background: rgba(10,17,26,.72); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--muted-dark); backdrop-filter: blur(4px); }
.hud-t { color: var(--on-dark); font-weight: 700; margin-right: 2px; }
.hud-item { display: inline-flex; align-items: center; gap: 5px; padding: 1px 6px; border-radius: 5px; }
.hud-item i { width: 10px; height: 10px; border-radius: 2px; border: 1.5px dashed #8193a8; }
.hud-item[data-state="1"] { color: var(--on-dark); } .hud-item[data-state="1"] i { border-style: solid; border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.hud-item[data-state="2"] { color: var(--on-dark); } .hud-item[data-state="2"] i { border: 0; background: var(--accent); box-shadow: 0 0 8px rgba(232,137,58,.7); }
.slate { position: absolute; right: 12px; top: 12px; z-index: 4; font-family: var(--mono); font-size: 11px; color: #b8c6d6; background: rgba(10,17,26,.6); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; max-width: 46%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-badge { position: absolute; right: 12px; bottom: 60px; z-index: 4; font-size: 11px; color: #c9d4e0; background: rgba(10,17,26,.6); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; }
.stage-note { position: absolute; right: 12px; top: 46px; z-index: 5; max-width: min(420px, 70%); display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.5; background: rgba(40,28,14,.92); border: 1px solid var(--accent); color: #fbe7d3; border-radius: 8px; padding: 5px 6px 5px 10px; }
.stage-note[hidden] { display: none; }
.stage-note button { flex: none; border: 0; background: transparent; color: #fbe7d3; font-size: 16px; line-height: 1; padding: 0 4px; }
.stage-ctrl { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 6px; background: rgba(10,17,26,.82); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(6px); }
.cbtn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--steel-2); color: var(--on-dark); border-radius: 7px; padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.cbtn:hover { border-color: #4b5f78; }
.cbtn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.cbtn.primary.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(232,137,58,.5); } 50% { box-shadow: 0 0 0 6px rgba(232,137,58,0); } }
.cbtn[aria-pressed="false"] { color: var(--muted-dark); }
.shotbar { flex: 1 1 auto; height: 4px; background: var(--steel-3); border-radius: 2px; overflow: hidden; min-width: 40px; }
#shotfill { height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }
.shottime { font-family: var(--mono); font-size: 11.5px; color: var(--muted-dark); white-space: nowrap; }

.caption { display: none; position: absolute; left: 16px; bottom: 64px; z-index: 4; width: min(640px, calc(100% - 32px)); background: rgba(243,238,228,.94); color: var(--ink); border-radius: 10px; padding: 12px 16px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.45); border-left: 4px solid var(--accent); }
.app[data-theater="1"] .caption { display: block; }
.app[data-capmin="1"] #capBody { display: none; }
.app[data-capmin="1"] .caption { width: auto; padding: 6px 10px; }
.cap-toggle { position: absolute; right: 8px; top: 8px; border: 1px solid var(--paper-line); background: transparent; border-radius: 6px; font-size: 12px; padding: 1px 8px; color: var(--ink-2); }
.app[data-capmin="1"] .cap-toggle { position: static; }
.cap-id { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.cap-title { font-weight: 800; font-size: clamp(17px, 1.7vw, 24px); line-height: 1.35; margin: 2px 60px 6px 0; }
.cap-copy { margin: 0; font-size: clamp(14px, 1.15vw, 17px); line-height: 1.7; }

/* 側欄（紙白） */
.panel { background: var(--paper); color: var(--ink); overflow: auto; padding: 18px 20px 28px; border-left: 1px solid #0a0f15; }
.panel:focus { outline: none; }
.p-chapter { font-size: 12.5px; color: var(--ink-2); letter-spacing: .02em; }
.p-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.pid { font-family: var(--mono); font-weight: 700; color: var(--ink); background: var(--paper-2); border: 1px solid var(--paper-line); border-radius: 5px; padding: 0 6px; }
.star-badge { font-weight: 700; border-radius: 999px; padding: 0 10px; color: #0b1620; }
.star-badge.s-S { background: var(--sS); } .star-badge.s-T { background: var(--sT); color: #1a1406; } .star-badge.s-A { background: var(--sA); color: #1a1208; } .star-badge.s-R { background: var(--sR); color: #07160f; }
.p-title { font-size: clamp(20px, 1.7vw, 26px); line-height: 1.35; margin: 10px 0 8px; font-weight: 800; letter-spacing: .01em; }
.p-copy { font-size: 16px; line-height: 1.85; margin: 0 0 8px; }
.p-orig { font-size: 12.5px; color: var(--ink-2); margin: 0 0 12px; }
.p-shot { border: 1px solid var(--paper-line); border-radius: 8px; background: var(--paper-2); padding: 0 12px; margin-bottom: 16px; }
.p-shot summary { padding: 8px 0; font-weight: 700; font-size: 14px; cursor: pointer; }
.p-shot dl { margin: 0 0 10px; font-size: 13.5px; }
.p-shot dt { font-weight: 700; color: var(--ink-2); margin-top: 6px; font-size: 12.5px; }
.p-shot dd { margin: 2px 0 0; }
.star-work { border-top: 2px solid var(--ink); padding-top: 10px; }
.star-work h2 { font-size: 15px; margin: 0 0 8px; }
.sw-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sw-tabs [role=tab] { border: 1px solid var(--paper-line); background: transparent; border-radius: 7px 7px 0 0; padding: 5px 2px; font-size: 12.5px; color: var(--ink-2); position: relative; }
.sw-tabs [role=tab] b { display: block; font-size: 15px; color: var(--ink); }
.sw-tabs [role=tab][aria-selected="true"] { background: #fffaf1; color: var(--ink); border-bottom-color: #fffaf1; font-weight: 700; }
.sw-tabs [role=tab].page-star::after { content: "本頁"; position: absolute; top: -8px; right: 4px; font-size: 10px; background: var(--ink); color: var(--paper); border-radius: 4px; padding: 0 4px; line-height: 1.5; }
.sw-body { background: #fffaf1; border: 1px solid var(--paper-line); border-top: 0; border-radius: 0 0 8px 8px; padding: 12px; }
.sw-q { margin: 0 0 10px; font-size: 14px; }
.sw-hint { font-size: 13px; color: var(--ink-2); margin: 0 0 8px; }
.fld { display: block; margin-bottom: 10px; }
.fld span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.fld input, .fld textarea { width: 100%; border: 1px solid var(--paper-line); border-radius: 6px; background: #fff; padding: 7px 9px; font-size: 14px; color: var(--ink); resize: vertical; }
.fld input:focus, .fld textarea:focus { border-color: var(--accent); outline: 2px solid rgba(232,137,58,.3); }
.sw-files { margin-bottom: 12px; }
.sw-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); border-radius: 7px; padding: 6px 12px; font-size: 13.5px; text-decoration: none; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn .ic { width: 15px; height: 15px; }
.sw-foot { margin-top: 10px; }
.save-status { font-size: 12.5px; color: var(--ink-2); margin: 0 0 6px; }
.save-status.warn { color: var(--bad); font-weight: 700; }
.scores { border: 1px solid var(--paper-line); border-radius: 8px; margin: 0 0 12px; padding: 8px 10px; }
.scores legend { font-size: 13px; font-weight: 700; padding: 0 4px; }
.score-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; padding: 2px 0; }
.score-row > span { width: 110px; font-weight: 700; }
.p-foot { font-size: 12px; color: var(--ink-2); margin-top: 18px; border-top: 1px solid var(--paper-line); padding-top: 8px; }

/* 底部導覽 */
.bar { display: flex; align-items: center; gap: 10px; padding: 8px var(--gutter); background: #0d1620; border-top: 1px solid var(--line); min-width: 0; }
.nbtn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--steel-2); color: var(--on-dark); border-radius: 8px; padding: 7px 12px; font-size: 13.5px; white-space: nowrap; flex: none; }
.nbtn:disabled { opacity: .4; cursor: default; }
#btnNext { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.timeline { flex: 1 1 auto; display: flex; gap: 6px; min-width: 0; }
.tl-ch { flex: 1 1 0; min-width: 0; }
.tl-name { display: block; font-size: 10.5px; color: var(--muted-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.tl-ticks { display: flex; gap: 2px; }
.tick { flex: 1 1 0; min-width: 0; height: 22px; padding: 0; border: 0; background: transparent; display: flex; align-items: flex-end; }
.tick span { display: block; width: 100%; height: 8px; border-radius: 2px; background: var(--steel-3); transition: height .15s; }
.tick.s-S span { box-shadow: inset 0 -2px 0 var(--sS); } .tick.s-T span { box-shadow: inset 0 -2px 0 var(--sT); } .tick.s-A span { box-shadow: inset 0 -2px 0 var(--sA); } .tick.s-R span { box-shadow: inset 0 -2px 0 var(--sR); }
.tick.seen span { background: #56677d; }
.tick.noted span { background: #8b7a58; }
.tick:hover span { height: 14px; }
.tick.cur span { height: 20px; background: var(--accent); box-shadow: 0 0 10px rgba(232,137,58,.6); }
.jump { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted-dark); flex: none; }
.jump input { width: 52px; background: var(--steel-1); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; text-align: center; color: var(--on-dark); }

/* 對話框 */
dialog { width: min(720px, calc(100vw - 24px)); max-height: min(86vh, 900px); border: 1px solid var(--line); border-radius: 12px; background: #101a26; color: var(--on-dark); padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
dialog.wide { width: min(1100px, calc(100vw - 24px)); }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(3,6,10,.7); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 17px; }
.x { border: 1px solid var(--line); background: var(--steel-2); color: var(--on-dark); border-radius: 7px; width: 32px; height: 32px; font-size: 18px; line-height: 1; }
.dlg-body { overflow: auto; padding: 10px 16px 18px; min-height: 0; flex: 1 1 auto; }
.toc-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 0; }
.toc-filters button { border: 1px solid var(--line); background: var(--steel-1); color: var(--on-dark); border-radius: 999px; padding: 3px 12px; font-size: 13px; }
.toc-filters button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.toc-sum { font-size: 12.5px; color: var(--muted-dark); margin: 6px 16px 0; }
.toc-ch h3 { font-size: 14px; margin: 14px 0 6px; color: var(--on-dark); display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.toc-ch h3 small { font-weight: 400; color: var(--muted-dark); font-size: 12px; }
.toc-ch ol, .search-results { list-style: none; margin: 0; padding: 0; }
.toc-item, .sr-item { width: 100%; display: grid; grid-template-columns: 28px 24px 1fr auto; gap: 8px; align-items: center; text-align: left; border: 1px solid transparent; background: transparent; color: var(--on-dark); border-radius: 7px; padding: 6px 8px; font-size: 14px; }
.sr-item { grid-template-columns: 28px 24px 1fr; }
.toc-item:hover, .sr-item:hover, .toc-item:focus-visible, .sr-item:focus-visible { background: var(--steel-2); border-color: var(--line); }
.toc-item.cur { background: var(--accent-soft); border-color: var(--accent); }
.toc-n { font-family: var(--mono); color: var(--muted-dark); font-size: 12.5px; }
.toc-m { font-size: 12px; color: var(--muted-dark); white-space: nowrap; }
.star-dot { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 11.5px; font-weight: 800; color: #0b1620; }
.star-dot.s-S { background: var(--sS); } .star-dot.s-T { background: var(--sT); } .star-dot.s-A { background: var(--sA); } .star-dot.s-R { background: var(--sR); }
.sr-item small { display: block; color: var(--muted-dark); font-size: 12.5px; line-height: 1.5; }
.sr-item mark, .search-results mark { background: rgba(232,137,58,.35); color: inherit; border-radius: 2px; }
.search-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px 0; }
.search-row input { flex: 1; background: var(--steel-1); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 15px; }
.search-row span { font-size: 12.5px; color: var(--muted-dark); white-space: nowrap; }
.search-results .empty { color: var(--muted-dark); font-size: 13.5px; padding: 10px 4px; }
.files-tabs { display: flex; gap: 4px; padding: 8px 16px 0; overflow-x: auto; border-bottom: 1px solid var(--line); }
.files-tabs [role=tab] { border: 1px solid transparent; border-bottom: 0; background: transparent; color: var(--muted-dark); padding: 6px 12px; border-radius: 7px 7px 0 0; font-size: 13.5px; white-space: nowrap; }
.files-tabs [role=tab][aria-selected="true"] { background: var(--steel-2); color: var(--on-dark); border-color: var(--line); font-weight: 700; }
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.file { display: flex; gap: 12px; align-items: center; justify-content: space-between; border: 1px solid var(--line); background: var(--steel-1); border-radius: 9px; padding: 10px 12px; }
.file-name { font-family: var(--mono); font-weight: 700; font-size: 14px; color: #ffd2aa; word-break: break-all; }
.file-label { display: block; font-size: 12.5px; color: var(--muted-dark); }
.file p { margin: 4px 0 0; font-size: 13px; color: #c9d4e0; }
.file-act { display: flex; flex-direction: column; gap: 6px; flex: none; }
.file .btn { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; justify-content: center; }
.file .btn.ghost { background: transparent; color: var(--on-dark); border-color: var(--line); font-weight: 400; }
.doc-note { font-size: 13px; color: var(--muted-dark); margin: 4px 0 10px; }
.doc-note code, .doc code { font-family: var(--mono); font-size: 12.5px; background: var(--steel-2); padding: 0 4px; border-radius: 3px; }
.doc { font-size: 14.5px; }
.doc h2, .doc h3, .doc h4 { margin: 18px 0 6px; color: #fff; scroll-margin-top: 8px; }
.doc h2 { font-size: 18px; } .doc h3 { font-size: 16px; border-bottom: 1px solid var(--line); padding-bottom: 4px; } .doc h4 { font-size: 14.5px; }
.doc blockquote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--steel-1); color: #dde5ee; font-size: 13.5px; }
.tbl-wrap { overflow-x: auto; margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; }
.tbl-wrap table { border-collapse: collapse; width: 100%; font-size: 13px; }
.tbl-wrap th, .tbl-wrap td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.tbl-wrap th { background: var(--steel-2); position: sticky; top: 0; white-space: nowrap; }
.data-ctl { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; }
.data-ctl label { display: flex; align-items: center; gap: 6px; }
.data-ctl select, .data-ctl input { background: var(--steel-1); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.data-count { font-size: 12.5px; color: var(--muted-dark); margin: 8px 0 0; }
.data-wrap { max-height: 52vh; overflow: auto; }
.data-wrap td { white-space: pre-wrap; min-width: 80px; max-width: 420px; }
.help table { border-collapse: collapse; font-size: 14px; margin: 8px 0 14px; }
.help th { text-align: left; font-weight: 400; padding: 4px 16px 4px 0; white-space: nowrap; }
.help td { padding: 4px 0; color: #c9d4e0; }
.help ul { padding-left: 20px; font-size: 13.5px; color: #c9d4e0; }
.help h3 { font-size: 15px; margin: 10px 0 4px; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 60; background: #f3eee4; color: var(--ink); padding: 8px 14px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.5); transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 劇院 */
.app[data-theater="1"] .main { grid-template-columns: minmax(0, 1fr); }
.app[data-theater="1"] .panel { display: none; }

/* 窄螢幕 */
@media (max-width: 1180px) { .tbtn span { display: none; } .star-chip span { display: none; } .star-chip { padding: 3px; } }
@media (max-width: 900px) {
  .app { height: auto; min-height: 100dvh; grid-template-rows: auto auto auto; }
  .main { grid-template-columns: minmax(0, 1fr); }
  .stage { aspect-ratio: 4 / 3.3; max-height: 64vh; min-height: 280px; }
  .panel { overflow: visible; border-left: 0; padding: 16px var(--gutter) 24px; }
  .bar { position: sticky; bottom: 0; z-index: 20; flex-wrap: wrap; gap: 6px; padding: 6px var(--gutter) calc(6px + env(safe-area-inset-bottom)); }
  .timeline { order: -1; flex: 1 1 100%; }
  .tl-name { display: none; }
  .tick { height: 16px; }
  .nbtn { padding: 6px 12px; }
  .jump { margin: 0 auto; }
  .course { font-size: 13.5px; }
  .kicker { display: none; }
  .star-steps { display: none; }
  .tools { gap: 0; }
  .tbtn { padding: 6px; }
  .slate { display: none; }
  .hud { font-size: 11px; gap: 3px; padding: 4px 6px; }
  .hud-t { display: none; }
  .stage-badge { bottom: 54px; font-size: 10.5px; }
  .shottime { display: none; }
  .cbtn span { display: none; }
  .cbtn.primary span { display: inline; }
  .app[data-theater="1"] .stage { aspect-ratio: auto; height: calc(100dvh - 120px); max-height: none; }
  .caption { bottom: 58px; left: 8px; width: calc(100% - 16px); padding: 10px 12px; }
  .cap-copy { font-size: 14px; line-height: 1.6; }
  .file { flex-direction: column; align-items: stretch; }
  .file-act { flex-direction: row; }
  .toc-item { grid-template-columns: 26px 22px 1fr; }
  .toc-m { grid-column: 3; }
}
@media (max-width: 420px) { .brand-mark { display: none; } .stage-badge { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .fade.go-dim, .fade.go-cut, .wipe.go, #gl.whip, #scene2d.whip, .cbtn.primary.pulse { animation: none !important; }
  .toast, .tick span { transition: none; }
}

.csv-list { margin-top: 6px; font-size: 12.5px; }
.csv-list summary { cursor: pointer; color: #ffd2aa; }
.csv-list ul { list-style: none; padding: 0; margin: 6px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 12px; }
.csv-list li { display: flex; justify-content: space-between; gap: 8px; }
.csv-list a { color: #e7edf4; font-family: var(--mono); }
.csv-list span { color: var(--muted-dark); white-space: nowrap; }
.file-warn { color: #fbd3ad !important; font-weight: 700; }
.btn.disabled { opacity: .6; cursor: not-allowed; background: var(--steel-3) !important; border-color: var(--line) !important; color: var(--on-dark) !important; }
.record-text { width: 100%; background: var(--steel-1); color: var(--on-dark); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-family: var(--mono); font-size: 12.5px; }

/* ── RPG 改版 */
.map-layer { position: absolute; inset: 0; z-index: 7; background: #0b131d; }
.map-layer[hidden] { display: none; }
.map-layer svg { width: 100%; height: 100%; display: block; font-family: var(--font); }
.level-banner { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); z-index: 8; text-align: center; background: rgba(10,17,26,.86); border: 1px solid var(--accent); border-left: 0; border-right: 0; padding: 12px 40px 14px; min-width: min(520px, 90%); box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.level-banner[hidden], .level-result[hidden], .next-level[hidden], .enc[hidden] { display: none; }
#lbKick { font-size: 13px; letter-spacing: .12em; color: var(--accent); font-weight: 700; }
#lbTitle { font-size: clamp(20px, 2.4vw, 32px); font-weight: 800; margin: 2px 0; }
#lbMeta { font-size: 12.5px; color: var(--muted-dark); }
.level-result { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); z-index: 8; background: rgba(14,31,25,.94); border: 1px solid #62c497; border-radius: 10px; padding: 10px 18px; text-align: center; max-width: min(560px, 92%); }
#lrKick { color: #62c497; font-weight: 800; font-size: 14px; letter-spacing: .08em; }
#lrText { font-size: 14.5px; }
.next-level { position: absolute; left: 50%; top: calc(46% + 50px); transform: translateX(-50%); z-index: 9; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 9px 22px; font-weight: 800; font-size: 14.5px; box-shadow: 0 6px 24px rgba(232,137,58,.45); white-space: nowrap; }
.app[data-phase="in"] .hud, .app[data-phase="in"] .stage-badge, .app[data-phase="out"] .stage-badge { opacity: 0; }
.enc { position: absolute; left: 12px; bottom: 62px; z-index: 5; display: flex; gap: 10px; align-items: center; max-width: min(430px, calc(100% - 24px)); background: rgba(10,17,26,.86); border: 1px solid var(--line); border-left: 3px solid var(--ac, var(--accent)); border-radius: 9px; padding: 7px 12px 7px 8px; font-size: 12.5px; backdrop-filter: blur(4px); }
.enc-av { flex: none; display: grid; place-items: center; width: 38px; height: 44px; background: #0e1620; border-radius: 7px; border: 1px solid var(--line); }
.enc-main { min-width: 0; }
.enc-l1, .enc-l2, .enc-l3 { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.enc-l1 b { white-space: nowrap; }
.enc-act { color: #ffd2aa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.enc-l2 { color: #c9d4e0; }
.enc-l2 span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.enc-tag { flex: none; font-size: 10.5px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; color: var(--muted-dark); }
.enc-tag.foe { border-color: #7a4a3a; color: #f0b199; }
.enc-bar { flex: 1 1 auto; min-width: 70px; height: 5px; background: var(--steel-3); border-radius: 3px; overflow: hidden; align-self: center; }
.enc-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #6fb0ea, #62c497); }
.enc-res { display: none; color: #62c497; font-weight: 700; margin-top: 2px; }
.enc.done .enc-res { display: block; }
.map-dlg { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; }
.map-big svg { width: 100%; height: auto; display: block; border-radius: 8px; border: 1px solid var(--line); font-family: var(--font); }
.map-side h3 { font-size: 14px; margin: 4px 0 6px; }
.map-levels, .map-cast { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.lvl { width: 100%; display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; text-align: left; border: 1px solid var(--line); background: var(--steel-1); color: var(--on-dark); border-radius: 8px; padding: 6px 8px; font-size: 13.5px; }
.lvl b { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--steel-3); }
.lvl.cur { border-color: var(--accent); background: var(--accent-soft); }
.lvl.cur b { background: var(--accent); color: var(--accent-ink); }
.lvl small { display: block; color: var(--muted-dark); font-size: 11.5px; }
.lvl em { font-style: normal; font-size: 11.5px; color: #62c497; }
.map-cast li { display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.map-cast small { display: block; color: var(--muted-dark); font-size: 11px; }
@media (max-width: 900px) {
  .enc { bottom: 54px; left: 8px; padding: 5px 8px 5px 6px; font-size: 11.5px; max-width: calc(100% - 16px); }
  .enc-av { width: 30px; height: 36px; }
  .enc-av svg { width: 22px; height: 28px; }
  .enc-l3 { display: none; }
  .map-dlg { grid-template-columns: 1fr; }
  .level-banner { padding: 8px 18px 10px; top: 18%; }
  .next-level { font-size: 13px; padding: 8px 16px; }
  .app[data-theater="1"] .enc { display: none; }
}
@media (max-width: 420px) { .enc-l2 { display: none; } }
.app[data-theater="1"] .enc { bottom: auto; top: 56px; }
