:root {
  --bg-void: #020711;
  --bg-deep: #071422;
  --bg-mid: #0c1e31;
  --panel: rgba(7, 20, 34, 0.88);
  --panel-strong: rgba(9, 26, 42, 0.96);
  --panel-soft: rgba(8, 22, 36, 0.74);
  --line: rgba(124, 187, 224, 0.22);
  --line-strong: rgba(128, 224, 255, 0.5);
  --ink: #e7f4ff;
  --ink-soft: #8caabd;
  --ink-muted: #628199;
  --accent: #6fe1ff;
  --accent-strong: #b0f5ff;
  --accent-warm: #ffb24a;
  --accent-warm-soft: #ffd78b;
  --danger: #ff7767;
  --success: #95ffcb;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  --canvas-bg:
    radial-gradient(circle at 50% -8%, rgba(101, 230, 255, 0.14), transparent 34%),
    linear-gradient(180deg, #06101a 0%, #0b1a2a 48%, #102840 100%);
  --ray-miss: rgba(240, 243, 247, 0.34);
  --ray-direct: #9fffcc;
  --ray-prebounce: #ffd24e;
  --ray-reflected: #ff9547;
  --font-display: "Eurostile", "Microgramma D Extended", "Avenir Next Condensed",
    "Trebuchet MS", sans-serif;
  --font-ui: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --font-mono: "SFMono-Regular", "IBM Plex Mono", "Menlo", "Consolas", monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  position: relative;
  color: var(--ink);
  font-family: var(--font-ui);
  background:
    radial-gradient(circle at 16% 12%, rgba(73, 189, 255, 0.16), transparent 24%),
    radial-gradient(circle at 86% 18%, rgba(255, 183, 76, 0.12), transparent 18%),
    linear-gradient(180deg, var(--bg-void) 0%, var(--bg-deep) 44%, #050c15 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background-image:
    linear-gradient(rgba(131, 198, 233, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(131, 198, 233, 0.03) 1px, transparent 1px);
  background-size: 84px 84px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent 92%);
}

body::after {
  background: none;
  opacity: 0;
}

.page-shell {
  position: relative;
  z-index: 1;
  max-width: 1640px;
  margin: 0 auto;
  padding: 30px 20px 46px;
}

.hero,
.viewer-chrome,
.controls-panel,
.legend,
.notes,
.sweep-panel,
.rotation-panel {
  animation: panel-enter 420ms ease both;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 420px);
  gap: 22px;
  align-items: stretch;
  margin-bottom: 22px;
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(11, 28, 43, 0.95), rgba(7, 18, 29, 0.98));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-copy {
  display: grid;
  align-content: start;
  gap: 14px;
}

.viewer-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(111, 225, 255, 0.24);
  border-radius: 4px;
  color: var(--accent-strong);
  background: rgba(87, 177, 217, 0.06);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0;
  color: var(--accent-warm-soft);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.hero-copy h1 {
  margin: 0;
  max-width: 14ch;
  color: #f6fbff;
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 4.5vw, 5rem);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lede {
  max-width: 62ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.7;
}

.panel-kicker,
.info-kicker,
.section-heading p,
.control span,
.toggle span,
.summary-label,
.panel-note,
.hero-note-label {
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
}

.hero-note {
  position: relative;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 20px 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(5, 17, 28, 0.42);
}

.hero-note-label {
  margin: 0;
  color: var(--accent);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.hero-note > p:not(.hero-note-label) {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 400px);
  gap: 22px;
  align-items: start;
}

.viewer-panel {
  min-width: 0;
}

.viewer-chrome {
  position: relative;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(11, 29, 47, 0.95), rgba(5, 16, 27, 0.98));
  box-shadow: var(--shadow);
}

.viewer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.viewer-head h2,
.controls-header h2,
.section-heading h2,
.sweep-header h2 {
  margin: 0;
  color: #f8fcff;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.viewer-head h2 {
  font-size: clamp(1.2rem, 2vw, 1.7rem);
}

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

.canvas-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(111, 225, 255, 0.24);
  border-radius: 8px;
  background: var(--canvas-bg);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    inset 0 10px 28px rgba(116, 227, 255, 0.04);
  min-height: 520px;
}

.canvas-frame::before,
.canvas-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.canvas-frame::before {
  background-image:
    linear-gradient(rgba(127, 213, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(127, 213, 255, 0.035) 1px, transparent 1px);
  background-size: 52px 52px;
  opacity: 0.28;
}

.canvas-frame::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 14%);
}

#scene {
  display: block;
  width: 100%;
  height: auto;
}

.legend-and-notes {
  display: grid;
  grid-template-columns: minmax(260px, 0.84fr) minmax(0, 1.16fr);
  gap: 14px;
  margin-top: 14px;
}

