:root {
  color-scheme: dark;
  --bg: #0f1417;
  --rail: #11181c;
  --surface: #161d21;
  --surface-2: #1c252a;
  --surface-3: #222d32;
  --line: rgba(220, 235, 231, 0.13);
  --line-strong: rgba(220, 235, 231, 0.22);
  --text: #eef6f3;
  --muted: #9eaca7;
  --faint: #6f7d79;
  --ink: #17201e;
  --paper: #f5f8f5;
  --teal: #36c8c1;
  --teal-soft: rgba(54, 200, 193, 0.12);
  --teal-text: #92f5eb;
  --amber: #f1aa48;
  --amber-soft: rgba(241, 170, 72, 0.12);
  --coral: #ec6b5f;
  --blue: #8fb7ff;
  --green: #87d991;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(140deg, rgba(54, 200, 193, 0.08), transparent 28%),
    linear-gradient(180deg, #10171b 0%, #0d1114 100%);
  color: var(--text);
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
}

.product-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(17, 24, 28, 0.94);
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 3;
}

.brand-lockup {
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
}

.brand-lockup img {
  width: 46px;
  height: 46px;
}

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

.brand-lockup strong {
  font-size: 16px;
  line-height: 1;
}

.brand-lockup small {
  color: var(--muted);
  font-size: 12px;
}

.rail-nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 46px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease, border 0.16s ease;
}

.nav-button:hover,
.nav-button.is-active {
  color: var(--text);
  border-color: rgba(54, 200, 193, 0.34);
  background: var(--teal-soft);
}

.nav-icon {
  font-size: 22px;
  line-height: 1;
  text-align: center;
}

.nav-button span:last-child {
  font-size: 13px;
  white-space: nowrap;
}

.rail-status {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 16px rgba(135, 217, 145, 0.8);
}

.studio {
  min-width: 0;
  padding: 18px;
}

.top-bar {
  min-height: 74px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(260px, 360px) auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-text);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
}

h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

h3 {
  margin: 0;
  font-size: 14px;
}

.project-switcher {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 8px 12px;
  display: grid;
  gap: 2px;
}

.project-switcher span,
.project-switcher small {
  color: var(--muted);
  font-size: 11px;
}

.project-switcher strong {
  font-size: 13px;
}

.top-actions,
.button-row,
.viewer-toolbar,
.toolbar-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.top-actions {
  justify-content: flex-end;
}

.confidence-pill {
  min-height: 30px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(54, 200, 193, 0.32);
  color: var(--teal-text);
  background: var(--teal-soft);
  font-size: 12px;
  white-space: nowrap;
}

.confidence-pill.muted {
  color: #f3d6a3;
  border-color: rgba(241, 170, 72, 0.36);
  background: var(--amber-soft);
}

.confidence-pill.small {
  min-height: 24px;
  padding: 0 8px;
  font-size: 11px;
}

.icon-text-button,
.segment,
.scene-button,
.panel-tab,
.audience-button,
.tool-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  border-radius: 8px;
  min-height: 36px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.14s ease, background 0.14s ease, border 0.14s ease;
}

.icon-text-button:hover,
.segment:hover,
.scene-button:hover,
.panel-tab:hover,
.audience-button:hover,
.tool-button:hover {
  transform: translateY(-1px);
  border-color: rgba(54, 200, 193, 0.44);
}

.icon-text-button.accent,
.segment.is-active,
.panel-tab.is-active,
.audience-button.is-active,
.scene-button.is-active,
.tool-button.is-active {
  background: var(--teal);
  color: #062220;
  border-color: transparent;
  font-weight: 800;
}

.showroom-grid {
  min-height: calc(100vh - 108px);
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 438px;
  gap: 14px;
}

.view-tools,
.viewer-pane,
.control-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(22, 29, 33, 0.88);
  box-shadow: var(--shadow);
  min-width: 0;
}

