:root {
  --bg: #0f0f12;
  --panel: #18181d;
  --panel-2: #212128;
  --line: #2e2e37;
  --text: #ececf1;
  --muted: #9a9aa6;
  --accent: #ff4d5e;
  --accent-2: #ff8a3d;
  --ok: #2fd07a;
  --warn: #f5a524;
  --err: #ff4d5e;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: #8ab4ff; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
small, .muted { color: var(--muted); }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.hidden { display: none !important; }

button, .btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font: inherit; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, border-color .15s, transform .05s;
}
button:hover, .btn:hover { border-color: #4a4a57; background: #2a2a33; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: #ff6573; }
button.danger { color: var(--err); }
button.small, .btn.small { padding: 4px 9px; font-size: .85rem; border-radius: 8px; }
button.icon { padding: 8px 10px; }
button.on { background: #2b3a2f; border-color: var(--ok); }
button.off { background: #3a2626; border-color: var(--err); }

input, select, textarea {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; width: 100%;
}
input[type=checkbox], input[type=range], input[type=color] { width: auto; }
input[type=color] { padding: 0; height: 32px; width: 40px; border-radius: 8px; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 0 0 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #131317; position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .8rem; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.rec { background: rgba(255, 77, 94, .15); border-color: var(--accent); color: #ffd4d8; }
.pill.ok { border-color: rgba(47, 208, 122, .5); color: #b7f5d2; }
.pill.warn { border-color: rgba(245, 165, 36, .6); color: #ffe1a8; }
.pill.err { border-color: var(--err); color: #ffc4ca; }
.blink { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: .85rem; }

.toast-box { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #26262e; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.4); max-width: min(560px, 92vw); }
.toast.err { border-color: var(--err); }

/* ---------- Studio ---------- */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; padding: 14px; align-items: start; }
@media (max-width: 980px) { .studio { grid-template-columns: 1fr; } }
.stage { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tile { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; border: 2px solid transparent; transition: border-color .1s; }
.tile.speaking { border-color: var(--ok); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #0b0b0d; }
.tile .name { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); padding: 3px 8px; border-radius: 8px; font-size: .85rem; display: flex; gap: 6px; align-items: center; }
.tile .badges { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.tile .avatar { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.4rem; font-weight: 700; color: #55555f; }
.tile.local video { transform: scaleX(-1); }
.stage.external .tile { aspect-ratio: auto; min-height: 96px; background: var(--panel); }

.side { display: flex; flex-direction: column; gap: 14px; }
.meter { height: 8px; background: #26262e; border-radius: 4px; overflow: hidden; position: relative; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, var(--ok) 0 70%, var(--warn) 70% 90%, var(--err) 90%); transition: width .05s linear; }
.meter.clip { outline: 2px solid var(--err); }

.recbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.timer { font-variant-numeric: tabular-nums; font-size: 1.6rem; font-weight: 700; letter-spacing: .02em; }
.bigrec { background: var(--accent); border: none; color: #fff; font-weight: 700; padding: 12px 18px; border-radius: 12px; }
.bigrec.stop { background: #3a3a44; }

.pads { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad { position: relative; height: 64px; border-radius: 10px; border: 1px solid rgba(255,255,255,.08); color: #fff; font-weight: 600; font-size: .85rem; padding: 6px; text-align: center; justify-content: center; line-height: 1.15; overflow: hidden; }
.pad .key { position: absolute; top: 4px; left: 6px; font-size: .7rem; opacity: .7; }
.pad .prog { position: absolute; left: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.85); width: 0; }
.pad.playing { box-shadow: 0 0 0 2px #fff inset; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tagbtn { border-radius: 99px; padding: 6px 12px; font-size: .85rem; border: 1px solid; background: transparent; }
.markers { max-height: 260px; overflow: auto; }
.marker { display: grid; grid-template-columns: 74px 1fr auto; gap: 8px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: .9rem; }
.marker .tc { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .82rem; }
.marker .lbl { display: flex; gap: 6px; align-items: center; min-width: 0; }
.marker .lbl span.txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dotc { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.kbd { font-family: ui-monospace, monospace; font-size: .75rem; border: 1px solid var(--line); border-bottom-width: 2px; padding: 0 5px; border-radius: 5px; color: var(--muted); }

.overlay { position: fixed; inset: 0; background: rgba(5,5,8,.85); display: grid; place-items: center; z-index: 50; padding: 16px; }
.overlay .card { width: min(520px, 100%); max-height: 92vh; overflow: auto; }
.preview { aspect-ratio: 16/9; background: #000; border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.progress { height: 6px; background: #26262e; border-radius: 3px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); width: 0; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 10px; color: var(--muted); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
details > summary { cursor: pointer; color: var(--muted); }
.primary .kbd { color: #fff; border-color: rgba(255,255,255,.5); }
.table-scroll { overflow-x: auto; }
