:root {
  color-scheme: dark;
  --bg: #04080d;
  --panel: #09131d;
  --panel-2: #0d1b26;
  --line: #203746;
  --line-strong: #345669;
  --text: #ebf6fa;
  --muted: #91a8b4;
  --dim: #617b88;
  --orange: #ff9b42;
  --cyan: #58d8ff;
  --green: #75ffc0;
  --red: #ff6d75;
  --fore: #58d8ff;
  --port: #ffd35c;
  --starboard: #ff934d;
  --aft: #d783ff;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  background:
    radial-gradient(circle at 18% 7%, rgba(30, 105, 137, 0.15), transparent 31rem),
    radial-gradient(circle at 90% 85%, rgba(72, 255, 164, 0.07), transparent 36rem),
    linear-gradient(180deg, #061019 0%, var(--bg) 52%, #050a0f 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(94, 186, 222, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(94, 186, 222, 0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
canvas:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  width: min(1760px, 100%);
  min-height: 100vh;
  padding: 18px clamp(14px, 2.2vw, 36px) 20px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 18px;
  padding: 0 4px 14px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand-mark {
  position: relative;
  flex: 0 0 10px;
  align-self: stretch;
  min-height: 46px;
  border-radius: 8px 2px 2px 8px;
  background: var(--orange);
  box-shadow: 0 0 20px rgba(255, 155, 66, 0.22);
}

.brand-mark::after {
  position: absolute;
  right: -10px;
  bottom: 0;
  width: 7px;
  height: 14px;
  content: "";
  background: #75ffc0;
}

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

.eyebrow {
  margin: 0 0 3px;
  color: var(--orange);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2.3vw, 2rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.top-actions,
.view-nav,
.camera-controls,
.mode-switch,
.display-grid {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-nav {
  min-height: 40px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  background: rgba(5, 14, 21, 0.8);
}

.view-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 11px;
  color: #8fa7b3;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-decoration: none;
}

.view-link:hover {
  color: var(--text);
  background: #112430;
}

.view-link.is-current {
  color: #071018;
  background: var(--orange);
}

.local-indicator {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(5, 14, 21, 0.7);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.09em;
}

.local-indicator::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  content: "";
  background: var(--green);
  box-shadow: 0 0 10px rgba(111, 255, 194, 0.7);
}

.utility-button,
.camera-button,
.preset-button,
.mode-button,
.display-button {
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: #0d1b25;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.utility-button:hover,
.camera-button:hover,
.preset-button:hover,
.mode-button:hover,
.display-button:hover {
  border-color: var(--orange);
  background: #142633;
}

.utility-button:active,
.camera-button:active,
.preset-button:active,
.mode-button:active,
.display-button:active {
  transform: translateY(1px);
}

.utility-button,
.camera-button {
  padding: 0 11px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(380px, 0.72fr);
  align-items: start;
  gap: 14px;
}

.panel {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-top-color: #3b6073;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(12, 27, 38, 0.96), rgba(6, 15, 22, 0.97));
  box-shadow: var(--shadow);
}

.panel::before {
  position: absolute;
  top: -1px;
  left: -1px;
  width: 78px;
  height: 3px;
  content: "";
  background: var(--orange);
  box-shadow: 79px 0 0 var(--green);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 31, 43, 0.5);
}

.panel-label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.69rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.03rem;
  line-height: 1.2;
}

.camera-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.camera-button {
  min-height: 36px;
  color: #a9c0ca;
  font-size: 0.69rem;
}

.camera-button[aria-pressed="true"] {
  border-color: var(--cyan);
  color: #e2f8ff;
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.canvas-shell {
  position: relative;
  height: clamp(570px, 69vh, 840px);
  min-height: 570px;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 44%, rgba(20, 70, 86, 0.22), transparent 40%),
    linear-gradient(180deg, rgba(3, 10, 16, 0.48), rgba(4, 11, 17, 0.88));
  isolation: isolate;
}

.canvas-shell::before,
.canvas-shell::after {
  position: absolute;
  z-index: 2;
  width: 60px;
  height: 60px;
  content: "";
  pointer-events: none;
}

.canvas-shell::before {
  top: 12px;
  left: 12px;
  border-top: 1px solid rgba(255, 155, 66, 0.66);
  border-left: 1px solid rgba(255, 155, 66, 0.66);
}

.canvas-shell::after {
  right: 12px;
  bottom: 12px;
  border-right: 1px solid rgba(88, 216, 255, 0.42);
  border-bottom: 1px solid rgba(88, 216, 255, 0.42);
}

#sceneCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#sceneCanvas.is-dragging {
  cursor: grabbing;
}

