:root {
  --midnight-blue: #000052;
  --ember-orange: #ff8e2b;
  --deep-rose: #610019;
  --ink: #f7f8ff;
  --muted: rgba(247, 248, 255, 0.72);
  --quiet: rgba(247, 248, 255, 0.52);
  --card: rgba(255, 255, 255, 0.10);
  --card-strong: rgba(255, 255, 255, 0.15);
  --line: rgba(255, 255, 255, 0.18);
  --math-cyan: #79ebff;
  --math-cyan-soft: rgba(121, 235, 255, 0.18);
  --math-frame: #2a6a87;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --max: 1180px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 14% 10%, rgba(255, 142, 43, 0.30), transparent 24rem),
    radial-gradient(circle at 82% 22%, rgba(97, 0, 25, 0.54), transparent 27rem),
    radial-gradient(circle at 52% 92%, rgba(255, 142, 43, 0.18), transparent 30rem),
    linear-gradient(135deg, #020213 0%, var(--midnight-blue) 43%, #240014 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -4;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(circle at center, black, transparent 76%);
  opacity: 0.42;
}

button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid rgba(255, 188, 128, 0.95); outline-offset: 3px; }

#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -3;
  pointer-events: none;
}

.ambient {
  position: fixed;
  z-index: -2;
  width: 38vmax;
  height: 38vmax;
  border-radius: 999px;
  filter: blur(44px);
  opacity: 0.44;
  pointer-events: none;
  animation: drift 18s ease-in-out infinite alternate;
}
.ambient-one { top: -10vmax; left: -10vmax; background: rgba(0, 0, 82, 0.74); }
.ambient-two { right: -12vmax; top: 18vh; background: rgba(255, 142, 43, 0.40); animation-delay: -8s; }
.ambient-three { left: 38vw; bottom: -18vmax; background: rgba(97, 0, 25, 0.46); animation-delay: -4s; }
@keyframes drift { from { transform: translate3d(-2rem, 1rem, 0) scale(.95); } to { transform: translate3d(2rem, -1.5rem, 0) scale(1.08); } }

.section-shell { width: min(calc(100% - 2rem), var(--max)); margin: 0 auto; }
.mathlab-shell { position: relative; z-index: 1; }

