:root {
  --bg-0: #07080a;
  --bg-1: #111824;
  --bg-2: #0d2431;
  --surface: rgba(17, 25, 37, 0.76);
  --surface-strong: rgba(18, 30, 44, 0.92);
  --line: rgba(146, 189, 207, 0.22);
  --line-strong: rgba(146, 189, 207, 0.38);
  --text: #f2f7fb;
  --muted: #9ab2c5;
  --accent: #ffb347;
  --accent-strong: #ff8d29;
  --accent-cold: #58d0ff;
  --danger: #ff6d6d;
  --ok: #3ed6a2;
  --radius: 18px;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(88, 208, 255, 0.45) rgba(255, 255, 255, 0.05);
}

html {
  background: var(--bg-0);
  overscroll-behavior-y: none;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(88, 208, 255, 0.7), rgba(88, 208, 255, 0.38));
  border-radius: 999px;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font-family: 'Sora', sans-serif;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  background:
    radial-gradient(1000px 620px at 90% -15%, rgba(88, 208, 255, 0.18), transparent 58%),
    radial-gradient(860px 500px at -10% 0%, rgba(255, 179, 71, 0.18), transparent 56%),
    linear-gradient(165deg, var(--bg-1), var(--bg-0) 46%, var(--bg-2));
}

body::before,
body::after {
  content: '';
  position: fixed;
  pointer-events: none;
  z-index: -1;
}

body::before {
  inset: 0;
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.03), transparent 34%),
    linear-gradient(-125deg, rgba(255, 255, 255, 0.02), transparent 30%);
}

body::after {
  top: -180px;
  right: -120px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(70px);
  background: radial-gradient(circle, rgba(255, 141, 41, 0.2), transparent 68%);
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(circle at center, black 40%, transparent 95%);
  opacity: 0.2;
}

.layout {
  width: min(1260px, 100% - 30px);
  margin: 28px auto 46px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 20px 22px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(140deg, rgba(12, 26, 39, 0.95), rgba(13, 20, 31, 0.8));
  box-shadow: var(--shadow);
  animation: rise 0.45s ease-out both;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 5vw, 48px);
  letter-spacing: -0.02em;
  font-weight: 800;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 610px;
}

.user-pill {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 14px;
  background: linear-gradient(120deg, rgba(255, 179, 71, 0.16), rgba(88, 208, 255, 0.08));
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
}

.control-grid,
.panel-grid {
  display: grid;
  gap: 12px;
}

.control-grid {
  grid-template-columns: 1.1fr 0.9fr;
}

.panel-grid {
  grid-template-columns: 0.95fr 1.05fr;
  margin-top: 12px;
}

.card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 15px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, var(--surface), rgba(8, 15, 24, 0.72));
  backdrop-filter: blur(11px);
  box-shadow: var(--shadow);
  animation: rise 0.55s ease-out both;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(88, 208, 255, 0.06), transparent 45%);
  pointer-events: none;
}

.control-grid .card:nth-child(1) {
  animation-delay: 0.08s;
}

.control-grid .card:nth-child(2) {
  animation-delay: 0.15s;
}

.player-card {
  margin-top: 12px;
  padding: 10px;
  animation-delay: 0.22s;
}

.panel-grid .card:nth-child(1) {
  animation-delay: 0.3s;
}

.panel-grid .card:nth-child(2) {
  animation-delay: 0.38s;
}

label,
small {
  color: var(--muted);
}

label {
  display: block;
  font-size: 12px;
  margin-top: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inline {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.room-actions {
  margin-top: 10px;
}

.video-controls input[type='file'] {
  padding: 8px;
}

.video-controls .inline button {
  white-space: nowrap;
}

.upload-row {
  align-items: center;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-pick-btn {
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 22, 0.68);
  color: var(--text);
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  white-space: nowrap;
  transition: transform 0.18s ease, background 0.2s ease, border-color 0.2s ease;
}

.file-pick-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.1);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-top: 12px;
  text-transform: none;
  letter-spacing: normal;
  font-size: 13px;
}

