:root {
  --bg: #0d1110; --panel: rgba(14, 18, 16, 0.78); --panel-solid: #141a17; --line: rgba(255, 255, 255, 0.09);
  --text: #eef1e8; --muted: #9aa596; --accent: #e8c15a; --accent-ink: #1d1806; --good: #9bd17a; --red: #ff6b5e;
  --r: 12px; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.55 "Noto Sans Thai", "Segoe UI", system-ui, sans-serif; }
[hidden] { display: none !important; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .92em; background: rgba(255,255,255,.07); padding: .1em .4em; border-radius: 6px; }
.muted { color: var(--muted); }
.grow { flex: 1; }

.btn { font: inherit; color: var(--text); background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; transition: background .15s, transform .05s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: rgba(255,255,255,.14); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #f1cf6f; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.round { width: 46px; height: 46px; border-radius: 50%; justify-content: center; padding: 0; background: var(--accent); color: var(--accent-ink); font-size: 16px; }

/* landing */
#landing { min-height: 100%; display: grid; place-items: center; padding: 40px 16px; background:
  radial-gradient(1200px 600px at 80% -10%, rgba(232,193,90,.12), transparent 60%),
  radial-gradient(900px 500px at -10% 110%, rgba(120,170,90,.14), transparent 60%), var(--bg); }
.hero { width: min(760px, 100%); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; color: var(--accent); }
.logo { width: 26px; height: 26px; border-radius: 50%; background: conic-gradient(from 200deg, #e8c15a, #8bb466, #e8c15a); }
h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.2; margin: 18px 0 12px; }
.lead { color: #c9d0c2; max-width: 640px; }
.drop { margin: 26px 0 16px; border: 2px dashed rgba(232,193,90,.45); border-radius: 18px; padding: 34px 20px; text-align: center; background: rgba(255,255,255,.03); transition: background .15s, border-color .15s; }
.drop.over { background: rgba(232,193,90,.1); border-color: var(--accent); }
.drop-ico { font-size: 34px; color: var(--accent); }
.drop-t { font-size: 19px; font-weight: 600; }
.drop-s { color: var(--muted); margin: 6px 0 12px; }
.pathbox { background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; color: #c9d0c2; font-size: 14px; }
.pathrow { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.pathrow code { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.facts { list-style: none; padding: 0; margin: 22px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.facts li { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; font-size: 13.5px; color: var(--muted); }
.facts b { display: block; color: var(--text); font-size: 14.5px; margin-bottom: 2px; }

/* loading */
#loading { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.loadbox { width: min(520px, 100%); text-align: center; }
.load-t { font-size: 18px; font-weight: 600; margin-bottom: 14px; overflow-wrap: anywhere; }
.bar { height: 10px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8bb466, var(--accent)); transition: width .2s; }
.load-s { color: var(--muted); margin-top: 10px; font-size: 14px; }

/* player */
#player { position: fixed; inset: 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.topbar { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; }
.topbar .meta { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; min-width: 0; font-size: 14px; }
.topbar .meta span { color: #c9d0c2; }
.side { position: absolute; top: 76px; left: 12px; width: 290px; max-height: calc(100% - 260px); display: flex; flex-direction: column; background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.side-h { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.side-h em { font-style: normal; color: var(--accent); margin-left: 4px; }
#plist { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; }
#plist li { padding: 7px 10px; border-radius: 9px; cursor: pointer; display: flex; flex-direction: column; }
#plist li:hover { background: rgba(255,255,255,.06); }
#plist li.on { background: rgba(232,193,90,.16); box-shadow: inset 3px 0 0 var(--accent); }
#plist li.dim { opacity: .55; }
#plist .pn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#plist .ps { font-size: 12.5px; color: var(--muted); }
.opts { border-top: 1px solid var(--line); padding: 8px 12px; display: grid; gap: 4px; font-size: 13.5px; }
.opts label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
body.side-closed #plist, body.side-closed .opts { display: none; }
body.side-closed .side { width: auto; }
#mini { position: absolute; top: 76px; right: 12px; width: 220px; height: 220px; border-radius: 50%; cursor: crosshair; box-shadow: 0 6px 30px rgba(0,0,0,.45); }
.tcard { position: absolute; right: 12px; top: 308px; padding: 10px 14px; width: 220px; background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; }
.tc-n { font-size: 18px; font-weight: 700; }
.tc-s { font-size: 13.5px; color: #c9d0c2; }
.controls { position: absolute; left: 12px; right: 12px; bottom: 12px; padding: 10px 14px 8px; background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; }
.timeline { position: relative; }
#seek { width: 100%; accent-color: var(--accent); height: 22px; }
#markers { position: absolute; left: 8px; right: 8px; top: 0; height: 6px; pointer-events: none; }
#markers i { position: absolute; top: -3px; width: 3px; height: 9px; margin-left: -1px; background: var(--red); border-radius: 2px; }
.crow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.time { font-variant-numeric: tabular-nums; color: #c9d0c2; }
.spd { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }
select, input:not([type]) { font: inherit; color: var(--text); background: #1d2420; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.seg { display: inline-flex; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { font: inherit; font-size: 13.5px; color: var(--muted); background: none; border: 0; padding: 5px 11px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel-solid); color: var(--text); padding: 0; width: min(640px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.dlg { padding: 20px 22px; }
.dlg h2 { margin: 0 0 6px; font-size: 20px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 14px 0 10px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; color: var(--muted); }
.grid label.chk { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.tin { display: flex; gap: 6px; } .tin input { width: 90px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#ex-video { width: 100%; border-radius: 10px; margin-top: 8px; background: #000; }
#ex-progress .bar { margin: 18px 0 10px; }

#toast { position: fixed; left: 50%; bottom: 170px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #1f2622; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; transition: all .25s; max-width: calc(100% - 32px); text-align: center; z-index: 10; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .side { display: none; }
  #mini { width: 140px; height: 140px; }
  .tcard { top: 226px; width: 140px; }
  .topbar .meta span { display: none; }
  .hint { display: none; }
  .grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.credits { color: var(--muted); font-size: 12.5px; margin-top: 18px; }
.credits a { color: #c9d0c2; }
