/* =========================================================
   VSEPR LAB — interface
   ========================================================= */

:root {
  --paper: #f3efe6;
  --paper-2: #fbf8f1;
  --paper-3: #eee7da;
  --ink: #172421;
  --ink-soft: #344641;
  --muted: #6b756f;
  --muted-2: #8f968f;
  --line: rgba(23, 36, 33, 0.12);
  --line-strong: rgba(23, 36, 33, 0.2);
  --accent: #de4a2c;
  --accent-deep: #b93a22;
  --accent-soft: #f6d8ce;
  --teal: #1d8a78;
  --teal-soft: #d8eee8;
  --stage: #0d1d20;
  --stage-deep: #091518;
  --cream: #f6f0e4;
  --lone: #ff7557;
  --bond: #58d7c1;
  --gold: #f1c86d;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Songti SC", SimSun, serif;
  --sans: "Aptos", "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  --shadow-panel: 0 14px 42px rgba(40, 44, 37, 0.055);
  --radius: 20px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.92), transparent 27rem),
    radial-gradient(circle at 88% 12%, rgba(225, 75, 44, 0.055), transparent 24rem),
    var(--paper);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
a,
select,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.stage:focus-visible {
  outline: 1px solid rgba(241, 200, 133, 0.58);
  outline-offset: 2px;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

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

ol,
ul {
  padding: 0;
  list-style: none;
}

sub,
sup {
  line-height: 0;
}

::selection {
  color: #fff;
  background: var(--accent);
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: -0.15em;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.page-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 0 26px;
}

/* =========================================================
   Header
   ========================================================= */

.site-header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  flex: 0 0 auto;
}

.brand-mark {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(23, 36, 33, 0.17);
  border-radius: 50%;
  color: var(--teal);
  background: rgba(255, 252, 245, 0.48);
}

.brand-mark svg {
  width: 31px;
  height: 31px;
  overflow: visible;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.08;
  gap: 4px;
}

.brand-copy strong {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.045em;
}

.brand-copy span {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.22em;
  color: var(--muted-2);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.course-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 27px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 10.5px;
  letter-spacing: 0.035em;
  white-space: nowrap;
  background: rgba(255, 252, 245, 0.36);
}

.course-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}

.progress-label {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.progress-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.progress-dots span {
  width: 15px;
  height: 4px;
  border-radius: 99px;
  background: rgba(23, 36, 33, 0.13);
  transition: width 0.25s ease, background 0.25s ease;
}

.progress-dots span.is-done {
  width: 22px;
  background: var(--teal);
}

.progress-dots span.is-current {
  background: var(--accent);
}

.progress-text {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
}

.progress-text.is-complete {
  color: var(--teal);
}

.ghost-btn {
  height: 31px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 11px;
  color: var(--ink-soft);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.ghost-btn:hover {
  background: rgba(255, 252, 245, 0.74);
  border-color: var(--line-strong);
}

.ghost-btn:active {
  transform: translateY(1px);
}

/* =========================================================
   Intro
   ========================================================= */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: end;
  gap: 44px;
  padding: 21px 2px 15px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--accent-deep);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.115em;
  text-transform: uppercase;
}

.eyebrow-dot {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(222, 74, 44, 0.1);
}

.intro h1 {
  font-family: var(--serif);
  font-size: clamp(34px, 3.2vw, 46px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.12;
  color: var(--ink);
}

.marker {
  position: relative;
  white-space: nowrap;
  color: var(--accent-deep);
  font-style: italic;
}

.marker::after {
  content: "";
  position: absolute;
  left: 1%;
  right: 0;
  bottom: -3px;
  height: 7px;
  border-top: 2px solid rgba(222, 74, 44, 0.5);
  border-radius: 50%;
  transform: rotate(-1.2deg);
}

.intro-aside {
  padding-left: 24px;
  border-left: 1px solid var(--line);
}

.intro-aside p {
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.82;
}

.intro-note {
  display: block;
  margin-top: 9px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

/* =========================================================
   Workspace layout
   ========================================================= */

.workspace {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr) 302px;
  gap: 14px;
  align-items: stretch;
  height: 720px;
  min-height: 0;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 252, 245, 0.78);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(12px);
}

/* =========================================================
   Controls
   ========================================================= */

.controls {
  display: flex;
  flex-direction: column;
  padding: 17px 18px 16px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  margin-bottom: 12px;
}

.panel-index {
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
}

.panel-heading {
  min-width: 0;
  line-height: 1.25;
}

.panel-heading h2 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel-heading p {
  margin-top: 2px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.13em;
}

.panel-state {
  margin-left: auto;
  max-width: 88px;
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--teal);
  background: rgba(29, 138, 120, 0.09);
  font-size: 8px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.field-head label,
.lp-top label,
.display-label > span {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.field-head > span {
  color: var(--muted-2);
  font-size: 8.5px;
}

.formula-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 6px;
}

.formula-row input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.035em;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.formula-row input::placeholder {
  color: #a3a79f;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
}

.formula-row input:hover {
  border-color: rgba(23, 36, 33, 0.32);
}

.formula-row input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fffdf8;
  box-shadow: 0 0 0 3px rgba(222, 74, 44, 0.1);
}

.formula-row input.is-error {
  border-color: var(--accent);
  animation: fieldShake 0.3s ease;
}

