/* ---------- Tokens ---------- */

:root {
  color-scheme: light dark;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --bg: #f2f2f7;
  --surface: #ffffff;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.2);
  --segment-active: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --separator: rgba(60, 60, 67, 0.14);
  --glass: rgba(242, 242, 247, 0.82);
  --floating: rgba(255, 255, 255, 0.86);
  --floating-shadow: 0 0.5rem 1.875rem rgba(0, 0, 0, 0.16);

  --accent: #fa2d48;
  --accent-hover: #e8203b;
  --on-accent: #ffffff;

  --radius-xs: 0.25rem;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.625rem;

  --gutter: 1rem;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.36);
    --segment-active: #636366;
    --text: #f5f5f7;
    --text-secondary: #98989d;
    --separator: rgba(84, 84, 88, 0.55);
    --glass: rgba(0, 0, 0, 0.78);
    --floating: rgba(44, 44, 46, 0.88);
    --floating-shadow: 0 0.5rem 1.875rem rgba(0, 0, 0, 0.5);
  }
}

/* The host screen is always dark — it's meant for a projector or TV. */
.theme-dark {
  color-scheme: dark;
  --bg: #000000;
  --surface: #121213;
  --fill: rgba(118, 118, 128, 0.24);
  --fill-strong: rgba(118, 118, 128, 0.36);
  --segment-active: #636366;
  --text: #f5f5f7;
  --text-secondary: #8e8e93;
  --separator: rgba(84, 84, 88, 0.5);
  --glass: rgba(18, 18, 19, 0.85);
  --floating: rgba(44, 44, 46, 0.88);
  --floating-shadow: 0 0.5rem 1.875rem rgba(0, 0, 0, 0.5);
}

/* ---------- Base ---------- */

/* Sizes are in rem. Guests use the browser's 16px; the host view grows with the display (it's often a TV). */
.scale-with-screen {
  font-size: clamp(16px, 1vw, 32px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  -webkit-user-select: none;
  user-select: none;
}

img {
  display: block;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 0.125rem solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 0.125rem;
}

/* ---------- Typography ---------- */

.eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.error-text {
  font-size: 0.9375rem;
  color: var(--accent);
  text-align: center;
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.75rem;
  padding: 0 1.25rem;
  border: 0;
  border-radius: var(--radius-md);
  font-size: 1.0625rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), transform 0.15s var(--ease), opacity 0.2s var(--ease);
}

.button:active:not(:disabled) {
  transform: scale(0.98);
}

.button:disabled {
  opacity: 0.5;
  cursor: default;
}

.button-primary {
  background: var(--accent);
  color: var(--on-accent);
}

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

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

.button-secondary:hover:not(:disabled) {
  background: var(--fill-strong);
}

.button-large {
  height: 3.125rem;
  padding: 0 1.75rem;
}

.button-block {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.125rem;
  height: 2.125rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--fill);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.15s var(--ease);
}

.icon-button:hover:not(:disabled) {
  background: var(--fill-strong);
}

.icon-button:active:not(:disabled) {
  transform: scale(0.94);
}

.icon-button:disabled {
  opacity: 0.3;
  cursor: default;
}

.icon-button svg {
  width: 1.125rem;
  height: 1.125rem;
}

.icon-button-plain {
  background: transparent;
  color: var(--text-secondary);
}

.text-button {
  padding: 0.5rem 0.25rem;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 1.0625rem;
  cursor: pointer;
}

.small-button {
  flex: none;
  height: 1.875rem;
  padding: 0 0.75rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--fill);
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

