:root {
  --bg: #09111f;
  --bg-soft: #101a2d;
  --surface: rgba(12, 20, 36, 0.78);
  --surface-strong: rgba(17, 26, 46, 0.9);
  --surface-light: rgba(255, 255, 255, 0.06);
  --border: rgba(153, 178, 220, 0.16);
  --text: #f3f6ff;
  --muted: #9faecb;
  --accent: #4fd1c5;
  --accent-strong: #19b5a8;
  --warm: #ffb454;
  --danger: #ff6b6b;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(79, 209, 197, 0.18), transparent 26%),
    radial-gradient(circle at right top, rgba(255, 180, 84, 0.18), transparent 24%),
    linear-gradient(145deg, #060b14 0%, #0c1627 44%, #121d33 100%);
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(15, 26, 45, 0.94), rgba(8, 14, 25, 0.86)),
    rgba(255, 255, 255, 0.02);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -80px -80px auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 209, 197, 0.22), transparent 70%);
  pointer-events: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(79, 209, 197, 0.1);
  color: var(--accent);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.eyebrow::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 20px rgba(79, 209, 197, 0.5);
}

h1,
h2,
h3,
.scene-button,
.tool-card strong,
.readout-card strong,
.object-item strong,
.hero-stat strong {
  font-family: "Space Grotesk", sans-serif;
}

h1 {
  margin: 18px 0 16px;
  font-size: clamp(3rem, 8vw, 5.6rem);
  line-height: 0.94;
}

.hero-text,
.panel-head p,
#status-text,
.hero-stat span,
.legend-chip,
.readout-card span,
.object-item small,
.empty-note,
.status-chip,
.inspector-note,
.field label {
  color: var(--muted);
}

.hero-text {
  max-width: 60ch;
  line-height: 1.8;
  margin: 0 0 24px;
}

.hero-actions,
.inline-actions,
.scene-switch,
.workspace-top,
.stage-toolbar,
.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.primary-button,
.secondary-button,
.scene-button,
.tool-card,
.object-item {
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.primary-button,
.secondary-button,
.scene-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 13px 18px;
  cursor: pointer;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #062225;
  border-color: transparent;
  font-weight: 700;
}

.secondary-button,
.scene-button {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.primary-button:hover,
.secondary-button:hover,
.scene-button:hover,
.tool-card:hover,
.object-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.2);
}

.secondary-button.compact {
  padding-inline: 15px;
}

.scene-button.active {
  background: rgba(79, 209, 197, 0.14);
  border-color: rgba(79, 209, 197, 0.3);
  color: var(--accent);
}

.hero-panel {
  display: grid;
  gap: 14px;
  align-self: stretch;
}

.hero-stat,
.panel,
.readout-card {
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-stat {
  padding: 20px;
}

.hero-stat span,
.readout-card span {
  display: block;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.hero-stat strong {
  font-size: 1.2rem;
}

.lab-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 24px;
  margin-top: 24px;
}

.sidebar,
.workspace {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 22px;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.panel-head p,
#status-text {
  margin: 0;
  line-height: 1.7;
}

.tool-grid,
.readout-grid,
.object-list,
.inspector-grid {
  display: grid;
  gap: 12px;
}

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

.tool-card,
.object-item {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-light);
}

.tool-card {
  padding: 16px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 10px;
}

