:root {
  --bg: #0e1116;
  --surface: #171b22;
  --surface-2: #1f2530;
  --border: #2a3140;
  --text: #e8ecf2;
  --muted: #8b95a7;
  --accent: #ff4d4f;
  --accent-text: #fff;
  --bar-h: 56px;
  --foot-h: 34px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f5f8; --surface: #fff; --surface-2: #eef1f5; --border: #d8dee8;
    --text: #151a22; --muted: #5d6779; color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  scroll-behavior: smooth;
}
html { scroll-behavior: smooth; }

.bar {
  position: sticky; top: 0; z-index: 20;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--accent);
}
.controls { flex: none; }
.btn { white-space: nowrap; }
.tagline { margin: 0; flex: 1; min-width: 0; color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.btn { text-decoration: none; display: inline-block; }
.btn.how { color: var(--muted); background: transparent; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: .2px; }
.brand svg { color: var(--accent); }
.controls { display: flex; align-items: center; gap: 8px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  background: transparent; color: var(--muted); border: 0; padding: 7px 13px; cursor: pointer; font: inherit; font-weight: 600;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button:hover { background: var(--surface-2); color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

.btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font: inherit;
}
.btn:hover { border-color: var(--muted); }
.btn.ghost { background: transparent; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Grid */
.grid {
  height: calc(100dvh - var(--bar-h));
  min-height: 440px;
  display: grid;
  gap: 6px;
  padding: 6px;
}
.grid[data-n="1"] { grid-template: 1fr / 1fr; }
.grid[data-n="2"] { grid-template: 1fr / 1fr 1fr; }
.grid[data-n="3"] { grid-template: 1fr 1fr / 1fr 1fr; }
.grid[data-n="3"] .tile:nth-child(1) { grid-row: 1 / span 2; }
.grid[data-n="4"] { grid-template: 1fr 1fr / 1fr 1fr; }

.tile {
  position: relative;
  min-width: 0; min-height: 0;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.tile[hidden] { display: none; }
.tile.audio { border-color: var(--accent); }
.tile iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; background: var(--surface); text-align: center;
}
.empty .slot-no { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.empty form { display: flex; gap: 6px; width: min(460px, 100%); }
.empty input {
  flex: 1; min-width: 0; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
.empty input::placeholder { color: var(--muted); }
.empty button[type="submit"] {
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px;
  padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
.empty .err { color: #ff8a8c; font-size: 13px; min-height: 1.2em; margin: 0; }

/* Transparent layer over the video: a click expands / collapses the tile */
.hit {
  position: absolute; inset: 0 0 52px 0; z-index: 1; width: 100%;
  background: transparent; border: 0; padding: 0; cursor: zoom-in;
}
.hit[hidden], .ctl[hidden], .empty[hidden] { display: none; }
.tile:fullscreen .hit, .tile.expanded .hit { cursor: zoom-out; }

.ctl {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 24px 10px 8px;
  background: linear-gradient(to top, rgba(0,0,0,.78), rgba(0,0,0,0));
  opacity: 0; transition: opacity .15s;
}
.tile:hover .ctl, .tile:focus-within .ctl { opacity: 1; }
@media (hover: none) { .ctl { opacity: 1; } }
.grp { display: flex; align-items: center; gap: 6px; }
.ctl button {
  min-width: 34px; height: 34px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 700; letter-spacing: .5px;
  background: rgba(0,0,0,.62); color: #fff; border: 1px solid rgba(255,255,255,.22); border-radius: 8px;
}
.ctl button:hover:not(:disabled) { background: rgba(0,0,0,.9); }
.ctl button:disabled { opacity: .4; cursor: default; }
.ctl .snd[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.ctl .live i { width: 8px; height: 8px; border-radius: 50%; background: #9aa3b2; display: block; }
.ctl .live.at-live i { background: var(--accent); }

.tile.expanded {
  position: fixed; inset: 0; z-index: 50; border-radius: 0; border: 0;
  aspect-ratio: auto; width: auto; height: auto;
}
.tile:fullscreen { border-radius: 0; border: 0; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
code, kbd { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.how { padding: 56px 0 48px; border-top: 1px solid var(--border); background: var(--bg); }
.how h2 { margin: 0 0 28px; text-align: center; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.3px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.steps li { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.steps b {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 14px; margin-bottom: 12px;
}
.steps h3 { margin: 0 0 6px; font-size: 17px; }
.steps p { margin: 0; color: var(--muted); }

.site-foot { background: var(--surface); border-top: 1px solid var(--border); padding-top: 40px; color: var(--muted); font-size: 14px; }
.site-foot .cols { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr; gap: 32px; }
.site-foot h4 { margin: 0 0 10px; color: var(--text); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.site-foot p { margin: 8px 0 0; }
.site-foot ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.brand.small { font-size: 16px; }
.site-foot .brand svg { color: var(--accent); }
.legal {
  display: flex; justify-content: space-between; gap: 24px; margin-top: 32px; padding-top: 16px; padding-bottom: 20px;
  border-top: 1px solid var(--border); font-size: 12.5px;
}
.legal span:last-child { max-width: 640px; text-align: right; }

.toast {
  position: fixed; left: 50%; bottom: 52px; transform: translate(-50%, 20px);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 9px 14px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .2s; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Phones: stack tiles, page scrolls */
@media (max-width: 720px) {
  .bar { height: auto; flex-wrap: wrap; padding: 10px 16px; position: static; }
  .tagline, .btn.how { display: none; }
  .controls { flex-wrap: wrap; }
  .grid, .grid[data-n] { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .steps, .site-foot .cols { grid-template-columns: 1fr; }
  .legal { flex-direction: column; gap: 8px; }
  .legal span:last-child { text-align: left; }
  .grid .tile, .grid[data-n="3"] .tile:nth-child(1) { grid-row: auto; aspect-ratio: 16 / 9; flex: none; }
  .btn.ghost { display: none; }
}