.eyebrow {
  margin: 0 0 1rem;
  color: rgba(255, 197, 147, 0.96);
  font-size: .79rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin: 0;
  font-size: clamp(3.35rem, 8vw, 7.1rem);
  line-height: .88;
  letter-spacing: -.075em;
}
h1 span {
  background: linear-gradient(100deg, #fff 3%, #ffd4ad 38%, var(--ember-orange) 73%, #ff9ab2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
h2 { margin-bottom: 1rem; font-size: clamp(2.2rem, 4vw, 4.2rem); line-height: .98; letter-spacing: -.06em; }

.mathlab-hero {
  min-height: calc(100vh - 90px);
  padding: 6rem 0 5rem;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr);
  gap: 3.5rem;
  align-items: center;
}
.hero-title-row { display: flex; align-items: flex-start; gap: 1.25rem; }
.mathlab-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: clamp(68px, 7vw, 96px);
  aspect-ratio: 1;
  margin-top: .35rem;
  border: 1px solid rgba(121,235,255,.25);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(8,26,50,.86), rgba(3,7,28,.72));
  box-shadow: 0 20px 60px rgba(0,0,0,.28), inset 0 0 35px rgba(121,235,255,.07);
}
.mathlab-mark img { width: 66%; height: 66%; image-rendering: pixelated; }
.hero-text { max-width: 780px; margin: 1.7rem 0 0; color: var(--muted); font-size: 1.05rem; line-height: 1.78; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 2rem; }
.primary-button, .secondary-button, .icon-button, .toolbar-button {
  appearance: none;
  border: 1px solid var(--line);
  cursor: pointer;
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  min-height: 48px;
  padding: .82rem 1.15rem;
  border-radius: 999px;
  color: #180008;
  font-weight: 800;
  background: linear-gradient(135deg, var(--ember-orange), #ffd4ad);
  box-shadow: 0 14px 34px rgba(255,142,43,.18);
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgba(255,142,43,.28); }
.secondary-button {
  min-height: 48px;
  padding: .82rem 1.15rem;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 750;
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(12px);
}
.secondary-button:hover { transform: translateY(-2px); background: rgba(255,255,255,.13); }
.hero-readouts { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1.65rem; }
.hero-readouts span {
  display: inline-flex;
  align-items: center;
  gap: .48rem;
  min-height: 31px;
  padding: .46rem .7rem;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 999px;
  background: rgba(6,7,37,.42);
  color: rgba(247,248,255,.58);
  font: 700 .68rem/1 "Courier New", monospace;
  letter-spacing: .08em;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #69ffb4; box-shadow: 0 0 9px #69ffb4; animation: livePulse 2.8s ease-in-out infinite; }
@keyframes livePulse { 50% { opacity: .45; transform: scale(.78); } }

.hero-instrument {
  position: relative;
  overflow: hidden;
  min-height: 510px;
  padding: 1.2rem;
  border: 1px solid rgba(255,255,255,.17);
  border-radius: var(--radius-xl);
  background: linear-gradient(150deg, rgba(255,255,255,.12), rgba(4,4,32,.48));
  box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.08);
  backdrop-filter: blur(22px) saturate(120%);
}
.instrument-glow { position: absolute; width: 310px; height: 310px; right: -110px; top: -120px; border-radius: 50%; background: rgba(255,142,43,.25); filter: blur(45px); }
.instrument-topline { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--quiet); font: 800 .68rem/1 "Courier New",monospace; letter-spacing: .12em; }
.instrument-live { display: inline-flex; align-items: center; gap: .42rem; color: #a7ffd1; }
.instrument-live i { width: 6px; height: 6px; border-radius: 50%; background: #69ffb4; box-shadow: 0 0 8px #69ffb4; }
.instrument-orbit { position: relative; display: grid; place-items: center; height: 315px; margin: 1rem 0 .5rem; }
.instrument-orbit::before { content: ""; position: absolute; width: 250px; height: 250px; border-radius: 50%; background: radial-gradient(circle, rgba(121,235,255,.09), transparent 68%); }
.instrument-icon {
  position: relative;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 128px;
  height: 128px;
  border: 1px solid rgba(121,235,255,.28);
  border-radius: 34px;
  background: rgba(2,8,24,.78);
  box-shadow: 0 0 60px rgba(121,235,255,.11), inset 0 0 34px rgba(121,235,255,.06);
}
.instrument-icon img { width: 82px; height: 82px; image-rendering: pixelated; }
.orbit { position: absolute; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; }
.orbit::before { content: ""; position: absolute; left: 50%; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--ember-orange); box-shadow: 0 0 18px rgba(255,142,43,.9); }
.orbit-a { width: 245px; height: 245px; animation: spin 12s linear infinite; }
.orbit-b { width: 195px; height: 195px; border-color: rgba(121,235,255,.18); animation: spinReverse 9s linear infinite; }
.orbit-b::before { background: var(--math-cyan); box-shadow: 0 0 16px rgba(121,235,255,.9); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spinReverse { to { transform: rotate(-360deg); } }
.instrument-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.instrument-grid > div { padding: .78rem .85rem; border: 1px solid rgba(255,255,255,.09); border-radius: 14px; background: rgba(2,6,28,.38); }
.instrument-grid small, .instrument-grid strong { display: block; }
.instrument-grid small { color: rgba(247,248,255,.42); font: 700 .59rem "Courier New",monospace; letter-spacing: .11em; }
.instrument-grid strong { margin-top: .28rem; color: #fff; font: 800 .78rem "Courier New",monospace; }

.archive-section { padding: 3.5rem 0 6rem; }
.archive-heading { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 2rem; margin-bottom: 1.4rem; }
.section-heading p:not(.eyebrow) { max-width: 760px; margin-bottom: 0; color: var(--muted); line-height: 1.72; }
.archive-actions { display: flex; align-items: center; gap: .75rem; }
.archive-count { min-width: 132px; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.07); text-align: right; backdrop-filter: blur(14px); }
.archive-count small, .archive-count span { display: block; color: var(--quiet); font: 700 .58rem "Courier New",monospace; letter-spacing: .11em; }
.archive-count strong { display: block; margin: .08rem 0; font: 700 1.7rem/1 "Courier New",monospace; color: #fff; }
.icon-button { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.08); font-size: 1.25rem; }
.icon-button:hover { transform: translateY(-2px) rotate(18deg); background: rgba(255,255,255,.13); }

.library-status { display: flex; align-items: center; gap: .72rem; min-height: 48px; margin-bottom: 1rem; padding: .85rem 1rem; border: 1px solid rgba(255,255,255,.11); border-radius: 16px; background: rgba(5,7,32,.50); color: var(--muted); font: 700 .76rem "Courier New",monospace; backdrop-filter: blur(14px); }
.library-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--ember-orange); box-shadow: 0 0 12px rgba(255,142,43,.85); animation: livePulse 1.3s ease-in-out infinite; }
.library-status.is-error i { background: #ff7594; box-shadow: 0 0 12px rgba(255,117,148,.8); }

.observation-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 1rem; }
.observation-card {
  --pointer-x: 50%;
  --pointer-y: 50%;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 25px;
  background: linear-gradient(150deg, rgba(255,255,255,.105), rgba(5,5,34,.48));
  box-shadow: 0 18px 50px rgba(0,0,0,.19);
  backdrop-filter: blur(18px) saturate(115%);
  opacity: 0;
  transform: translateY(18px);
  animation: cardIn .62s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 65ms);
  transition: transform .36s var(--ease), border-color .25s ease, box-shadow .36s ease;
}
.observation-card::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; background: radial-gradient(480px circle at var(--pointer-x) var(--pointer-y), rgba(255,142,43,.16), transparent 38%); transition: opacity .25s ease; }
.observation-card:hover { transform: translateY(-7px); border-color: rgba(255,201,156,.29); box-shadow: 0 26px 65px rgba(0,0,0,.30); }
.observation-card:hover::before { opacity: 1; }
@keyframes cardIn { to { opacity: 1; transform: translateY(0); } }
.thumb-frame { position: relative; overflow: hidden; aspect-ratio: 16 / 9; background: #020211; }
.thumb-frame::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 48%, rgba(3,3,24,.82)); pointer-events: none; }
.thumb { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .8s var(--ease), filter .4s ease; }
.observation-card:hover .thumb { transform: scale(1.045); filter: saturate(1.08) brightness(1.04); }
.live-badge { position: absolute; top: 13px; right: 13px; z-index: 3; padding: .4rem .58rem; border: 1px solid rgba(255,196,140,.36); border-radius: 999px; background: rgba(61,21,4,.72); color: #ffd5ad; font: 800 .58rem "Courier New",monospace; letter-spacing: .08em; backdrop-filter: blur(10px); }
.card-body { position: relative; z-index: 2; padding: 1rem; }
.card-kicker { color: rgba(255,197,147,.76); font: 800 .62rem "Courier New",monospace; letter-spacing: .1em; }
.card-title { margin-top: .38rem; color: #fff; font-size: 1.07rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { margin-top: .28rem; color: var(--quiet); font: .66rem "Courier New",monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; margin: .9rem 0; }
.metric { padding: .66rem .7rem; border: 1px solid rgba(255,255,255,.075); border-radius: 12px; background: rgba(2,3,25,.28); }
.metric span, .metric strong { display: block; }
.metric span { color: rgba(247,248,255,.39); font: 700 .54rem "Courier New",monospace; letter-spacing: .1em; text-transform: uppercase; }
.metric strong { margin-top: .24rem; color: rgba(255,255,255,.91); font: 800 .67rem "Courier New",monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 4px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.10); }
.progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--deep-rose), var(--ember-orange), #ffd4ad); box-shadow: 0 0 13px rgba(255,142,43,.35); }
.open-observation { width: 100%; min-height: 42px; margin-top: .9rem; border: 1px solid rgba(255,255,255,.10); border-radius: 13px; background: rgba(255,255,255,.075); color: #fff; font-weight: 800; cursor: pointer; transition: transform .2s ease, background .2s ease, border-color .2s ease; }
.open-observation:hover { transform: translateY(-2px); background: rgba(255,142,43,.15); border-color: rgba(255,192,135,.28); }

.viewer-view { padding: 2.5rem 0 6rem; }
.viewer-toolbar { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 1rem; margin-bottom: .9rem; padding: .75rem; border: 1px solid var(--line); border-radius: 22px; background: rgba(5,7,32,.58); backdrop-filter: blur(20px); }
.toolbar-button { min-height: 40px; padding: 0 .85rem; border-radius: 999px; background: rgba(255,255,255,.075); font-size: .79rem; font-weight: 800; }
.toolbar-button:hover { transform: translateY(-1px); background: rgba(255,255,255,.13); }
.viewer-heading { min-width: 0; }
.viewer-heading small, .viewer-heading strong, .viewer-heading span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-heading small { color: rgba(255,197,147,.72); font: 800 .55rem "Courier New",monospace; letter-spacing: .12em; }
.viewer-heading strong { margin-top: .2rem; font-size: .95rem; }
.viewer-heading span { margin-top: .12rem; color: var(--quiet); font: .62rem "Courier New",monospace; }
.viewer-actions { display: flex; gap: .45rem; }
.viewer-layout { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: .9rem; min-height: 650px; }
.optical-panel, .telemetry-panel { overflow: hidden; border: 1px solid rgba(255,255,255,.15); border-radius: 28px; background: linear-gradient(160deg, rgba(255,255,255,.10), rgba(3,3,26,.58)); box-shadow: 0 24px 70px rgba(0,0,0,.28); backdrop-filter: blur(20px); }
.optical-panel { display: flex; flex-direction: column; padding: .55rem; }
.optical-label { display: flex; align-items: center; gap: .8rem; padding: .45rem .6rem .72rem; color: rgba(247,248,255,.48); font: 800 .58rem "Courier New",monospace; letter-spacing: .12em; }
.optical-label i { height: 1px; flex: 1; background: linear-gradient(90deg, rgba(255,142,43,.34), transparent); }
.stage { position: relative; flex: 1; min-height: 570px; overflow: hidden; border-radius: 21px; background: #01010d; cursor: crosshair; touch-action: none; user-select: none; }
.stage.dragging { cursor: grabbing; }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at center, transparent 56%, rgba(0,0,0,.26)); box-shadow: inset 0 0 58px rgba(0,0,0,.60); }
.reticle i { position: absolute; z-index: 3; width: 34px; height: 34px; pointer-events: none; border-color: rgba(255,187,124,.56); }
.reticle i:nth-child(1) { top: 16px; left: 16px; border-top: 1px solid; border-left: 1px solid; }
.reticle i:nth-child(2) { top: 16px; right: 16px; border-top: 1px solid; border-right: 1px solid; }
.reticle i:nth-child(3) { bottom: 16px; left: 16px; border-bottom: 1px solid; border-left: 1px solid; }
.reticle i:nth-child(4) { bottom: 16px; right: 16px; border-bottom: 1px solid; border-right: 1px solid; }
.tile-status, .interaction-hint { position: absolute; z-index: 4; border: 1px solid rgba(255,255,255,.13); border-radius: 999px; background: rgba(5,7,32,.70); backdrop-filter: blur(12px); color: rgba(247,248,255,.65); font: 700 .58rem "Courier New",monospace; pointer-events: none; }
.tile-status { left: 15px; top: 15px; padding: .48rem .65rem; }
.interaction-hint { left: 50%; bottom: 15px; transform: translateX(-50%); padding: .48rem .7rem; white-space: nowrap; }
.telemetry-panel { display: flex; flex-direction: column; }
.telemetry-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; border-bottom: 1px solid rgba(255,255,255,.10); }
.telemetry-head small, .telemetry-head strong { display: block; }
.telemetry-head small { color: var(--quiet); font: 700 .55rem "Courier New",monospace; letter-spacing: .11em; }
.telemetry-head strong { margin-top: .22rem; font-size: 1rem; }
.telemetry-pulse { display: inline-flex; align-items: center; gap: .4rem; color: #b9ffda; font: 800 .58rem "Courier New",monospace; letter-spacing: .08em; }
.telemetry-pulse i { width: 6px; height: 6px; border-radius: 50%; background: #69ffb4; box-shadow: 0 0 9px #69ffb4; }
.metadata { padding: .85rem 1rem 1rem; overflow: auto; }
.meta-group { margin-bottom: 1.1rem; }
.meta-group h3 { margin: 0 0 .4rem; color: rgba(255,197,147,.72); font: 800 .57rem "Courier New",monospace; letter-spacing: .12em; text-transform: uppercase; }
.meta-row { display: grid; grid-template-columns: 82px 1fr; gap: .55rem; padding: .55rem 0; border-bottom: 1px solid rgba(255,255,255,.07); font: .64rem/1.35 "Courier New",monospace; }
.meta-row span:first-child { color: rgba(247,248,255,.42); }
.meta-row span:last-child { text-align: right; color: rgba(255,255,255,.88); overflow-wrap: anywhere; }
.viewer-statusbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .75rem; padding: .7rem .9rem; border: 1px solid rgba(255,255,255,.10); border-radius: 17px; background: rgba(5,7,32,.46); color: var(--quiet); font: 700 .58rem "Courier New",monospace; }
.viewer-statusbar > span { display: flex; align-items: center; gap: .55rem; }
.viewer-statusbar > span > i { width: 6px; height: 6px; border-radius: 50%; background: #69ffb4; box-shadow: 0 0 8px #69ffb4; }
.viewer-context b + b::before { content: "/"; margin-right: .55rem; color: rgba(247,248,255,.24); }
.stage:fullscreen, .stage:-webkit-full-screen { width: 100vw !important; height: 100vh !important; min-height: 100vh; border-radius: 0; background: #01010d; }
.stage:fullscreen::backdrop { background: #01010d; }
.stage:fullscreen canvas, .stage:-webkit-full-screen canvas { width: 100% !important; height: 100% !important; }

.mathlab-notes { display: grid; grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr); gap: 1rem; padding: 0 0 6rem; }
.notes-card { border: 1px solid var(--line); border-radius: var(--radius-xl); background: rgba(255,255,255,.085); box-shadow: 0 18px 54px rgba(0,0,0,.20); backdrop-filter: blur(18px); }
.notes-main { padding: clamp(1.5rem, 4vw, 2.4rem); }
.notes-main p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.72; }
.flow-card { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: .65rem; padding: 1.15rem; }
.flow-card > div { min-width: 0; padding: 1rem .8rem; border: 1px solid rgba(255,255,255,.08); border-radius: 16px; background: rgba(4,5,31,.32); }
.flow-card span, .flow-card strong, .flow-card small { display: block; }
.flow-card span { color: rgba(255,197,147,.7); font: 800 .58rem "Courier New",monospace; }
.flow-card strong { margin-top: .35rem; font-size: .87rem; }
.flow-card small { margin-top: .18rem; color: var(--quiet); line-height: 1.4; }
.flow-card > i { color: rgba(255,255,255,.28); font-style: normal; }

.mathlab-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 0 2rem; color: var(--quiet); }
.mathlab-footer > div { display: flex; align-items: center; gap: .8rem; }
.mathlab-footer p { margin: 0; font-size: .8rem; line-height: 1.5; }
.mathlab-footer strong { color: rgba(255,255,255,.88); }
.mathlab-footer a { color: rgba(255,215,180,.9); text-decoration: none; font-weight: 800; }
.footer-mark { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid rgba(121,235,255,.18); border-radius: 12px; background: rgba(3,7,28,.50); }
.footer-mark img { width: 26px; height: 26px; image-rendering: pixelated; }

.transition-overlay { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 1rem; background: rgba(2,2,19,.66); backdrop-filter: blur(12px); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .25s ease, visibility .25s ease; }
.transition-overlay.active { opacity: 1; visibility: visible; }
.transition-card { position: relative; display: grid; place-items: center; width: 230px; min-height: 230px; padding: 1.2rem; border: 1px solid rgba(255,255,255,.17); border-radius: 34px; background: linear-gradient(150deg, rgba(255,255,255,.13), rgba(4,4,32,.82)); box-shadow: 0 30px 90px rgba(0,0,0,.45); text-align: center; overflow: hidden; }
.transition-card img { position: relative; z-index: 2; width: 54px; height: 54px; margin-bottom: .8rem; image-rendering: pixelated; }
.transition-card small { position: relative; z-index: 2; color: rgba(255,197,147,.72); font: 800 .57rem "Courier New",monospace; letter-spacing: .12em; }
.transition-card strong { position: relative; z-index: 2; display: block; margin-top: .35rem; font-size: .8rem; }
.transition-orbit { position: absolute; inset: 24px; }
.transition-orbit i { position: absolute; inset: 0; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; animation: spin 1.6s linear infinite; }
.transition-orbit i:last-child { inset: 26px; border-color: rgba(121,235,255,.14); animation: spinReverse 2.2s linear infinite; }
.transition-orbit i::before { content: ""; position: absolute; top: -4px; left: 50%; width: 7px; height: 7px; border-radius: 50%; background: var(--ember-orange); box-shadow: 0 0 14px rgba(255,142,43,.8); }
.transition-orbit i:last-child::before { background: var(--math-cyan); box-shadow: 0 0 14px rgba(121,235,255,.8); }

.modal-backdrop { position: fixed; inset: 0; z-index: 1300; display: grid; place-items: center; padding: 1.2rem; background: rgba(1,1,14,.68); backdrop-filter: blur(14px); }
.about-card { position: relative; width: min(560px, 100%); padding: 2rem; border: 1px solid rgba(255,255,255,.18); border-radius: 30px; background: linear-gradient(150deg, rgba(255,255,255,.14), rgba(5,5,34,.94)); box-shadow: 0 32px 95px rgba(0,0,0,.48); animation: modalIn .35s var(--ease) both; }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-close { position: absolute; right: 15px; top: 15px; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; background: rgba(255,255,255,.08); color: white; cursor: pointer; }
.about-mark { display: grid; place-items: center; width: 66px; height: 66px; margin-bottom: 1.2rem; border: 1px solid rgba(121,235,255,.18); border-radius: 18px; background: rgba(2,7,27,.55); }
.about-mark img { width: 40px; height: 40px; image-rendering: pixelated; }
.about-card h2 { font-size: clamp(2rem, 5vw, 3rem); }
.about-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.7; }
.about-grid { display: grid; grid-template-columns: 1fr auto; gap: .7rem 1rem; margin: 1.4rem 0; padding: 1rem; border: 1px solid rgba(255,255,255,.09); border-radius: 16px; background: rgba(3,4,27,.35); font: .68rem "Courier New",monospace; }
.about-grid span { color: var(--quiet); }
.about-grid strong { color: rgba(255,255,255,.90); text-align: right; }
.modal-ok { width: 100%; border: 0; }
[hidden] { display: none !important; }

