:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-subtle: #f5f5f7;
  --surface-muted: rgba(118, 118, 128, 0.10);
  --ink: #1d1d1f;
  --ink-secondary: #6e6e73;
  --ink-tertiary: #86868b;
  --line: rgba(0, 0, 0, 0.075);
  --line-strong: rgba(0, 0, 0, 0.14);
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --blue-active: #0066cc;
  --blue-soft: rgba(0, 113, 227, 0.085);
  --green: #34c759;
  --amber: #ff9f0a;
  --red: #d70015;
  --red-soft: rgba(255, 59, 48, 0.09);
  --red-soft-hover: rgba(255, 59, 48, 0.15);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.025), 0 8px 28px -8px rgba(0, 0, 0, 0.055);
  --shadow-card-hover: 0 2px 6px rgba(0, 0, 0, 0.035), 0 14px 36px -10px rgba(0, 0, 0, 0.085);
  --shadow-float: 0 2px 8px rgba(0, 0, 0, 0.04), 0 12px 32px -6px rgba(0, 0, 0, 0.08);
  --shadow-dialog: 0 24px 68px -12px rgba(0, 0, 0, 0.24), 0 0 0 1px rgba(0, 0, 0, 0.06);
  --radius-card: 22px;
  --radius-control: 12px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button, input, select {
  font: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.28);
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.44;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

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

svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* App Shell */
.app {
  min-height: 100dvh;
  background: linear-gradient(180deg, #fafafa 0%, var(--bg) 38%);
}

.titlebar {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 56px;
  background: rgba(245, 245, 247, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.title-inner {
  height: 100%;
  max-width: 1200px;
  padding: 0 28px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-decoration: none;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  white-space: nowrap;
  color: var(--ink);
  border-radius: 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(180deg, #1a8cff 0%, #0066dc 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 1px 3px rgba(0, 113, 227, 0.28);
}

.brand-mark i {
  position: absolute;
  border: 1.5px solid rgba(255, 255, 255, 0.96);
  width: 11px;
  height: 8.5px;
  border-radius: 2px;
  top: 7.5px;
  left: 6.5px;
}

.brand-mark i + i {
  top: 11.5px;
  left: 10px;
  background: #0b78ef;
}

/* Workspace Layout */
.workspace {
  width: min(1120px, calc(100% - 56px));
  margin: auto;
  padding: 24px 0 40px;
}

.workspace-home {
  width: min(840px, calc(100% - 48px));
  min-height: calc(100dvh - 56px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 36px 0 68px;
}

.intro {
  margin-bottom: 20px;
}

.workspace-home .intro {
  text-align: center;
  margin-bottom: 36px;
}

h1 {
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.workspace-home h1 {
  font-size: clamp(34px, 4vw, 44px);
  letter-spacing: -0.02em;
}

h2 {
  font-size: 21px;
  line-height: 1.25;
  font-weight: 620;
  letter-spacing: -0.015em;
  color: var(--ink);
}

h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.intro p, .muted, .card p {
  color: var(--ink-secondary);
  line-height: 1.6;
}

.intro p {
  margin-top: 8px;
  font-size: 15.5px;
}

.workspace-home .intro p {
  margin-top: 10px;
  font-size: 16.5px;
}

/* Buttons */
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 550;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.16s var(--ease), border-color 0.16s var(--ease), color 0.16s var(--ease), box-shadow 0.16s var(--ease), transform 0.12s var(--ease);
}

.btn:hover:not(:disabled) {
  background: #f5f5f7;
  border-color: rgba(0, 0, 0, 0.18);
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn.primary {
  color: #ffffff;
  background: var(--blue);
  border-color: transparent;
}

.btn.primary:hover:not(:disabled) {
  background: var(--blue-hover);
  border-color: transparent;
}

.btn.primary:active:not(:disabled) {
  background: var(--blue-active);
}

.btn.secondary-dark {
  color: #ffffff;
  background: var(--ink);
  border-color: transparent;
}

.btn.secondary-dark:hover:not(:disabled) {
  background: #333336;
  border-color: transparent;
}

.btn.secondary-dark:active:not(:disabled) {
  background: #141416;
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-secondary);
}

.btn.ghost:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
  border-color: transparent;
  color: var(--ink);
}

.btn.stop {
  color: var(--red);
  background: var(--red-soft);
  border-color: transparent;
}

.btn.stop:hover:not(:disabled) {
  background: var(--red-soft-hover);
  border-color: transparent;
}

.btn.square {
  padding: 8px;
  min-width: 38px;
}

.btn.big {
  min-height: 46px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 560;
  border-radius: var(--radius-control);
}

.btn.active,
.btn[aria-pressed="true"] {
  background: var(--blue-soft);
  border-color: rgba(0, 113, 227, 0.22);
  color: var(--blue);
}

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

/* Home View */
.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.home-card {
  padding: 32px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.22s var(--ease), box-shadow 0.22s var(--ease);
}

.home-card:hover {
  border-color: rgba(0, 0, 0, 0.11);
  box-shadow: var(--shadow-card-hover);
}

.home-card h2 {
  font-size: 22px;
  margin-top: 18px;
}

.home-card > p {
  margin-top: 6px;
  font-size: 14.5px;
  color: var(--ink-secondary);
}

.feature-icon {
  width: 46px;
  height: 46px;
  background: var(--surface-subtle);
  border: 1px solid rgba(0, 0, 0, 0.045);
  color: var(--ink);
  display: grid;
  place-items: center;
  border-radius: 13px;
}

.feature-icon.accent {
  background: var(--blue-soft);
  border-color: rgba(0, 113, 227, 0.12);
  color: var(--blue);
}

.feature-icon svg {
  width: 22px;
  height: 22px;
}

.home-action-group {
  margin-top: 28px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
}

.home-action-group .big {
  width: 100%;
  margin-top: 12px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 560;
  color: var(--ink-secondary);
  margin-bottom: 8px;
  letter-spacing: -0.005em;
}

/* Apple Segmented Control */
.segmented {
  display: inline-flex;
  gap: 3px;
  background: var(--surface-muted);
  padding: 4px;
  border-radius: var(--radius-control);
}

.home-segmented {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 48px;
  align-items: stretch;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 13.5px;
  font-weight: 540;
  border-radius: 9px;
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background-color 0.16s var(--ease), color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.seg-btn:hover {
  color: var(--ink);
}

.seg-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 1px rgba(0, 0, 0, 0.04);
}

/* Inputs */
.field {
  width: 100%;
  padding: 10px 14px;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: #fbfbfd;
  color: var(--ink);
  transition: border-color 0.16s var(--ease), background-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.field:hover {
  border-color: rgba(0, 0, 0, 0.22);
}

.field:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--blue);
  box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.16);
}

.field[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.12);
}

.code-field {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  text-align: center;
  padding-inline: 14px;
}

.code-field::placeholder {
  color: #b4b4ba;
  font-weight: 400;
}

.card-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  min-height: 38px;
  display: flex;
  align-items: center;
}

