:root {
  --bg: #0a0c10;
  --bg-soft: #12151c;
  --bg-elevated: #181c25;
  --ink: #e8eaef;
  --ink-dim: #b4bac6;
  --muted: #7d8596;
  --line: rgba(232, 234, 239, 0.08);
  --line-strong: rgba(232, 234, 239, 0.14);
  --accent: #c9a882;
  --accent-soft: rgba(201, 168, 130, 0.1);
  --live: #e5484d;
  --live-soft: rgba(229, 72, 77, 0.12);
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --pad: clamp(1.25rem, 3.5vw, 2.5rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 50% -5%, rgba(201, 168, 130, 0.05), transparent 50%),
    linear-gradient(180deg, #0e1117 0%, #0a0c10 100%);
}

/* Top bar */
.topbar {
  position: relative;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem var(--pad);
  border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 16, 0.92);
  backdrop-filter: blur(10px);
}

.wordmark {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  transition: color 0.2s var(--ease);
}

.wordmark:hover {
  color: var(--accent);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--live);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.45);
  animation: pulse 1.7s ease-out infinite;
}

/* Stage */
.stage {
  flex: 1;
  padding: 1.5rem var(--pad) 2rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* Multi player grid */
.players {
  display: grid;
  gap: 1.25rem;
}

.players--one {
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.players--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.players--many {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 1100px) {
  .players--many {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .players--two,
  .players--many {
    grid-template-columns: 1fr;
  }
}

.stream-card {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.stream-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
  padding: 0 0.1rem;
}

.stream-card-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  min-width: 0;
}

a.stream-card-title:hover {
  color: var(--accent);
}

.channel-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
  flex-shrink: 0;
}

.channel-status.is-live {
  color: var(--live);
}

.player-box {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  max-width: 100%;
  max-height: 460px;
  background: #000;
  border: 1px solid var(--line-strong);
  overflow: hidden;
  isolation: isolate;
  contain: layout paint;
  border-radius: 2px;
}

.players--one .player-box {
  max-height: 500px;
}

.player-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.player-frame iframe,
.player-frame video,
.player-frame embed,
.player-frame object {
  display: block;
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  border: 0;
  pointer-events: auto;
}

.player-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg-soft);
}

.player-empty span {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.footer {
  padding: 1rem var(--pad) 1.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  font-weight: 400;
  border-top: 1px solid var(--line);
}

/* Panel (shared) */
.panel-body {
  min-height: 100vh;
  background: var(--bg);
}

.panel-wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem clamp(1.25rem, 4vw, 2rem) 4rem;
}

.panel-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.panel-top h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.panel-top p {
  color: var(--muted);
  margin-top: 0.25rem;
  font-size: 0.875rem;
}

.panel-actions {
  display: flex;
  gap: 0.6rem;
}

.panel-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.panel-card h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.panel-card .hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-row {
  display: grid;
  gap: 0.4rem;
}

.form-row label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-row input,
.form-row textarea,
.form-row select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.85rem 1rem;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.2s;
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
  border-color: rgba(244, 244, 242, 0.35);
}

.form-row textarea {
  min-height: 160px;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
}

.form-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.4rem;
  border: 1px solid transparent;
  border-radius: 2px;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.25s var(--ease), background 0.25s, border-color 0.25s, color 0.25s;
  background: var(--ink);
  color: var(--bg);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #1a1208;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: transparent;
  border-color: rgba(225, 29, 46, 0.4);
  color: var(--live);
}

.btn-danger:hover {
  background: var(--live-soft);
}

.btn-sm {
  padding: 0.5rem 0.85rem;
  font-size: 0.8rem;
}

.alert {
  padding: 0.9rem 1rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--line);
  font-size: 0.9rem;
}

.alert-ok {
  background: rgba(244, 244, 242, 0.05);
  color: var(--ink);
}

.alert-err {
  background: var(--live-soft);
  border-color: rgba(225, 29, 46, 0.35);
  color: var(--live);
}

.stream-editor {
  display: grid;
  gap: 1rem;
}

.stream-block {
  border: 1px solid var(--line);
  padding: 1rem;
  background: var(--bg);
}

.stream-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.stream-block-head strong {
  font-weight: 600;
  font-size: 0.875rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 1.75rem;
}

.login-box h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.login-box .hint {
  color: var(--muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.login-box .btn {
  width: 100%;
  margin-top: 0.5rem;
}

@media (max-width: 640px) {
  .form-inline {
    grid-template-columns: 1fr;
  }

  .channel {
    flex-basis: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .channel:last-child {
    border-bottom: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 74, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(255, 59, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 74, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .wordmark,
  .live-badge,
  .players {
    opacity: 1;
  }
}