.tool-glyph {
  position: relative;
  width: 56px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.tool-glyph span,
.tool-glyph::before,
.tool-glyph::after {
  content: "";
  position: absolute;
}

.tool-glyph.laser::before {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f8fbff;
  left: 10px;
}

.tool-glyph.laser::after {
  width: 26px;
  height: 2px;
  background: linear-gradient(90deg, #ffffff, rgba(255, 255, 255, 0));
  right: 8px;
}

.tool-glyph.optical-object::before {
  width: 4px;
  height: 24px;
  background: #7bd389;
  bottom: 8px;
}

.tool-glyph.optical-object::after {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 10px solid #7bd389;
  top: 6px;
}

.tool-glyph.round-object::before {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #7bd389;
}

.tool-glyph.eye::before {
  width: 28px;
  height: 18px;
  border-radius: 18px / 12px;
  border: 2px solid #f7f1cf;
}

.tool-glyph.eye::after {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f7f1cf;
}

.tool-glyph.depth-tank::before {
  width: 32px;
  height: 28px;
  border: 2px solid #c8f0ff;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.tool-glyph.depth-tank::after {
  width: 28px;
  height: 10px;
  background: rgba(89, 179, 255, 0.45);
  bottom: 8px;
}

.tool-glyph.fiber::before {
  width: 34px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid #78ebff;
}

.tool-glyph.fiber::after {
  width: 20px;
  height: 2px;
  background: #b7fcff;
}

.tool-glyph.prism::before {
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 24px solid rgba(212, 224, 255, 0.72);
}

.tool-glyph.prism::after {
  width: 18px;
  height: 2px;
  background: linear-gradient(90deg, #ff3b30, #ff7a00, #ffd60a, #34c759, #32ade6, #5856d6, #bf5af2);
  right: 4px;
  bottom: 10px;
  transform: rotate(-18deg);
}

.tool-glyph.plane-mirror::before {
  width: 4px;
  height: 28px;
  background: #ffd166;
}

.tool-glyph.concave-mirror::before,
.tool-glyph.convex-mirror::before {
  width: 24px;
  height: 28px;
  border: 3px solid #ffd166;
  border-top-color: transparent;
  border-bottom-color: transparent;
}

.tool-glyph.concave-mirror::before {
  border-left-color: transparent;
  border-radius: 0 18px 18px 0;
}

.tool-glyph.convex-mirror::before {
  border-right-color: transparent;
  border-radius: 18px 0 0 18px;
}

.tool-glyph.convex-lens::before,
.tool-glyph.concave-lens::before {
  width: 20px;
  height: 28px;
  border: 2px solid #7eb7ff;
}

.tool-glyph.convex-lens::before {
  border-radius: 14px / 22px;
}

.tool-glyph.concave-lens::before {
  border-radius: 10px;
  transform: scaleX(0.72);
}

.tool-glyph.block::before {
  width: 26px;
  height: 18px;
  background: #7bd389;
}

.tool-glyph.force::before {
  width: 22px;
  height: 3px;
  background: #ffb454;
}

.tool-glyph.force::after {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid #ffb454;
  right: 12px;
}

.tool-card strong,
.object-item strong,
.readout-card strong {
  display: block;
  font-size: 1rem;
}

.tool-card small,
.object-item small {
  display: block;
  line-height: 1.6;
  margin-top: 6px;
}

.workspace-top {
  justify-content: space-between;
}

.legend-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
}

.status-chip::before,
.legend-chip::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.status-chip.muted::before {
  background: var(--warm);
}

.legend-chip.laser::before {
  background: var(--danger);
}

.legend-chip.mirror::before {
  background: #ffd166;
}

.legend-chip.lens::before {
  background: #6ea8fe;
}

.legend-chip.block::before {
  background: #7bd389;
}

.legend-chip.force::before {
  background: var(--warm);
}

.stage-panel {
  border-radius: 28px;
  padding: 22px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(18, 30, 53, 0.82), rgba(10, 18, 31, 0.94)),
    var(--surface-strong);
  box-shadow: var(--shadow);
}

.stage-toolbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

.stage-toolbar h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.canvas-shell {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(153, 178, 220, 0.14);
  background:
    radial-gradient(circle at top left, rgba(79, 209, 197, 0.08), transparent 28%),
    radial-gradient(circle at right bottom, rgba(255, 180, 84, 0.12), transparent 22%),
    linear-gradient(180deg, rgba(14, 23, 39, 0.92), rgba(8, 13, 22, 0.98));
  min-height: 600px;
}

#lab-canvas {
  display: block;
  width: 100%;
  height: 600px;
  touch-action: none;
}

.empty-note {
  position: absolute;
  top: 20px;
  left: 20px;
  max-width: 320px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.7;
  pointer-events: none;
}

.readout-card {
  padding: 18px;
}

.object-panel {
  padding-top: 20px;
}

.object-list {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.object-item {
  padding: 16px;
  cursor: pointer;
  text-align: left;
}

.object-item.active {
  background: rgba(79, 209, 197, 0.12);
  border-color: rgba(79, 209, 197, 0.28);
}

.inspector-note {
  line-height: 1.7;
}

.inspector-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

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

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.88rem;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

@media (max-width: 1120px) {
  .hero,
  .lab-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 18px, 1440px);
    padding-top: 18px;
  }

  .hero,
  .panel,
  .stage-panel,
  .hero-stat,
  .readout-card {
    border-radius: 22px;
  }

  .tool-grid,
  .readout-grid,
  .inspector-grid,
  .object-list {
    grid-template-columns: 1fr;
  }

  .stage-toolbar,
  .workspace-top {
    align-items: flex-start;
    flex-direction: column;
  }
}
