:root {
  --bg: #0a1018;
  --bg-2: #111a26;
  --shell: rgba(10, 16, 24, 0.72);
  --panel: rgba(16, 24, 36, 0.86);
  --panel-2: rgba(20, 30, 45, 0.88);
  --panel-3: rgba(9, 14, 22, 0.94);
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.22);
  --ink: #f8fbff;
  --muted: #9eb0c7;
  --muted-2: #6d8199;
  --accent: #23d3a1;
  --accent-2: #1ab8ff;
  --accent-soft: rgba(35, 211, 161, 0.14);
  --warn: #ffba49;
  --shadow: 0 28px 64px rgba(0, 0, 0, 0.34);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 18%, rgba(26, 184, 255, 0.16), transparent 28%),
    radial-gradient(circle at 86% 14%, rgba(35, 211, 161, 0.14), transparent 22%),
    linear-gradient(180deg, #071019 0%, #09111b 38%, #0d1622 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(18px);
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 340px;
  height: 340px;
  top: -80px;
  right: -120px;
  background: rgba(26, 184, 255, 0.12);
}

body::after {
  width: 420px;
  height: 420px;
  bottom: -160px;
  left: -140px;
  background: rgba(35, 211, 161, 0.09);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1840px, calc(100% - 24px));
  margin: 12px auto 20px;
}

.panel,
.topbar {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.panel {
  background: var(--panel);
  border-radius: var(--radius-xl);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 18px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(18, 26, 39, 0.9), rgba(10, 16, 24, 0.84)),
    var(--shell);
}

.reveal {
  animation: rise-in 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.topbar-brand,
.topbar-meta,
.stage-toolbar,
.stage-toolbar-meta,
.panel-head,
.token-head,
.console-head,
.remote-meta {
  display: flex;
  align-items: center;
}

.topbar-brand {
  gap: 14px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(35, 211, 161, 0.94), rgba(26, 184, 255, 0.88));
  box-shadow:
    0 10px 24px rgba(26, 184, 255, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong,
.stage-toolbar h1,
.panel-head h2,
.token-head h3,
.console-head h3 {
  margin: 0;
  font-family: "Sora", sans-serif;
  letter-spacing: -0.03em;
}

.brand-copy strong {
  font-size: 1rem;
  font-weight: 600;
}

.brand-label,
.section-kicker {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.topbar-meta {
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
}

.top-pill,
.token-tag,
.panel-status,
.audience-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.86rem;
}

.panel-status {
  color: #dffbf2;
  border-color: rgba(35, 211, 161, 0.22);
  background: rgba(35, 211, 161, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 392px;
  gap: 16px;
  margin-top: 14px;
  align-items: start;
}

.sidebar-stack {
  display: grid;
  gap: 16px;
}

.stage-panel,
.control-panel,
.token-panel,
.console-panel {
  padding: 18px;
}

.stage-toolbar,
.panel-head,
.token-head,
.console-head {
  justify-content: space-between;
  gap: 14px;
}

.stage-toolbar-meta {
  justify-content: end;
  gap: 10px;
  flex-wrap: wrap;
}

.stage-toolbar h1,
.panel-head h2,
.token-head h3,
.console-head h3 {
  font-size: clamp(1.1rem, 1.7vw, 1.5rem);
  font-weight: 600;
}

.compact-head {
  align-items: start;
}

.section-kicker {
  margin-bottom: 8px;
}

.audience-pill {
  color: #dffbf2;
  border-color: rgba(35, 211, 161, 0.18);
  background: rgba(35, 211, 161, 0.08);
}

.orientation-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.orientation-button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.orientation-button:hover {
  color: var(--ink);
}

.orientation-button.is-active {
  color: #02140f;
  background: linear-gradient(135deg, var(--accent), #7affd3);
}

.orientation-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 184, 255, 0.18);
}

.profile-toggle {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease;
}

.profile-toggle.is-active {
  color: #dffbf2;
  border-color: rgba(35, 211, 161, 0.2);
  background: rgba(35, 211, 161, 0.12);
}

.profile-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 184, 255, 0.18);
}

.stage-surface.viewport-landscape {
  max-width: none;
  min-height: 420px;
}

.stage-surface.viewport-portrait {
  width: 100%;
  max-width: none;
  min-height: 420px;
  margin-left: 0;
  margin-right: 0;
}

.audience-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(35, 211, 161, 0.12);
}

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

.summary-item {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    var(--panel-2);
}

.summary-item span,
.field-hint,
.warning-card p {
  color: var(--muted);
}

.summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: 0.98rem;
  word-break: break-all;
}

.stage-surface {
  position: relative;
  min-height: clamp(560px, 74vh, 900px);
  margin-top: 14px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background:
    radial-gradient(circle at top, rgba(26, 184, 255, 0.12), transparent 28%),
    linear-gradient(180deg, rgba(6, 11, 17, 0.94), rgba(3, 8, 13, 0.98));
  overflow: hidden;
}

.video-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--remote-columns, 1), minmax(0, var(--remote-card-width, 100%)));
  justify-content: center;
  gap: 14px;
  width: 100%;
}

.empty-state {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  background:
    radial-gradient(circle at center, rgba(26, 184, 255, 0.08), transparent 36%),
    rgba(255, 255, 255, 0.02);
}

.empty-orbit {
  width: 124px;
  height: 124px;
  border-radius: 999px;
  border: 2px solid rgba(35, 211, 161, 0.16);
  box-shadow:
    0 0 0 22px rgba(35, 211, 161, 0.05),
    inset 0 0 0 18px rgba(26, 184, 255, 0.06);
}

