:root {
  --bg: #0E1116;
  --panel: #161B22;
  --panel-2: #1D232C;
  --line: #2A323D;
  --text: #E8ECF1;
  --muted: #8B96A5;
  --accent: #FF6B2C;
  --accent-2: #FFB547;
  --ok: #3DDC97;
  --err: #FF5A6A;
  --sel: #FF6B2C;
  --unsel: #3A4757;
  --radius: 14px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
body { padding-bottom: env(safe-area-inset-bottom); }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: .95rem; margin-top: 1.1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
code { background: var(--panel-2); padding: 0 .3em; border-radius: 4px; }
a { color: var(--accent-2); }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; background: rgba(14,17,22,.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); text-decoration: none;
  font-weight: 800; font-style: italic; letter-spacing: .04em; font-size: 1.15rem; }
.brand b { color: var(--accent); margin-left: .15rem; }
.ball { width: 22px; height: 22px; border-radius: 50%; background:
  radial-gradient(circle at 30% 30%, #fff 0 18%, transparent 19%), var(--accent); box-shadow: 0 0 0 2px #0E1116 inset; }
.top-right { display: flex; align-items: center; gap: .6rem; }
.icon-btn { background: none; border: 0; padding: .35rem; border-radius: 10px; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.icon-btn:hover svg { stroke: var(--text); }
.queue { font-size: .8rem; color: var(--accent-2); background: rgba(255,181,71,.12); padding: .2rem .55rem; border-radius: 99px; }

/* layout */
.view { max-width: 1280px; margin: 0 auto; padding: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.section-title { margin: 1.4rem 0 .7rem; }
.row { display: flex; align-items: center; }
.row.gap { gap: .6rem; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 160px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .6rem 0; }

.game-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1rem; align-items: start; }
.col-right { position: sticky; top: 4.4rem; }
@media (max-width: 980px) { .game-grid { grid-template-columns: 1fr; } .col-right { position: static; } }

/* form */
.field { display: flex; flex-direction: column; gap: .3rem; margin: .7rem 0; }
.field > span { font-size: .82rem; color: var(--muted); }
.field.inline { margin: .3rem 0; }
.field.narrow { width: 120px; }
input, select, textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: .6rem .7rem; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=range] { padding: 0; accent-color: var(--accent); border: 0; background: none; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.check { display: inline-flex; align-items: center; gap: .45rem; font-size: .9rem; cursor: pointer; margin: .3rem 0; }
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem 1rem; font: inherit; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: #3d4756; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #140A05; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: .38rem .7rem; font-size: .85rem; }
.btn.big { width: 100%; padding: .9rem; font-size: 1.05rem; margin-top: .6rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger { color: var(--err); }

.tabs, .seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.tabs { display: flex; margin-bottom: .4rem; }
.tab, .seg button { flex: 1; white-space: nowrap; background: none; border: 0; color: var(--muted); padding: .5rem .8rem; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; }
.seg button { padding: .32rem .65rem; font-size: .85rem; }
.tab.active, .seg button.active { background: var(--panel-2); color: var(--text); }

.drop { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 120px; border: 2px dashed var(--line);
  border-radius: var(--radius); color: var(--muted); cursor: pointer; padding: 1rem; margin: .6rem 0; }
.drop.over { border-color: var(--accent); color: var(--text); }

.progress { position: relative; height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: .6rem 0; }
.progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; transition: width .4s; }
.progress span { position: absolute; right: 0; top: 10px; font-size: .75rem; color: var(--muted); }

/* media browser */
.browser { border: 1px solid var(--line); border-radius: 10px; max-height: 340px; overflow: auto; margin-top: .6rem; }
.browser .crumbs { padding: .55rem .7rem; font-size: .85rem; color: var(--muted); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.browser .crumbs a { cursor: pointer; }
.browser .item { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem .7rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.browser .item:hover { background: var(--panel-2); }
.browser .item:last-child { border-bottom: 0; }
.browser .empty { padding: 1rem; color: var(--muted); }

/* game list */
.game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.game { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; cursor: pointer; display: flex; flex-direction: column; gap: .35rem; }
.game:hover { border-color: #3d4756; }
.game .t { font-weight: 700; }
.status-pill { font-size: .75rem; font-weight: 700; padding: .18rem .55rem; border-radius: 99px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.status-pill.ready { color: var(--ok); background: rgba(61,220,151,.12); }
.status-pill.error { color: var(--err); background: rgba(255,90,106,.12); }
.status-pill.busy { color: var(--accent-2); background: rgba(255,181,71,.12); }

.game-head { display: flex; align-items: center; gap: .7rem; margin-bottom: 1rem; }
.title-input { font-size: 1.25rem; font-weight: 800; background: transparent; border-color: transparent; padding: .3rem .4rem; }
.title-input:hover { border-color: var(--line); }

.busy-row { display: flex; align-items: center; gap: .7rem; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* player */
.player-card video { width: 100%; max-height: 56vh; background: #000; border-radius: 10px; display: block; }
#timeline { width: 100%; height: 56px; display: block; margin: .6rem 0; cursor: pointer; border-radius: 8px; background: var(--bg); }

/* clips */
.auto-row { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; margin: .3rem 0 .8rem; }
.auto-row .field { flex: 1 1 220px; }
.clip-list { display: flex; flex-direction: column; gap: .55rem; }
.clip { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: .75rem; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: .55rem; }
.clip.sel { border-color: rgba(255,107,44,.65); box-shadow: inset 3px 0 0 var(--sel); }
.clip.playing { outline: 2px solid var(--accent-2); }
.thumb { position: relative; width: 132px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: #000; cursor: pointer; border: 0; padding: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .play { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.25); opacity: 0; transition: opacity .15s; color: #fff; font-size: 1.6rem; }
.thumb:hover .play { opacity: 1; }
.thumb .dur { position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.75); font-size: .72rem; padding: 0 .3rem; border-radius: 4px; }
.clip-main { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.clip-top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.clip-top .time { font-weight: 700; font-variant-numeric: tabular-nums; }
.stars { color: var(--accent-2); letter-spacing: 1px; font-size: .85rem; }
.tag { font-size: .7rem; padding: .05rem .45rem; border-radius: 99px; background: rgba(255,255,255,.07); color: var(--muted); }
.tag.hot { background: rgba(255,107,44,.16); color: var(--accent); }
.clip-ctrl { display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; }
.toggle { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; cursor: pointer; user-select: none; }
.nudge { display: inline-flex; align-items: center; gap: .2rem; font-size: .78rem; color: var(--muted); }
.nudge button { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: .1rem .42rem; cursor: pointer; font: inherit; font-size: .78rem; }
.cap { padding: .38rem .55rem; font-size: .88rem; }
.del { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .8rem; }
.del:hover { color: var(--err); }
@media (max-width: 560px) {
  .clip { grid-template-columns: 96px minmax(0, 1fr); gap: .55rem; }
  .thumb { width: 96px; }
  .nudge { display: none; }
  .clip.playing .nudge, .clip:focus-within .nudge { display: inline-flex; }
  .tab { padding: .5rem .4rem; font-size: .88rem; }
}

.fold summary { list-style: none; cursor: pointer; display: flex; flex-direction: column; gap: .15rem; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary h2 { margin: 0; }
.fold summary h2::before { content: "▸ "; color: var(--accent); }
.fold[open] summary h2::before { content: "▾ "; }
.fold[open] summary { margin-bottom: .6rem; }
.report { list-style: none; padding: 0; margin: .6rem 0 0; font-size: .85rem; }
.report li { padding: .25rem 0; border-bottom: 1px dashed var(--line); }
.report .ok { color: var(--ok); }
.report .bad { color: var(--err); }

/* reel settings */
.layouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .4rem; }
.lay { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .3rem; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .15rem; font: inherit; }
.lay small { color: var(--muted); font-size: .72rem; }
.lay.active { border-color: var(--accent); background: rgba(255,107,44,.08); }
.ph { width: 34px; height: 60px; border-radius: 5px; background: linear-gradient(#2c3440, #1c222a); position: relative; overflow: hidden; margin-bottom: .3rem; }
.ph .band { position: absolute; left: 0; right: 0; top: 50%; height: 19px; transform: translateY(-50%); background: linear-gradient(135deg, #e07a3a, #c4562a); }
.ph .band.tall { height: 42px; }
.ph .band.full { height: 100%; }
.logo-prev { width: 44px; height: 44px; object-fit: contain; background: var(--bg); border-radius: 8px; border: 1px solid var(--line); }

/* renders */
.render-list { display: flex; flex-direction: column; gap: .8rem; }
.render { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: .7rem; }
.render video { width: 100%; max-height: 60vh; aspect-ratio: 9/16; background: #000; border-radius: 8px; display: block; margin: .5rem 0; }
.render .meta { font-size: .82rem; color: var(--muted); }
.empty-note { color: var(--muted); font-size: .9rem; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(560px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.dlg { padding: 1.2rem; }

.toast { position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line);
  padding: .7rem 1.1rem; border-radius: 12px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 92vw; }
.toast.err { border-color: var(--err); color: #ffd6da; }

/* login + team */
.login-card { max-width: 400px; margin: 8vh auto 0; text-align: left; }
.login-ball { width: 46px; height: 46px; border-radius: 50%; margin-bottom: .8rem;
  background: radial-gradient(circle at 30% 30%, #fff 0 16%, transparent 17%), var(--accent); }
.login-err { color: var(--err); font-size: .9rem; margin: .3rem 0; }
.user-chip { display: inline-flex; align-items: center; gap: .45rem; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 99px; padding: .2rem .7rem .2rem .25rem; cursor: pointer; font: inherit; font-size: .85rem; font-weight: 600; }
.avatar, .av { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: .72rem; font-weight: 800;
  color: #140A05; background: var(--accent-2); flex: none; }
.av { width: 20px; height: 20px; font-size: .64rem; }
.users { list-style: none; padding: 0; margin: .4rem 0 .8rem; }
.users li { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.users li .grow { min-width: 120px; }
.activity { list-style: none; padding: 0; margin: .3rem 0 0; font-size: .86rem; max-height: 320px; overflow: auto; }
.activity li { display: flex; gap: .55rem; align-items: flex-start; padding: .38rem 0; border-bottom: 1px dashed var(--line); }
.activity .when { color: var(--muted); font-size: .76rem; white-space: nowrap; margin-left: auto; padding-left: .5rem; }
.edited { font-size: .74rem; color: var(--muted); display: inline-flex; align-items: center; gap: .3rem; }
.by { font-size: .78rem; color: var(--muted); }
.live { font-size: .75rem; color: var(--ok); }
.saving { opacity: .7; }
