:root {
  --brand: #2563eb;
  --ink: #0f172a;
  --mut: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #fff;
  --red: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; color: var(--ink); background: var(--bg); }
.hidden { display: none !important; }
.mut { color: var(--mut); }
.small { font-size: 13px; }
.err { color: var(--red); font-size: 14px; min-height: 1em; margin: 8px 0 0; }
h1, h2 { letter-spacing: -.02em; }
h2 { font-size: 18px; margin: 0 0 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }

/* gate */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate-card { width: 100%; max-width: 360px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.gate-card h1 { margin: 0; font-size: 22px; }
.gate-card p { margin: 0; }
.logo-big { font-size: 40px; }

/* bar */
.bar { display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand .mut { font-weight: 500; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 14px; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 500; color: var(--mut); cursor: pointer; }
.tabs button.active { background: var(--bg); color: var(--ink); }

.tab { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }

/* inputs */
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
input, select { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
input[type=color] { height: 42px; padding: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { background: #f8fafc; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: none; color: var(--mut); }
.btn.ghost:hover { color: var(--ink); background: var(--bg); }
.btn.big { width: 100%; padding: 13px; font-size: 16px; margin-top: 18px; }
.row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.row .btn { flex: 1; }

.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 8px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--mut); cursor: pointer; }
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* record */
.rec-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.stage { position: relative; background: #0b0d12; border-radius: 14px; overflow: hidden; aspect-ratio: 16/9; }
.stage canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.hint { font-size: 13px; margin: 10px 2px 0; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 140px; font-weight: 800; color: #fff; background: rgba(0,0,0,.45); }
.rec-badge { position: absolute; top: 14px; left: 14px; display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.6); color: #fff; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-badge .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: pulse 1.2s infinite; }
.rec-badge.paused .dot { animation: none; background: #facc15; }
@keyframes pulse { 50% { opacity: .3; } }
.meter { height: 6px; background: var(--bg); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.meter div { height: 100%; width: 0; background: #22c55e; transition: width .08s; }
.bubble-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#reviewVid { width: 100%; border-radius: 10px; background: #000; aspect-ratio: 16/9; }
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress div { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.done-thumb { width: 100%; border-radius: 10px; margin-bottom: 10px; display: block; }

/* library */
.lib-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.lib-head h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.vcard { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.vcard .thumb { aspect-ratio: 16/9; background: #0b0d12 center/cover no-repeat; cursor: pointer; position: relative; }
.vcard .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.vcard .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.vcard .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vcard .s { font-size: 13px; color: var(--mut); }
.stats { display: flex; gap: 12px; font-size: 13px; margin-top: 4px; }
.stats b { font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--bg); color: var(--mut); }
.pill.hot { background: #dcfce7; color: #15803d; }
.vcard .acts { display: flex; border-top: 1px solid var(--line); }
.vcard .acts button { flex: 1; border: 0; background: none; padding: 10px 4px; font: inherit; font-size: 13px; font-weight: 600; color: var(--mut); cursor: pointer; }
.vcard .acts button:hover { background: var(--bg); color: var(--ink); }
.vcard .acts button + button { border-left: 1px solid var(--line); }

/* settings */
.settings { max-width: 520px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; padding: 20px; z-index: 20; }
.modal-card { width: 100%; max-width: 640px; max-height: 85vh; overflow: auto; position: relative; }
.x { position: absolute; top: 12px; right: 12px; border: 0; background: var(--bg); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; }
table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 10px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--mut); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 500; z-index: 30; }

@media (max-width: 900px) {
  .rec-layout { grid-template-columns: 1fr; }
  .tabs button { padding: 8px 10px; }
  .brand .mut { display: none; }
}
