:root {
  color-scheme: dark;
  --bg: #080a1a;
  --panel: rgba(17, 20, 48, 0.78);
  --panel-solid: #11142e;
  --line: rgba(158, 170, 255, 0.16);
  --text: #f5f6ff;
  --muted: #9ba3c7;
  --purple: #8b6cff;
  --cyan: #3ddcff;
  --mint: #24e1ad;
  --danger: #ff668a;
  font-family: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, #202050 0, transparent 38%),
    linear-gradient(145deg, #070817 0%, #0a0c21 55%, #080a18 100%);
}

button, input { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 30rem;
  height: 30rem;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .17;
  pointer-events: none;
}

.ambient-one { top: 8%; left: -12rem; background: var(--purple); }
.ambient-two { right: -12rem; top: 42%; background: var(--cyan); }

.app-shell {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto;
}

.hero {
  position: relative;
  padding: 38px 0 52px;
  text-align: center;
}

.brand {
  position: absolute;
  top: 34px;
  left: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  color: #dfe3ff;
  font-family: "Space Grotesk", sans-serif;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(114, 218, 255, .28);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(139,108,255,.2), rgba(61,220,255,.08));
}

.brand-mark svg { width: 23px; fill: none; stroke: var(--cyan); stroke-width: 2; }
.brand-mark circle { fill: var(--purple); stroke: none; }

.site-cta {
  position: absolute;
  top: 31px;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 24px;
  border: 1px solid rgba(117, 167, 255, .48);
  border-radius: 999px;
  color: #eef4ff;
  background:
    linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.04)),
    rgba(10, 13, 35, .58);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, .18),
    0 0 0 1px rgba(255,255,255,.04) inset,
    0 0 30px rgba(61,220,255,.08);
  font-family: "Space Grotesk", sans-serif;
  font-size: .94rem;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
  transition: transform .2s, border-color .2s, box-shadow .2s, color .2s;
}
.site-cta:hover {
  border-color: rgba(61, 220, 255, .78);
  color: #ffffff;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, .22),
    0 0 0 1px rgba(255,255,255,.08) inset,
    0 0 34px rgba(61,220,255,.22);
  transform: translateY(-2px);
}
.site-cta span {
  color: var(--cyan);
  font-size: 1.1rem;
  line-height: 1;
}

.hero-copy { max-width: 790px; margin: 40px auto 8px; }
.eyebrow, .kicker {
  margin: 0 0 12px;
  color: var(--cyan);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .2em;
}

h1, h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -.04em;
}

h1 { font-size: clamp(2.6rem, 5.5vw, 5.8rem); line-height: .98; }
h1 span {
  color: transparent;
  background: linear-gradient(110deg, var(--purple), var(--cyan) 70%, var(--mint));
  background-clip: text;
  -webkit-background-clip: text;
}

.subtitle {
  max-width: 640px;
  margin: 24px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.16rem);
  line-height: 1.7;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, .88fr) minmax(500px, 1.12fr);
  gap: 20px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 25px;
  background: linear-gradient(145deg, rgba(21,25,57,.88), rgba(12,15,38,.86));
  box-shadow: 0 28px 70px rgba(0,0,0,.26), inset 0 1px rgba(255,255,255,.04);
  backdrop-filter: blur(20px);
}

.input-panel { padding: clamp(26px, 3vw, 42px); }
.visual-panel { display: flex; flex-direction: column; overflow: hidden; padding-top: clamp(26px, 3vw, 42px); }

.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.panel-heading h2, .learn-strip h2 { font-size: clamp(1.55rem, 2vw, 2.05rem); }
.text-button {
  border: 0;
  color: #aab3d4;
  background: none;
  cursor: pointer;
  font-size: .82rem;
}
.text-button:hover { color: var(--cyan); }
.text-button span { display: inline-block; margin-right: 5px; font-size: 1.1rem; }

.instruction {
  margin: 18px 0 28px;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.6;
}