/* ---------- Inputs ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field-label {
  padding-left: 0.125rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.input {
  width: 100%;
  height: 3rem;
  padding: 0 0.875rem;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--fill);
  font-size: 1.0625rem;
  outline: none;
  transition: box-shadow 0.2s var(--ease);
}

.input::placeholder {
  color: var(--text-secondary);
}

.input:focus {
  box-shadow: 0 0 0 0.125rem color-mix(in srgb, var(--accent) 50%, transparent);
}

.input-code {
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.input-code::placeholder {
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

/* Checkbox with a filled, rounded-square check */
.checkbox {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.9375rem;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.checkbox input {
  appearance: none;
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  border: 0.125rem solid var(--fill-strong);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.checkbox input:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.checkbox input:checked::after {
  content: "";
  width: 0.3125rem;
  height: 0.625rem;
  border: solid #ffffff;
  border-width: 0 0.125rem 0.125rem 0;
  transform: translateY(-0.0625rem) rotate(45deg);
}

/* ---------- Tabs ---------- */

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.625rem var(--gutter);
  background: var(--glass);
  border-bottom: 0.0625rem solid var(--separator);
  -webkit-backdrop-filter: saturate(180%) blur(1.25rem);
  backdrop-filter: saturate(180%) blur(1.25rem);
}

.segmented {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  padding: 0.125rem;
  border-radius: var(--radius-md);
  background: var(--fill);
}

.segment {
  height: 1.875rem;
  padding: 0 0.375rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.segment.is-active {
  background: var(--segment-active);
  box-shadow: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.12), 0 0.0625rem 0.0625rem rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

.segment-count {
  margin-left: 0.25rem;
  color: var(--text-secondary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.segment-count:empty {
  display: none;
}

/* ---------- Lists ---------- */

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
}

.list:empty {
  display: none;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.75rem;
  padding: 0.5rem var(--gutter);
}

.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: var(--separator-inset, 6.25rem);
  height: 0.0625rem;
  background: var(--separator);
}

.row-art {
  flex: none;
  width: 4.5rem;
  height: 2.5rem;
  border-radius: var(--radius-xs);
  object-fit: cover;
  background: var(--fill);
}

.row-text {
  flex: 1;
  min-width: 0;
}

.row-title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.3;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.row-meta {
  margin-top: 0.125rem;
  overflow: hidden;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row-actions {
  display: flex;
  gap: 0.25rem;
}

/* The host drags a queue row by this handle. It doesn't scroll the page while held. */
.drag-handle {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.125rem;
  height: 2.125rem;
  color: var(--text-secondary);
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.drag-handle svg {
  width: 1.125rem;
  height: 1.125rem;
}

.row.is-dragging {
  z-index: 2;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--floating-shadow);
  cursor: grabbing;
}

.row.is-dragging::before,
.row.is-dragging + .row::before {
  display: none;
}

.row-mine .row-meta {
  color: var(--accent);
}

.queue-position {
  flex: none;
  width: 1.125rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.add-button {
  color: var(--accent);
}

.add-button.is-added {
  background: var(--accent);
  color: var(--on-accent);
}

.queue-list {
  --separator-inset: 8.125rem;
}

.people-list {
  --separator-inset: 4.25rem;
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--avatar-color, var(--fill-strong));
  color: #ffffff;
  font-size: 1.0625rem;
  font-weight: 600;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-large {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.5rem;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr));
  gap: 0.625rem;
  padding: 0.25rem 0.125rem;
}

.avatar-option {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text-secondary);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}

.avatar-option:active {
  transform: scale(0.94);
}

.avatar-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-option svg {
  width: 1.25rem;
  height: 1.25rem;
}

.avatar-option.is-selected {
  box-shadow: 0 0 0 0.125rem var(--bg), 0 0 0 0.25rem var(--accent);
}

.empty {
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ---------- Search ---------- */

.search-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem var(--gutter);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.375rem;
  padding: 0 0.625rem;
  border-radius: var(--radius-md);
  background: var(--fill);
  color: var(--text-secondary);
}

.search-bar svg {
  flex: none;
  width: 1.0625rem;
  height: 1.0625rem;
}

.search-bar input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  font-size: 1.0625rem;
  color: var(--text);
  outline: none;
}

.search-bar input::placeholder {
  color: var(--text-secondary);
}


.search-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-row .search-bar {
  flex: 1;
  min-width: 0;
}

.hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.hint:empty {
  display: none;
}

.spinner {
  width: 1.375rem;
  height: 1.375rem;
  margin: 2rem auto;
  border: 0.1562rem solid var(--fill-strong);
  border-top-color: var(--text-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Host crown ---------- */

.avatar-slot {
  position: relative;
  flex: none;
  display: inline-flex;
}

.crown {
  position: absolute;
  right: -0.1875rem;
  bottom: -0.1875rem;
  display: grid;
  place-items: center;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: #ffd60a;
  color: #6b4f00;
  box-shadow: 0 0 0 0.125rem var(--surface);
}

.crown svg {
  width: 0.6875rem;
  height: 0.6875rem;
}

.host-line {
  overflow: hidden;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.host-line.is-away {
  color: var(--accent);
}

/* ---------- Banner ---------- */

.banner {
  position: fixed;
  top: calc(0.5rem + env(safe-area-inset-top));
  left: 50%;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: min(25rem, calc(100% - 1rem));
  padding: 0.625rem 0.5rem 0.625rem 0.625rem;
  border-radius: 0.875rem;
  background: var(--floating);
  box-shadow: var(--floating-shadow);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 1rem));
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1), opacity 0.3s var(--ease);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
}

.banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.banner .avatar {
  width: 2.25rem;
  height: 2.25rem;
  font-size: 0.9375rem;
}

.banner-text {
  flex: 1;
  min-width: 0;
}