.build-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 42px;
  padding: 0 8px;
  border-radius: 9px;
  color: #fff9ee;
  background: var(--ink);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.build-btn .icon {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.build-btn:hover {
  background: var(--accent-deep);
  box-shadow: 0 6px 16px rgba(185, 58, 34, 0.2);
}

.build-btn:hover .icon {
  transform: translateX(2px);
}

.build-btn:active {
  transform: translateY(1px);
}

.field-help,
.field-error {
  font-size: 8.7px;
  line-height: 1.45;
}

.field-help {
  margin-top: 5px;
  color: var(--muted-2);
}

.field-error {
  display: none;
  margin-top: 5px;
  color: var(--accent-deep);
  font-weight: 600;
}

.field-error.is-visible {
  display: block;
}

.preset-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 13px 0 6px;
  color: var(--ink-soft);
  font-size: 9.5px;
  font-weight: 700;
}

.preset-head span:last-child {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
}

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

.preset-btn {
  position: relative;
  min-width: 0;
  height: 39px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  border: 1px solid rgba(23, 36, 33, 0.11);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.4);
  text-align: left;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.preset-btn:hover {
  border-color: rgba(23, 36, 33, 0.27);
  background: rgba(255, 255, 255, 0.82);
  transform: translateY(-1px);
}

.preset-btn.is-active {
  border-color: rgba(222, 74, 44, 0.55);
  background: var(--accent-soft);
}

.preset-btn.is-active::before {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.preset-formula {
  display: block;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.preset-formula sub {
  font-size: 8px;
}

.preset-name {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 8.3px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-shape {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-size: 7.5px;
  line-height: 1.1;
  text-align: right;
}

.preset-btn.is-active .preset-name,
.preset-btn.is-active .preset-shape {
  color: #88573e;
}

.extra-presets {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 8.5px;
}

.extra-presets span {
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.08em;
}

.extra-presets button {
  color: var(--accent-deep);
  font-family: var(--mono);
  font-size: 9px;
  border-bottom: 1px dotted rgba(185, 58, 34, 0.45);
  line-height: 1.2;
  padding: 0;
}

.extra-presets button:hover {
  border-bottom-style: solid;
}

.section-rule {
  position: relative;
  height: 19px;
  display: flex;
  align-items: center;
  margin: 9px 0 8px;
  color: var(--muted-2);
  font-size: 8.5px;
  letter-spacing: 0.04em;
}

.section-rule::before {
  content: "";
  width: 100%;
  height: 1px;
  background: var(--line);
}

.section-rule span {
  position: absolute;
  left: 0;
  padding-right: 8px;
  background: #faf6ed;
}

.manual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 0.9fr;
  gap: 6px;
}

.select-field,
.count-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.select-field > span,
.count-field > span {
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.select-field select {
  width: 100%;
  height: 31px;
  padding: 0 20px 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  appearance: none;
  color: var(--ink);
  background-color: rgba(255, 255, 255, 0.58);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='6'%3E%3Cpath d='m1 1 3.5 3.5L8 1' fill='none' stroke='%236b756f' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.select-field select:hover {
  border-color: var(--line-strong);
}

.stepper {
  height: 31px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 22px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.58);
  overflow: hidden;
}

.stepper button {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  transition: color 0.15s ease, background 0.15s ease;
}

.stepper button:hover {
  color: var(--accent);
  background: rgba(222, 74, 44, 0.06);
}

.stepper strong {
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}

/* Lone pair slider */

.lp-control {
  padding: 10px 12px 9px;
  border: 1px solid rgba(222, 74, 44, 0.18);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(246, 216, 206, 0.5), rgba(255, 253, 247, 0.32));
}

.lp-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.lp-top > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.lp-sub {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.12em;
}

.lp-number {
  display: flex;
  align-items: baseline;
  gap: 3px;
  color: var(--accent-deep);
  line-height: 1;
}

.lp-number strong {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.lp-number span {
  font-size: 8px;
  color: var(--muted);
}

#lpSlider {
  --pct: 50%;
  width: 100%;
  height: 26px;
  margin: 7px 0 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

#lpSlider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--accent) 0 var(--pct), rgba(23, 36, 33, 0.12) var(--pct) 100%);
}

#lpSlider::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: rgba(23, 36, 33, 0.12);
}

#lpSlider::-moz-range-progress {
  height: 4px;
  border-radius: 99px;
  background: var(--accent);
}

#lpSlider::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -7px;
  appearance: none;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #fff9ed;
  box-shadow: 0 2px 5px rgba(92, 42, 28, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#lpSlider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #fff9ed;
  box-shadow: 0 2px 5px rgba(92, 42, 28, 0.18);
}

#lpSlider:hover::-webkit-slider-thumb {
  transform: scale(1.12);
  box-shadow: 0 0 0 5px rgba(222, 74, 44, 0.1);
}

#lpSlider:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.range-ticks {
  display: flex;
  justify-content: space-between;
  margin: -3px 4px 0;
}

.range-ticks button {
  min-width: 22px;
  height: 17px;
  padding: 0;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 17px;
  text-align: center;
}

