:root {
  --navy-950: #020b1f;
  --navy-900: #061738;
  --navy-850: #0a2048;
  --navy-800: #0b285a;
  --cyan-500: #20c8d8;
  --cyan-300: #74e4ed;
  --blue-600: #2367f2;
  --white: #ffffff;
  --mist-100: #e7edf6;
  --mist-300: #9fb0c8;
  --line: rgb(255 255 255 / 14%);
  --line-strong: rgb(116 228 237 / 38%);
  --danger: #ffb4a8;
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--navy-950);
  color: var(--white);
  font-family: "Avenir Next", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  width: 34vw;
  height: 34vw;
  border: 1px solid rgb(32 200 216 / 9%);
  border-radius: 50%;
  content: "";
}

body::before { top: -20vw; right: -8vw; }
body::after { bottom: -24vw; left: -12vw; }

button, input, select { font: inherit; }
button { color: inherit; }
h1, p { margin-top: 0; text-wrap: pretty; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 12px;
  left: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--navy-900);
  transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1240px, calc(100vw - 64px));
  height: 88px;
  margin-inline: auto;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand img { border-radius: 11px; }
.brand-copy { display: grid; line-height: 1; }
.brand-copy strong { font-size: 17px; font-weight: 600; letter-spacing: .18em; }
.brand-copy span { margin-top: 5px; color: var(--cyan-300); font-size: 9px; font-weight: 700; letter-spacing: .36em; }

.privacy-note {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--mist-300);
  font-size: 13px;
}
.privacy-note span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan-500);
  box-shadow: 0 0 18px var(--cyan-500);
}

.cast-shell {
  display: grid;
  grid-template-columns: minmax(380px, .84fr) minmax(520px, 1.16fr);
  gap: clamp(40px, 6vw, 92px);
  align-items: center;
  width: min(1240px, calc(100vw - 64px));
  min-height: calc(100vh - 156px);
  margin-inline: auto;
  padding-block: 48px;
}

.eyebrow {
  margin-bottom: 16px;
  color: var(--cyan-300);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .26em;
}

h1 {
  margin-bottom: 22px;
  font-size: clamp(40px, 4.4vw, 68px);
  font-weight: 500;
  letter-spacing: -.045em;
  line-height: 1.08;
}
h1 span { color: var(--cyan-300); }
.lead { max-width: 600px; margin-bottom: 34px; color: var(--mist-300); font-size: 17px; }

.room-form label,
.select-control > span {
  display: block;
  margin-bottom: 9px;
  color: var(--mist-100);
  font-size: 13px;
  font-weight: 600;
}
.room-entry { display: grid; grid-template-columns: minmax(160px, 1fr) auto; gap: 12px; }

input[type="text"], select {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  background: rgb(10 32 72 / 64%);
  color: var(--white);
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}
input[type="text"] {
  padding: 0 18px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: .16em;
}
select { padding: 0 42px 0 15px; appearance: auto; }
input[type="text"]:focus, select:focus-visible {
  border-color: var(--cyan-300);
  background: var(--navy-850);
  box-shadow: 0 0 0 4px rgb(32 200 216 / 14%);
}

.field-help { margin: 9px 0 0; color: var(--mist-300); font-size: 12px; }
.button {
  min-height: 54px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 650;
  transition: transform 180ms var(--ease), background 180ms ease, border-color 180ms ease, opacity 180ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-2px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:focus-visible { outline: 3px solid var(--cyan-300); outline-offset: 3px; }
.button:disabled { cursor: not-allowed; opacity: .42; }
.button-primary { background: var(--cyan-500); color: var(--navy-950); }
.button-primary:hover:not(:disabled) { background: var(--cyan-300); }
.button-stop { border-color: var(--line); background: transparent; }
.button-stop:hover:not(:disabled) { border-color: var(--line-strong); background: var(--navy-850); }

.cast-options {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 14px;
  margin-top: 24px;
}
.select-control, .toggle-control {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgb(6 23 56 / 62%);
}
.select-control > span { margin-bottom: 7px; }
.select-control select { min-height: 42px; font-size: 13px; }
.toggle-control { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.toggle-control > span { display: grid; }
.toggle-control strong { font-size: 13px; }
.toggle-control small { margin-top: 3px; color: var(--mist-300); font-size: 10px; }
.toggle-control input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-control i {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--navy-950);
  transition: background 180ms ease, border-color 180ms ease;
}
.toggle-control i::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--mist-300);
  content: "";
  transition: transform 180ms var(--ease), background 180ms ease;
}
.toggle-control input:checked + i { border-color: var(--cyan-500); background: rgb(32 200 216 / 24%); }
.toggle-control input:checked + i::after { background: var(--cyan-300); transform: translateX(18px); }
.toggle-control input:focus-visible + i { outline: 3px solid var(--cyan-300); outline-offset: 3px; }

