:root {
  --bg: #080b10;
  --panel: #111722;
  --panel-2: #151d2a;
  --panel-3: #1d2635;
  --navy: #1d3557;
  --crimson: #d72638;
  --gold: #cba135;
  --text: #f8fafc;
  --muted: #b1b1b1;
  --line: rgba(255, 255, 255, 0.12);
  --good: #36d399;
  --warn: #f4b942;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(29, 53, 87, 0.42), transparent 34rem),
    radial-gradient(circle at top right, rgba(215, 38, 56, 0.14), transparent 22rem),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 72px;
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 16, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: max-content;
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(203, 161, 53, 0.55);
  background: linear-gradient(145deg, #1d3557, #111722);
  color: #fff;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.05rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.top-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}

.viewer .top-actions .jump-link {
  display: none;
}

.menu-toggle {
  display: none;
  place-items: center;
  gap: 0.24rem;
  width: 44px;
  height: 42px;
  margin-left: auto;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
}

.top-actions a,
.support-menu summary,
.ghost,
.secondary,
.primary,
.danger {
  min-height: 42px;
  border: 1px solid var(--line);
  padding: 0.62rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.top-actions a:hover,
.support-menu summary:hover,
.ghost:hover,
.secondary:hover {
  border-color: rgba(203, 161, 53, 0.5);
  background: rgba(203, 161, 53, 0.1);
}

.support-menu {
  position: relative;
}

.support-menu summary {
  list-style: none;
}

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

.support-menu-panel {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 80;
  display: grid;
  gap: 0.35rem;
  min-width: 180px;
  border: 1px solid var(--line);
  padding: 0.45rem;
  background: #0d121b;
  box-shadow: var(--shadow);
}

.support-menu-panel a {
  min-height: 38px;
  white-space: nowrap;
}

.primary {
  border-color: rgba(215, 38, 56, 0.7);
  background: var(--crimson);
  color: #fff;
  font-weight: 800;
}

.primary:hover {
  filter: brightness(1.08);
}

.primary:disabled,
.secondary:disabled,
.ghost:disabled,
.danger:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  filter: none;
}

.secondary {
  border-color: rgba(203, 161, 53, 0.7);
  background: rgba(203, 161, 53, 0.16);
}

.danger {
  border-color: rgba(215, 38, 56, 0.8);
  background: #7d1420;
  color: #fff;
  font-weight: 900;
}

.wide {
  width: 100%;
}

.mobile-video-cta,
.mobile-video-toggle {
  display: none;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 42px;
  border: 1px solid rgba(215, 38, 56, 0.5);
  padding: 0.58rem 0.82rem;
  color: #fff;
  font-weight: 900;
  text-transform: uppercase;
}

.live-dot {
  width: 0.64rem;
  height: 0.64rem;
  background: var(--crimson);
  border-radius: 999px;
  box-shadow: 0 0 0 5px rgba(215, 38, 56, 0.16);
}

.viewer-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.75fr);
  grid-template-areas:
    "stage chat"
    "interaction save"
    "notice pulse"
    "bio pulse";
  gap: 1rem;
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
}

.stage-panel,
.chat-panel,
.interaction-panel,
.save-panel,
.notice-panel,
.monitoring-panel,
.bio-panel,
.login-panel,
.admin-card,
.admin-status-panel {
  border: 1px solid var(--line);
  background: rgba(17, 23, 34, 0.86);
  box-shadow: var(--shadow);
}

.stage-panel {
  grid-area: stage;
  padding: 1rem;
}

.chat-panel {
  grid-area: chat;
  min-height: 520px;
  padding: 1rem;
}

.interaction-panel {
  grid-area: interaction;
  padding: 1rem;
}

.save-panel {
  grid-area: save;
  padding: 1rem;
}

.notice-panel {
  grid-area: notice;
  padding: 1rem;
}

.monitoring-panel {
  grid-area: pulse;
  padding: 1rem;
  overflow: hidden;
}

.bio-panel {
  grid-area: bio;
  padding: 1rem;
}

.section-heading,
.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.section-heading h1,
.panel-title h2,
.admin-status-panel h1 {
  margin: 0;
}

