:root {
  color-scheme: light dark;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #60708a;
  --line: #d9e1ec;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #dbeafe;
  --danger: #b42318;
  --on-solid: #ffffff;
  --danger-soft: #fee4e2;
  --success: #087443;
  --radius: 18px;
  --shadow: 0 12px 32px rgb(32 52 82 / 10%);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101827;
    --surface: #182235;
    --surface-soft: #202d43;
    --text: #edf3ff;
    --muted: #aebbd0;
    --line: #34435c;
    --accent: #75a7ff;
    --accent-strong: #9bbdff;
    --accent-soft: #1d3c70;
    --danger: #ff958b;
    --on-solid: #0b1220;
    --danger-soft: #582a30;
    --success: #6ee7a9;
    --shadow: 0 12px 32px rgb(0 0 0 / 24%);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button,
input[type="checkbox"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 700;
}

label.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 700;
}

.file-input:focus-visible + label.button {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

button:focus-visible,
input:focus-visible,
a:focus-visible,
label:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

input[type="text"] {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

label {
  display: block;
  margin-bottom: 7px;
  font-size: .92rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(1.7rem, 6vw, 2.6rem);
  line-height: 1.13;
  letter-spacing: -.035em;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.15rem;
}

.shell {
  width: min(1120px, 100%);
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 36px
    max(16px, env(safe-area-inset-left));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}

.brand {
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -.04em;
  text-decoration: none;
}

.tagline,
.intro,
.join-card p,
.field-help,
.one-way-note {
  color: var(--muted);
}

.tagline {
  margin: 0;
  font-size: .9rem;
}

.view[hidden],
[hidden] {
  display: none !important;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  max-width: 720px;
  padding: clamp(24px, 6vw, 52px);
  margin: 5vh auto 24px;
}

.eyebrow {
  margin-bottom: 9px;
  color: var(--accent);
  font-size: .79rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.intro {
  max-width: 52ch;
  margin-bottom: 28px;
  line-height: 1.55;
}

.share-options {
  display: grid;
  gap: 18px;
}

.toggle-row {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  margin: 0;
  cursor: pointer;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
}

.toggle-control {
  position: relative;
  display: block;
  width: 46px;
  height: 26px;
  background: var(--line);
  border-radius: 20px;
  transition: background .18s ease;
}

.toggle-control::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  content: "";
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgb(0 0 0 / 22%);
  transition: transform .18s ease;
}

.toggle-row input:checked + .toggle-control {
  background: var(--accent);
}

.toggle-row input:checked + .toggle-control::after {
  transform: translateX(20px);
}

.toggle-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.35;
}

.button {
  padding: 10px 16px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.button:hover:not(:disabled) {
  filter: brightness(.97);
}

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

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

.button-danger {
  color: var(--on-solid);
  background: var(--danger);
  border-color: var(--danger);
}

.notice {
  padding: 14px;
  color: var(--text);
  line-height: 1.5;
  background: var(--accent-soft);
  border-radius: 10px;
}

.error-message {
  margin: 18px 0 0;
  padding: 12px 14px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 10px;
  line-height: 1.4;
}

.join-card {
  max-width: 720px;
  padding: 24px;
  margin: 0 auto;
}

.join-card input {
  margin-bottom: 12px;
}

.host-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .8fr);
  gap: 22px;
}

.video-card,
.viewer-video-card {
  padding: clamp(16px, 3vw, 26px);
}

.host-side {
  display: grid;
  align-content: start;
  gap: 22px;
}

.host-side .card {
  padding: 22px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.section-heading h1,
.section-heading h2 {
  margin-bottom: 0;
}

.section-heading.compact {
  align-items: center;
  margin-bottom: 12px;
}

.status-pill,
.count {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: 29px;
  padding: 4px 9px;
  color: var(--accent-strong);
  font-size: .81rem;
  font-weight: 800;
  white-space: nowrap;
  background: var(--accent-soft);
  border-radius: 100px;
}

.status-pill[data-state="live"] {
  color: var(--success);
}

.status-pill[data-state="error"],
.status-pill[data-state="ended"] {
  color: var(--danger);
}

video {
  display: block;
  width: 100%;
  max-height: 70vh;
  background: #09111e;
  border-radius: 12px;
  object-fit: contain;
}

#local-video {
  aspect-ratio: 16 / 9;
}

.video-card > .button-danger {
  width: 100%;
  margin-top: 16px;
}

.one-way-note {
  margin: 10px 0 0;
  font-size: .82rem;
  line-height: 1.45;
}

.copy-row {
  display: flex;
  gap: 8px;
}

.copy-row input {
  min-width: 0;
}

.qr-image {
  display: block;
  width: min(210px, 100%);
  aspect-ratio: 1;
  padding: 8px;
  margin: 18px auto;
  background: white;
  border-radius: 10px;
}

.viewer-list,
.file-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 12px 0 0;
  list-style: none;
}

.viewer-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--surface-soft);
  border-radius: 10px;
}

.viewer-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-state {
  display: block;
  color: var(--muted);
  font-size: .78rem;
}

.viewer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.viewer-actions .button {
  min-height: 44px;
  padding: 7px 10px;
  font-size: .84rem;
}

.file-drop-zone {
  padding: 14px;
  text-align: center;
  background: var(--surface-soft);
  border: 2px dashed var(--line);
  border-radius: 12px;
}

.file-drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-drop-zone .field-help {
  margin: 10px 0 0;
  font-size: .82rem;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-input:focus-visible + label {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  background: var(--surface-soft);
  border-radius: 10px;
}

.file-item-main {
  min-width: 0;
}

.file-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.file-meta,
.file-state {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.35;
}

.file-item .button {
  align-self: center;
  min-height: 44px;
  padding: 7px 10px;
  font-size: .84rem;
}

.file-item progress {
  grid-column: 1 / -1;
  width: 100%;
  height: 12px;
  accent-color: var(--accent);
}

.viewer-files-card {
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
}

.join-flow {
  width: min(520px, 100%);
  padding: clamp(24px, 6vw, 42px);
  margin: 9vh auto;
}

.join-flow input {
  margin-bottom: 14px;
}

.join-flow .button {
  width: 100%;
}

.waiting-message {
  padding: 28px 18px;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  background: var(--surface-soft);
  border-radius: 12px;
}

.remote-wrap.actual-size {
  max-height: 72vh;
  overflow: auto;
  background: #09111e;
  border-radius: 12px;
}

.remote-wrap.actual-size video {
  width: auto;
  max-width: none;
  min-width: 100%;
  max-height: none;
}

.video-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

#viewer-end-actions {
  margin-top: 18px;
}

.site-footer {
  padding: 0 max(16px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}

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

@media (max-width: 760px) {
  .site-header {
    margin-bottom: 18px;
  }

  .tagline {
    display: none;
  }

  .hero {
    margin-top: 16px;
  }

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

  .host-side {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .copy-row {
    flex-direction: column;
  }

  .copy-row .button {
    width: 100%;
  }

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

  .viewer-item,
  .file-item {
    grid-template-columns: 1fr;
  }

  .viewer-actions,
  .file-item .button {
    justify-self: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