.footer-note {
  font-size: 13px;
  color: var(--ink-tertiary);
  letter-spacing: -0.005em;
}

.link-button {
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--blue);
  font-weight: 550;
  font-size: 13.5px;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 6px;
  transition: opacity 0.15s var(--ease);
}

.link-button svg {
  width: 16px;
  height: 16px;
}

.link-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.error {
  font-size: 13px !important;
  color: var(--red) !important;
  margin-top: 8px;
}

.notice {
  padding: 12px 16px;
  background: rgba(0, 113, 227, 0.065);
  border: 1px solid rgba(0, 113, 227, 0.16);
  border-radius: 12px;
  color: #0051a8;
  font-size: 14px;
  margin-bottom: 18px;
}

.demo-tray {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 16px;
  font-size: 13.5px;
  color: var(--ink-secondary);
}

.demo-tray strong {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--ink);
  font-weight: 600;
}

/* Source Picker */
.pick {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(268px, 1fr);
  gap: 20px;
  align-items: start;
}

.pick-card {
  padding: 24px;
}

.tabs {
  display: inline-flex;
  gap: 3px;
  background: var(--surface-muted);
  padding: 4px;
  border-radius: 11px;
  margin-bottom: 18px;
  max-width: 100%;
}

.tabs .btn {
  border-color: transparent;
  background: transparent;
  color: var(--ink-secondary);
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13.5px;
}

