:root {
  --bg: #0d0d0f;
  --panel: #151518;
  --panel-2: #1c1c20;
  --line: #2a2a30;
  --text: #ececef;
  --muted: #9a9aa3;
  --accent: #ff6b3d;
  --accent-ink: #1a0b05;
  --ok: #3ccf8e;
  --warn: #f5b942;
  --danger: #ff5d5d;
  --radius: 10px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer; white-space: nowrap; font-weight: 500;
  text-decoration: none !important; color: var(--text);
}
.btn:hover { border-color: #3a3a42; background: #222227; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; }
.btn.ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); color: var(--ok); }
.btn.ok.active { background: var(--ok); color: #04140c; border-color: var(--ok); }
.btn.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); color: var(--warn); }
.btn.warn.active { background: var(--warn); color: #1d1300; border-color: var(--warn); }
.btn.danger { color: var(--danger); }
.btn svg { width: 16px; height: 16px; flex: none; }
.ico { display: inline-flex; vertical-align: middle; flex: none; }
.ico svg { width: 16px; height: 16px; }
.drop .ico svg { width: 20px; height: 20px; margin-right: 6px; }
.share-box > .ico { color: var(--muted); }

.input, textarea.input, select.input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); outline: none;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 44px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }

.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.chip.approved { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.chip.changes { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip.admin { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; letter-spacing: 0; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, #2a160d 0%, transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: grid; gap: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.login-card h1 { margin: 0; font-size: 20px; }
.login-card p { margin: 0; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- top bar ---------- */
.topbar { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 20; }
.topbar .title { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.topbar .title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: var(--muted); }

/* ---------- project grid ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 28px 20px 60px; }
.page h2 { margin: 0 0 4px; font-size: 22px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin-top: 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s; text-align: left; padding: 0; }
.card:hover { transform: translateY(-2px); border-color: #3a3a42; }
.thumb { aspect-ratio: 16/9; background: #000; position: relative; display: block; }
.thumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.thumb .badge { position: absolute; left: 8px; bottom: 8px; }
.card-body { padding: 12px 14px; display: grid; gap: 6px; }
.card-body strong { font-size: 15px; }
.card-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; margin-top: 22px; }

/* ---------- review layout ---------- */
.review { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: calc(100vh - 56px); }
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #08080a; }
.video-wrap { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; background: #000; user-select: none; }
.video-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.video-wrap.drawing canvas { pointer-events: auto; cursor: crosshair; }
.video-wrap .big-play { position: absolute; width: 72px; height: 72px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; cursor: pointer; }
.video-wrap .big-play svg { width: 30px; height: 30px; margin-left: 4px; }
.draw-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.7); padding: 6px 12px; border-radius: 99px; font-size: 12px; pointer-events: none; }

.controls { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.controls .time { font-size: 13px; color: var(--muted); min-width: 140px; }
.controls .time b { color: var(--text); font-weight: 500; }
.scrub { position: relative; flex: 1; height: 28px; cursor: pointer; display: flex; align-items: center; }
.scrub .track { position: absolute; left: 0; right: 0; height: 4px; border-radius: 4px; background: #33333a; overflow: hidden; }
.scrub .buffered { position: absolute; left: 0; top: 0; bottom: 0; background: #4a4a52; }
.scrub .progress { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); }
.scrub .handle { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #fff; transform: translateX(-50%); pointer-events: none; }
.scrub .marker { position: absolute; top: 50%; margin-top: -6px; width: 12px; height: 12px; border-radius: 50%; background: var(--warn); transform: translateX(-50%); border: 2px solid var(--panel); cursor: pointer; z-index: 2; }
.scrub .marker.resolved { background: #66666e; }
.scrub .marker.active { background: #fff; }
.scrub .hover-time { position: absolute; bottom: 26px; transform: translateX(-50%); background: #000; padding: 2px 6px; border-radius: 4px; font-size: 11px; pointer-events: none; }
.controls select.input { width: auto; height: 30px; padding: 0 8px; }
.volume { width: 80px; accent-color: var(--accent); }

.composer { border-top: 1px solid var(--line); background: var(--panel); padding: 12px 14px; display: grid; gap: 10px; }
.composer-row { display: flex; gap: 10px; align-items: flex-start; }
.composer textarea { flex: 1; min-height: 44px; max-height: 160px; }
.tc-toggle { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.tc-toggle.off { color: var(--muted); text-decoration: line-through; }
.composer-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tool.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { border-color: #fff; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* ---------- comments panel ---------- */
.comments { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.comments-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.comments-head h3 { margin: 0; font-size: 15px; flex: 1; }
.comments-head label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.comment-list { overflow-y: auto; flex: 1; padding: 8px; }
.comment { padding: 12px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; display: grid; gap: 6px; }
.comment:hover { background: var(--panel-2); }
.comment.active { border-color: var(--accent); background: var(--panel-2); }
.comment.resolved { opacity: .55; }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; color: #111; }
.comment-head .name { font-weight: 600; }
.comment-head .ago { color: var(--muted); font-size: 12px; margin-left: auto; }
.tc { font-family: var(--mono); font-size: 12px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); padding: 1px 7px; border-radius: 5px; border: 0; cursor: pointer; }
.comment-body { white-space: pre-wrap; word-break: break-word; }
.drawn { font-size: 12px; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.comment-actions { display: flex; gap: 2px; margin-left: -8px; }
.comment-actions .btn { height: 24px; padding: 0 8px; font-size: 12px; color: var(--muted); }
.comment-actions .btn:hover { color: var(--text); }
.replies { margin-left: 18px; padding-left: 12px; border-left: 2px solid var(--line); display: grid; gap: 4px; }
.replies .comment { padding: 8px; }
.reply-form { display: flex; gap: 6px; }
.reply-form textarea { min-height: 36px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #26262c; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.toast.error { border-color: var(--danger); color: #ffd3d3; }

/* ---------- admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; margin-top: 18px; }
.admin-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr.row { cursor: pointer; }
.admin-table tr.row:hover td { background: var(--panel); }
.admin-table tr.archived td { opacity: .5; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.row-flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.share-box { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 6px 6px 12px; }
.share-box code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 13px; }
.asset { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-top: 14px; overflow: hidden; }
.asset-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; flex-wrap: wrap; }
.asset-head .asset-title { font-weight: 600; font-size: 15px; flex: 1; min-width: 160px; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; margin-left: -6px; }
.asset-head .asset-title:hover { border-color: var(--line); }
.asset-head .asset-title:focus { border-color: var(--accent); outline: none; background: var(--bg); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--muted); }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 99px; background: #3a3a42; position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { left: 17px; }
.version-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.version-row .vnum { font-weight: 700; width: 34px; }
.version-row .fname { flex: 1; min-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-bar { height: 6px; border-radius: 6px; background: #33333a; overflow: hidden; flex: 1; min-width: 120px; }
.progress-bar > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 26px; text-align: center; color: var(--muted); margin-top: 14px; cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .review { grid-template-columns: 1fr; height: auto; }
  .stage { height: auto; }
  .video-wrap { aspect-ratio: 16/9; flex: none; }
  .comments { border-left: 0; border-top: 1px solid var(--line); min-height: 50vh; }
  .controls .time { min-width: 0; }
  .volume, .hide-mobile { display: none; }
  .topbar { height: auto; min-height: 56px; flex-wrap: wrap; padding: 8px 12px; }
}
