:root {
  --bg: #121a17; --panel: #18231f; --line: #2a3a34; --text: #e7efe9; --muted: #8fa39a;
  --mesh: #4fc3f7; --club: #ffc64a; --accent: #3ddc97; --danger: #ff7b72;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; height: 100dvh; }
h2 { font-size: 17px; font-weight: 600; margin: 18px 0 8px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
p { margin: 6px 0; }
code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

header { display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; color: var(--text); text-decoration: none; white-space: nowrap; }
#crumb { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
header .primary { margin-left: auto; }

select, button, input[type=text], input[type=number], .filebtn { font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; }
button, .filebtn { cursor: pointer; min-width: 40px; min-height: 38px; display: inline-block; }
button:active { background: var(--line); }
button:disabled { opacity: .5; cursor: default; }
button.on { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #06281a; font-weight: 600; }
button.ghost { border-color: transparent; background: none; font-size: 22px; line-height: 1; padding: 2px 8px; }
button.danger { color: var(--danger); border-color: var(--danger); background: none; margin: 16px 0 24px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.view { flex: 1; min-height: 0; }
.scroll { overflow-y: auto; padding: 4px 14px calc(20px + env(safe-area-inset-bottom)); max-width: 760px; width: 100%; margin: 0 auto; }
.lead { color: var(--muted); margin: 12px 0; }
.hint { color: var(--muted); font-size: 13px; }
.err { color: var(--danger); font-size: 14px; min-height: 0; }
.err:empty { display: none; }

/* danh sách */
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { display: flex; gap: 12px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  color: inherit; text-decoration: none; }
.card:active { border-color: var(--accent); }
.thumb { width: 64px; height: 96px; border-radius: 8px; background: #0c1210; overflow: hidden; flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; align-items: flex-start; }
.meta strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.meta span { color: var(--muted); font-size: 13px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 10px; border: 1px solid var(--line); }
.meta .chip.wait, .chip.wait { color: var(--club); border-color: var(--club); }
.meta .chip.ok, .chip.ok { color: var(--accent); border-color: var(--accent); }
.meta .chip.demo { color: var(--muted); }

/* cú mới */
.drop { display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; cursor: pointer;
  padding: 34px 16px; border: 1.5px dashed var(--line); border-radius: 14px; background: var(--panel); }
.drop strong { font-size: 17px; color: var(--accent); }
.drop span { color: var(--muted); font-size: 13px; max-width: 320px; }
.tips { color: var(--muted); font-size: 13px; padding-left: 18px; }
.trimVideo { background: #000; border-radius: 10px; overflow: hidden; display: flex; justify-content: center; }
.trimVideo video { max-width: 100%; max-height: 46dvh; display: block; }
.track { position: relative; height: 44px; margin: 12px 10px 4px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; touch-action: none; cursor: pointer; }
.sel { position: absolute; top: 0; bottom: 0; background: rgba(61, 220, 151, .22); border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); pointer-events: none; }
.handle { position: absolute; top: -5px; bottom: -5px; width: 22px; margin-left: -11px; border-radius: 6px; background: var(--accent); cursor: ew-resize; }
.handle::after { content: ""; position: absolute; left: 9px; top: 14px; bottom: 14px; width: 4px; border-radius: 2px; background: #06281a; }
.playhead { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: #fff; pointer-events: none; }
.trimInfo { justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.trimInfo .bad { color: var(--danger); }
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form input, .form select { width: 100%; }

/* cú đang chờ */
.status { display: flex; align-items: center; gap: 10px; margin: 12px 0; color: var(--muted); font-size: 13px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 12px 0; }
.box p { color: var(--muted); font-size: 13px; }
.box pre { background: #0c1210; padding: 10px; border-radius: 8px; overflow-x: auto; margin: 8px 0; }

/* trang xem 2 màn */
#vSwing { display: flex; flex-direction: column; }
#viewer { flex: 1; min-height: 0; display: flex; flex-direction: column; }
main { flex: 1; min-height: 0; display: grid; grid-template-rows: 1fr 1fr; gap: 1px; background: var(--line); }
@media (orientation: landscape) and (min-width: 700px) { main { grid-template-rows: none; grid-template-columns: 1fr 1fr; } }
.pane { position: relative; background: var(--bg); min-height: 0; min-width: 0; overflow: hidden; }
.tag { position: absolute; left: 8px; top: 6px; z-index: 3; font-size: 12px; color: var(--muted);
  background: rgba(18, 26, 23, .7); padding: 2px 8px; border-radius: 10px; pointer-events: none; }
#paneVideo .tag { top: auto; bottom: 8px; }
.fit { position: absolute; inset: 0; }
.fit video, .fit canvas { position: absolute; left: 0; top: 0; }
#fitVideo video { width: 100%; height: 100%; object-fit: contain; background: #000; }
#hudVideo, #glVideo { pointer-events: none; }
#fit3d canvas { width: 100%; height: 100%; touch-action: none; }
#hud3d { pointer-events: none; }
.views { position: absolute; right: 8px; bottom: 8px; z-index: 3; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.views button { font-size: 12px; padding: 4px 8px; min-height: 30px; background: rgba(24, 35, 31, .85); }

footer { border-top: 1px solid var(--line); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row + .row { margin-top: 6px; }
.grow { flex: 1; }
#seek { flex: 1; min-width: 0; accent-color: var(--accent); height: 28px; }
#clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; white-space: nowrap; }
.opts { flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.opts label { display: flex; align-items: center; gap: 5px; }
.opts select { padding: 3px 6px; }
#note { font-size: 12px; color: var(--club); margin-top: 4px; }
#note:empty { display: none; }
button.link { border: none; background: none; color: var(--danger); font-size: 12px; min-height: 28px; padding: 2px 6px; margin-left: auto; }
.bar { height: 8px; border-radius: 4px; background: #0c1210; overflow: hidden; margin: 10px 0 4px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.meta .chip.bad, .chip.bad { color: var(--danger); border-color: var(--danger); }

/* xem riêng một màn + toàn màn hình (các nút điều khiển vẫn nằm dưới) */
.solo { position: absolute; right: 8px; top: 6px; z-index: 4; min-width: 36px; min-height: 36px; padding: 2px 8px; font-size: 18px;
  background: rgba(24, 35, 31, .85); }
main.solo-video, main.solo-3d { grid-template-rows: 1fr; grid-template-columns: 1fr; }
main.solo-video #pane3d, main.solo-3d #paneVideo { display: none; }
body.immersive header { display: none; }
body.immersive footer { padding-top: 6px; }
body.immersive #delSwing2 { display: none; }
#full { font-size: 18px; padding: 2px 8px; }
@media (orientation: landscape) and (max-height: 520px) {      /* điện thoại xoay ngang: gom điều khiển cho gọn */
  footer { padding: 4px 10px calc(4px + env(safe-area-inset-bottom)); }
  footer .row + .row { margin-top: 2px; }
  button { min-height: 32px; }
}
