/* app.css — Multi Perspective Recorder UI. Vanilla, portable, cinematic dark theme. */
:root {
  --bg: #090b10;
  --bg-2: #0e1219;
  --panel: rgba(22, 27, 36, 0.72);
  --panel-solid: #161b24;
  --panel-2: #1b212c;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eaf0f7;
  --muted: #93a1b3;
  --accent: #6c5cff;
  --accent-2: #00e0b8;
  --accent-3: #ff4d8d;
  --danger: #ff4d5e;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --glow: 0 0 0 1px rgba(108, 92, 255, 0.35), 0 8px 30px rgba(108, 92, 255, 0.35);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 78% -12%, #1c2348 0%, rgba(28, 35, 72, 0) 60%),
    radial-gradient(900px 600px at 8% 8%, #0c2a2a 0%, rgba(12, 42, 42, 0) 55%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  background-attachment: fixed;
}

/* faint engineering grid behind everything */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 75%);
}
.wrap, .topbar { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: #9b8eff; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 16, 0.6);
  backdrop-filter: blur(14px) saturate(140%);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; letter-spacing: .2px; display: flex; align-items: center; gap: 11px; font-size: 15px; }
.brand .dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
  box-shadow: 0 0 16px rgba(108, 92, 255, 0.8);
  animation: spin 6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.brand small { color: var(--muted); font-weight: 500; letter-spacing: .3px; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- layout */
.wrap { max-width: 1180px; margin: 0 auto; padding: 32px 20px 90px; }
h1 {
  font-size: clamp(26px, 4vw, 40px); margin: 6px 0 8px; line-height: 1.08; letter-spacing: -0.5px;
  background: linear-gradient(120deg, #fff 20%, #b9c4ff 60%, #7ef0d8 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
h2 { font-size: 19px; margin: 30px 0 14px; letter-spacing: -0.2px; }
.lead { color: var(--muted); margin: 0 0 26px; max-width: 64ch; font-size: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}
.card::before { /* top sheen */
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
}
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .grid.cols-2 { grid-template-columns: 1fr; } }

label { display: block; font-size: 12.5px; color: var(--muted); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .6px; }
input[type=text], select {
  width: 100%; padding: 12px 14px; background: rgba(11, 14, 20, 0.7); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px; font-size: 15px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type=text]:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108, 92, 255, 0.18); }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  padding: 11px 18px; border-radius: 11px; border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  color: var(--text); font-size: 15px; font-weight: 600; letter-spacing: .2px;
  transition: transform .06s ease, background .15s ease, border-color .15s ease, box-shadow .2s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--line-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #8a7bff 55%, var(--accent-2)); border-color: transparent; color: #fff; }