.view-tools {
  padding: 10px 8px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.tool-button {
  width: 52px;
  min-height: 58px;
  padding: 6px 0;
  display: grid;
  gap: 2px;
}

.tool-button span {
  font-size: 21px;
  line-height: 1;
}

.tool-button em {
  font-style: normal;
  font-size: 11px;
}

.viewer-pane {
  padding: 14px;
  display: grid;
  grid-template-rows: auto minmax(480px, 1fr) auto;
  gap: 12px;
}

.viewer-toolbar {
  justify-content: space-between;
}

.segmented {
  padding: 4px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.segment {
  min-height: 30px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
}

.canvas-frame {
  position: relative;
  min-height: 480px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    radial-gradient(circle at 50% 48%, rgba(54, 200, 193, 0.13), transparent 40%),
    #0b1012;
}

#reactorCanvas {
  width: 100%;
  height: 100%;
  min-height: 480px;
  display: block;
}

.hud-stack {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 150px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.hud-stack div,
.canvas-note {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(9, 13, 15, 0.72);
  backdrop-filter: blur(14px);
}

.hud-stack div {
  padding: 9px 10px;
}

.hud-stack span,
.canvas-note span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 2px;
}

.hud-stack strong {
  font-size: 18px;
}

.canvas-note {
  position: absolute;
  left: 14px;
  bottom: 14px;
  max-width: 420px;
  padding: 10px 12px;
}

.canvas-note strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.scene-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.scene-button {
  flex: 0 0 auto;
  min-height: 34px;
  font-size: 12px;
}

.control-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.panel-tabs {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  border-bottom: 1px solid var(--line);
}

.panel-tab {
  min-height: 34px;
  padding: 0 8px;
}

.panel-page {
  display: none;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.panel-page.is-active {
  display: grid;
  align-content: start;
  gap: 12px;
}

.panel-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.section-title {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.toggle-grid label {
  min-height: 34px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
}

input[type="checkbox"],
input[type="range"] {
  accent-color: var(--teal);
}

.slider-row {
  min-height: 35px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
}

.slider-row label {
  color: var(--muted);
  font-size: 12px;
}

.slider-row output {
  color: var(--text);
  font-size: 12px;
  text-align: right;
}

input[type="range"] {
  width: 100%;
}

.metric-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric {
  min-height: 86px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.metric span,
.metric em {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.metric strong {
  display: block;
  margin: 8px 0 6px;
  font-size: 18px;
}

.audience-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.audience-button {
  min-height: 38px;
}

.narration-box textarea {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(7, 11, 13, 0.7);
  padding: 12px;
  line-height: 1.65;
}

.report-card {
  padding: 14px;
  display: grid;
  gap: 10px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.report-card img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: #dfe8e5;
}

.report-card h4 {
  margin: 0;
  font-size: 17px;
}

.report-card p {
  margin-bottom: 7px;
  color: #34413e;
  line-height: 1.55;
}

.report-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.report-card td,
.report-card th {
  padding: 7px 4px;
  border-bottom: 1px solid #d5ded9;
  text-align: left;
  vertical-align: top;
}

.evidence-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 9px;
}

.evidence-list li,
.brief-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.evidence-list li {
  padding: 10px;
  display: grid;
  gap: 5px;
}

.evidence-list strong,
.brief-card strong {
  color: var(--teal-text);
}

.evidence-list span,
.boundary-card p,
.brief-hero p,
.brief-card span {
  color: var(--muted);
  line-height: 1.62;
}

.boundary-card {
  border-color: rgba(241, 170, 72, 0.34);
  background: rgba(241, 170, 72, 0.08);
}

.brief-hero {
  background:
    linear-gradient(135deg, rgba(54, 200, 193, 0.14), transparent),
    rgba(255, 255, 255, 0.035);
}

.brief-hero h3 {
  margin-bottom: 10px;
  font-size: 19px;
  line-height: 1.32;
}

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

.brief-card {
  min-height: 116px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .product-rail {
    padding: 16px 10px;
  }

  .brand-lockup {
    display: grid;
    justify-items: center;
    text-align: center;
  }

  .nav-button {
    min-height: 62px;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 4px;
  }

  .nav-button span:last-child {
    font-size: 11px;
  }

  .showroom-grid {
    grid-template-columns: minmax(0, 1fr) 420px;
  }

  .view-tools {
    display: none;
  }
}

@media (max-width: 1060px) {
  .top-bar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .top-actions {
    justify-content: flex-start;
  }

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

  .control-pane {
    min-height: 760px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .product-rail {
    position: static;
    height: auto;
    width: 100%;
    padding: 10px;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .brand-lockup {
    display: flex;
    min-width: 150px;
    text-align: left;
  }

  .rail-nav {
    display: flex;
    gap: 6px;
  }

  .nav-button {
    min-width: 76px;
    min-height: 54px;
    padding: 0 8px;
  }

  .rail-status {
    display: none;
  }

  .studio {
    padding: 12px;
  }

  h1 {
    font-size: 34px;
  }

  .viewer-toolbar {
    align-items: flex-start;
  }

  .toolbar-cluster {
    width: 100%;
    justify-content: space-between;
  }

  .canvas-note {
    display: none;
  }

  .hud-stack {
    width: min(42vw, 160px);
  }

  .toggle-grid,
  .metric-grid,
  .audience-grid,
  .brief-grid {
    grid-template-columns: 1fr;
  }

  .slider-row {
    grid-template-columns: 48px minmax(0, 1fr) 72px;
  }

  .panel-tabs {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