.legend,
.notes,
.sweep-panel,
.rotation-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(11, 27, 43, 0.86), rgba(7, 18, 29, 0.94));
  box-shadow: var(--shadow);
}

.legend,
.notes {
  padding: 18px 20px;
}

.legend {
  display: grid;
  gap: 12px;
}

.info-kicker {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.notes .info-kicker,
.legend .info-kicker {
  margin: 0 0 2px;
  color: var(--accent);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.legend-line {
  width: 42px;
  height: 4px;
  border-radius: 999px;
}

.ray-miss {
  background: var(--ray-miss);
}

.ray-direct {
  background: var(--ray-direct);
}

.ray-prebounce {
  background: var(--ray-prebounce);
}

.ray-reflected {
  background: var(--ray-reflected);
}

.notes p {
  margin: 0 0 12px;
  color: var(--ink-soft);
  line-height: 1.75;
}

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

.sweep-panel {
  margin-top: 14px;
  padding: 18px 20px 20px;
}

.rotation-panel {
  margin-top: 14px;
  padding: 18px 20px 20px;
}

.sweep-header {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.sweep-header h2 {
  font-size: 1.15rem;
}

.sweep-header p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

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

.rotation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 14px;
  margin-bottom: 14px;
}

.deck-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(111, 225, 255, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(7, 18, 30, 0.96), rgba(6, 14, 22, 0.98));
  display: flex;
  align-items: center;
  justify-content: center;
}

#deckScene {
  display: block;
  width: 100%;
  height: auto;
}

.ring-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(111, 225, 255, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(7, 18, 30, 0.96), rgba(6, 14, 22, 0.98));
  min-height: 320px;
}

#ringScene {
  display: block;
  width: 100%;
  height: auto;
}

.rotation-side {
  display: grid;
  gap: 12px;
  align-content: start;
}

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

.rotation-headline-grid {
  margin-top: 2px;
}

.rotation-note {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid rgba(111, 225, 255, 0.12);
  border-radius: 8px;
  color: var(--ink-soft);
  line-height: 1.7;
  background: rgba(255, 255, 255, 0.025);
}

.summary-card {
  padding: 16px 18px;
  border: 1px solid rgba(111, 225, 255, 0.14);
  border-radius: 8px;
  background: rgba(8, 18, 29, 0.74);
}

.summary-label {
  display: block;
  margin-bottom: 10px;
  color: var(--ink-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 1.8vw, 1.8rem);
  letter-spacing: 0.06em;
}

.summary-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.6;
}

.compact-card {
  box-shadow: none;
}

.sweep-rows {
  display: grid;
  gap: 10px;
}

.rotation-rows {
  display: grid;
  gap: 10px;
}

.sweep-row {
  display: grid;
  grid-template-columns: 72px 1fr 132px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(111, 225, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
}

.rotation-row {
  display: grid;
  grid-template-columns: 72px 1fr 168px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(111, 225, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
}

.sweep-angle,
.sweep-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.rotation-angle,
.rotation-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.sweep-angle {
  color: var(--accent-strong);
  font-weight: 700;
}

.rotation-angle {
  color: var(--accent-strong);
  font-weight: 700;
}

.sweep-value {
  color: var(--ink);
  text-align: right;
}

.rotation-value {
  color: var(--ink);
  text-align: right;
}

.sweep-bar {
  position: relative;
  overflow: hidden;
  height: 12px;
  border: 1px solid rgba(111, 225, 255, 0.1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}

.rotation-bar {
  position: relative;
  overflow: hidden;
  height: 12px;
  border: 1px solid rgba(111, 225, 255, 0.1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}

.sweep-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #3ad4ff 0%, #ffb14d 100%);
  box-shadow: 0 0 10px rgba(111, 225, 255, 0.16);
}

.rotation-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #8de9b1 0%, #3ad4ff 100%);
  box-shadow: 0 0 10px rgba(111, 225, 255, 0.14);
}

.iso-panel {
  margin-top: 24px;
  padding: 20px 24px 24px;
  border: 1px solid rgba(111, 225, 255, 0.14);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(8, 20, 34, 0.94), rgba(5, 14, 23, 0.97));
}

.iso-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(111, 225, 255, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(6, 16, 26, 0.96), rgba(4, 10, 18, 0.98));
  margin-top: 16px;
  min-height: 300px;
}

#isoScene {
  display: block;
  width: 100%;
  height: auto;
}

.controls-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(9, 24, 39, 0.95), rgba(5, 15, 24, 0.98));
  box-shadow: var(--shadow);
}

.controls-header {
  padding: 10px 4px 2px;
}

.controls-header h2 {
  font-size: clamp(1.2rem, 1.8vw, 1.7rem);
}

.controls-header p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.panel-section {
  position: relative;
  padding: 16px;
  border: 1px solid rgba(111, 225, 255, 0.12);
  border-radius: 8px;
  background: rgba(7, 18, 29, 0.62);
}