.range-ticks button span {
  display: inline-block;
  min-width: 16px;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.range-ticks button:hover span {
  color: var(--accent-deep);
}

.range-ticks button.active span {
  color: #fff9ee;
  background: var(--accent);
}

.range-ticks button.is-disabled {
  opacity: 0.3;
  pointer-events: none;
}

.helper {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8.3px;
  line-height: 1.45;
}

/* Display options */

.display-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 11px;
}

.display-label {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.display-label em {
  margin-top: 1px;
  color: var(--muted-2);
  font-size: 7.8px;
  font-style: normal;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.4);
}

.segmented button {
  height: 25px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 8.5px;
  white-space: nowrap;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button.active {
  color: var(--ink);
  background: #fffdf7;
  box-shadow: 0 1px 4px rgba(25, 35, 31, 0.1);
}

.balloon-dot {
  width: 7px;
  height: 9px;
  border-radius: 50% 50% 45% 45%;
  border: 1px solid var(--accent);
  background: rgba(222, 74, 44, 0.12);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.toggle-row > div {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.toggle-row strong {
  font-size: 9.5px;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.toggle-row span:not(.switch-knob) {
  margin-top: 1px;
  color: var(--muted-2);
  font-size: 7.8px;
}

.switch {
  position: relative;
  width: 34px;
  height: 19px;
  flex: 0 0 auto;
  border-radius: 99px;
  background: rgba(23, 36, 33, 0.18);
  transition: background 0.22s ease;
}

.switch.is-on {
  background: var(--teal);
}

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fffaf0;
  box-shadow: 0 1px 3px rgba(16, 30, 27, 0.24);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.switch.is-on .switch-knob {
  transform: translateX(15px);
}

.control-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
}

.reset-btn {
  height: 29px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink-soft);
  font-size: 8.8px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.reset-btn .icon {
  width: 12px;
  height: 12px;
}

.reset-btn:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.6);
}

.key-hint {
  color: var(--muted-2);
  font-size: 7.5px;
  text-align: right;
}

/* =========================================================
   Stage
   ========================================================= */

.stage {
  position: relative;
  min-width: 0;
  min-height: 720px;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 47%, rgba(36, 100, 92, 0.37) 0%, rgba(15, 36, 38, 0.08) 38%, transparent 67%),
    radial-gradient(circle at 14% 8%, rgba(226, 75, 45, 0.15), transparent 35%),
    radial-gradient(circle at 88% 94%, rgba(52, 109, 105, 0.16), transparent 35%),
    linear-gradient(155deg, #12292b 0%, #0d1f22 48%, #091519 100%);
  box-shadow:
    0 24px 55px rgba(16, 27, 29, 0.19),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  touch-action: none;
  cursor: grab;
}

.stage:active {
  cursor: grabbing;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: 4;
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 21px;
  pointer-events: none;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(5, 15, 17, 0.35), transparent 22%, transparent 72%, rgba(5, 13, 16, 0.55)),
    radial-gradient(ellipse at 50% 50%, transparent 50%, rgba(3, 10, 12, 0.42) 100%);
}

#moleculeCanvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.stage-grid {
  position: absolute;
  inset: -10%;
  z-index: 1;
  opacity: 0.53;
  background-image:
    radial-gradient(circle, rgba(181, 225, 214, 0.21) 1px, transparent 1.35px),
    linear-gradient(90deg, transparent 49.8%, rgba(154, 212, 201, 0.04) 50%, transparent 50.2%),
    linear-gradient(0deg, transparent 49.8%, rgba(154, 212, 201, 0.04) 50%, transparent 50.2%);
  background-size: 23px 23px, 115px 115px, 115px 115px;
  -webkit-mask-image: radial-gradient(circle at 50% 49%, #000 0%, rgba(0, 0, 0, 0.85) 38%, transparent 74%);
  mask-image: radial-gradient(circle at 50% 49%, #000 0%, rgba(0, 0, 0, 0.85) 38%, transparent 74%);
  pointer-events: none;
}

.stage-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 32%, rgba(3, 12, 14, 0.22) 100%);
}

.stage-hud {
  position: absolute;
  top: 20px;
  left: 21px;
  right: 19px;
  z-index: 6;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.stage-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(213, 234, 227, 0.5);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stage-kicker > span:first-child {
  color: rgba(237, 195, 148, 0.9);
}

.hypo-tag {
  margin-left: 2px;
  padding: 2px 5px;
  border: 1px solid rgba(240, 175, 100, 0.35);
  border-radius: 4px;
  color: #f0c28d;
  font-family: var(--sans);
  font-size: 7px;
  letter-spacing: 0.04em;
}

.formula-line {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  margin-top: 3px;
}

.formula-line h2 {
  color: #f7f0e2;
  font-family: var(--serif);
  font-size: clamp(44px, 4.3vw, 59px);
  font-weight: 500;
  line-height: 0.97;
  letter-spacing: -0.045em;
  text-shadow: 0 10px 35px rgba(0, 0, 0, 0.24);
}

.formula-line h2 sub {
  font-size: 0.45em;
  vertical-align: -0.23em;
  letter-spacing: 0;
}

.formula-line h2 sup {
  font-size: 0.38em;
  vertical-align: 0.5em;
  letter-spacing: 0;
}

.molecule-name {
  margin-bottom: 5px;
  padding: 3px 7px;
  border: 1px solid rgba(241, 200, 109, 0.25);
  border-radius: 999px;
  color: #e7c98e;
  font-size: 8.5px;
  line-height: 1;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.shape-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  color: rgba(205, 229, 221, 0.63);
  font-size: 9px;
  line-height: 1.3;
}

.shape-line strong {
  color: #f2c485;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.shape-line .separator {
  width: 18px;
  height: 1px;
  background: rgba(213, 234, 227, 0.23);
}

.stage-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border: 1px solid rgba(217, 238, 231, 0.12);
  border-radius: 999px;
  color: rgba(210, 235, 226, 0.56);
  background: rgba(7, 20, 22, 0.26);
  backdrop-filter: blur(8px);
  font-size: 7.5px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.live-badge i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #67d7b5;
  box-shadow: 0 0 0 3px rgba(103, 215, 181, 0.1);
  animation: livePulse 2.8s ease-in-out infinite;
}