.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.is-visible { opacity: 1; transform: none; }

@media (max-width: 960px) {
  .mathlab-hero { grid-template-columns: 1fr; min-height: auto; padding-top: 4.5rem; }
  .hero-instrument { min-height: 430px; }
  .instrument-orbit { height: 245px; }
  .viewer-layout { grid-template-columns: 1fr; min-height: 0; }
  .stage { min-height: 60vh; }
  .telemetry-panel { max-height: 420px; }
  .mathlab-notes { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .section-shell { width: min(calc(100% - 1rem), var(--max)); }
  .mathlab-hero { padding: 3.25rem 0 4rem; gap: 2rem; }
  .hero-title-row { display: block; }
  .mathlab-mark { width: 65px; margin: 0 0 1rem; border-radius: 18px; }
  h1 { font-size: clamp(3rem, 15vw, 5.2rem); }
  .hero-text { font-size: .96rem; }
  .hero-instrument { min-height: 390px; border-radius: 26px; }
  .instrument-orbit { height: 220px; }
  .instrument-icon { width: 104px; height: 104px; border-radius: 28px; }
  .instrument-icon img { width: 67px; height: 67px; }
  .orbit-a { width: 190px; height: 190px; }
  .orbit-b { width: 148px; height: 148px; }
  .archive-heading { grid-template-columns: 1fr; align-items: start; }
  .archive-actions { justify-content: space-between; }
  .observation-grid { grid-template-columns: 1fr; }
  .viewer-toolbar { grid-template-columns: auto 1fr; }
  .viewer-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .stage { min-height: 56vh; }
  .interaction-hint { max-width: calc(100% - 30px); text-align: center; white-space: normal; line-height: 1.35; }
  .viewer-statusbar { align-items: flex-start; flex-direction: column; }
  .flow-card { grid-template-columns: 1fr; }
  .flow-card > i { transform: rotate(90deg); justify-self: center; }
  .mathlab-footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