.tabs .btn:hover:not(:disabled) {
  color: var(--ink);
  background: transparent;
}

.tabs .btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 1px rgba(0, 0, 0, 0.04);
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.source {
  color: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  min-width: 0;
  transition: border-color 0.16s var(--ease), background-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.source:hover {
  border-color: rgba(0, 0, 0, 0.18);
  background: #fbfbfd;
}

.source[aria-pressed="true"] {
  border-color: var(--blue);
  background: rgba(0, 113, 227, 0.035);
  box-shadow: 0 0 0 1px var(--blue);
}

.source-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 9px 4px 2px;
  font-size: 14px;
  font-weight: 580;
  color: var(--ink);
}

.source-caption span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-caption svg {
  width: 16px;
  height: 16px;
  color: var(--blue);
}

.source-caption small {
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 500;
}

.aside {
  padding: 24px;
}

.aside h3 {
  margin-bottom: 14px;
}

.aside .source-caption {
  padding-left: 0;
}

.meta {
  font-size: 13px;
  color: var(--ink-secondary);
  margin-top: 4px;
  line-height: 1.5;
}

.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

/* Apple Toggle Switch */
.switch {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 560;
  min-height: 34px;
  color: var(--ink);
  cursor: pointer;
}

.switch input {
  appearance: none;
  -webkit-appearance: none;
  width: 42px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: #e5e5ea;
  margin: 0;
  padding: 2px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s var(--ease);
}

.switch input:before {
  content: "";
  display: block;
  background: #ffffff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 1px rgba(0, 0, 0, 0.08);
  transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}

.switch input:checked {
  background: var(--green);
}

.switch input:checked:before {
  transform: translateX(16px);
}

.aside .big {
  width: 100%;
  margin-top: 18px;
}

/* Preview Art & Native Thumbnails */
.preview-art {
  overflow: hidden;
  background: #f5f5f7;
  aspect-ratio: 16 / 9;
  border-radius: 9px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  position: relative;
  color: var(--ink);
  pointer-events: none;
}

.source[style*="grid-column"] .preview-art {
  max-height: 310px;
  width: 100%;
}

.preview-art > [style-fallback] {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.preview-art .mini-head {
  height: 24px;
  min-height: 10%;
  background: #fafafa;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  color: var(--ink-secondary);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 11px;
  white-space: nowrap;
}

.mini-head b {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d2d2d7;
}

.mini-head span {
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 4px;
}

.mini-body {
  display: flex;
  flex: 1;
  min-height: 0;
  background: linear-gradient(145deg, #ffffff 0%, #f2f2f7 100%);
}

.mini-side {
  width: 18%;
  background: #f5f5f7;
  padding: 7% 4% 0;
  border-right: 1px solid rgba(0, 0, 0, 0.055);
  display: flex;
  flex-direction: column;
  gap: 8%;
  overflow: hidden;
}

.mini-side i {
  display: block;
  height: 4px;
  min-height: 2px;
  background: rgba(0, 0, 0, 0.10);
  border-radius: 3px;
}

.mini-side i:first-child {
  background: rgba(0, 113, 227, 0.35);
  width: 82%;
}

.mini-side i:nth-child(3) {
  width: 64%;
}

.mini-canvas {
  flex: 1;
  padding: 8%;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 7%;
}

.mini-canvas i {
  display: block;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.045);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.mini-canvas i:first-child {
  grid-row: 1 / -1;
  background: linear-gradient(160deg, rgba(0, 113, 227, 0.11) 0%, rgba(0, 113, 227, 0.03) 100%);
  border-color: rgba(0, 113, 227, 0.10);
}

.art-deck .mini-side {
  width: 22%;
}

.art-deck .mini-canvas {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.art-explorer .mini-body {
  background: #ffffff;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  gap: 6%;
  padding: 8%;
}

.file-grid i {
  background: #ececf0;
  border-radius: 5px;
}

.art-screen .mini-side {
  width: 19%;
}

.art-screen2 .mini-canvas i:first-child {
  background: linear-gradient(160deg, rgba(29, 29, 31, 0.09) 0%, rgba(29, 29, 31, 0.025) 100%);
  border-color: rgba(0, 0, 0, 0.06);
}

.preview-art.native-art {
  background: #141416;
  border-color: transparent;
  display: grid;
  place-items: center;
}

.native-art img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.region-frame {
  position: absolute;
  border: 2px dashed var(--blue);
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.34);
  pointer-events: none;
}

.region-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.region-fields label {
  font-size: 12.5px;
  font-weight: 560;
  color: var(--ink-secondary);
}

.region-fields input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fbfbfd;
  color: var(--ink);
  margin-top: 5px;
}

.region-fields input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.16);
}

