:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #64748b;
  --line: #d9e0e8;
  --primary: #0f8b8d;
  --primary-dark: #0b6e70;
  --danger: #c2410c;
  --ok: #15803d;
  --shadow: 0 12px 30px rgba(24, 39, 75, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #e8eef3;
  color: var(--text);
}

button.secondary:hover {
  background: #dbe4ec;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
}

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

.admin-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.admin-header,
.live-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-header h1,
.live-title h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
}

.panel,
.room-card,
.chat-panel,
.video-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

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

.room-list {
  display: grid;
  gap: 12px;
}

.room-card {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.room-card h3 {
  margin: 0;
  font-size: 18px;
}

.meta-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e8eef3;
  color: #334155;
  font-size: 12px;
}

.badge.live {
  background: #dcfce7;
  color: var(--ok);
}

.badge.ended,
.badge.error {
  background: #ffedd5;
  color: var(--danger);
}

.code-line {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  overflow-wrap: anywhere;
}

.live-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.live-header {
  padding: 14px 18px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  margin: 0;
}

.live-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.live-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

.video-panel {
  min-height: 420px;
  overflow: hidden;
  display: grid;
  background: #111827;
}

.video-wrap {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  min-height: 280px;
  background: #111827;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111827;
}

.video-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  color: #fff;
  background: rgba(17, 24, 39, 0.72);
}

.video-state.hidden {
  display: none;
}

.chat-panel {
  min-height: 420px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.chat-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.messages {
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  display: grid;
  gap: 4px;
}

.message strong {
  font-size: 12px;
  color: var(--primary-dark);
}

.message span {
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.notice {
  padding: 10px 12px;
  border-radius: 6px;
  background: #e0f2fe;
  color: #075985;
  margin-bottom: 12px;
}

@media (max-width: 860px) {
  .admin-grid,
  .live-layout {
    grid-template-columns: 1fr;
  }

  .admin-shell {
    padding: 14px;
  }

  .live-layout {
    padding: 10px;
  }

  .live-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .video-panel,
  .chat-panel {
    min-height: auto;
  }

  .chat-panel {
    height: min(52vh, 520px);
  }
}
