:root {
  color: #d8e5f7;
  background: #07111f;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 12px;
  color: #eaf3ff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.25);
}

button:hover {
  transform: translateY(-1px);
}

button.active {
  border-color: rgba(96, 165, 250, 0.72);
  color: #ffffff;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.95), rgba(124, 58, 237, 0.95));
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28);
}

code {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  padding: 2px 6px;
  color: #bfe0ff;
  background: rgba(15, 23, 42, 0.75);
}

#app {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  min-height: 100vh;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid rgba(148, 163, 184, 0.18);
  padding: 32px;
  background:
    radial-gradient(circle at 10% 0%, rgba(56, 189, 248, 0.14), transparent 36%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.98));
}

.eyebrow {
  margin: 0 0 8px;
  color: #60a5fa;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  color: #ffffff;
  font-size: clamp(34px, 4vw, 52px);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

h2 {
  margin-bottom: 8px;
  color: #f8fbff;
  font-size: 15px;
}

h3 {
  color: #f8fbff;
  font-size: 13px;
}

.lede,
.notes,
.readout {
  color: #a8b7cb;
  line-height: 1.65;
}

.equation-form {
  display: grid;
  gap: 12px;
}

.equation-form label {
  color: #f8fbff;
  font-size: 14px;
  font-weight: 700;
}

.equation-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.72);
}

.equation-row span {
  color: #93c5fd;
  white-space: nowrap;
}

.equation-row input {
  width: 100%;
  border: 0;
  outline: 0;
  color: #ffffff;
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.error {
  min-height: 20px;
  color: #fb7185;
  font-size: 13px;
}

.mode-tabs,
.shape-tabs,
.presets,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-tabs button,
.shape-tabs button,
.presets button,
.actions button {
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: #dbeafe;
  background: rgba(15, 23, 42, 0.76);
  box-shadow: none;
}

.tool-panel {
  display: grid;
  gap: 18px;
}

.hidden {
  display: none !important;
}

.formula-controls {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  padding: 16px;
  color: #a8b7cb;
  background: rgba(15, 23, 42, 0.42);
}

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

.formula-field {
  display: grid;
  gap: 8px;
  color: #dbeafe;
  font-size: 13px;
  font-weight: 700;
}

.formula-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.formula-field output {
  color: #fde68a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.formula-field .number-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(96, 165, 250, 0.22);
  border-radius: 12px;
  padding: 9px 10px;
  background: rgba(15, 23, 42, 0.7);
}

.formula-field input {
  width: 100%;
  border: 0;
  outline: 0;
  color: #ffffff;
  background: transparent;
}

.formula-range {
  cursor: ew-resize;
  filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.16));
}

.formula-field small {
  color: #93c5fd;
}

.sliders {
  display: grid;
  gap: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
}

.sliders label {
  display: grid;
  gap: 8px;
}

.sliders label span {
  display: flex;
  justify-content: space-between;
  color: #dbeafe;
}

.sliders output {
  color: #93c5fd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

input[type='range'] {
  width: 100%;
  accent-color: #60a5fa;
}

.readout,
.notes {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.42);
}

.stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 74% 22%, rgba(37, 99, 235, 0.2), transparent 34%),
    radial-gradient(circle at 30% 80%, rgba(124, 58, 237, 0.18), transparent 30%),
    #07111f;
}

.formula-stage {
  min-height: 100vh;
  overflow: auto;
  padding: clamp(22px, 4vw, 54px);
}

.formula-card {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
  gap: clamp(20px, 4vw, 46px);
  align-items: center;
  min-height: calc(100vh - 108px);
}

.formula-visual,
.formula-detail,
.formula-block {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 26px;
  background: rgba(15, 23, 42, 0.46);
  box-shadow: 0 24px 80px rgba(2, 6, 23, 0.28);
}

.formula-visual {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  min-height: 340px;
  padding: 28px;
}

.visual-hint {
  border: 1px solid rgba(250, 204, 21, 0.28);
  border-radius: 999px;
  padding: 7px 12px;
  color: #fde68a;
  background: rgba(113, 63, 18, 0.18);
  font-size: 12px;
}