/* The banner lets taps pass through to the page; only its × can be tapped. */
.banner-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text-secondary);
  cursor: pointer;
}

.banner.is-visible .banner-close {
  pointer-events: auto;
}

.banner-close svg {
  width: 0.875rem;
  height: 0.875rem;
}

.banner-title {
  overflow: hidden;
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.banner-subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.banner-subtitle:empty {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .banner {
    transition: opacity 0.2s linear;
  }
}

/* ---------- Action sheet ---------- */

.sheet {
  width: min(100% - 1rem, 26rem);
  max-width: none;
  margin: auto auto calc(0.5rem + env(safe-area-inset-bottom));
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

.sheet[open] {
  animation: sheet-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

.sheet-card,
.sheet-cancel {
  border-radius: 0.875rem;
  background: var(--floating);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
}

.sheet-card {
  overflow: hidden;
}

.sheet-header {
  padding: 1rem 1rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: center;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0 1rem 1rem;
  text-align: left;
}

.sheet-title {
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.sheet-action {
  display: block;
  width: 100%;
  padding: 1rem;
  border: 0;
  border-top: 0.0625rem solid var(--separator);
  background: transparent;
  color: var(--accent);
  font-size: 1.0625rem;
  cursor: pointer;
}

.sheet-action:active {
  background: var(--fill);
}

.sheet-action.is-destructive {
  color: #ff3b30;
}

.sheet .sheet-cancel {
  margin-top: 0.5rem;
  border-top: 0;
  background: var(--floating);
  font-weight: 600;
}

/* On wide screens the sheet sits in the middle like a dialog. */
@media (min-width: 760px) {
  .sheet {
    margin: auto;
  }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100% - 2rem);
  padding: 0.6875rem 1.125rem;
  border-radius: var(--radius-lg);
  background: rgba(40, 40, 42, 0.94);
  color: #ffffff;
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.75rem);
  transition: opacity 0.25s var(--ease), transform 0.3s var(--ease);
  -webkit-backdrop-filter: blur(1.25rem);
  backdrop-filter: blur(1.25rem);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Back links ---------- */

.back-link {
  display: inline-flex;
  border: 0;
  background: none;
  cursor: pointer;
  align-items: center;
  gap: 0.125rem;
  padding: 0.5rem 0.625rem 0.5rem 0.25rem;
  color: var(--accent);
  font-size: 1.0625rem;
  text-decoration: none;
}

.back-link svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* ---------- Landing screens (home, join, host start) ---------- */

.landing > .back-link {
  position: absolute;
  top: calc(0.5rem + env(safe-area-inset-top));
  left: 0.5rem;
}

.landing {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.25rem;
  min-height: 100dvh;
  padding: 2.5rem 1.5rem calc(2.5rem + env(safe-area-inset-bottom));
  text-align: center;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.app-icon {
  width: 5rem;
  height: 5rem;
  filter: drop-shadow(0 0.5rem 1.25rem rgba(250, 45, 72, 0.28));
}

.brand h1 {
  margin-top: 1.375rem;
  font-size: clamp(2.5rem, 9vw, 4rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.tagline {
  margin-top: 0.625rem;
  font-size: clamp(1.1875rem, 3vw, 1.5rem);
  color: var(--text-secondary);
  letter-spacing: -0.015em;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 22.5rem;
}

.stack-form {
  text-align: left;
}

.join-inline {
  display: flex;
  gap: 0.5rem;
}

.join-inline .input {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.join-inline .button {
  height: 3rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.25rem 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 0.0625rem;
  background: var(--separator);
}

.footnote {
  max-width: 20rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ---------- Guest (phone) ---------- */

.guest {
  min-height: 100dvh;
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  background: var(--bg);
}

.guest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(0.5rem + env(safe-area-inset-top)) var(--gutter) 0.5rem;
  background: var(--surface);
}

.guest-title {
  min-width: 0;
}

.guest-header h1 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.room-badge {
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--fill);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.now-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem var(--gutter) 0.875rem;
  background: var(--surface);
}

.now-art {
  flex: none;
  width: 6rem;
  height: 3.375rem;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--fill);
}

.now-text {
  flex: 1;
  min-width: 0;
}

.now-title {
  margin-top: 0.0625rem;
  overflow: hidden;
  font-size: 1.0625rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.now-meta {
  overflow: hidden;
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.guest .search-controls {
  background: var(--surface);
  border-bottom: 0.0625rem solid var(--separator);
}

/* Full-bleed on phones; a centered column with edges on wide screens. */
@media (min-width: 760px) {
  .guest {
    max-width: 45rem;
    margin: 0 auto;
    border-right: 0.0625rem solid var(--separator);
    border-left: 0.0625rem solid var(--separator);
  }
}

/* ---------- Host view ---------- */

.host-mode {
  --sidebar: clamp(21.25rem, 27vw, 28.75rem);

  overflow: hidden;
}

/* In the host view, banners sit over the video, not the sidebar. */
.host-mode .banner {
  left: calc((100% - var(--sidebar)) / 2);
}

/* Side padding keeps content clear of the notch or Dynamic Island when a phone is sideways. */
.host {
  display: grid;
  padding-right: env(safe-area-inset-right);
  padding-left: env(safe-area-inset-left);
  grid-template-columns: minmax(0, 1fr) var(--sidebar);
  height: 100dvh;
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #000000;
}

.player-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000000;
  overflow: hidden;
  container-type: size;
}

/* The player script sizes the iframe in pixels to fill this frame (see player.js). */
.player-frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  border: 0;
}

.idle {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  background: radial-gradient(120% 100% at 50% 0%, #2a1015 0%, #0b0b0c 55%, #000000 100%);
  text-align: center;
}

.idle h2 {
  font-size: clamp(2rem, 3.6vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.idle p {
  font-size: clamp(1.125rem, 1.7vw, 1.75rem);
  color: var(--text-secondary);
}

.idle .qr {
  width: clamp(11.25rem, 20vw, 21.25rem);
  margin-top: 1.75rem;
  padding: clamp(0.75rem, 1.2vw, 1.25rem);
  border-radius: var(--radius-lg);
}

/* Short frames, like a phone held upright: smaller text and a QR that fits the height. */
@container (max-height: 30rem) {
  .idle {
    gap: 0.375rem;
    padding: 1rem;
  }

  .idle h2 {
    font-size: 1.5rem;
  }

  .idle p {
    font-size: 0.9375rem;
  }

  .idle .qr {
    width: auto;
    height: 45cqh;
    aspect-ratio: 1;
    margin-top: 0.375rem;
    padding: 0.5rem;
    border-radius: var(--radius-md);
  }
}

.qr {
  flex: none;
  background: #ffffff;
  line-height: 0;
}

.qr svg {
  width: 100%;
  height: auto;
}

.now-playing {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.5rem;
  background: var(--surface);
  border-top: 0.0625rem solid var(--separator);
}

.now-playing-text {
  flex: 1;
  min-width: 0;
}

.now-playing h2 {
  overflow: hidden;
  font-size: clamp(1.375rem, 2vw, 2.125rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.now-playing-meta {
  overflow: hidden;
  font-size: clamp(0.9375rem, 1.1vw, 1.1875rem);
  color: var(--text-secondary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.requested-by {
  color: var(--accent);
}

.transport {
  display: flex;
  flex: none;
  gap: 0.5rem;
}

.transport .icon-button {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: var(--radius-lg);
}

.transport .icon-button svg {
  width: 1.5rem;
  height: 1.5rem;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 0.0625rem solid var(--separator);
}

.sidebar-header {
  padding: 0.25rem 0.5rem 0;
}

.join-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem var(--gutter) 1rem;
}

.join-card .qr {
  width: clamp(5.75rem, 6.5vw, 7.75rem);
  padding: 0.4375rem;
  border-radius: var(--radius-md);
}

.join-details {
  min-width: 0;
}

.room-code {
  font-size: clamp(2.25rem, 3vw, 3.25rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.08em;
}

.join-url {
  margin-top: 0.125rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

/* The shared room panel fills the rest of the sidebar while you're the host. */
.sidebar .room-panel {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

/* Shown when the browser won't start the video by itself (common on phones). */
.tap-to-play {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  border: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-backdrop-filter: blur(0.5rem);
  backdrop-filter: blur(0.5rem);
}

.tap-to-play-icon {
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: var(--accent);
}

.tap-to-play-icon svg {
  width: 2rem;
  height: 2rem;
  margin-left: 0.25rem;
}

.sidebar .tabs {
  position: static;
  border-top: 0.0625rem solid var(--separator);
}

.sidebar .panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar .search-controls {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  border-bottom: 0.0625rem solid var(--separator);
}

.sidebar .row:hover {
  background: var(--fill);
}

.sidebar .empty {
  padding: 2.5rem 1.5rem;
  font-size: 0.9375rem;
}

@media (max-width: 900px) {
  .host-mode {
    overflow: auto;
  }

  .host-mode .banner {
    left: 50%;
  }

  .host {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: 100dvh;
  }

  /* Narrow screens let the title and requester wrap instead of cutting them off. */
  .now-playing h2,
  .now-playing-meta {
    white-space: normal;
  }

  .player-frame {
    flex: none;
    aspect-ratio: 16 / 9;
  }

  .sidebar {
    border-left: 0;
  }
}