.session-actions { display: flex; align-items: center; gap: 18px; margin-top: 22px; }
.session-actions p { margin: 0; color: var(--mist-300); font-size: 11px; line-height: 1.45; }

.preview-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--navy-900);
  box-shadow: 0 42px 120px rgb(0 7 24 / 42%);
}
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.status { display: flex; align-items: center; gap: 9px; color: var(--mist-300); font-size: 12px; }
.status span { width: 8px; height: 8px; border-radius: 50%; background: var(--mist-300); }
.status[data-state="waiting"] span, .status[data-state="connecting"] span { background: var(--cyan-500); box-shadow: 0 0 14px rgb(32 200 216 / 64%); }
.status[data-state="connected"] { color: var(--cyan-300); }
.status[data-state="connected"] span { background: var(--cyan-300); box-shadow: 0 0 14px var(--cyan-500); }
.status[data-state="error"] { color: var(--danger); }
.status[data-state="error"] span { background: var(--danger); }
.transport { color: var(--mist-300); font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; letter-spacing: .08em; }

.screen-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid rgb(255 255 255 / 9%);
  border-radius: var(--radius-md);
  background: var(--navy-950);
}
.screen-frame video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.empty-preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 32px;
  text-align: center;
}
.empty-preview[hidden] { display: none; }
.empty-preview strong { margin-top: 10px; font-size: clamp(18px, 2vw, 26px); font-weight: 550; }
.empty-preview span { color: var(--mist-300); font-size: 13px; }
.signal-mark { display: flex; align-items: end; gap: 6px; height: 44px; }
.signal-mark i { width: 7px; border-radius: 8px; background: var(--cyan-500); }
.signal-mark i:nth-child(1) { height: 15px; opacity: .45; }
.signal-mark i:nth-child(2) { height: 28px; opacity: .72; }
.signal-mark i:nth-child(3) { height: 42px; }

.session-detail { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 12px; margin-top: 16px; }
.session-detail > span { color: var(--cyan-300); font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.session-detail p { margin: 0; color: var(--mist-300); font-size: 13px; }
.error-detail { margin-top: 14px; padding: 12px 14px; border: 1px solid rgb(255 180 168 / 30%); border-radius: var(--radius-sm); color: var(--danger); font-size: 12px; }

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 24px;
  width: min(1240px, calc(100vw - 64px));
  margin-inline: auto;
  padding: 18px 0 28px;
  border-top: 1px solid var(--line);
  color: var(--mist-300);
  font-size: 11px;
}

footer a {
  color: inherit;
  transition: color 180ms ease;
}

footer a:hover,
footer a:focus-visible {
  color: var(--cyan-300);
}

@media (max-width: 980px) {
  .cast-shell { grid-template-columns: 1fr; width: min(720px, calc(100vw - 40px)); padding-block: 38px; }
  .topbar, footer { width: calc(100vw - 40px); }
  .preview-panel { order: -1; }
}

@media (max-width: 640px) {
  .topbar { height: 72px; }
  .privacy-note { display: none; }
  .cast-shell { width: calc(100vw - 28px); gap: 34px; padding-block: 24px 36px; }
  .room-entry, .cast-options { grid-template-columns: 1fr; }
  .room-entry .button { width: 100%; }
  .session-actions { align-items: flex-start; flex-direction: column; }
  .session-actions .button { width: 100%; }
  .preview-panel { padding: 12px; border-radius: var(--radius-md); }
  .transport { display: none; }
  footer { flex-direction: column; width: calc(100vw - 28px); }
}

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