.empty-title {
  font-family: "Sora", sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
}

.empty-state p {
  margin: 0;
}

.remote-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top left, rgba(35, 211, 161, 0.18), transparent 26%),
    radial-gradient(circle at top right, rgba(26, 184, 255, 0.2), transparent 24%),
    linear-gradient(180deg, #132133 0%, #0a111b 100%);
  box-shadow: inset 0 -100px 120px rgba(0, 0, 0, 0.42);
  animation: tile-in 280ms ease both;
  aspect-ratio: 16 / 9;
}

.remote-video {
  position: absolute;
  inset: 0;
}

.remote-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: grid;
  gap: 6px;
  max-width: min(86%, 420px);
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(5, 10, 16, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
}

.profile-line {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.74rem;
  line-height: 1.35;
  word-break: break-word;
}

.remote-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.92rem;
}

.remote-card.has-video .remote-placeholder {
  opacity: 0;
  pointer-events: none;
}

body.profile-overlay-hidden .profile-overlay {
  display: none;
}

.stage-surface.viewport-portrait .remote-card {
  aspect-ratio: 9 / 16;
}

.stage-surface.viewport-landscape .remote-card {
  aspect-ratio: 16 / 9;
}

.remote-meta {
  position: absolute;
  right: 14px;
  bottom: 14px;
  left: 14px;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

.remote-title {
  display: grid;
  gap: 4px;
}

.remote-title strong {
  color: #fff;
  font-size: 1rem;
}

.remote-title span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.85rem;
}

.remote-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.remote-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(5, 10, 16, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.76rem;
  backdrop-filter: blur(12px);
}

.warning-card {
  margin-top: 14px;
  padding: 14px 15px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 186, 73, 0.18);
  background: linear-gradient(180deg, rgba(255, 186, 73, 0.08), rgba(255, 186, 73, 0.04));
}

.warning-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffe1a4;
  margin-bottom: 6px;
}

.warning-card p {
  margin: 0;
  line-height: 1.55;
}

.player-form {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-label {
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select,
.token-preview {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: inherit;
}

.field input,
.field select {
  min-height: 48px;
  padding: 0 14px;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.field input::placeholder {
  color: var(--muted-2);
}

.field input:focus,
.field select:focus,
.btn:focus,
.token-preview:focus {
  outline: none;
  border-color: rgba(26, 184, 255, 0.34);
  box-shadow: 0 0 0 4px rgba(26, 184, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.field-hint {
  font-size: 0.82rem;
  line-height: 1.45;
  word-break: break-all;
}

.layout-config {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.layout-config-head {
  display: grid;
  gap: 4px;
}

.layout-mode-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.layout-mode-title {
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #dbe7f7;
  text-transform: uppercase;
}

.layout-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.compact-field .field-label {
  font-size: 0.8rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.segment {
  position: relative;
  display: inline-flex;
}

.segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment span {
  width: 100%;
  min-height: 46px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

.segment input:checked + span {
  color: #02140f;
  background: linear-gradient(135deg, var(--accent), #7affd3);
  border-color: transparent;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 180ms ease,
    opacity 180ms ease,
    box-shadow 180ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  color: #02140f;
  background: linear-gradient(135deg, var(--accent), #7affd3);
  box-shadow: 0 18px 32px rgba(35, 211, 161, 0.2);
}

.btn-secondary {
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.btn-ghost {
  min-height: auto;
  padding: 10px 14px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.token-panel {
  background: var(--panel-2);
}

.token-preview {
  min-height: 138px;
  margin-top: 14px;
  padding: 14px;
  resize: vertical;
  line-height: 1.5;
}

.token-tag {
  color: #dffbf2;
  background: rgba(35, 211, 161, 0.12);
  border-color: rgba(35, 211, 161, 0.18);
}

.console-panel {
  background:
    linear-gradient(180deg, rgba(12, 18, 28, 0.96), rgba(7, 11, 17, 0.98));
}

.log-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
}

.log-list li {
  display: grid;
  gap: 4px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.log-time {
  font-size: 0.74rem;
  color: #7ba0b7;
}

.log-message {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #eef4fb;
}

.autoplay-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(520px, calc(100% - 24px));
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(35, 211, 161, 0.16);
  background: rgba(9, 14, 22, 0.96);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(18px);
}

.autoplay-toast strong {
  display: block;
  margin-bottom: 4px;
}

.autoplay-toast p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.is-hidden {
  display: none !important;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tile-in {
  from {
    opacity: 0;
    transform: scale(0.985) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@media (max-width: 1320px) {
  .workspace {
    grid-template-columns: 1fr 360px;
  }
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar-stack {
    grid-template-columns: 1fr;
  }

  .stage-surface {
    min-height: 460px;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 14px, 1840px);
    margin-top: 8px;
  }

  .topbar,
  .stage-panel,
  .control-panel,
  .token-panel,
  .console-panel {
    padding: 14px;
  }

  .topbar,
  .topbar-meta,
  .stage-toolbar,
  .stage-toolbar-meta,
  .panel-head,
  .token-head,
  .console-head,
  .autoplay-toast,
  .remote-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .session-summary,
  .action-row {
    grid-template-columns: 1fr;
  }

  .layout-config-grid {
    grid-template-columns: 1fr;
  }

  .stage-surface {
    min-height: 360px;
  }
}