.domain-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.domain-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid rgba(217, 238, 231, 0.1);
  border-radius: 999px;
  color: rgba(225, 241, 235, 0.7);
  background: rgba(7, 20, 22, 0.36);
  backdrop-filter: blur(8px);
  font-size: 8px;
  white-space: nowrap;
}

.domain-pill i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.domain-pill.bond i {
  background: var(--bond);
  box-shadow: 0 0 8px rgba(88, 215, 193, 0.4);
}

.domain-pill.lone i {
  background: var(--lone);
  box-shadow: 0 0 8px rgba(255, 117, 87, 0.45);
}

.domain-pill b {
  font-family: var(--mono);
  font-weight: 600;
}

.stage-tools {
  position: absolute;
  right: 15px;
  top: 50%;
  z-index: 8;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(217, 238, 231, 0.09);
  border-radius: 9px;
  background: rgba(8, 22, 24, 0.4);
  backdrop-filter: blur(10px);
}

.stage-tools button {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: rgba(219, 239, 232, 0.58);
  transition: color 0.15s ease, background 0.15s ease;
}

.stage-tools button:hover {
  color: #fff8e9;
  background: rgba(255, 255, 255, 0.08);
}

.stage-tools .icon {
  width: 13px;
  height: 13px;
}

.tool-divider {
  height: 1px;
  margin: 2px 4px;
  background: rgba(217, 238, 231, 0.1);
}

.stage-bottom {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 15px;
  z-index: 7;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.angle-card {
  width: 150px;
  flex: 0 0 auto;
  padding: 9px 11px 10px;
  border: 1px solid rgba(217, 238, 231, 0.11);
  border-radius: 10px;
  background: rgba(7, 20, 22, 0.48);
  backdrop-filter: blur(10px);
}

.card-label {
  display: block;
  color: rgba(213, 234, 227, 0.47);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.07em;
}

.angle-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 2px;
  line-height: 1;
}

.angle-value strong {
  color: #f5ce8a;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.angle-value span {
  color: rgba(213, 234, 227, 0.4);
  font-size: 7.5px;
}

.angle-note {
  display: block;
  margin-top: 5px;
  color: rgba(206, 230, 222, 0.5);
  font-size: 7.5px;
  line-height: 1.35;
}

.orbit-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 7px;
  padding: 5px 9px;
  border: 1px solid rgba(217, 238, 231, 0.09);
  border-radius: 999px;
  color: rgba(207, 231, 223, 0.42);
  background: rgba(7, 20, 22, 0.27);
  backdrop-filter: blur(8px);
  font-size: 7.8px;
  white-space: nowrap;
  transition: opacity 0.4s ease;
}

.orbit-hint.hide {
  opacity: 0;
}

.orbit-hint .icon {
  width: 12px;
  height: 12px;
}

.force-card {
  width: 195px;
  flex: 0 0 auto;
  padding: 9px 10px 8px;
  border: 1px solid rgba(217, 238, 231, 0.11);
  border-radius: 10px;
  background: rgba(7, 20, 22, 0.55);
  backdrop-filter: blur(11px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.force-card.is-hidden {
  opacity: 0;
  transform: translateY(5px);
  pointer-events: none;
}

.force-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: rgba(213, 234, 227, 0.55);
  font-size: 7.5px;
  letter-spacing: 0.035em;
}

.force-head > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.force-head em {
  color: #f2c485;
  font-style: normal;
  font-size: 7px;
  white-space: nowrap;
}

.pulse-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--lone);
  animation: livePulse 2s ease-in-out infinite;
}

.force-rows {
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.force-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 19px;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 7px;
  color: rgba(213, 234, 227, 0.52);
}

.force-row .bar {
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(220, 240, 233, 0.09);
}

