:root {
  --bg: #121110;
  --panel: #1b1a18;
  --panel-2: #23211f;
  --line: #2f2c29;
  --text: #ece7df;
  --muted: #9a938a;
  --accent: #f2a93b;
  --accent-ink: #1a1206;
  --danger: #e5604f;
  --ok: #7cc48a;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; min-height: 100vh; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 13.5px; }

/* brand: a strip of film sprocket holes beside the word */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: 14px; }
.brand-lg { font-size: 18px; margin-bottom: 4px; }
.sprocket { width: 14px; height: 22px; border-radius: 3px; background:
  radial-gradient(circle at 50% 4px, var(--bg) 2px, transparent 2.5px) 0 0 / 100% 7px repeat-y, var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #47423c; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { filter: brightness(1.07); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: transparent; }
.btn-danger { color: var(--danger); }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
input, select { height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; padding: 0 11px; }
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* gate */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(380px, 100%); display: grid; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.gate-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.gate-card input { width: 100%; height: 42px; }
.gate-card .btn { height: 42px; }
.gate-card p { margin: 0; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px max(20px, env(safe-area-inset-left)); background: rgba(18,17,16,.88); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.usage { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-left: 6px; }
.spacer { flex: 1; }
#search { width: 200px; }
.upload-btn { position: relative; }
.hint { margin: 12px 20px 0; font-size: 12.5px; color: var(--muted); }
.hint:empty { display: none; }

/* grid */
main { padding: 18px 20px 120px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; user-select: none; -webkit-user-drag: element; }
.card:hover { border-color: #4a443d; }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card.dragging { opacity: .5; }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #0b0a09; display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.thumb .ph { color: #4b463f; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.dur { position: absolute; right: 7px; bottom: 7px; background: rgba(0,0,0,.72); color: #fff; padding: 2px 6px; border-radius: 4px; font-family: var(--mono); font-size: 11px; }
.card-body { padding: 10px 12px 11px; }
.card-name { font-weight: 560; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; color: var(--muted); font-family: var(--mono); font-size: 11.5px; }

.empty { text-align: center; padding: 12vh 20px; }
.empty h2 { margin: 18px 0 4px; font-size: 18px; }
.empty-frame { width: 120px; height: 76px; margin: 0 auto; border: 2px dashed var(--line); border-radius: 10px; display: grid; place-items: center; }

/* drop overlay */
.drop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(18,17,16,.78); pointer-events: none; }
.drop div { border: 2px dashed var(--accent); color: var(--accent); border-radius: 18px; padding: 50px 70px; font-weight: 650; font-size: 20px; letter-spacing: .02em; }

/* upload tray */
.tray { position: fixed; right: 18px; bottom: 18px; z-index: 20; width: min(400px, calc(100vw - 36px)); max-height: 60vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.45); }
.tray-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 8px 16px; }
.tray-head strong { flex: 1; font-size: 14px; }
.tray-note { margin: 0 16px 8px; font-size: 12px; }
.tray ul { list-style: none; margin: 0; padding: 0 8px 10px; overflow: auto; }
.tray.collapsed ul, .tray.collapsed .tray-note { display: none; }
.up { padding: 8px; border-radius: 8px; }
.up + .up { border-top: 1px solid var(--line); }
.up-row { display: flex; align-items: center; gap: 8px; }
.up-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.up-status { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.up.done .up-status { color: var(--ok); }
.up.failed .up-status { color: var(--danger); }
.bar { height: 4px; border-radius: 4px; background: var(--panel-2); margin-top: 7px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.up.done .bar i { background: var(--ok); }
.up .icon-btn { width: 26px; height: 26px; font-size: 14px; }

/* player */
.player { width: min(1280px, 96vw); max-height: 94vh; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); }
.player::backdrop { background: rgba(5,5,5,.82); }
.player-inner { position: relative; display: grid; grid-template-columns: 1fr 300px; }
.player video { width: 100%; max-height: 86vh; background: #000; display: block; }
.player-side { padding: 54px 18px 18px; display: flex; flex-direction: column; gap: 14px; border-left: 1px solid var(--line); }
.name-input { width: 100%; font-weight: 600; font-size: 15px; height: 40px; padding-right: 36px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; color: var(--muted); }
.facts dd { margin: 0; color: var(--text); text-align: right; }
.actions { display: grid; gap: 8px; }
.close { position: absolute; top: 10px; right: 10px; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 54px; font-size: 28px; background: rgba(0,0,0,.4); color: #fff; }
.prev { left: 8px; }
.next { right: 308px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 550; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }

@media (max-width: 760px) {
  .top { padding: 12px 14px; }
  .brand { order: 0; } .spacer { order: 1; } .upload-btn { order: 2; } #logout { order: 3; padding: 0 6px; }
  #search { order: 10; flex: 1 1 0; width: auto; min-width: 0; }
  #sort { order: 11; flex: 0 0 auto; }
  .usage { display: none; }
  main { padding: 14px 14px 140px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .player-inner { grid-template-columns: 1fr; }
  .player-side { border-left: 0; border-top: 1px solid var(--line); padding-top: 18px; }
  .next { right: 8px; }
  .nav { top: 30%; }
  .tray { right: 10px; left: 10px; bottom: 10px; width: auto; }
}
