:root {
  --bg: #0e0f12;
  --surface: #17191e;
  --surface-2: #21242b;
  --border: #2b2f38;
  --text: #f2f3f5;
  --muted: #9aa1ad;
  --accent: #ff3d3d;
  --on-accent: #ffffff;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #eef0f3;
    --border: #dfe2e7;
    --text: #15171b;
    --muted: #5d6470;
    --shadow: 0 10px 30px rgba(20, 25, 35, .08);
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.wrap-wide { width: 100%; max-width: 1800px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 1.05rem; min-width: 0; }
.brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  flex: none; width: 30px; height: 22px; border-radius: 7px; background: var(--accent); position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; left: 12px; top: 6px;
  border-left: 8px solid var(--on-accent); border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
.nav { display: flex; align-items: center; gap: 4px; flex: none; }
.nav a:not(.btn) { text-decoration: none; color: var(--muted); padding: 8px 10px; border-radius: 8px; font-size: .95rem; }
.nav a:not(.btn):hover, .nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); text-decoration: none; font-weight: 600; font-size: .92rem;
  cursor: pointer; white-space: nowrap; transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-ghost { background: transparent; }

/* Hero */
.hero { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 28px; padding: 28px 0 8px; align-items: start; }
.player-shell {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: #000; box-shadow: var(--shadow);
}
.player-shell iframe, .player-shell .lite, .player-shell .skeleton { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #aaa; padding: 24px; text-align: center; }
.lite { padding: 0; border: 0; cursor: pointer; background: #000; }
.lite img { width: 100%; height: 100%; object-fit: cover; opacity: .92; transition: opacity .2s; }
.lite:hover img { opacity: 1; }
.play-icon {
  position: absolute; left: 50%; top: 50%; width: 72px; height: 50px; transform: translate(-50%, -50%);
  background: var(--accent); border-radius: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); transition: transform .15s;
}
.play-icon::after {
  content: ""; position: absolute; left: 29px; top: 14px;
  border-left: 18px solid var(--on-accent); border-top: 11px solid transparent; border-bottom: 11px solid transparent;
}
.lite:hover .play-icon, .card-thumb:hover .play-icon { transform: translate(-50%, -50%) scale(1.08); }
.play-icon.sm { width: 48px; height: 34px; border-radius: 10px; opacity: 0; transition: opacity .15s, transform .15s; }
.play-icon.sm::after { left: 19px; top: 9px; border-left-width: 13px; border-top-width: 8px; border-bottom-width: 8px; }
.card-thumb:hover .play-icon.sm, .card-thumb:focus-visible .play-icon.sm { opacity: 1; }

.hero-info { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; min-width: 0; }
.eyebrow { margin: 0; color: var(--accent); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.hero-info h1 { font-size: clamp(1.4rem, 2.4vw, 2rem); overflow-wrap: anywhere; }
.meta { margin: 0; color: var(--muted); font-size: .88rem; }
.desc { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.intro { padding: 18px 0 4px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.tagline { margin: 0; font-size: 1.05rem; color: var(--muted); }
.links { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.links a { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; font-size: .88rem; }
.links a:hover { border-color: var(--accent); }

/* Sections and grid */
section { padding: 20px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.3rem; }
.section-head .link { color: var(--muted); text-decoration: none; font-size: .9rem; }
.section-head .link:hover { color: var(--text); }
input[type="search"], .mv-add input, select {
  height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); min-width: 0;
}
input[type="search"] { width: min(280px, 100%); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px 16px; }
.card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card-thumb {
  position: relative; padding: 0; border: 0; cursor: pointer; aspect-ratio: 16 / 9;
  border-radius: 12px; overflow: hidden; background: var(--surface-2);
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.card-thumb:hover img { transform: scale(1.03); }
.badge {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 6px; border-radius: 6px;
  background: rgba(0, 0, 0, .8); color: #fff; font-size: .75rem; font-weight: 600; letter-spacing: .02em;
}
.badge.live { background: #e02424; }
.section-head .count { font-size: .85rem; font-weight: 500; color: var(--muted); margin-left: 6px; }
.dev-note {
  margin: 16px 0 0; padding: 12px 14px; border-radius: 10px; font-size: .9rem; overflow-wrap: anywhere;
  border: 1px solid #d97706; background: color-mix(in srgb, #f59e0b 14%, var(--surface));
}
.more-row { display: flex; justify-content: center; margin-top: 24px; }
.card-body { display: flex; flex-direction: column; gap: 4px; }
.card-title {
  font-size: .98rem; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-mv { align-self: flex-start; color: var(--muted); font-size: .82rem; text-decoration: none; }
.card-mv:hover { color: var(--accent); }
.empty { color: var(--muted); }

.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.card-skel { aspect-ratio: 16 / 9; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; padding: 22px 0; margin-top: 24px; }

/* Multiview */
.mv-bar { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 0 6px; align-items: center; }
.mv-add { display: flex; gap: 8px; flex: 1 1 420px; min-width: 0; }
.mv-add input { flex: 1; }
.mv-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.mv-controls select { width: 240px; max-width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { height: 36px; padding: 0 12px; border: 0; background: var(--surface); cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.hint { color: var(--muted); font-size: .85rem; margin: 4px 0 12px; }

.mv-grid {
  --cols: 1; --fit: 1; --bars: 1;
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 10px;
  margin: 0 auto 24px;
  max-width: min(100%, max(560px, calc((100vh - 220px - var(--bars) * 50px) * 16 / 9 * var(--fit))));
}
.mv-grid[data-layout="spotlight"] .tile.is-main { grid-column: 1 / -1; }
.tile {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.tile.has-audio { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile-frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.tile-frame iframe, .tile-frame > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.tile-bar { display: flex; align-items: center; gap: 2px; padding: 4px 6px; min-height: 40px; }
.tile-title { flex: 1; min-width: 0; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.icon-btn {
  flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.audio[aria-pressed="true"] { color: var(--accent); }
.icon-btn[data-act="main"][aria-pressed="true"] { color: var(--text); }

.mv-empty { max-width: 620px; margin: 8vh auto; text-align: center; color: var(--muted); }
.mv-empty h1 { color: var(--text); font-size: clamp(1.5rem, 3vw, 2.1rem); margin-bottom: 12px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 18px; padding-top: 16px; }
}
@media (max-width: 640px) {
  .nav a:not(.btn):not([aria-current]) { display: none; }
  .nav a[href="/"]:not([aria-current]), .nav a[href="/multiview"]:not([aria-current]) { display: inline-block; }
  .nav a:not(.btn) { padding: 8px 6px; font-size: .9rem; }
  .brand { font-size: .95rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px 12px; }
  .mv-grid { grid-template-columns: 1fr; max-width: 100%; }
  .mv-grid[data-layout="spotlight"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mv-add { flex-basis: 100%; }
  .mv-controls select { width: 100%; }
  .mv-controls .btn { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