.force-row .bar i {
  display: block;
  width: var(--v);
  height: 100%;
  border-radius: inherit;
  transform-origin: left center;
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.force-row[data-type="LL"] .bar i {
  background: linear-gradient(90deg, #c94d38, var(--lone));
}

.force-row[data-type="LB"] .bar i {
  background: linear-gradient(90deg, #b8894e, var(--gold));
}

.force-row[data-type="BB"] .bar i {
  background: linear-gradient(90deg, #2f8f85, var(--bond));
}

.force-row b {
  color: rgba(238, 248, 244, 0.73);
  font-weight: 500;
  text-align: right;
}

.force-row.is-empty {
  opacity: 0.35;
}

.force-row.is-strong b {
  color: #ffd7a2;
}

.force-focus {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid rgba(217, 238, 231, 0.08);
  color: rgba(206, 230, 222, 0.36);
  font-size: 6.7px;
  line-height: 1.35;
}

.force-focus strong {
  color: rgba(241, 200, 133, 0.8);
  font-weight: 500;
}

.hover-tip {
  position: absolute;
  z-index: 10;
  width: max-content;
  max-width: 185px;
  padding: 7px 9px;
  border: 1px solid rgba(241, 200, 133, 0.22);
  border-radius: 7px;
  color: #e8f3ee;
  background: rgba(5, 17, 19, 0.88);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
  font-size: 8.5px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -100%) translateY(-8px);
  transition: opacity 0.12s ease;
}

.hover-tip.is-visible {
  opacity: 1;
}

.hover-tip strong {
  display: block;
  margin-bottom: 2px;
  color: #f2c485;
  font-size: 9px;
  font-weight: 600;
}

.hover-tip span {
  color: rgba(214, 235, 227, 0.67);
}

.stage-flash {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(119, 222, 201, 0.16), transparent 48%);
}

.stage-flash.is-active {
  animation: stageFlash 0.6s ease-out;
}

/* =========================================================
   AI coach
   ========================================================= */

.coach {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px;
  overflow: hidden;
}

.coach-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.coach-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #f7ecd9;
  background:
    radial-gradient(circle at 34% 28%, rgba(116, 199, 174, 0.55), transparent 40%),
    linear-gradient(145deg, #1f4f49, #102c2c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.13);
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
}

.coach-avatar::before {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(29, 138, 120, 0.24);
  border-radius: 50%;
  transform: rotate(-24deg) scaleY(0.62);
}

.coach-avatar i {
  position: absolute;
  right: 1px;
  bottom: 2px;
  width: 7px;
  height: 7px;
  border: 2px solid #f7f2e8;
  border-radius: 50%;
  background: #4dc89f;
}

.coach-title {
  min-width: 0;
  line-height: 1.25;
}

.coach-title h2 {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.coach-title p {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 7.5px;
  white-space: nowrap;
}

.online-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #3cb98e;
  box-shadow: 0 0 0 3px rgba(60, 185, 142, 0.1);
}

.icon-btn {
  width: 27px;
  height: 27px;
  margin-left: auto;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--muted-2);
  transition: color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: var(--ink);
  background: rgba(23, 36, 33, 0.05);
}

.icon-btn .icon {
  width: 14px;
  height: 14px;
}

.coach-context {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.34);
  color: var(--muted-2);
  font-size: 7.5px;
  white-space: nowrap;
  overflow: hidden;
}

.coach-context strong {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
}

.coach-context strong sub {
  font-size: 6px;
}

.context-shape {
  margin-left: auto;
  padding-left: 8px;
  border-left: 1px solid var(--line);
  color: var(--accent-deep);
  font-size: 7.5px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat {
  flex: 1 1 0;
  min-height: 100px;
  margin: 10px -3px 8px 0;
  padding-right: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 36, 33, 0.18) transparent;
}

.chat::-webkit-scrollbar {
  width: 3px;
}

.chat::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(23, 36, 33, 0.17);
}

.chat.is-scrolled {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16px, #000 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 16px, #000 100%);
}

.coach-scaffold {
  flex: 0 0 auto;
  margin-bottom: 8px;
  padding: 8px 9px 7px;
  border: 1px solid rgba(23, 36, 33, 0.1);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(255, 252, 245, 0.7), rgba(237, 230, 217, 0.52));
}

.scaffold-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 7.5px;
  letter-spacing: 0.02em;
}

.scaffold-head > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}

.scaffold-head i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(29, 138, 120, 0.08);
}

.scaffold-head em {
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--teal);
  background: rgba(29, 138, 120, 0.08);
  font-family: var(--mono);
  font-size: 6.5px;
  font-style: normal;
}

.coach-scaffold ol {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.coach-scaffold li {
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr);
  gap: 5px;
  align-items: start;
}

.coach-scaffold li > span {
  padding-top: 1px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 6.5px;
}

.coach-scaffold strong {
  display: block;
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 600;
  line-height: 1.3;
}

.coach-scaffold p {
  margin-top: 1px;
  color: var(--muted);
  font-size: 7.4px;
  line-height: 1.35;
}

.coach-scaffold p b {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 7.2px;
  font-weight: 600;
}

.coach-scaffold p em {
  margin-left: 4px;
  color: var(--muted-2);
  font-size: 6.4px;
  font-style: normal;
}

.family-card {
  flex: 0 0 auto;
  margin-bottom: 8px;
  padding: 7px 8px 8px;
  border: 1px solid rgba(222, 74, 44, 0.16);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(246, 216, 206, 0.34), rgba(255, 252, 245, 0.55));
}

.family-card.is-muted {
  opacity: 0.62;
}

.family-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: 7.5px;
  font-weight: 700;
}

.family-head > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.family-head i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(222, 74, 44, 0.08);
}

.family-head em {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 6.2px;
  font-style: normal;
  font-weight: 400;
}

.family-track {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8px minmax(0, 1fr) 8px minmax(0, 1fr);
  align-items: center;
  gap: 2px;
}

.family-track > i {
  color: var(--muted-2);
  font-size: 7px;
  font-style: normal;
  text-align: center;
}