.checkbox-line input[type='checkbox'] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.checkbox-ui {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 14, 22, 0.68);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.checkbox-ui::after {
  content: '';
  width: 10px;
  height: 6px;
  border: 2px solid transparent;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg) scale(0.8);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}

#createWithPassword:checked + .checkbox-ui {
  border-color: rgba(88, 208, 255, 0.76);
  background: rgba(88, 208, 255, 0.2);
  box-shadow: 0 0 0 3px rgba(88, 208, 255, 0.2);
}

#createWithPassword:checked + .checkbox-ui::after {
  border-color: #d8f6ff;
  opacity: 1;
  transform: rotate(-45deg) scale(1);
}

input,
button {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 22, 0.68);
  color: var(--text);
  padding: 11px 12px;
  font-family: inherit;
  font-size: 14px;
}

input {
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input:focus-visible {
  outline: none;
  border-color: rgba(88, 208, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(88, 208, 255, 0.16);
  background: rgba(10, 20, 31, 0.9);
}

button {
  cursor: pointer;
  transition: transform 0.18s ease, background 0.2s ease, border-color 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.1);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.62;
  cursor: wait;
  transform: none;
}

button.accent {
  border: 0;
  background: linear-gradient(125deg, var(--accent), var(--accent-strong));
  color: #1f1002;
  font-weight: 800;
}

#player {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.11);
}

.player-hint {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.panel-title {
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.panel-subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}

.voice-actions {
  display: flex;
  gap: 8px;
}

.participants {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.participant-row {
  font-size: 13px;
  border: 1px solid rgba(146, 189, 207, 0.28);
  padding: 8px 10px;
  border-radius: 11px;
  background: rgba(7, 12, 19, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.participant-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-empty {
  color: var(--muted);
  font-size: 13px;
}

.kick-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.admin-badge {
  margin-top: 8px;
  color: var(--ok);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}

.chat-messages {
  height: 220px;
  overflow: auto;
  border: 1px solid rgba(146, 189, 207, 0.28);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(7, 12, 19, 0.6);
}

.msg {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.4;
}

.msg span {
  color: var(--accent-cold);
  font-weight: 700;
}

.volume-controls {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.volume-row {
  display: grid;
  grid-template-columns: 1fr 130px;
  align-items: center;
  gap: 8px;
}

.volume-row label {
  font-size: 12px;
  margin: 0;
}

.volume-row input[type='range'] {
  padding: 0;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(88, 208, 255, 0.35), rgba(255, 179, 71, 0.35));
  border: 1px solid rgba(146, 189, 207, 0.24);
}

.volume-row input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f5f9ff;
  border: 2px solid #4fc8ff;
  cursor: pointer;
}

.volume-row input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f5f9ff;
  border: 2px solid #4fc8ff;
  cursor: pointer;
}

.volume-empty {
  color: var(--muted);
  font-size: 12px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 11, 0.82);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  animation: fadeIn 0.35s ease both;
}

.auth-box {
  width: min(560px, 100%);
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: linear-gradient(150deg, var(--surface-strong), rgba(13, 18, 27, 0.96));
  box-shadow: var(--shadow);
}

.auth-box h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

.auth-box p {
  color: var(--muted);
  margin-bottom: 10px;
}

.auth-box a {
  color: var(--accent);
}

.auth-steps {
  margin: 0 0 12px;
  padding-left: 19px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 6px;
}

.open-bot {
  display: inline-block;
  margin-bottom: 12px;
  font-weight: 700;
}

.error {
  min-height: 20px;
  margin-top: 8px;
  color: var(--danger);
}

.hidden {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 980px) {
  .control-grid,
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .layout {
    width: min(1260px, 100% - 20px);
    margin-top: 18px;
  }

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

  .user-pill {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 16px;
  }

  .card {
    padding: 12px;
  }

  .inline {
    flex-direction: column;
  }

  .voice-actions {
    flex-direction: column;
  }

  .volume-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .chat-messages {
    height: 180px;
  }
}