.section-heading h1 {
  font-size: clamp(1.35rem, 2.2vw, 2.4rem);
  line-height: 1.05;
}

.panel-title h2 {
  font-size: 1rem;
  text-transform: uppercase;
}

.panel-title span,
.eyebrow {
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 0.25rem;
}

.muted,
.privacy-note {
  color: var(--muted);
}

.privacy-note {
  margin: 0.65rem 0;
  font-size: 0.85rem;
}

.video-frame {
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #030507;
}

.video-frame iframe,
.video-frame > div,
.chat-frame iframe {
  width: 100%;
  height: 100%;
}

.chat-frame {
  overflow: hidden;
  height: calc(100% - 3.1rem);
  min-height: 470px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #07090d;
}

.empty-frame {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

.interaction-body {
  min-height: 270px;
}

.idle-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.idle-list li,
.option-button,
.moment-list li,
.current-box,
.activity-log article {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
}

.idle-list li {
  padding: 1rem;
  color: #dfe5ee;
}

.interaction-question {
  margin: 0 0 1rem;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  line-height: 1.12;
}

.option-stack {
  display: grid;
  gap: 0.65rem;
}

.option-button {
  position: relative;
  overflow: hidden;
  min-height: 54px;
  padding: 0.8rem 1rem;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.option-button.is-selected {
  border-color: var(--gold);
  background: rgba(203, 161, 53, 0.14);
}

.option-button:disabled {
  cursor: default;
  opacity: 0.86;
}

.result-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--pct);
  background: rgba(203, 161, 53, 0.18);
  pointer-events: none;
}