.family-node {
  min-width: 0;
  height: 37px;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid rgba(23, 36, 33, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.42);
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.family-node b {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1;
}

.family-node b sub {
  font-size: 6px;
}

.family-node em {
  color: var(--muted);
  font-size: 6.3px;
  font-style: normal;
  line-height: 1.2;
  white-space: nowrap;
}

.family-node:hover {
  border-color: rgba(222, 74, 44, 0.3);
  background: rgba(255, 255, 255, 0.75);
  transform: translateY(-1px);
}

.family-node.is-active {
  border-color: rgba(222, 74, 44, 0.5);
  background: rgba(246, 216, 206, 0.72);
}

.family-node.is-active em {
  color: var(--accent-deep);
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 8px;
  animation: msgIn 0.26s ease both;
}

.msg-avatar {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  margin-top: 1px;
  border-radius: 50%;
  color: #f5ecda;
  background: #163e39;
  font-family: var(--serif);
  font-size: 9px;
  font-style: italic;
}

.bubble {
  max-width: calc(100% - 26px);
  padding: 8px 10px;
  border: 1px solid rgba(23, 36, 33, 0.08);
  border-radius: 3px 10px 10px 10px;
  color: var(--ink-soft);
  background: rgba(243, 239, 229, 0.9);
  font-size: 10.4px;
  line-height: 1.72;
  letter-spacing: 0.005em;
}

.bubble strong {
  color: var(--accent-deep);
  font-weight: 600;
}

.bubble sub {
  font-size: 7px;
}

.msg.user {
  justify-content: flex-end;
}

.msg.user .bubble {
  max-width: 86%;
  border-color: transparent;
  border-radius: 10px 3px 10px 10px;
  color: #fff8eb;
  background: #284d47;
  font-size: 10px;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 12px;
}

.typing i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1.2s ease-in-out infinite;
}

.typing i:nth-child(2) {
  animation-delay: 0.14s;
}

.typing i:nth-child(3) {
  animation-delay: 0.28s;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  max-height: 55px;
  overflow: auto;
  scrollbar-width: none;
}

.suggestions::-webkit-scrollbar {
  display: none;
}

.suggestions button {
  height: 23px;
  padding: 0 7px;
  border: 1px solid rgba(23, 36, 33, 0.12);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.35);
  font-size: 7.8px;
  line-height: 1;
  white-space: nowrap;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.suggestions button:hover {
  color: var(--accent-deep);
  border-color: rgba(222, 74, 44, 0.3);
  background: rgba(255, 250, 240, 0.85);
}

.quiz-card {
  flex: 0 0 auto;
  padding: 10px;
  border: 1px solid rgba(23, 36, 33, 0.11);
  border-radius: 11px;
  background:
    linear-gradient(140deg, rgba(255, 252, 244, 0.76), rgba(240, 232, 218, 0.62));
}

.quiz-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.quiz-kicker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-deep);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.035em;
}

.quiz-kicker .icon {
  width: 10px;
  height: 10px;
}

.quiz-tag {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 7px;
}

.quiz-card h3 {
  margin-top: 5px;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
}

.quiz-card h3 sub {
  font-size: 8px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 7px;
}

.quiz-option {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border: 1px solid rgba(23, 36, 33, 0.1);
  border-radius: 6px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.4);
  font-size: 9px;
  text-align: left;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.quiz-option span {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--muted-2);
  background: rgba(23, 36, 33, 0.05);
  font-family: var(--mono);
  font-size: 6.5px;
}

.quiz-option:hover {
  border-color: rgba(23, 36, 33, 0.25);
  background: rgba(255, 255, 255, 0.72);
  transform: translateX(1px);
}

.quiz-option.is-correct {
  border-color: rgba(29, 138, 120, 0.45);
  color: #15574c;
  background: rgba(216, 238, 232, 0.8);
}

.quiz-option.is-correct span {
  color: #fff;
  background: var(--teal);
}

.quiz-option.is-wrong {
  border-color: rgba(222, 74, 44, 0.35);
  color: var(--accent-deep);
  background: rgba(246, 216, 206, 0.62);
}

.quiz-option.is-wrong span {
  color: #fff;
  background: var(--accent);
}

.quiz-option:disabled {
  cursor: default;
  transform: none;
}

.quiz-feedback {
  min-height: 12px;
  margin-top: 5px;
  color: var(--teal);
  font-size: 7.8px;
  line-height: 1.35;
}

.quiz-feedback.is-error {
  color: var(--accent-deep);
}