fieldset { margin: 0; padding: 0; border: 0; }
legend {
  margin-bottom: 13px;
  color: #d8dcf5;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field {
  display: block;
  min-width: 0;
  padding: 13px 13px 10px;
  border: 1px solid rgba(158,170,255,.15);
  border-radius: 14px;
  background: rgba(7,9,27,.52);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.field:focus-within {
  border-color: rgba(61,220,255,.65);
  box-shadow: 0 0 0 3px rgba(61,220,255,.08);
  transform: translateY(-1px);
}
.field > span { display: flex; align-items: baseline; gap: 7px; }
.field b {
  color: #f1f3ff;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.08rem;
  font-style: italic;
}
.field small { overflow: hidden; color: #6f789d; font-size: .61rem; white-space: nowrap; text-overflow: ellipsis; }
.input-wrap { display: flex; align-items: flex-end; margin-top: 8px; }
.input-wrap input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: none;
  color: var(--cyan);
  background: transparent;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.55rem;
  font-weight: 600;
  appearance: textfield;
}
.input-wrap input::-webkit-inner-spin-button { appearance: none; }
.input-wrap input::placeholder { color: #3f4667; }
.input-wrap > span { padding-bottom: 3px; color: #60698d; font-size: .57rem; }

.form-divider { display: flex; align-items: center; gap: 10px; margin: 20px 0; color: #4d5577; font-size: .55rem; letter-spacing: .14em; }
.form-divider::before, .form-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.form-message { min-height: 20px; margin: 15px 0 5px; color: var(--danger); font-size: .77rem; }

.solve-button {
  display: flex;
  width: 100%;
  height: 58px;
  padding: 0 9px 0 23px;
  border: 0;
  border-radius: 15px;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  color: #080a18;
  background: linear-gradient(100deg, #8e72ff, #4ddaff 65%, #28e2ad);
  box-shadow: 0 14px 35px rgba(67,199,255,.16);
  cursor: pointer;
  font-family: "Space Grotesk", sans-serif;
  font-size: .9rem;
  font-weight: 700;
  transition: transform .2s, box-shadow .2s;
}
.solve-button:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(67,199,255,.24); }
.solve-button:active { transform: translateY(0); }
.button-arrow {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 11px;
  color: white;
  background: rgba(8,10,24,.7);
  font-size: 1.25rem;
}

.visual-heading { padding: 0 clamp(26px, 3vw, 42px) 22px; }
.visual-badges {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}
.case-badge {
  display: inline-flex;
  min-height: 34px;
  padding: 5px 11px;
  border: 1px solid rgba(139, 108, 255, .35);
  border-radius: 10px;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(139, 108, 255, .18), rgba(61, 220, 255, .08));
  box-shadow: 0 0 20px rgba(139, 108, 255, .09);
}
.case-badge[hidden] { display: none; }
.case-badge small {
  color: #7e88ae;
  font-size: .5rem;
  font-weight: 700;
  letter-spacing: .12em;
}
.case-badge strong {
  color: #c7baff;
  font-family: "Space Grotesk", sans-serif;
  font-size: .82rem;
  letter-spacing: .08em;
}
.status-badge {
  display: inline-flex;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 99px;
  align-items: center;
  gap: 7px;
  color: #8f98bc;
  font-size: .65rem;
  white-space: nowrap;
}
.status-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #69708c;
  box-shadow: 0 0 0 3px rgba(105,112,140,.14);
}
.status-badge.solved { color: var(--mint); border-color: rgba(36,225,173,.2); }
.status-badge.solved i { background: var(--mint); box-shadow: 0 0 0 3px rgba(36,225,173,.12), 0 0 12px var(--mint); }

.triangle-stage {
  position: relative;
  display: grid;
  min-height: 415px;
  flex: 1;
  place-items: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 50%, rgba(81,92,193,.14), transparent 55%),
    rgba(5,7,23,.4);
  overflow: hidden;
}
.triangle-stage::after {
  position: absolute;
  right: -15%;
  bottom: -70%;
  width: 90%;
  height: 90%;
  border: 1px solid rgba(61,220,255,.07);
  border-radius: 50%;
  box-shadow: 0 0 0 45px rgba(139,108,255,.025), 0 0 0 90px rgba(61,220,255,.018);
  content: "";
}
#triangleSvg { width: min(94%, 660px); height: auto; overflow: visible; }
.grid-lines { fill: none; stroke: rgba(132,149,222,.055); stroke-width: 1; }
#trianglePolygon {
  fill: url(#triangleFill);
  stroke: url(#triangleStroke);
  stroke-width: 3;
  filter: url(#glow);
  vector-effect: non-scaling-stroke;
  transition: points .7s cubic-bezier(.22,.8,.24,1);
}
#trianglePolygon.deemphasized { opacity: .42; }
.ambiguous-altitude {
  opacity: 0;
  transition: opacity .35s ease;
}
.ambiguous-altitude.visible { opacity: 1; }
#altitudeLine {
  stroke: rgba(255, 255, 255, .38);
  stroke-width: 1.5;
  stroke-dasharray: 5 6;
  vector-effect: non-scaling-stroke;
}
#altitudeLabel {
  fill: #9ca6cc;
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  font-weight: 600;
  paint-order: stroke;
  stroke: #090b20;
  stroke-width: 4px;
  text-anchor: start;
}
.alternate-triangle {
  opacity: 0;
  transition: opacity .35s ease;
}
.alternate-triangle.visible { opacity: 1; }
.alternate-triangle.selected #alternatePolygon {
  fill: rgba(139, 108, 255, .24);
  stroke-width: 3.5;
  filter: drop-shadow(0 0 11px rgba(139, 108, 255, .85));
}
.alternate-triangle.selected #alternateVertex {
  fill: #ad94ff;
  stroke: #f0ecff;
}
.alternate-triangle.selected #alternateLabel { fill: #ded6ff; }
#alternatePolygon {
  fill: rgba(139, 108, 255, .14);
  stroke: #ad94ff;
  stroke-width: 2.75;
  filter: drop-shadow(0 0 7px rgba(139, 108, 255, .45));
  vector-effect: non-scaling-stroke;
  transition: points .7s cubic-bezier(.22,.8,.24,1);
}
#alternateVertex {
  fill: #090b20;
  stroke: #ad94ff;
  stroke-width: 3;
  filter: drop-shadow(0 0 7px rgba(139, 108, 255, .7));
  transition: cx .7s, cy .7s;
}
#alternateLabel {
  fill: #c3b5ff;
  font-family: "Space Grotesk", sans-serif;
  font-size: 14px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #090b20;
  stroke-width: 5px;
  text-anchor: middle;
  transition: x .7s, y .7s;
}
.alternate-side-label {
  fill: #ad94ff !important;
  font-family: "Space Grotesk", sans-serif !important;
  font-size: 12px !important;
  font-weight: 700;
  paint-order: stroke;
  stroke: #090b20;
  stroke-width: 5px;
  text-anchor: middle;
}
.vertices circle { fill: #090b20; stroke: var(--cyan); stroke-width: 3; filter: url(#glow); transition: cx .7s, cy .7s; }
.diagram-labels text {
  fill: #eef1ff;
  font-family: "Space Grotesk", sans-serif;
  font-size: 15px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #0a0c21;
  stroke-width: 5px;
  stroke-linejoin: round;
}
.diagram-labels.deemphasized { opacity: .42; }
.diagram-labels .side-label { fill: var(--cyan); font-size: 13px; }
.angle-arcs path { fill: none; stroke: rgba(155,135,255,.8); stroke-width: 2; }
.stage-prompt {
  position: absolute;
  bottom: 22px;
  z-index: 2;
  margin: 0;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: #747da3;
  background: rgba(8,10,26,.72);
  font-size: .68rem;
  backdrop-filter: blur(8px);
  transition: opacity .3s;
}
.prompt-icon { margin-right: 6px; color: var(--purple); }
.triangle-stage.solved .stage-prompt { opacity: 0; pointer-events: none; }

.results-section { min-height: 150px; padding: 24px clamp(26px, 3vw, 42px) 28px; }
.empty-results { display: flex; height: 98px; align-items: center; justify-content: space-around; color: #5b6383; }
.empty-results div { text-align: center; }
.empty-results span { color: #8089ae; font-family: "Space Grotesk"; font-size: 1.65rem; font-weight: 700; }
.empty-results p { margin: 4px 0 0; font-size: .57rem; letter-spacing: .07em; text-transform: uppercase; }
.empty-results b { color: #343b5b; font-weight: 400; }
.empty-results .accent span { color: var(--purple); }

.solution-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.solution-tab {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #929bbe;
  background: transparent;
  cursor: pointer;
  font-size: .68rem;
}
.solution-tab.active { color: #0b0d1f; border-color: transparent; background: var(--cyan); font-weight: 700; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.result-card {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(5,7,23,.45);
}
.result-card span { display: block; color: #697294; font-size: .57rem; letter-spacing: .08em; }
.result-card strong { display: block; margin-top: 5px; color: #edf0ff; font-family: "Space Grotesk"; font-size: 1rem; }
.result-card strong em { color: #7881a2; font-size: .58rem; font-style: normal; font-weight: 500; }
.result-card.calculated {
  border-color: rgba(61, 220, 255, .34);
  background:
    linear-gradient(135deg, rgba(139, 108, 255, .11), rgba(61, 220, 255, .07)),
    rgba(5, 7, 23, .58);
  box-shadow: inset 0 0 20px rgba(61, 220, 255, .025);
}
.result-card.calculated span { color: #8d98c5; }
.result-card.calculated strong { color: var(--cyan); }
.result-card.calculated.metric {
  border-color: rgba(36, 225, 173, .3);
}
.result-card.calculated.metric strong { color: var(--mint); }
.method-line { margin: 13px 0 0; color: #7d86a8; font-size: .66rem; }
.method-line b { color: var(--purple); }
.solution-guide {
  margin-top: 18px;
  border: 1px solid rgba(139, 108, 255, .2);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(5, 7, 23, .36);
}
.solution-guide summary {
  display: flex;
  padding: 14px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: #e8eaff;
  background: linear-gradient(100deg, rgba(139,108,255,.1), rgba(61,220,255,.04));
  cursor: pointer;
  font-family: "Space Grotesk", sans-serif;
  font-size: .84rem;
  font-weight: 700;
  list-style: none;
}
.solution-guide summary::-webkit-details-marker { display: none; }
.solution-guide summary::after {
  color: var(--cyan);
  content: "−";
  font-size: 1.1rem;
}
.solution-guide:not([open]) summary::after { content: "+"; }
.solution-guide summary span { display: flex; flex-direction: column; gap: 3px; }
.solution-guide summary small {
  color: var(--cyan);
  font-family: "DM Sans", sans-serif;
  font-size: .48rem;
  letter-spacing: .14em;
}
.solution-guide summary b {
  margin-left: auto;
  color: #a99aff;
  font-size: .6rem;
  letter-spacing: .08em;
  white-space: nowrap;
}
.solution-guide ol {
  display: grid;
  margin: 0;
  padding: 15px;
  gap: 10px;
  list-style: none;
}
.guide-step {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid rgba(158,170,255,.1);
  border-radius: 10px;
  background: rgba(9,11,31,.5);
}
.step-number {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid rgba(61,220,255,.25);
  border-radius: 8px;
  color: var(--cyan);
  background: rgba(61,220,255,.06);
  font-family: "Space Grotesk", sans-serif;
  font-size: .68rem;
  font-weight: 700;
}
.guide-step h4 { margin: 1px 0 3px; color: #edf0ff; font-size: .73rem; }
.guide-step p { margin: 0; color: #7f88aa; font-size: .63rem; line-height: 1.45; }
.step-equation {
  max-width: 100%;
  margin-top: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  color: #dfe4ff;
  font-size: .72rem;
  scrollbar-width: thin;
}
.step-equation mjx-container { margin: 0 !important; }

.learn-strip {
  display: grid;
  grid-template-columns: minmax(240px, .85fr) repeat(2, minmax(260px, 1fr));
  gap: 15px;
  margin: 20px 0;
  padding: 30px clamp(25px, 3vw, 42px);
  border: 1px solid var(--line);
  border-radius: 22px;
  align-items: center;
  background: rgba(14,17,42,.62);
}
.learn-strip > div:first-child {
  grid-row: 1 / 3;
  align-self: center;
}
.learn-strip h2 { max-width: 300px; }
.formula-card {
  position: relative;
  padding: 17px 20px;
  border-left: 2px solid var(--purple);
  background: linear-gradient(90deg, rgba(139,108,255,.07), transparent);
  transition: border-color .25s, background .25s, box-shadow .25s, transform .25s;
}
.formula-card:nth-child(3),
.formula-card:nth-child(5) {
  border-left-color: var(--cyan);
  background: linear-gradient(90deg, rgba(61,220,255,.07), transparent);
}
.formula-card:nth-child(4) {
  border-left-color: var(--mint);
  background: linear-gradient(90deg, rgba(36,225,173,.07), transparent);
}
.formula-heading {
  display: flex;
  min-height: 18px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.formula-heading span { color: #7982a4; font-size: .6rem; font-weight: 700; letter-spacing: .13em; }
.formula-heading b {
  display: none;
  padding: 4px 7px;
  border: 1px solid rgba(36, 225, 173, .3);
  border-radius: 999px;
  color: var(--mint);
  background: rgba(36, 225, 173, .08);
  font-size: .48rem;
  letter-spacing: .11em;
  white-space: nowrap;
}
.formula-card.first-step {
  border-left-color: var(--mint);
  background:
    linear-gradient(105deg, rgba(36,225,173,.14), rgba(61,220,255,.07) 62%, transparent);
  box-shadow: inset 0 0 24px rgba(36,225,173,.04), 0 0 28px rgba(36,225,173,.07);
  transform: translateY(-1px);
}
.formula-card.first-step .formula-heading span { color: #c2f8e8; }
.formula-card.first-step .formula-heading b { display: inline-flex; }
.formula-card p {
  min-height: 32px;
  margin: 9px 0 0;
  color: #dce0f6;
  font-size: clamp(.92rem, 1.3vw, 1.1rem);
  line-height: 1.5;
}
.formula-card mjx-container {
  margin: 0 !important;
  color: #eef1ff;
}
.formula-card mjx-container svg { overflow: visible; }

footer { display: flex; padding: 24px 2px 36px; justify-content: space-between; color: #555e80; font-size: .65rem; }
footer span { font-family: "Space Grotesk"; font-weight: 700; letter-spacing: .15em; }
footer p { margin: 0; }

@media (max-width: 1040px) {
  .site-cta {
    padding: 0 20px;
    font-size: .86rem;
  }
  .workspace { grid-template-columns: 1fr; }
  .visual-panel { min-height: 700px; }
  .learn-strip { grid-template-columns: 1fr 1fr; }
  .learn-strip > div:first-child { grid-column: 1 / -1; grid-row: auto; }
}

@media (max-width: 680px) {
  .app-shell { width: min(100% - 24px, 1500px); }
  .hero { padding-top: 138px; }
  .brand { top: 24px; left: 50%; transform: translateX(-50%); white-space: nowrap; }
  .site-cta {
    top: 76px;
    left: 50%;
    right: auto;
    max-width: calc(100vw - 32px);
    padding: 0 18px;
    transform: translateX(-50%);
    white-space: nowrap;
  }
  .site-cta:hover { transform: translateX(-50%) translateY(-2px); }
  .hero-copy { margin-top: 22px; }
  .field-grid { grid-template-columns: 1fr; }
  .field { display: grid; grid-template-columns: 1fr 1.2fr; align-items: center; }
  .field > span { display: flex; }
  .input-wrap { margin-top: 0; }
  .visual-heading { flex-direction: column; gap: 12px; }
  .triangle-stage { min-height: 330px; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .learn-strip { grid-template-columns: 1fr; }
  .learn-strip > div:first-child { grid-column: auto; }
  footer { flex-direction: column; gap: 7px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