.canvas-help,
.model-badge,
.scene-status,
.arc-legend {
  position: absolute;
  z-index: 3;
  border: 1px solid rgba(42, 76, 93, 0.76);
  background: rgba(4, 13, 20, 0.82);
  font-family: var(--mono);
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.canvas-help {
  top: 14px;
  right: 14px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: right;
}

.model-badge {
  top: 14px;
  left: 14px;
  padding: 8px 10px;
  color: #ffd6ac;
  border-color: rgba(255, 155, 66, 0.45);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.scene-status {
  left: 14px;
  bottom: 14px;
  max-width: min(560px, calc(100% - 28px));
  padding: 10px 12px;
  color: #bbd0da;
  font-size: 0.73rem;
  font-weight: 750;
  line-height: 1.35;
}

.scene-status strong {
  color: var(--green);
}

.arc-legend {
  right: 14px;
  bottom: 14px;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 7px 12px;
  padding: 9px 10px;
  color: #a9bec8;
  font-size: 0.65rem;
  font-weight: 750;
}

.arc-key,
.sector-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.arc-key::before,
.sector-chip::before {
  width: 10px;
  height: 10px;
  border: 1px solid color-mix(in srgb, var(--sector-color) 75%, white);
  content: "";
  background: color-mix(in srgb, var(--sector-color) 30%, transparent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--sector-color) 48%, transparent);
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  background: #071119;
}

.comparison-card {
  min-height: 92px;
  padding: 13px 15px;
  border-right: 1px solid var(--line);
}

.comparison-card:last-child {
  border-right: 0;
}

.comparison-card.is-active {
  background: linear-gradient(90deg, rgba(84, 216, 255, 0.1), transparent 68%);
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.comparison-label {
  display: block;
  margin-bottom: 8px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.sector-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}

.sector-chip {
  min-height: 26px;
  padding: 0 8px 0 6px;
  border: 1px solid #294654;
  background: rgba(9, 25, 35, 0.9);
  color: #d7e6ec;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 800;
}

.sector-chip::before {
  width: 7px;
  height: 7px;
  border: 0;
}

.teaching-strip {
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr);
  align-items: center;
  min-height: 70px;
  gap: 12px;
  padding: 11px 15px;
  border-top: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(36, 122, 112, 0.14), rgba(6, 17, 25, 0.96) 50%);
}

