:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #191d24;
  --panel-strong: #202631;
  --line: #313846;
  --text: #f4f1e8;
  --muted: #a7b0bd;
  --teal: #38c7b5;
  --teal-dark: #1f8f83;
  --amber: #f4b860;
  --danger: #ff6b6b;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(56, 199, 181, 0.08), transparent 34%),
    linear-gradient(240deg, rgba(244, 184, 96, 0.08), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(100%, 980px);
  display: grid;
  place-items: center;
}

.login-panel,
.placeholder-panel,
.admin-panel,
.metric-panel,
.chat-panel,
.stream-info {
  background: rgba(25, 29, 36, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(100%, 420px);
  padding: 32px;
}

.brand-block {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
}

.form-stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1319;
  color: var(--text);
  outline: none;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 78px;
  resize: vertical;
  padding: 12px;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(56, 199, 181, 0.16);
}

.primary-button,
.ghost-button,
.mode-button,
.primary-link {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.primary-button,
.primary-link {
  background: var(--teal);
  color: #07110f;
  font-weight: 800;
}

.ghost-button,
.mode-button {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: var(--text);
}

.mode-button.active {
  background: rgba(56, 199, 181, 0.16);
  border-color: var(--teal);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.topbar {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.status-badge,
.viewer-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.status-badge.online {
  color: #06120f;
  background: var(--teal);
  border-color: var(--teal);
  font-weight: 800;
}

.status-badge.offline {
  color: #211404;
  background: var(--amber);
  border-color: var(--amber);
  font-weight: 800;
}

.viewer-pill strong {
  margin-left: 6px;
  font-size: 18px;
}

.live-layout {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 24px 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
}

.theater {
  min-width: 0;
}

.video-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050608;
  aspect-ratio: 16 / 9;
  box-shadow: var(--shadow);
}

video {
  width: 100%;
  height: 100%;
  display: block;
  background: #050608;
}

.offline-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 8, 0.76);
  color: var(--amber);
  font-size: 28px;
  font-weight: 900;
}

.offline-overlay.hidden {
  display: none;
}

.player-controls {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-panel {
  min-height: 520px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chat-messages {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.chat-messages.compact {
  max-height: 420px;
}

.chat-message {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 10px 12px;
}

.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.chat-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.chat-form {
  margin-top: 14px;
}

.chat-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stream-info {
  grid-column: 1 / -1;
  padding: 18px;
}

.info-grid {
  margin: 14px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.info-grid div {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.035);
}

dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.45;
}

.admin-grid {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 24px 32px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.metric-panel,
.admin-panel {
  padding: 18px;
}

.metric-panel {
  display: grid;
  gap: 10px;
}

.metric-panel strong {
  overflow-wrap: anywhere;
  font-size: 20px;
}

.wide {
  grid-column: span 2;
}

.user-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.user-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.placeholder-page {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 0 24px 32px;
}

.placeholder-panel {
  padding: 28px;
}

code {
  color: var(--teal);
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .live-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  .chat-panel {
    min-height: 460px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar,
  .live-layout,
  .admin-grid,
  .placeholder-page {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar-actions,
  .player-controls,
  .chat-actions {
    width: 100%;
  }

  .ghost-button,
  .mode-button,
  .primary-button {
    flex: 1 1 auto;
  }

  .chat-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