.formula-detail {
  display: grid;
  gap: 18px;
  padding: clamp(22px, 4vw, 34px);
  color: #a8b7cb;
  line-height: 1.65;
}

.formula-detail h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
  letter-spacing: -0.04em;
}

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

.formula-block {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.formula-list {
  display: grid;
  gap: 8px;
}

.probe-block {
  border-color: rgba(250, 204, 21, 0.28);
  background:
    linear-gradient(135deg, rgba(250, 204, 21, 0.08), transparent 42%),
    rgba(15, 23, 42, 0.52);
}

.probe-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.probe-head span {
  border: 1px solid rgba(96, 165, 250, 0.24);
  border-radius: 999px;
  padding: 3px 8px;
  color: #93c5fd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.probe-block strong {
  color: #ffffff;
  font-size: 22px;
}

.steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

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

.result-list div {
  border: 1px solid rgba(96, 165, 250, 0.18);
  border-radius: 14px;
  padding: 12px;
  background: rgba(2, 6, 23, 0.28);
}

.result-list span,
.result-list strong {
  display: block;
}

.result-list span {
  color: #93c5fd;
  font-size: 12px;
}

.result-list strong {
  margin-top: 4px;
  color: #ffffff;
  font-size: 18px;
}

.warning {
  color: #fbbf24;
}

.shape-svg {
  width: min(100%, 420px);
  height: auto;
  overflow: visible;
}

.shape-fill,
.shape-edge,
.shape-guide,
.shape-corner,
.shape-node,
.shape-label {
  cursor: pointer;
  transition:
    stroke 160ms ease,
    fill 160ms ease,
    opacity 160ms ease,
    filter 160ms ease,
    transform 160ms ease;
}

.shape-fill {
  fill: rgba(56, 189, 248, 0.14);
  stroke: #60a5fa;
  stroke-width: 4;
  stroke-linejoin: round;
}

.shape-edge {
  fill: none;
  stroke: #60a5fa;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shape-edge.muted {
  stroke: rgba(96, 165, 250, 0.58);
}

.shape-guide,
.shape-corner {
  fill: none;
  stroke: #facc15;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shape-guide.dashed,
.shape-edge.dashed {
  stroke-dasharray: 8 8;
}

.shape-node {
  fill: rgba(250, 204, 21, 0.16);
  stroke: rgba(250, 204, 21, 0.72);
  stroke-width: 2;
}

.shape-dot {
  fill: #facc15;
}

.shape-label {
  fill: #dbeafe;
  stroke: rgba(2, 6, 23, 0.72);
  stroke-width: 3px;
  paint-order: stroke;
  text-anchor: middle;
  dominant-baseline: middle;
  font: 800 15px ui-sans-serif, system-ui, sans-serif;
}

.hotspot:hover,
.hotspot.active {
  stroke: #facc15;
  filter: drop-shadow(0 0 12px rgba(250, 204, 21, 0.58));
}

.shape-fill.hotspot:hover,
.shape-fill.hotspot.active {
  fill: rgba(250, 204, 21, 0.18);
}

.shape-node.hotspot.active,
.shape-label.hotspot.active {
  fill: #fef3c7;
}

.surface-stage,
#scene {
  width: 100%;
  height: 100%;
  min-height: 100vh;
}

.badge {
  position: absolute;
  right: 20px;
  bottom: 20px;
  border: 1px solid rgba(191, 219, 254, 0.22);
  border-radius: 999px;
  padding: 8px 12px;
  color: #dbeafe;
  background: rgba(2, 6, 23, 0.72);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  backdrop-filter: blur(12px);
}

@media (max-width: 860px) {
  #app {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    padding: 24px;
  }

  .stage,
  .formula-stage,
  .surface-stage,
  #scene {
    min-height: 62vh;
  }

  .formula-card,
  .formula-grid,
  .result-list,
  .formula-inputs {
    grid-template-columns: 1fr;
  }

  .formula-card {
    min-height: auto;
  }
}
