:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-muted: #eceff1;
  --border: #d7dce0;
  --text: #202428;
  --muted: #64707a;
  --primary: #244766;
  --primary-hover: #1b354d;
  --danger: #7a2e2e;
  --danger-hover: #632525;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  padding: 0 16px;
  font-weight: 600;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

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

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

input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0 12px;
}

input:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(36, 71, 102, 0.18);
}

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

.page-center {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.join-panel {
  width: min(520px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 28px;
}

.name-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(32, 36, 40, 0.45);
  padding: 16px;
}

.name-modal[hidden] {
  display: none;
}

.name-panel {
  width: min(480px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 24px;
}

.name-panel h1 {
  margin: 0;
  font-size: 1.5rem;
}

.name-panel p {
  margin: 6px 0 20px;
  color: var(--muted);
}

.join-panel h1,
.room-header h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  letter-spacing: 0;
}

.join-panel p,
.status-message {
  margin: 8px 0 0;
  color: var(--muted);
}

.join-form {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.room-page {
  display: grid;
  gap: 20px;
}

.room-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.back-link {
  color: var(--primary);
  display: inline-block;
  margin-bottom: 6px;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.status-message {
  text-align: right;
}

.controls {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  min-width: 42px;
  padding: 0;
  place-items: center;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.icon-button.is-muted {
  background: #59636e;
}

.icon-button.is-muted:hover:not(:disabled) {
  background: #48515a;
}

.icon-button .mic-icon-off,
.icon-button.is-muted .mic-icon-on {
  display: none;
}

.icon-button.is-muted .mic-icon-off {
  display: block;
}

.controls button:nth-child(2) {
  background: var(--danger);
}

.controls button:nth-child(2):hover:not(:disabled) {
  background: var(--danger-hover);
}

.video-section {
  display: grid;
  gap: 16px;
}

.featured-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.featured-panel[hidden] {
  display: none;
}

.featured-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  padding: 6px 8px 6px 12px;
}

.featured-title {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
}

.close-featured {
  min-height: 32px;
  padding: 0 12px;
}

.video-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.video-card:focus-visible {
  outline: 2px solid rgba(36, 71, 102, 0.35);
  outline-offset: 2px;
}

.video-card.is-hidden {
  display: none;
}

.video-card-header {
  min-height: 38px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 0.95rem;
  font-weight: 600;
}

video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111820;
  object-fit: cover;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 20px, 1120px);
    padding: 18px 0;
  }

  .join-panel {
    padding: 20px;
  }

  .join-row,
  .room-header {
    grid-template-columns: 1fr;
  }

  .join-row,
  .room-header {
    display: grid;
  }

  .status-message {
    text-align: left;
  }

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