.option-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.correct-tag {
  color: var(--good);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.save-grid,
.form-grid {
  display: grid;
  gap: 0.75rem;
}

.save-estimate {
  margin: -0.2rem 0 0.8rem;
  color: #dfe5ee;
  font-size: 0.94rem;
  font-weight: 800;
}

.save-grid label,
.form-grid label {
  display: grid;
  gap: 0.35rem;
}

label span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.field-help {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.form-subhead {
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.check-label {
  display: flex !important;
  grid-template-columns: none !important;
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}

.check-label input {
  width: 18px;
  min-height: 18px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  padding: 0.68rem 0.78rem;
  background: rgba(8, 11, 16, 0.82);
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
}

.moment-actions,
.button-row,
.preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.moment-list {
  display: grid;
  gap: 0.55rem;
  max-height: 310px;
  margin: 1rem 0 0;
  padding-left: 1.2rem;
  overflow: auto;
}

.moment-list li {
  padding: 0.72rem;
}

.moment-list a {
  color: #fff;
  text-decoration: underline;
  text-decoration-color: rgba(203, 161, 53, 0.8);
}

.notice-panel.is-active {
  border-color: rgba(203, 161, 53, 0.5);
}

.notice-panel.is-warning {
  border-color: rgba(244, 185, 66, 0.65);
}

.notice-panel.is-light {
  border-color: rgba(215, 38, 56, 0.35);
}

.sponsor-strip {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 0.8rem;
  align-items: center;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.sponsor-strip img {
  width: 96px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.sponsor-strip span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.sponsor-strip strong,
.sponsor-strip p {
  display: block;
  margin: 0.1rem 0;
}

.sponsor-strip .secondary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-top: 0.25rem;
  padding: 0.42rem 0.62rem;
}

.monitoring-list {
  counter-reset: monitoring;
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding-left: 0;
}

.monitoring-list li {
  counter-increment: monitoring;
  display: grid;
  grid-template-columns: 1.45rem minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem;
  list-style: none;
  border: 1px solid var(--line);
  min-height: 34px;
  padding: 0.3rem 0.55rem;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font-weight: 800;
  line-height: 1.05;
}

.monitoring-list li::before {
  content: counter(monitoring) ".";
  color: var(--gold);
  font-weight: 900;
}

.monitoring-list .is-empty {
  counter-increment: none;
  list-style: none;
  display: block;
  color: var(--muted);
  font-weight: 600;
}

.monitoring-list .is-empty::before {
  content: none;
}

.stat-row,
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
}

.stat-row span,
.status-grid span {
  border: 1px solid var(--line);
  padding: 0.7rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.stat-row b,
.status-grid b {
  display: block;
  color: var(--text);
  font-size: 1.25rem;
}

.judge-dialog {
  width: min(680px, calc(100% - 2rem));
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.judge-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.dialog-card {
  position: relative;
  border: 1px solid rgba(203, 161, 53, 0.38);
  padding: 1.4rem;
  background: #101722;
  box-shadow: var(--shadow);
}

.dialog-card h2 {
  margin: 0.2rem 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.dialog-card h3 {
  margin: 1.1rem 0 0.3rem;
  color: var(--gold);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.faq-list {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.faq-list article {
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.faq-list h3 {
  margin: 0 0 0.35rem;
  color: var(--text);
  font-size: 1rem;
  text-transform: none;
}

.faq-list p {
  margin: 0;
  color: #dfe5ee;
  white-space: pre-wrap;
}

.icon-button {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
}

.footer-note {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 0 2rem 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.admin-shell {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
}

.login-panel {
  width: min(480px, 100%);
  margin: 4rem auto;
  padding: 1.25rem;
}

.admin-dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.admin-status-panel,
.admin-card {
  padding: 1rem;
}

.admin-status-panel,
.wide-card,
.danger-card {
  grid-column: 1 / -1;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-2 {
  grid-column: 1 / -1;
}

.interaction-admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 1.1fr);
  gap: 1rem;
}

.current-module h3 {
  margin: 0 0 0.75rem;
}

.current-box {
  min-height: 160px;
  padding: 1rem;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.preset-row button {
  min-height: 36px;
  padding: 0.48rem 0.65rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.activity-log {
  display: grid;
  gap: 0.55rem;
  max-height: 420px;
  overflow: auto;
}

.activity-log article {
  padding: 0.75rem;
}

.activity-log p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.error-text {
  min-height: 1.2rem;
  color: #ff8a96;
}

@media (min-width: 1200px) {
  body.viewer {
    height: 100vh;
    overflow: hidden;
  }

  .viewer .topbar {
    min-height: 67px;
    padding: 0.25rem clamp(1rem, 2vw, 1.5rem);
  }

  .viewer .brand-logo {
    width: 58px;
    height: 58px;
  }

  .viewer .top-actions a,
  .viewer .support-menu summary,
  .viewer .ghost,
  .viewer .secondary,
  .viewer .primary,
  .viewer .danger,
  .viewer .live-badge {
    min-height: 40px;
    padding: 0.52rem 0.78rem;
  }

  .viewer .top-actions .jump-link {
    display: none;
  }

  .viewer-shell {
    grid-template-columns: minmax(620px, 1.55fr) minmax(340px, 0.68fr) minmax(380px, 0.74fr);
    grid-template-rows: minmax(0, 1fr) 248px;
    grid-template-areas:
      "stage chat interaction"
      "notice pulse save";
    gap: 0.75rem;
    width: min(1880px, calc(100vw - 1.5rem));
    height: calc(100vh - 67px);
    padding: 0.75rem 0;
  }

  .stage-panel,
  .chat-panel,
  .interaction-panel,
  .save-panel,
  .notice-panel,
  .monitoring-panel {
    min-height: 0;
    padding: 0.8rem;
  }

  .stage-panel,
  .chat-panel,
  .interaction-panel,
  .save-panel,
  .monitoring-panel {
    display: flex;
    flex-direction: column;
  }

  .notice-panel {
    display: flex;
    flex-direction: column;
  }

  .notice-panel > p {
    margin: 0;
  }

  .section-heading,
  .panel-title {
    margin-bottom: 0.6rem;
  }

  .monitoring-panel .panel-title {
    margin-bottom: 0.42rem;
  }

  .section-heading h1 {
    font-size: clamp(1.45rem, 2vw, 2.05rem);
  }

  .video-frame {
    flex: 1;
    min-height: 0;
    aspect-ratio: auto;
  }

  .chat-panel {
    min-height: 0;
  }

  .chat-frame {
    flex: 1;
    height: auto;
    min-height: 0;
  }

  .interaction-body {
    min-height: 0;
    overflow: auto;
    padding-right: 0.15rem;
  }

  .interaction-question {
    margin-bottom: 0.75rem;
    font-size: clamp(1.2rem, 1.45vw, 1.65rem);
  }

  .option-stack {
    gap: 0.48rem;
  }

  .option-button {
    min-height: 46px;
    padding: 0.62rem 0.75rem;
  }

  .save-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
  }

  .save-grid .wide {
    grid-column: 1 / -1;
  }

  input,
  select,
  textarea {
    min-height: 38px;
    padding: 0.54rem 0.65rem;
  }

  .privacy-note {
    margin: 0.45rem 0;
    font-size: 0.78rem;
  }

  .save-estimate {
    margin-bottom: 0.55rem;
    font-size: 0.86rem;
  }

  .moment-list {
    max-height: 54px;
    margin-top: 0.55rem;
  }

  .save-panel {
    overflow: hidden;
  }

  .save-panel .privacy-note {
    display: none;
  }

  .save-panel .moment-actions {
    margin-top: 0.5rem;
  }

  .save-panel .ghost {
    min-height: 34px;
    padding: 0.42rem 0.65rem;
  }

  .sponsor-strip {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 0.7rem;
  }

  .sponsor-strip img {
    width: 112px;
    height: 62px;
  }

  .sponsor-strip p {
    font-size: 0.88rem;
    line-height: 1.25;
  }

  .monitoring-list {
    flex: 1;
    grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: 0.28rem;
    min-height: 0;
  }

  .monitoring-list li {
    grid-template-columns: 1.25rem minmax(0, 1fr);
    min-height: 0;
    padding: 0.24rem 0.5rem;
    font-size: 0.9rem;
  }

  .bio-panel,
  .viewer .footer-note {
    display: none;
  }
}

@media (max-width: 1100px) {
  .viewer .topbar {
    align-items: center;
    flex-wrap: nowrap;
  }

  .viewer .menu-toggle {
    display: grid;
  }

  .viewer .top-actions {
    position: absolute;
    top: calc(100% + 1px);
    right: clamp(0.8rem, 3vw, 1.5rem);
    left: clamp(0.8rem, 3vw, 1.5rem);
    display: none;
    grid-template-columns: 1fr;
    gap: 0.45rem;
    margin-left: 0;
    border: 1px solid var(--line);
    padding: 0.6rem;
    background: #080b10;
    box-shadow: var(--shadow);
  }

  .viewer .top-actions.is-open {
    display: grid;
  }

  .viewer .top-actions a,
  .viewer .support-menu summary,
  .viewer .top-actions button {
    display: flex;
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
  }

  .viewer .support-menu {
    width: 100%;
  }

  .viewer .support-menu-panel {
    position: static;
    min-width: 0;
    margin-top: 0.35rem;
    box-shadow: none;
  }

  .viewer-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "stage"
      "interaction"
      "save"
      "notice"
      "bio"
      "pulse"
      "chat";
  }

  .chat-panel {
    min-height: 420px;
  }

  .chat-frame {
    min-height: 360px;
  }

  .admin-dashboard,
  .interaction-admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body:not(.viewer) .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  body:not(.viewer) .top-actions {
    order: 3;
    width: 100%;
    overflow-x: auto;
    margin-left: 0;
    padding-bottom: 0.2rem;
  }

  body:not(.viewer) .top-actions a,
  body:not(.viewer) .support-menu summary,
  body:not(.viewer) .top-actions button,
  body:not(.viewer) .live-badge {
    min-width: max-content;
  }

  .viewer-shell {
    grid-template-areas:
      "interaction"
      "notice"
      "pulse"
      "bio"
      "save"
      "stage"
      "chat";
  }

  .viewer .stage-panel {
    display: none;
  }

  .viewer .stage-panel.is-video-open {
    display: block;
  }

  .viewer .mobile-video-cta,
  .viewer .mobile-video-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .viewer .mobile-video-cta {
    width: 100%;
    margin: -0.15rem 0 0.8rem;
  }

  .viewer .mobile-video-toggle {
    margin: 0 0 0.8rem;
  }

  .viewer-shell,
  .admin-shell {
    padding: 0.8rem;
  }

  .idle-list,
  .two-col,
  .stat-row,
  .status-grid,
  .button-grid {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.3rem;
  }

  .chat-panel {
    display: none;
  }
}
