:root {
  color-scheme: dark;
  --bg: #11100e;
  --panel: #1b1916;
  --panel-2: #24211d;
  --text: #f7f0e6;
  --muted: #b9afa2;
  --line: #3a352e;
  --accent: #19c37d;
  --accent-2: #f5b942;
  --danger: #ff6b6b;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 16px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #5a5146;
}

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

.primary {
  background: var(--accent);
  color: #07140e;
  font-weight: 700;
}

.danger {
  background: #3b1d1d;
  color: #ffd9d9;
}

.shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 7px;
}

.nav a:hover,
.nav a.active {
  background: var(--panel-2);
  color: var(--text);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  min-height: 30px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #777064;
}

.dot.live {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.15);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 14px;
}

.stage {
  position: relative;
  min-height: 520px;
  background: #050505;
  overflow: hidden;
}

.stage video {
  width: 100%;
  height: 100%;
  min-height: 520px;
  display: block;
  object-fit: contain;
  background: #050505;
}

.empty-stage {
  min-height: 520px;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.gift-overlay {
  position: absolute;
  inset: auto 14px 14px 14px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.gift-pop {
  width: fit-content;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(25, 195, 125, 0.92);
  color: #06130d;
  font-weight: 800;
  animation: rise 2.8s ease forwards;
}

@keyframes rise {
  0% {
    opacity: 0;
    transform: translateY(18px);
  }
  12%,
  75% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-18px);
  }
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.control-grid button,
.full {
  width: 100%;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.chat-row input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #0d0c0b;
  color: var(--text);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-height: 74px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151310;
}

.metric b {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.feed {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}

.feed-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151310;
}

.feed-item b {
  display: block;
  margin-bottom: 3px;
}

.feed-item small {
  color: var(--muted);
}

.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
}

.gift-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.home-link {
  display: grid;
  min-height: 190px;
  align-content: space-between;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  background: var(--panel);
}

.home-link:hover {
  border-color: #6a5f51;
}

.home-link h1,
.home-link h2 {
  margin: 0;
  font-size: 24px;
}

.home-link p {
  color: var(--muted);
  line-height: 1.45;
}

.hint {
  color: var(--muted);
  line-height: 1.45;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
}

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

  .stage,
  .stage video,
  .empty-stage {
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 16px, 1180px);
    padding-top: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding-bottom: 10px;
  }

  .nav {
    justify-content: flex-start;
  }

  .stage,
  .stage video,
  .empty-stage {
    min-height: 360px;
  }

  .control-grid,
  .metric-grid,
  .gift-row {
    grid-template-columns: 1fr;
  }

  .chat-row {
    grid-template-columns: 1fr;
  }
}