.btn.primary:hover { box-shadow: var(--glow); filter: brightness(1.05); }
.btn.danger { background: linear-gradient(135deg, var(--danger), #ff7a86); border-color: transparent; color: #fff; }
.btn.danger:hover { box-shadow: 0 0 0 1px rgba(255,77,94,.4), 0 8px 30px rgba(255,77,94,.4); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.big { padding: 15px 26px; font-size: 16px; border-radius: 12px; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ----------------------------------------------------------------- pills */
.pill { font-size: 12px; padding: 4px 11px; border-radius: 999px; background: rgba(255,255,255,0.05); border: 1px solid var(--line-strong); color: var(--muted); font-weight: 600; letter-spacing: .3px; }
.pill.live { color: #fff; background: var(--danger); border-color: transparent; position: relative; padding-left: 22px; animation: recpulse 1.4s ease-in-out infinite; }
.pill.live::before { content: ''; position: absolute; left: 9px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px #fff; }
@keyframes recpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,77,94,.55); } 50% { box-shadow: 0 0 0 7px rgba(255,77,94,0); } }
.pill.ok { color: #032; background: var(--accent-2); border-color: transparent; }

/* ---------------------------------------------------------- video stage */
.preview, .tile video, .program video { width: 100%; display: block; background: #000; }
.preview { aspect-ratio: 16/9; object-fit: cover; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 10px 40px rgba(0,0,0,.5); }

.recorder-stage { position: relative; }
.recorder-stage::after { /* cinematic vignette + corner ticks */
  content: ''; position: absolute; inset: 0; border-radius: 12px; pointer-events: none;
  box-shadow: inset 0 0 80px rgba(0,0,0,.55);
}
.recorder-stage .overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px; background: rgba(5, 7, 12, 0.62); border-radius: 12px; text-align: center;
  backdrop-filter: blur(2px);
}
.countdown { font-size: 92px; font-weight: 800; letter-spacing: 2px; line-height: 1;
  background: linear-gradient(120deg, #fff, var(--accent-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  animation: pop .9s ease-in-out infinite; }
@keyframes pop { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.12); opacity: 1; } }

/* ---------------------------------------------------------------- roster */
.roster { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.roster li { display: flex; align-items: center; gap: 11px; padding: 11px 13px; background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: 11px; transition: background .15s ease; }
.roster li:hover { background: rgba(255,255,255,0.06); }
.roster .who { font-weight: 600; }
.dotstat { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dotstat.recording { background: var(--danger); box-shadow: 0 0 0 0 rgba(255,77,94,.6); animation: recpulse 1.3s infinite; }
.dotstat.uploading { background: #ffb020; box-shadow: 0 0 8px #ffb020; }
.dotstat.done { background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }

/* ----------------------------------------------------------------- PLAYER */
.player { display: grid; grid-template-columns: 1fr 320px; gap: 18px; }
@media (max-width: 900px) { .player { grid-template-columns: 1fr; } }
.program { position: relative; background: #000; border-radius: 14px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.55), inset 0 0 0 1px rgba(255,255,255,.06); aspect-ratio: 16/9; }
.program video, .program canvas { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
select { padding: 8px 10px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: 8px; font-size: 13px; }
input[type=range] { accent-color: var(--accent); }
.program::after { content: ''; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(0,0,0,.5); }
.program .label {
  position: absolute; left: 14px; top: 14px; z-index: 2;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  padding: 6px 13px; border-radius: 9px; font-size: 13px; font-weight: 700; letter-spacing: .3px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.program .label::before { content: '● ON AIR  '; opacity: .85; font-size: 10px; letter-spacing: 1px; }

.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; align-content: start; max-height: 72vh; overflow: auto; padding-right: 4px; }
@media (max-width: 900px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
.gallery::-webkit-scrollbar { width: 8px; }
.gallery::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
.tile {
  position: relative; cursor: pointer; border-radius: 11px; overflow: hidden; background: #000;
  box-shadow: inset 0 0 0 1.5px var(--line-strong); aspect-ratio: 16/9;
  transition: transform .12s ease, box-shadow .15s ease, opacity .2s ease;
}
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile:hover { transform: translateY(-2px) scale(1.015); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tile.inactive { opacity: .42; filter: grayscale(0.4); }
.tile.on { box-shadow: 0 0 0 2px var(--danger), 0 0 22px rgba(255,77,94,.5); }
.tile .name { position: absolute; left: 7px; bottom: 7px; right: 7px; font-size: 11px; font-weight: 600; background: rgba(0,0,0,.62); padding: 3px 7px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; backdrop-filter: blur(4px); }
.tile .live { position: absolute; right: 7px; top: 7px; font-size: 9px; font-weight: 800; letter-spacing: .5px; padding: 2px 7px; border-radius: 999px; background: var(--danger); color: #fff; display: none; animation: recpulse 1.3s infinite; }
.tile.on .live { display: block; }

/* ------------------------------------------------------------- transport */
.transport { margin-top: 16px; }
.scrub { width: 100%; appearance: none; height: 8px; border-radius: 999px; outline: none; background: var(--panel-2); cursor: pointer; }
.scrub::-webkit-slider-thumb { appearance: none; width: 17px; height: 17px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 0 12px rgba(108,92,255,.7); cursor: pointer; }
.scrub::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
.timecode { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.timecode #tc { color: var(--text); font-weight: 700; }

.edl { height: 28px; border-radius: 8px; overflow: hidden; display: flex; box-shadow: inset 0 0 0 1px var(--line); margin-top: 12px; background: #0a0d12; }
.edl span { height: 100%; display: block; transition: width .15s ease; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }

/* QR join */
.qrwrap { margin-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.qr { background: #fff; padding: 10px; border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.35); line-height: 0; }
.qr svg { display: block; width: 200px; height: 200px; border-radius: 4px; }
.qr.small svg { width: 132px; height: 132px; }

/* fullscreen QR overlay (for projecting at an event) */
.qr-overlay { position: fixed; inset: 0; z-index: 100; background: radial-gradient(1000px 700px at 50% 30%, #161b2e, #06070b 70%); display: flex; align-items: center; justify-content: center; }
.qr-overlay-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }
.qr-overlay .qr { padding: 16px; }
.qr-overlay .qr svg { width: min(74vh, 74vw); height: min(74vh, 74vw); }
.qr-code-label { font-size: clamp(22px, 3vw, 34px); font-weight: 800; letter-spacing: 1px; }
.qr-code-label span { color: var(--accent-2); text-transform: uppercase; }
.qr-sub { color: var(--muted); font-size: clamp(13px, 1.4vw, 17px); max-width: 60ch; }
.qr-close { position: fixed; top: 18px; right: 18px; }

.help { color: var(--muted); font-size: 13px; }
.kbd { font: 12px/1 ui-monospace, SFMono-Regular, monospace; background: var(--panel-2); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; padding: 2px 7px; color: var(--text); }

/* ---------------------------------------------------------------- toasts */
#mpr-toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 9px; z-index: 60; }
.mpr-toast { background: var(--panel-solid); border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); padding: 11px 15px; border-radius: 11px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px) scale(.98); transition: all .26s cubic-bezier(.2,.9,.3,1); max-width: 340px; font-size: 14px; }
.mpr-toast.show { opacity: 1; transform: none; }
.mpr-toast.error { border-left-color: var(--danger); }
.mpr-toast.ok { border-left-color: var(--accent-2); }