.section-heading {
  margin-bottom: 14px;
}

.section-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  margin: -4px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.section-toggle:hover h2,
.section-toggle:focus-visible h2 {
  color: var(--accent-strong);
}

.section-toggle:focus-visible {
  outline: 1px solid rgba(111, 225, 255, 0.35);
  outline-offset: 6px;
  border-radius: 4px;
}

.section-toggle-copy {
  min-width: 0;
}

.section-toggle-icon {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1;
  transition: transform 160ms ease;
}

.panel-section.is-collapsed .section-toggle-icon {
  transform: rotate(-90deg);
}

.panel-section-body {
  overflow: hidden;
}

.panel-section.is-collapsed .section-heading {
  margin-bottom: 0;
}

.panel-section.is-collapsed .panel-section-body {
  display: none;
}

.section-heading h2 {
  font-size: 1rem;
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--ink-muted);
  font-size: 0.73rem;
  line-height: 1.7;
  text-transform: uppercase;
}

.control {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.control:last-child {
  margin-bottom: 0;
}

/* ── Collapsible sub-panel (used inside 3D Ring for group settings) ── */
.sub-panel {
  margin-top: 12px;
  border: 1px solid rgba(111, 225, 255, 0.10);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.025);
}

.sub-panel summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  user-select: none;
}

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

.sub-panel summary::before {
  content: "▶";
  font-size: 0.6rem;
  opacity: 0.7;
  transition: transform 160ms ease;
  flex-shrink: 0;
}

.sub-panel[open] summary::before {
  transform: rotate(90deg);
}

.sub-panel-body {
  padding: 4px 12px 14px;
}

.sub-panel-body .control:last-child {
  margin-bottom: 0;
}

.control span,
.toggle span {
  color: var(--ink-soft);
  font-size: 0.77rem;
  text-transform: uppercase;
}

.control strong {
  color: var(--accent-warm-soft);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.toggle input {
  inline-size: 18px;
  block-size: 18px;
  accent-color: var(--accent);
}

input[type="range"] {
  width: 100%;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(111, 225, 255, 0.18), rgba(255, 178, 74, 0.3)),
    rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(111, 225, 255, 0.1);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  margin-top: -5px;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f9feff, var(--accent) 70%);
  box-shadow: 0 0 18px rgba(111, 225, 255, 0.4);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(111, 225, 255, 0.18), rgba(255, 178, 74, 0.3)),
    rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(111, 225, 255, 0.1);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f9feff, var(--accent) 70%);
  box-shadow: 0 0 18px rgba(111, 225, 255, 0.4);
}

input[type="text"],
select {
  width: 100%;
  border: 1px solid rgba(111, 225, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: inherit;
  padding: 11px 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.015);
}

input[type="text"]::placeholder {
  color: rgba(140, 170, 189, 0.5);
}

select {
  min-height: 156px;
}

select option {
  color: #102334;
}

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

.segmented-control button,
.reset-button,
.secondary-button {
  border: 1px solid transparent;
  font: inherit;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.segmented-control button {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.04);
}

.segmented-control button.active {
  color: #071724;
  background: linear-gradient(135deg, var(--accent), #b0f5ff);
  box-shadow: 0 0 20px rgba(111, 225, 255, 0.2);
}

.segmented-control button:hover,
.reset-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.reset-button {
  min-height: 48px;
  padding: 14px 16px;
  border-radius: 6px;
  color: #081521;
  background: linear-gradient(135deg, var(--accent-warm-soft), var(--accent-warm));
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.secondary-button {
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(111, 225, 255, 0.1);
}

.danger-button {
  border-color: rgba(255, 119, 103, 0.2);
  background: rgba(255, 119, 103, 0.12);
  color: #ffd6d1;
}

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

.panel-note {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.76rem;
  line-height: 1.7;
  text-transform: uppercase;
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1200px) {
  .hero,
  .layout,
  .legend-and-notes,
  .rotation-layout {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    position: static;
    order: 2;
  }

  .viewer-panel {
    order: 1;
  }

  .viewer-head {
    flex-direction: column;
  }

  .viewer-badges {
    justify-content: flex-start;
  }
}

@media (max-width: 860px) {
  .page-shell {
    padding-inline: 14px;
  }

  .hero,
  .viewer-chrome,
  .controls-panel,
  .legend,
  .notes,
  .sweep-panel,
  .rotation-panel,
  .panel-section,
  .summary-card {
    border-radius: 10px;
  }

  .sweep-summary-grid,
  .rotation-summary-grid,
  .button-row,
  .sweep-row,
  .rotation-row {
    grid-template-columns: 1fr;
  }

  .hero-copy h1 {
    max-width: none;
    font-size: clamp(2rem, 10vw, 3.2rem);
  }

  .sweep-value,
  .rotation-value {
    text-align: left;
  }
}
