:root {
  color-scheme: light;
  --ink: #312645;
  --muted: #655a75;
  --purple: #69398e;
  --border: #e3d9eb;
  --paper: #fbf9fe;
  --blue: #184857;
  --blue-paper: #edf4f6;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font: 17px/1.55 Nunito, "Segoe UI", sans-serif; background: var(--paper); color: var(--ink); }
a { color: var(--purple); text-underline-offset: .18em; }
button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #8054a3; outline-offset: 3px; }
[hidden] { display: none !important; }
.wrap { width: min(1220px, calc(100% - 64px)); margin-inline: auto; }
.skip { position: absolute; left: 16px; top: -100px; z-index: 3; background: white; padding: 12px; }
.skip:focus { top: 12px; }
.site-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); font-weight: 750; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.intro { padding: 26px 0 25px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.8rem, 3.5vw, 3.05rem); line-height: 1.09; letter-spacing: -.035em; margin-bottom: 9px; }
h2 { line-height: 1.16; letter-spacing: -.016em; font-size: clamp(1.42rem, 2.35vw, 2rem); }
.intro > p { color: var(--muted); margin-bottom: 12px; }
.button { min-height: 44px; display: inline-flex; justify-content: center; align-items: center; padding: 9px 18px; border: 1px solid transparent; border-radius: 11px; background: var(--purple); color: white; font-weight: 800; text-decoration: none; }
.button:hover { background: #552b76; }
.button.secondary { color: var(--purple); background: white; border-color: var(--border); }
.button.secondary:hover { background: #f4eef9; }
#route { scroll-margin-top: 14px; }
.route-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 5px 12px; margin-bottom: 12px; }
.route-head h2 { margin: 0; }
#progress { color: var(--muted); }
#stages { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.stage { min-height: 54px; border: 1px solid var(--border); border-radius: 10px; padding: 7px 5px; display: grid; align-content: center; gap: 2px; color: var(--purple); background: white; font-size: .85rem; font-weight: 800; line-height: 1.2; }
.stage:hover { border-color: var(--purple); }
.stage small { font-size: .73rem; font-weight: 700; }
.stage[aria-current="step"] { color: white; background: var(--purple); border-color: var(--purple); }
.stage:disabled { color: var(--muted); background: #f5f1f8; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 17px; align-items: start; }
.task h2, .result h2 { scroll-margin-top: 20px; }
.equipment, .task, .result { border: 1px solid var(--border); border-radius: 17px; padding: clamp(16px, 2.2vw, 26px); background: white; }
.equipment { background: var(--blue-paper); color: var(--blue); }
.equipment p { margin-bottom: 0; }
.equipment h2, .task h2 { margin-bottom: 11px; }
.operation { border: 1px solid #c8dce1; border-radius: 12px; padding: 12px; background: var(--blue-paper); color: var(--blue); margin-bottom: 15px; }
.operation > p { margin: 0 0 8px; }
.operation figure { margin: 0; }
.operation canvas { display: block; width: 100%; height: auto; background: #f8fbfc; border-radius: 8px; }
.operation figcaption { font-size: .86rem; margin-top: 6px; }
.reaction { display: grid; margin-top: 10px; padding: 9px 11px; background: white; border-inline-start: 3px solid #8472a2; border-radius: 6px; }
.reaction > div { grid-area: 1 / 1; min-width: 0; }
.reaction > div[aria-hidden="true"] { visibility: hidden; }
.reaction strong, .reaction span { display: block; }
.reaction strong { color: #544174; font-size: 1.05rem; }
.reaction span { font-size: .88rem; }
.chemistry-detail { margin-top: 12px; }
.chemistry-detail summary { cursor: pointer; font-weight: 800; }
.chemistry-detail p { margin-top: 8px; }
.filtration-lab { margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: white; }
.filtration-lab h3, .filtration-lab > p, :is(.filtration-lab, .lab-exam) details > p { margin: 0 0 9px; }
.filtration-lab h3 { line-height: 1.25; scroll-margin-top: 16px; }
.lab-context { color: var(--muted); font-size: .9rem; }
:is(.filtration-lab, .lab-exam) details { padding: 9px 0; border-top: 1px solid var(--border); }
:is(.filtration-lab, .lab-exam) summary { min-height: 44px; padding-block: 8px; font-weight: 800; cursor: pointer; }
:is(.filtration-lab, .lab-exam) details[open] > p { margin-top: 8px; }
.lab-frame { margin: 10px 0; }
.lab-water, .lab-layer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; }
.lab-water { background: #d5edf2; color: #184857; border-radius: 7px 7px 0 0; margin-top: 6px; }
.lab-layer { background: #eee1c2; color: #4f3e26; border-radius: 0 0 7px 7px; }
.lab-resin { background: #e7dcf2; color: #503563; }
.lab-water > span:first-child, .lab-layer > span:first-child { flex-basis: 100%; font-weight: 700; }
.lab-ion { border-radius: 12px; padding: 2px 8px; background: white; font-weight: 800; }
.has-precipitate .lab-ion { background: #914822; color: white; }
.filtration-lab legend:not(.sr-only) { padding: 0; margin-bottom: 8px; font-weight: 800; }
.filtration-lab legend small { display: block; margin-bottom: 2px; color: var(--muted); font-weight: 700; }
.filtration-lab .choice { align-items: baseline; }
.filtration-lab .choice input { flex: none; margin: 0; }
:is(.filtration-lab, .lab-exam) .button { max-width: 100%; white-space: normal; }
.lab-feedback:empty { margin: 0; }
.lab-equation { margin: 8px 0 0; color: #544174; font-weight: 800; }
.lab-next { margin-top: 10px; }
.lab-applications { padding-inline-start: 25px; margin: 8px 0 12px; }
.lab-exam { margin-top: 20px; }
.lab-exam h3 { margin: 0 0 8px; line-height: 1.25; scroll-margin-top: 16px; }
.visual-tools { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.visual-tools button { border: 1px solid #7f9fa8; border-radius: 8px; color: var(--blue); background: white; min-height: 44px; padding: 6px 10px; font-weight: 800; }
.visual-tools button:hover { background: #e0eef1; }
.visual-tools[aria-busy="true"] button { cursor: progress; opacity: .72; }
.operation > .operation-status { margin: 0; min-block-size: 3.1em; }
.task .button:disabled { opacity: .6; }
.question { color: var(--muted); margin-bottom: 12px; }
fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
legend.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.choice { display: flex; align-items: center; gap: 11px; padding: 10px 12px; min-height: 46px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 7px; cursor: pointer; }
.choice:has(input:checked) { background: #f2eaf9; border-color: #a486b6; }
.choice input { accent-color: var(--purple); }
.match { display: grid; gap: 4px; margin-bottom: 9px; }
.match select { width: 100%; min-height: 43px; color: var(--ink); background: white; border: 1px solid #baa8c7; border-radius: 8px; padding: 4px 7px; }
.feedback { margin: 8px 0 0; }
.feedback.bad { color: #81324a; }
.feedback.good { color: #1e6350; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.result { max-width: 750px; margin-inline: auto; }
footer { margin: 34px 0 20px; padding: 18px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: .93rem; }
footer summary { cursor: pointer; }
footer p { margin-top: 10px; }
@media (max-width: 900px) {
  .wrap { width: calc(100% - 38px); }
  #stages { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  body { font-size: 16px; }
  .wrap { width: calc(100% - 28px); }
  .site-header { min-height: 62px; font-size: .89rem; }
  .brand img { width: 25px; height: 25px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .intro { padding: 19px 0; }
  #stages { display: flex; overflow-x: auto; padding: 3px 3px 7px; }
  .stage { flex: 0 0 auto; min-height: 44px; padding-inline: 10px; font-size: .86rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

.plant-photo {
  margin: 18px 0 0;
  border: 1px solid var(--border);
  border-radius: 17px;
  overflow: hidden;
  background: white;
}
.plant-photo img { display: block; width: 100%; height: auto; }
.plant-photo > a { display: block; position: relative; cursor: zoom-in; }
.plant-photo > a:focus-visible { outline-offset: -4px; }
.photo-zoom { position: absolute; right: 8px; bottom: 8px; border-radius: 6px; padding: 4px 8px; background: #193c49ed; color: white; font-size: .8rem; }
.plant-photo figcaption { padding: clamp(13px, 2vw, 20px); }
.plant-photo figcaption strong { display: block; font-size: 1.2rem; line-height: 1.22; margin-bottom: 7px; }
.plant-photo figcaption p { margin: 0 0 9px; }
.plant-photo figcaption small { color: var(--muted); font-size: .81rem; }
.result-illustration { margin: 23px 0 0; }
.result-illustration img { display: block; width: 100%; height: auto; border-radius: 12px; }
.result-illustration figcaption { margin-top: 6px; color: var(--muted); font-size: .86rem; }
.moscow-tour { margin: 22px 0; padding: 18px; border-radius: 12px; background: #f4eef9; }
.moscow-tour h3 { margin: 0 0 8px; }
.moscow-tour ul { margin: 12px 0 0; padding-inline-start: 20px; }
.moscow-tour li + li { margin-top: 5px; }
.moscow-photo-link, .plant-photo figcaption .moscow-photo-link { margin: 12px 0 0; font-size: .93rem; }

.intake-scene { position: relative; }
.screen-slot, .intake-screen { position: absolute; left: 45%; width: 11%; height: 40%; border-radius: 4px; }
.screen-slot { top: 39%; border: 2px dashed #4e8394; pointer-events: none; }
.intake-screen {
  top: 4%;
  border: 3px solid #244d60;
  background: repeating-linear-gradient(90deg, #3e5964 0 2px, #d9e4e8 2px 3px, #a8c2c930 3px 8px);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: top 230ms cubic-bezier(.18, .72, .33, 1);
}
.intake-screen::before { content: ''; position: absolute; inset: -5px; }
.intake-screen.is-dragging { z-index: 1; cursor: grabbing; transition: none; }
.intake-screen:focus-visible { outline-offset: 2px; }
.intake-scene + figcaption { min-block-size: 1.55em; }
.operation:has(.intake-scene) .operation-status { min-block-size: 3.1em; margin-top: 6px; }
@media (prefers-reduced-motion: reduce) {
  .intake-screen { transition: none; }
}

/* Equipment, explanation and controls form a single working area. */
.apparatus-heading{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;margin:10px 0}.apparatus-heading strong{font-size:16px}
.scene-pause,.backwash-toggle{font:inherit;font-size:12px;background:#fff;border:1px solid #c7d8df;border-radius:20px;color:#587080;padding:5px 10px;cursor:pointer}.backwash-toggle{margin:6px 0 9px}
.operation .apparatus-explanation{font-size:14px;line-height:1.5;margin:10px 0;color:#415b6a}
.operation .apparatus-reference{font-size:11px;color:#647785;margin-top:10px}.apparatus-reference a{color:#6f5891}
.operation canvas{aspect-ratio:15/8}.operation .visual-tools{gap:6px;margin-top:8px}.operation .visual-tools button{font-size:14px;padding:8px 12px}
.operation .operation-status:empty{min-block-size:0}.operation .reaction{font-size:14px;margin:7px 0}
.intake-screen{box-shadow:2px 3px 5px #526c7f40;border-color:#748d9c;transition:top 700ms cubic-bezier(.3,.1,.3,1)}
.stage-support .equipment{padding:16px}.workspace{grid-template-columns:minmax(0,1.45fr) minmax(270px,.8fr)}
.lab-apparatus{display:block;width:100%;height:auto;margin:8px 0;background:#f8fbfc;border-radius:10px}
.lab-frame .lab-water{min-height:60px}.lab-frame .lab-layer{min-height:54px}.lab-frame .lab-ion{font-size:14px}
@media(max-width:850px){.workspace{grid-template-columns:1fr}.operation{padding:9px}.apparatus-heading strong{font-size:15px}}
@media(prefers-reduced-motion:reduce){.intake-screen{transition:none}}