.ask-form {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 5px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.ask-form input {
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink);
  font-size: 9px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.ask-form input::placeholder {
  color: #9a9f97;
  font-size: 8.5px;
}

.ask-form input:focus {
  outline: none;
  border-color: rgba(222, 74, 44, 0.5);
  background: #fffdf8;
}

.ask-form button {
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff8eb;
  background: var(--ink);
  transition: background 0.18s ease, transform 0.18s ease;
}

.ask-form button:hover {
  background: var(--accent-deep);
}

.ask-form button:active {
  transform: translateY(1px);
}

.ask-form button .icon {
  width: 15px;
  height: 15px;
}

/* =========================================================
   Concept band
   ========================================================= */

.concept-band {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 30px;
  align-items: center;
  margin-top: 14px;
  padding: 13px 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.concept-intro > span {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.16em;
}

.concept-intro h2 {
  margin-top: 3px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.concept-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.concept-list li {
  display: flex;
  gap: 9px;
  min-width: 0;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.concept-num {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.8;
}

.concept-list strong {
  display: block;
  color: var(--ink);
  font-size: 10.5px;
  letter-spacing: 0.02em;
}

.concept-list p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.65;
}

/* =========================================================
   Footer
   ========================================================= */

.site-footer {
  min-height: 35px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.05em;
}

.site-footer i {
  margin: 0 4px;
  color: rgba(23, 36, 33, 0.25);
  font-style: normal;
}

.footer-center {
  text-align: center;
}

.footer-link {
  padding: 0;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 8.5px;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(23, 36, 33, 0.2);
}

.footer-link span {
  color: var(--accent);
}

/* =========================================================
   Toast + dialog
   ========================================================= */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 32px));
  padding: 9px 14px;
  border: 1px solid rgba(241, 200, 133, 0.23);
  border-radius: 9px;
  color: #f6efe1;
  background: rgba(8, 22, 24, 0.94);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
  font-size: 10px;
  line-height: 1.55;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.dialog-open {
  overflow: hidden;
}

.guide-dialog {
  width: min(980px, calc(100vw - 44px));
  max-height: min(86vh, 860px);
  padding: 0;
  border: 1px solid rgba(23, 36, 33, 0.16);
  border-radius: 22px;
  color: var(--ink);
  background: #f9f5eb;
  box-shadow: 0 30px 90px rgba(9, 20, 18, 0.3);
  overflow: hidden;
}

.guide-dialog::backdrop {
  background: rgba(13, 26, 27, 0.5);
  backdrop-filter: blur(5px);
}

.guide-dialog[open] {
  animation: dialogIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.guide-shell {
  max-height: inherit;
  display: flex;
  flex-direction: column;
}

.guide-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 25px 30px 20px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 94% 20%, rgba(222, 74, 44, 0.09), transparent 18rem),
    linear-gradient(180deg, #fbf7ed, #f7f2e7);
}

.guide-head .eyebrow {
  margin-bottom: 7px;
}

.guide-head h2 {
  font-family: var(--serif);
  font-size: clamp(25px, 3vw, 34px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.15;
}

.dialog-close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.dialog-close:hover {
  color: var(--ink);
  background: rgba(23, 36, 33, 0.05);
  transform: rotate(8deg);
}

.guide-body {
  padding: 22px 30px 24px;
  overflow-y: auto;
}

.guide-lead {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 220px;
  gap: 20px;
  align-items: start;
  padding-bottom: 19px;
  border-bottom: 1px solid var(--line);
}

.guide-kicker {
  color: var(--accent-deep);
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.guide-lead > p:nth-child(2) {
  max-width: 570px;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.8;
}

.guide-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.guide-tags span {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 8px;
  white-space: nowrap;
}

.guide-section {
  padding-top: 20px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.guide-grid article {
  position: relative;
  padding: 14px 13px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.38);
}

.guide-grid article > span {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 8px;
}

.guide-grid h3 {
  margin-top: 7px;
  font-size: 12px;
  font-weight: 600;
}

.guide-grid p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9.3px;
  line-height: 1.68;
}

.guide-two-col {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 34px;
  margin-top: 7px;
  padding-top: 19px;
  border-top: 1px solid var(--line);
}

.guide-flow {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.guide-flow li {
  display: flex;
  gap: 10px;
}

.guide-flow li > span {
  width: 26px;
  height: 20px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--accent-deep);
  background: rgba(222, 74, 44, 0.08);
  font-family: var(--mono);
  font-size: 7px;
}

.guide-flow strong {
  font-size: 10.5px;
  font-weight: 600;
}

.guide-flow p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}

.guide-goals {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-goals li {
  position: relative;
  padding-left: 13px;
  color: var(--ink-soft);
  font-size: 9.5px;
  line-height: 1.65;
}

.guide-goals li::before {
  content: "·";
  position: absolute;
  left: 0;
  top: -2px;
  color: var(--accent);
  font-size: 18px;
}

.guide-tech {
  margin-top: 16px;
  padding: 10px 12px;
  border-left: 2px solid rgba(29, 138, 120, 0.4);
  background: rgba(29, 138, 120, 0.045);
}

.guide-tech strong {
  font-size: 8px;
  color: var(--teal);
  letter-spacing: 0.06em;
}

.guide-tech p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8.5px;
  line-height: 1.6;
}

.guide-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 30px;
  border-top: 1px solid var(--line);
  background: rgba(238, 231, 218, 0.4);
  color: var(--muted-2);
  font-size: 8px;
}

.guide-start {
  height: 30px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 7px;
  color: #fff8eb;
  background: var(--ink);
  font-size: 9px;
  transition: background 0.18s ease;
}

.guide-start:hover {
  background: var(--accent-deep);
}

.guide-start .icon {
  width: 13px;
  height: 13px;
}

/* =========================================================
   Motion
   ========================================================= */

