:root {
  --bg: #f4f5f7; --panel: #ffffff; --text: #16181d; --muted: #646a76; --line: #e2e4e9;
  --accent: #6d4aff; --accent-soft: #efeaff; --ok: #138a4a; --warn: #b86e00; --err: #c62828;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --panel: #171a20; --text: #e8eaee; --muted: #9aa1ad; --line: #2a2f38;
          --accent: #9b84ff; --accent-soft: #241f3d; --ok: #3ccf7f; --warn: #f0a63a; --err: #ff6b6b;
          --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.hidden { display: none !important; }
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 16px 10px;
  background: var(--panel); border-right: 1px solid var(--line); }
.nav .brand { font-weight: 700; font-size: 16px; padding: 4px 10px 14px; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 8px; display: flex;
  justify-content: space-between; align-items: center; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav #logout { margin-top: auto; }
.view { padding: 22px 26px 60px; max-width: 1280px; width: 100%; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--err); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); }
tr:last-child td { border-bottom: none; }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 12px;
  border-radius: 8px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--err); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; }
textarea { width: 100%; min-height: 160px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
label.f > span.h { font-size: 11.5px; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--bg);
  border: 1px solid var(--line); }
.pill.ok { color: var(--ok); } .pill.err { color: var(--err); } .pill.warn { color: var(--warn); }
.badge { background: var(--err); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 11.5px; }
.clips { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.clip video { width: 100%; aspect-ratio: 9/16; background: #000; border-radius: 8px; }
.clip .t { font-weight: 600; margin: 6px 0 2px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #222; color: #fff;
  padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: 90vw; }
.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 320px; display: flex; flex-direction: column; gap: 12px; }
.editor { position: relative; display: inline-block; max-width: 100%; user-select: none; touch-action: none; }
.editor img { display: block; max-width: 100%; border-radius: 6px; }
.box { position: absolute; border: 2px solid; cursor: move; }
.box.cam { border-color: #22c55e; background: rgba(34,197,94,.12); }
.box.game { border-color: #3b82f6; background: rgba(59,130,246,.10); }
.box .lbl { position: absolute; top: 0; left: 0; font-size: 11px; color: #fff; padding: 1px 5px; background: rgba(0,0,0,.6); }
.box .rz { position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; background: #fff; border: 2px solid #000;
  cursor: nwse-resize; border-radius: 3px; }
.frames { display: flex; gap: 6px; margin: 8px 0; }
.frames img { width: 120px; border-radius: 4px; cursor: pointer; opacity: .6; }
.frames img.sel { opacity: 1; outline: 2px solid var(--accent); }
details summary { cursor: pointer; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; white-space: pre-wrap; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: sticky; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; z-index: 5;
    border-right: none; border-bottom: 1px solid var(--line); }
  .nav .brand { display: none; }
  .nav a { white-space: nowrap; padding: 6px 10px; }
  .nav #logout { margin: 0; }
  .view { padding: 16px; }
  table { display: block; overflow-x: auto; }
}