.source-grid > .notice {
  grid-column: 1 / -1;
  margin: 0;
}

/* Host & Viewer Session Views */
.session-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.session-head h1 {
  font-size: 30px;
}

.sharing-toolbar {
  position: sticky;
  top: 66px;
  z-index: 3;
  padding: 10px 12px 10px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-float);
  margin-bottom: 16px;
}

.active-title {
  min-width: 0;
  line-height: 1.3;
}

.active-title strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--ink);
}

.active-title span {
  display: block;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  font-size: 12.5px;
  color: var(--ink-secondary);
  margin-top: 2px;
}

.dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.18);
  flex-shrink: 0;
}

.active-title .dot {
  margin: 0;
}

.active-title .paused {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(255, 159, 10, 0.18);
}

.toolbar-actions {
  flex-wrap: nowrap;
}

.toolbar-actions .btn {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13.5px;
}

.voice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px 14px 10px 18px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.voice-bar strong {
  font-size: 14px;
  font-weight: 580;
  color: var(--ink);
}

.voice-bar .btn {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13.5px;
}

.session-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 18px;
}

/* Cinema Dark Stage */
.stage {
  background: #0b0b0d;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 18px;
  color: #f5f5f7;
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 14px 36px -14px rgba(0, 0, 0, 0.24);
}

.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 16px;
  background: #161618;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #e5e5ea;
  font-size: 13px;
  font-weight: 520;
  flex-wrap: wrap;
}

.stage-head span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-variant-numeric: tabular-nums;
}

.stage-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b0b0d;
  min-height: 340px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.stage-area > .preview-art {
  width: 100%;
  border-radius: 0;
  max-height: 62vh;
}

.stage-area video {
  display: block;
  max-width: 100%;
  max-height: 62vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.stage-area.actual {
  display: block;
  overflow: auto;
}

.stage-area.actual > .preview-art,
.stage-area.actual > video {
  width: var(--source-width, 1440px);
  height: auto;
  max-width: none;
  max-height: none;
}

.stage-area.fill video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
}

.mobile-imm-only {
  display: none;
}

.stage:fullscreen,
.stage.fullscreen-like {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: block;
  width: 100vw;
  height: 100dvh;
  background: #000000;
  border-radius: 0;
  border: 0;
}

.stage:fullscreen .stage-head,
.stage.fullscreen-like .stage-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.74) 0%, rgba(0, 0, 0, 0.32) 65%, rgba(0, 0, 0, 0) 100%);
  border-bottom: 0;
  padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 14px max(14px, env(safe-area-inset-left));
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
}

.stage:fullscreen.hud-hidden .stage-head,
.stage.fullscreen-like.hud-hidden .stage-head {
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
}

.stage:fullscreen .stage-area,
.stage.fullscreen-like .stage-area {
  position: absolute;
  inset: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  background: #000000;
}

.stage:fullscreen .stage-area:not(.actual) video,
.stage.fullscreen-like .stage-area:not(.actual) video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.stage:fullscreen .stage-area.fill video,
.stage.fullscreen-like .stage-area.fill video {
  object-fit: cover;
}

.stage:fullscreen .stage-area > .preview-art,
.stage.fullscreen-like .stage-area > .preview-art {
  max-height: 100%;
  height: 100%;
}