@keyframes fieldShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  55% { transform: translateX(3px); }
  80% { transform: translateX(-2px); }
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.82); }
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes typing {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

@keyframes stageFlash {
  0% { opacity: 0; }
  28% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes dialogIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1270px) {
  .page-shell {
    padding: 0 20px;
  }

  .workspace {
    grid-template-columns: 278px minmax(0, 1fr) 292px;
    gap: 12px;
  }

  .intro {
    grid-template-columns: minmax(0, 1fr) 305px;
    gap: 30px;
  }

  .intro h1 {
    font-size: clamp(32px, 3.25vw, 42px);
  }

  .controls {
    padding-left: 15px;
    padding-right: 15px;
  }

  .coach {
    padding-left: 14px;
    padding-right: 14px;
  }

  .formula-line h2 {
    font-size: 48px;
  }

  .force-card {
    width: 185px;
  }
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 286px minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }

  .stage {
    min-height: 650px;
  }

  .coach {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    grid-template-rows: auto auto auto auto;
    column-gap: 22px;
    min-height: 0;
    padding: 16px 18px;
  }

  .coach-head,
  .coach-context,
  .chat,
  .suggestions,
  .ask-form {
    grid-column: 1;
  }

  .quiz-card {
    grid-column: 2;
    grid-row: 1 / span 3;
    margin-top: 0;
  }

  .ask-form {
    grid-row: 4;
  }

  .chat {
    max-height: 210px;
  }

  .concept-band {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

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

  .site-header {
    min-height: 58px;
    gap: 10px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .course-pill {
    display: none;
  }

  .header-meta {
    gap: 10px;
  }

  .progress-label {
    display: none;
  }

  .ghost-btn {
    padding: 0 8px;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 17px 0 14px;
  }

  .intro-aside {
    padding-left: 0;
    border-left: 0;
  }

  .intro-aside p {
    display: none;
  }

  .intro-note {
    margin-top: 0;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .stage {
    order: -1;
    min-height: 520px;
  }

  .controls {
    order: 0;
  }

  .coach {
    order: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
  }

  .quiz-card {
    margin-top: 0;
  }

  .chat {
    max-height: 260px;
    min-height: 130px;
  }

  .concept-band {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 14px;
  }

  .concept-list {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .concept-list li {
    padding-left: 12px;
  }

  .site-footer {
    flex-wrap: wrap;
    gap: 5px 16px;
    padding: 9px 0;
  }

  .footer-center {
    order: 3;
    width: 100%;
    text-align: left;
  }

  .guide-body {
    padding: 18px 20px 20px;
  }

  .guide-head {
    padding: 20px;
  }

  .guide-lead {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .guide-tags {
    justify-content: flex-start;
  }

  .guide-grid {
    grid-template-columns: 1fr 1fr;
  }

  .guide-two-col {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .guide-foot {
    padding: 12px 20px;
  }
}

@media (max-width: 620px) {
  .brand-copy span,
  .progress-wrap {
    display: none;
  }

  .brand-copy strong {
    font-size: 14px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand-mark svg {
    width: 27px;
    height: 27px;
  }

  .ghost-btn {
    font-size: 0;
    width: 31px;
    padding: 0;
    justify-content: center;
  }

  .ghost-btn .icon {
    width: 14px;
    height: 14px;
  }

  .intro h1 {
    font-size: 30px;
  }

  .eyebrow {
    font-size: 7.5px;
    letter-spacing: 0.08em;
  }

  .stage {
    min-height: 455px;
    border-radius: 16px;
  }

  .stage-hud {
    top: 13px;
    left: 14px;
    right: 13px;
  }

  .stage-kicker {
    font-size: 6.5px;
  }

  .formula-line h2 {
    font-size: 38px;
  }

  .molecule-name {
    font-size: 7px;
    margin-bottom: 3px;
  }

  .shape-line {
    font-size: 8px;
    gap: 5px;
  }

  .shape-line strong {
    font-size: 11px;
  }

  .shape-line .separator {
    width: 10px;
  }

  .stage-badges {
    gap: 4px;
  }

  .live-badge {
    display: none;
  }

  .domain-pill {
    height: 19px;
    padding: 0 6px;
    font-size: 7px;
  }

  .stage-tools {
    right: 9px;
  }

  .stage-bottom {
    left: 9px;
    right: 9px;
    bottom: 9px;
    gap: 6px;
  }

  .angle-card {
    width: 108px;
    padding: 7px 8px;
  }

  .angle-value strong {
    font-size: 19px;
  }

  .angle-value span,
  .angle-note {
    font-size: 6px;
  }

  .angle-note {
    display: none;
  }

  .force-card {
    width: auto;
    min-width: 118px;
    padding: 7px 8px;
  }

  .force-head {
    font-size: 6.5px;
  }

  .force-head em {
    display: inline;
    font-size: 6.2px;
  }

  .force-rows {
    display: none;
  }

  .force-focus,
  .orbit-hint {
    display: none;
  }

  .controls {
    padding: 15px;
  }

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

  .manual-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .count-field .stepper {
    width: 88px;
  }

  .display-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    justify-content: center;
  }

  .control-foot {
    margin-top: 10px;
  }

  .concept-band {
    padding-bottom: 18px;
  }

  .site-footer {
    font-size: 6.8px;
  }

  .guide-dialog {
    width: calc(100vw - 22px);
    max-height: 90vh;
  }

  .guide-grid {
    grid-template-columns: 1fr;
  }

  .guide-head h2 {
    font-size: 24px;
  }
}

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