.teaching-label {
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.teaching-copy {
  margin: 0;
  color: #c5d8e0;
  font-size: 0.89rem;
  line-height: 1.48;
}

.controls-panel {
  max-height: calc(100vh - 104px);
  overflow: hidden;
}

.control-scroll {
  max-height: calc(100vh - 176px);
  overflow: auto;
  scrollbar-color: #36576a #09131b;
  scrollbar-width: thin;
}

.control-section {
  padding: 15px 16px 16px;
  border-bottom: 1px solid var(--line);
}

.control-section:last-child {
  border-bottom: 0;
}

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

.section-heading h3 {
  margin: 0;
  color: #c9dce5;
  font-family: var(--mono);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.section-heading h3::before {
  display: inline-block;
  width: 18px;
  height: 3px;
  margin-right: 8px;
  vertical-align: 3px;
  content: "";
  background: var(--orange);
}

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

.preset-button {
  width: 100%;
  min-height: 44px;
  padding: 7px 9px;
  color: #aec3cc;
  text-align: left;
  line-height: 1.2;
}

.preset-button.is-featured {
  grid-column: 1 / -1;
  color: #e4f2f6;
}

.preset-button.is-featured::after {
  float: right;
  content: "START HERE";
  color: var(--green);
  font-size: 0.61rem;
  letter-spacing: 0.08em;
}

.preset-button[aria-pressed="true"] {
  border-color: var(--orange);
  color: #ffe0bc;
  background: linear-gradient(90deg, rgba(255, 155, 66, 0.16), rgba(17, 37, 50, 0.9));
  box-shadow: inset 3px 0 0 var(--orange);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  padding: 3px;
  border: 1px solid var(--line-strong);
  background: #07131b;
}

.mode-button {
  min-height: 44px;
  border-color: transparent;
  color: #8ca4af;
}

.mode-button[aria-pressed="true"] {
  border-color: #39738b;
  color: #e6f8ff;
  background: rgba(31, 92, 113, 0.45);
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.mode-explainer {
  margin: 10px 0 0;
  color: #8ca4af;
  font-size: 0.82rem;
  line-height: 1.48;
}

.slider-list {
  display: grid;
  gap: 15px;
}

.slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 12px;
}

.slider-label {
  color: #c9dce4;
  font-size: 0.85rem;
  font-weight: 700;
}

.slider-value {
  min-width: 86px;
  color: #ffd0a2;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 800;
}

.slider-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 28px;
  accent-color: var(--orange);
  cursor: pointer;
}

.ratio-note {
  margin: 12px 0 0;
  padding: 9px 10px;
  border-left: 3px solid #3b839d;
  background: rgba(14, 48, 62, 0.35);
  color: #a9c0ca;
  font-size: 0.79rem;
  line-height: 1.45;
}

.ratio-note strong {
  color: #e2f4f9;
}

.display-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.display-button {
  min-height: 42px;
  padding: 6px 8px;
  color: #849ba6;
}

.display-button[aria-pressed="true"] {
  border-color: #3e819d;
  color: #e2f7ff;
  background: rgba(21, 66, 84, 0.46);
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.lesson-steps {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
  counter-reset: lesson;
}

.lesson-steps li {
  position: relative;
  min-height: 32px;
  padding-left: 40px;
  color: #a9bec8;
  font-size: 0.83rem;
  line-height: 1.45;
  counter-increment: lesson;
}

.lesson-steps li::before {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid #376278;
  color: var(--cyan);
  content: counter(lesson, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 800;
}

details.reference {
  color: var(--muted);
  font-size: 0.81rem;
  line-height: 1.5;
}

details.reference summary {
  min-height: 40px;
  padding: 10px 0 7px;
  color: #c5d8e1;
  font-family: var(--mono);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  list-style-position: inside;
  text-transform: uppercase;
  cursor: pointer;
}

.reference p:last-child {
  margin-bottom: 0;
}

.reference a {
  color: #82ddff;
  text-underline-offset: 3px;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 4px 0;
  color: #607783;
  font-family: var(--mono);
  font-size: 0.65rem;
  line-height: 1.4;
}

.focus-mode .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.focus-mode .controls-panel,
.focus-mode .footer {
  display: none;
}

.focus-mode .canvas-shell {
  height: calc(100vh - 310px);
  min-height: 480px;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.75fr);
  }

  .arc-legend {
    display: none;
  }
}

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

  .controls-panel,
  .control-scroll {
    max-height: none;
    overflow: visible;
  }

  .canvas-shell {
    height: min(68vh, 700px);
  }

  .focus-mode .canvas-shell {
    height: calc(100vh - 315px);
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
  }

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

  .local-indicator {
    display: none;
  }
}

@media (max-width: 680px) {
  .app {
    padding: 10px 9px 14px;
  }

  .topbar {
    align-items: flex-start;
    min-height: 84px;
    padding-bottom: 10px;
  }

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

  .view-nav {
    order: 3;
  }

  .view-link {
    padding-inline: 8px;
    font-size: 0.64rem;
  }

  .local-indicator {
    display: none;
  }

  .utility-button {
    min-height: 38px;
    padding: 0 9px;
    font-size: 0.68rem;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .camera-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .canvas-shell {
    height: 62vh;
    min-height: 455px;
  }

  .canvas-help {
    font-size: 0.59rem;
  }

  .model-badge {
    top: 58px;
  }

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

  .comparison-card {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .comparison-card:last-child {
    border-bottom: 0;
  }

  .teaching-strip {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .focus-mode .canvas-shell {
    height: calc(100vh - 430px);
    min-height: 390px;
  }

  .footer {
    flex-direction: column;
    gap: 4px;
  }
}

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