/* Automatic full-screen immersion on any phone in landscape */
@media (max-height: 540px) and (max-width: 1024px) {
  body.is-live-viewer .titlebar,
  body.is-live-viewer .workspace-viewer .session-head,
  body.is-live-viewer .workspace-viewer .voice-bar {
    display: none;
  }

  body.is-live-viewer .workspace-viewer {
    padding: 0;
    width: 100%;
  }

  body.is-live-viewer .viewer-stage {
    position: fixed;
    inset: 0;
    z-index: 8;
    display: block;
    width: 100vw;
    height: 100dvh;
    margin: 0 !important;
    background: #000000;
    border-radius: 0;
    border: 0;
  }

  body.is-live-viewer .viewer-stage .stage-head {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    min-height: 40px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.74) 0%, rgba(0, 0, 0, 0.32) 65%, rgba(0, 0, 0, 0) 100%);
    border-bottom: 0;
    padding: max(6px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
    transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
  }

  body.is-live-viewer .viewer-stage.hud-hidden .stage-head {
    opacity: 0;
    transform: translateY(-100%);
    pointer-events: none;
  }

  body.is-live-viewer .viewer-stage .stage-area {
    position: absolute;
    inset: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    background: #000000;
  }

  body.is-live-viewer .viewer-stage .stage-area:not(.actual) video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }

  body.is-live-viewer .viewer-stage .stage-area.fill video {
    object-fit: cover;
  }

  body.is-live-viewer .viewer-stage .mobile-imm-only {
    display: inline-flex;
  }
}

.viewer-tools .btn {
  min-height: 32px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.09);
  color: #f5f5f7;
  border-color: transparent;
  border-radius: 8px;
  font-size: 13px;
}

.viewer-tools .btn:hover:not(:disabled),
.viewer-tools .btn[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border-color: transparent;
}

.viewer-tools svg {
  width: 15px;
  height: 15px;
}

.viewer-tools.folded .foldable {
  display: none;
}

.state {
  padding: 48px 20px;
  text-align: center;
  min-height: 340px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
}

.state h2 {
  color: #f5f5f7;
  font-size: 20px;
}

.state-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f5f5f7;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

.state-icon svg {
  width: 25px;
  height: 25px;
}

.state p {
  font-size: 14px;
  line-height: 1.6;
  color: #a1a1a6;
}

.state .btn {
  margin-top: 8px;
  justify-self: center;
}

/* Invite Card */
.invite-card {
  padding: 22px;
  align-self: start;
}

.invite-card h2 {
  font-size: 18px;
}

.invite-card p {
  font-size: 13px;
  margin-top: 5px;
  color: var(--ink-secondary);
}

.invite-qr {
  width: 152px;
  height: 152px;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin: 18px auto 12px;
  background: #ffffff;
  padding: 8px;
}

.invite-qr img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.invite-code {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 620;
  line-height: 1.25;
  text-align: center;
  letter-spacing: 0.2em;
  padding-left: 0.2em;
  margin: 8px 0 16px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.invite-card .actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.invite-card .actions .btn {
  padding-inline: 10px;
  font-size: 13px;
}

.invite-card > .btn {
  width: 100%;
  margin-top: 8px;
  font-size: 13.5px;
}

/* Dialogs */
dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-dialog);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dialog-body {
  padding: 24px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.dialog-head h2 {
  font-size: 19px;
}

.dialog-body .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  font-size: 14px;
}

.dialog-body .row + .row {
  border-top: 1px solid var(--line);
}

.dialog-body .row select {
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  background: #fbfbfd;
  border-radius: 8px;
  color: var(--ink);
}

.dialog-body .row select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.16);
}

.dialog-body .actions {
  margin-top: 18px;
  justify-content: flex-end;
}

.dialog-body .stack {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.dialog-body .stack > .btn {
  justify-content: flex-start;
  min-height: 42px;
}

/* Network Mode Pill & Connection Settings */
.net-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink-secondary);
  font-size: 12.5px;
  font-weight: 550;
  transition: background-color 0.16s var(--ease), border-color 0.16s var(--ease), color 0.16s var(--ease);
}

.net-pill:hover {
  background: #ffffff;
  border-color: var(--line-strong);
  color: var(--ink);
}

.net-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aeaeb2;
  flex-shrink: 0;
}

.net-pill.online {
  color: var(--ink);
}

.net-pill.online i {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.18);
}

.invite-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.scope-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 580;
  white-space: nowrap;
}

.scope-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.scope-badge.public {
  background: rgba(52, 199, 89, 0.12);
  color: #1c7d36;
}

.scope-badge.public i {
  background: var(--green);
}

.scope-badge.lan {
  background: var(--surface-muted);
  color: var(--ink-secondary);
}

.scope-badge.lan i {
  background: #8e8e93;
}

.invite-url {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.invite-tip {
  margin-top: 12px;
  width: 100%;
  justify-content: center;
  font-size: 12.5px;
}

.field-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.field-row .field {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  font-size: 14px;
}

.field-row .btn {
  min-height: 42px;
  padding-inline: 14px;
}

.adv-details {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.adv-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-secondary);
  list-style: none;
}

.adv-details summary::-webkit-details-marker {
  display: none;
}

.adv-details summary:hover {
  color: var(--ink);
}

.code-area {
  min-height: 74px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
}

.ok-text {
  color: #1c7d36 !important;
  font-weight: 550;
}

/* Apple HUD Toast */
.toast {
  position: fixed;
  z-index: 9;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(29, 29, 31, 0.88);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 520;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
  max-width: calc(100% - 32px);
  text-align: center;
}

.compact-only,
.sharing-toolbar .compact-only {
  display: none;
}

/* Responsive */
@media (min-width: 1800px) {
  .app {
    zoom: 1.15;
    min-height: calc(100dvh / 1.15);
  }
  .workspace-home {
    min-height: calc((100dvh / 1.15) - 56px);
  }
}

@media (max-width: 1080px) {
  .toolbar-actions .foldable {
    display: none;
  }
  .compact-only,
  .sharing-toolbar .compact-only {
    display: inline-flex;
  }
  .session-grid {
    grid-template-columns: minmax(0, 1fr) 260px;
  }
  .workspace {
    padding-top: 28px;
  }
}

@media (min-width: 801px) and (max-width: 1080px) {
  .invite-card .actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .invite-card .actions .btn {
    padding-inline: 6px;
    gap: 5px;
  }
  .invite-card .actions .btn svg {
    width: 15px;
    height: 15px;
  }
}

@media (max-width: 800px) {
  .workspace,
  .workspace-home {
    width: calc(100% - 32px);
    padding-top: 28px;
    padding-bottom: 40px;
    min-height: auto;
    justify-content: flex-start;
  }
  .title-inner {
    padding-inline: 16px;
  }
  .home-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .home-card {
    padding: 24px;
  }
  .home-action-group {
    margin-top: 22px;
    margin-bottom: 18px;
  }
  .pick {
    grid-template-columns: 1fr;
  }
  .session-grid {
    grid-template-columns: 1fr;
  }
  .invite-card {
    width: 100%;
  }
  .session-head h1 {
    font-size: 26px;
  }
  .stage-area {
    min-height: 220px;
  }
  .workspace-viewer .viewer-stage {
    margin-inline: -16px;
    width: calc(100% + 32px);
    border-radius: 0;
    border-inline: 0;
  }
  .workspace-viewer .viewer-stage .stage-area:not(.actual) video {
    width: 100%;
    max-height: 76dvh;
  }
  .viewer-tools .foldable span {
    display: none;
  }
}

@media (max-width: 480px) {
  .titlebar {
    height: 52px;
  }
  .workspace,
  .workspace-home {
    width: calc(100% - 24px);
  }
  .workspace-home .intro {
    margin-bottom: 24px;
  }
  .home-card,
  .pick-card,
  .aside {
    padding: 20px;
  }
  .session-head {
    align-items: flex-start;
  }
  .stage-head {
    padding: 8px 12px;
  }
  .workspace-viewer .viewer-stage {
    margin-inline: -12px;
    width: calc(100% + 24px);
  }
  .toolbar-actions {
    gap: 5px;
  }
  .sharing-toolbar {
    padding: 8px 10px;
    gap: 8px;
  }
  .toolbar-actions .btn {
    padding: 6px 8px;
    gap: 4px;
  }
  .toolbar-actions .btn svg {
    width: 15px;
    height: 15px;
  }
  .region-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .demo-tray {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 360px) {
  .invite-card .actions .btn {
    padding-inline: 7px;
    gap: 5px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .reconnect-icon svg {
    animation: spin 1.2s linear infinite;
  }
  @keyframes spin {
    to {
      transform: rotate(360deg);
    }
  }
}
