/* Virtual Microscope — house style (sibling of LSS Cell Explorer). */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; }
body {
  overflow-wrap: break-word;
  word-wrap: break-word;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  background: #f0f6fb;
  background-image:
    radial-gradient(ellipse at top left, rgba(191,219,254,0.45), transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(187,247,208,0.4), transparent 55%);
  min-height: 100vh;
  color: #1e293b;
}
button { font-family: inherit; cursor: pointer; }
button:active { transform: translateY(1px); }
button:disabled { opacity:.45; cursor:not-allowed; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
kbd {
  background:#f1f5f9; border:1px solid #cbd5e1; border-bottom-width:2px;
  border-radius:5px; padding:1px 6px; font-size:.8rem; font-family:inherit;
}

/* ---------- Header ---------- */
header.app-header { background:#fff; box-shadow:0 2px 8px rgba(15,23,42,0.08); position:relative; z-index:5; }
.hd-inner {
  max-width:1300px; margin:0 auto; padding:14px 20px 10px;
  display:flex; flex-wrap:wrap; align-items:baseline; gap:6px 14px;
}
.hd-inner h1 { margin:0; font-size:1.55rem; font-weight:800; color:#0f172a; }
.hd-inner h1 .accent { color:#16a34a; }
.hd-sub { font-size:0.85rem; color:#64748b; }

/* ---------- Bench (top row) ---------- */
main.app-main { max-width:1300px; margin:0 auto; padding:16px 16px 60px; }

.bench {
  display:grid;
  grid-template-columns: minmax(0, 1fr);
  gap:16px;
  margin-bottom:18px;
}
@media (min-width: 1000px) {
  .bench { grid-template-columns: minmax(0, 1fr) minmax(400px, 520px); }
}

.card {
  background:#fff; border:1px solid #e2e8f0; border-radius:14px;
  box-shadow:0 4px 14px rgba(15,23,42,0.06); padding:16px;
}

/* 3D view panel */
.scope-panel { display:flex; flex-direction:column; gap:10px; padding:14px; }
#scope3d {
  position:relative;
  width:100%;
  flex:1 1 auto;
  min-height:480px;
  border-radius:10px;
  background:#eef2f7;
  overflow:hidden;
}
.cam-chips { display:flex; flex-wrap:wrap; gap:6px; }
.cam-chip {
  background:#f1f5f9; border:2px solid #cbd5e1; color:#334155;
  border-radius:999px; padding:6px 12px; font-weight:600; font-size:.85rem; min-height:36px;
}
.cam-chip[aria-pressed="true"] { border-color:#16a34a; background:#dcfce7; color:#15803d; }
.scope-hint { font-size:.82rem; color:#64748b; line-height:1.4; }

/* Eyepiece + controls panel */
.eyepiece-panel { display:flex; flex-direction:column; gap:12px; padding:14px; }

.eyepiece-wrap {
  width:100%;
  max-width:420px;
  margin:0 auto;
  aspect-ratio: 1 / 1;
  position:relative;
}
#eyepiece {
  width:100%;
  height:100%;
  position:relative;
  border-radius:50%;
  background:#0a0a0a;
}

/* Readouts */
.readouts {
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:6px 12px;
  background:#f8fafc;
  border:1px solid #e2e8f0;
  border-radius:10px;
  padding:10px 12px;
  font-size:.86rem;
}
.readouts .k { color:#64748b; }
.readouts .v { color:#0f172a; font-weight:600; text-align:right; }
.readouts .tot { grid-column: 1 / -1; display:flex; justify-content:space-between; padding-top:6px; border-top:1px dashed #cbd5e1; }
.readouts .tot .v { color:#15803d; font-weight:800; font-size:1rem; }
.readouts .focus-state {
  grid-column: 1 / -1;
  display:flex; justify-content:space-between; align-items:center;
  padding-top:4px;
}
.focus-word { padding:2px 10px; border-radius:999px; font-weight:700; font-size:.8rem; }
.focus-word.sharp   { background:#dcfce7; color:#15803d; }
.focus-word.nearly  { background:#fef9c3; color:#92400e; }
.focus-word.blurred { background:#e5e7eb; color:#475569; }
.focus-word.crash   { background:#fee2e2; color:#991b1b; }

/* Control panel */
.controls { display:flex; flex-direction:column; gap:12px; }

.slide-row { display:flex; flex-direction:column; gap:8px; }
.slide-picker { display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.slide-picker select {
  flex:1 1 180px; min-height:40px; border-radius:8px;
  border:1px solid #cbd5e1; background:#fff; padding:6px 8px;
}
.level-badge {
  display:inline-block; background:#dcfce7; color:#166534;
  border-radius:999px; font-size:.7rem; font-weight:700;
  padding:3px 9px; letter-spacing:.02em;
}
.level-badge.ol   { background:#dbeafe; color:#1d4ed8; }
.level-badge.both { background:#f3e8ff; color:#7e22ce; }
.slide-blurb { font-size:.82rem; color:#475569; line-height:1.35; }

.ctrl-grid {
  display:grid;
  grid-template-columns: auto 1fr auto;
  gap:8px 10px;
  align-items:center;
}
.ctrl-label { font-size:.82rem; color:#475569; font-weight:600; }

/* Buttons */
.btn {
  background:#16a34a; color:#fff; border:none; border-radius:9px;
  padding:8px 14px; font-size:.9rem; font-weight:600; min-height:44px;
}
.btn:hover:not(:disabled) { background:#15803d; }
.btn.secondary { background:#f1f5f9; color:#334155; border:1px solid #cbd5e1; }
.btn.secondary:hover:not(:disabled) { background:#e2e8f0; }
.btn.warn { background:#fef3c7; color:#92400e; border:1px solid #fcd34d; }
.btn.warn:hover:not(:disabled) { background:#fde68a; }
.btn.small { min-height:40px; padding:6px 10px; font-size:.85rem; }
.btn.xsmall { min-height:36px; padding:4px 10px; font-size:.8rem; font-weight:600; }

/* Arrow pad */
.arrowpad {
  display:grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap:4px;
  justify-content:center;
}
.arrowpad button {
  min-height:44px; min-width:44px;
  background:#f1f5f9; border:1px solid #cbd5e1;
  border-radius:8px; font-size:1.1rem; color:#334155;
}
.arrowpad button:hover { background:#e2e8f0; }
.arrowpad .up   { grid-area: 1 / 2; }
.arrowpad .left { grid-area: 2 / 1; }
.arrowpad .cent { grid-area: 2 / 2; background:transparent; border:none; color:#94a3b8; font-size:.7rem; }
.arrowpad .right{ grid-area: 2 / 3; }
.arrowpad .down { grid-area: 3 / 2; }

/* Coarse / fine buttons */
.stepper { display:flex; gap:6px; align-items:center; }
.stepper .btn { min-width:44px; padding:6px 10px; }

/* Objective + lamp row */
.obj-row { display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.obj-btn {
  min-height:44px; min-width:52px;
  background:#f1f5f9; border:2px solid #cbd5e1;
  border-radius:9px; font-weight:700; color:#334155; padding:6px 10px; font-size:.9rem;
}
.obj-btn[aria-pressed="true"] { background:#dcfce7; border-color:#16a34a; color:#15803d; }
.toggle-row { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.toggle-row .btn { flex: 0 0 auto; }

.condenser-row {
  display:flex; align-items:center; gap:10px;
}
.condenser-row input[type="range"] { flex:1; min-height:32px; }

/* ---------- Tabs ---------- */
.tabbar {
  max-width:1300px; margin:0 auto; padding:0 12px;
  display:flex; flex-wrap:wrap; align-items:center; gap:4px;
  border-bottom:2px solid #e2e8f0; background:transparent;
}
.tab-btn {
  border:none; background:transparent; padding:10px 16px 12px;
  font-size:0.98rem; font-weight:600; color:#475569;
  border-bottom:4px solid transparent; border-radius:6px 6px 0 0;
  min-height:44px;
}
.tab-btn:hover { background:#ecfdf5; color:#15803d; }
.tab-btn[aria-selected="true"] { color:#15803d; border-bottom-color:#22c55e; }
.tab-btn .tick { display:none; color:#16a34a; margin-left:4px; }
.tab-btn.done .tick { display:inline; }
.prog-wrap {
  margin-left:auto; display:flex; align-items:center; gap:8px;
  font-size:0.8rem; color:#64748b; padding:6px 4px;
}
.prog-pips { display:flex; gap:5px; }
.pip {
  width:18px; height:18px; border-radius:50%;
  background:#e2e8f0; border:2px solid #cbd5e1;
  display:inline-flex; align-items:center; justify-content:center;
  font-size:11px; color:transparent; transition:background 0.3s;
}
.pip.done { background:#22c55e; border-color:#16a34a; color:#fff; }

/* ---------- Stations ---------- */
.stations-wrap { padding-top:16px; }
.station { display:none; }
.station.active { display:block; }
.mission {
  background:#ecfdf5; border-left:5px solid #22c55e;
  border-radius:8px; padding:12px 16px; margin-bottom:14px;
  font-size:0.95rem; color:#14532d;
}
h2 { margin:0 0 4px; font-size:1.3rem; color:#0f172a; }
h3 { margin:0 0 8px; font-size:1.05rem; color:#0f172a; }
h4 { margin:14px 0 6px; font-size:.98rem; color:#0f172a; }
.hint { font-size:0.85rem; color:#64748b; }

.flexrow { display:flex; flex-wrap:wrap; gap:16px; }
.flexrow > .col { flex:1 1 300px; min-width:260px; }

.feedback { margin-top:10px; padding:10px 14px; border-radius:9px; font-size:0.93rem; display:none; }
.feedback.show { display:block; }
.feedback.good { background:#f0fdf4; color:#166534; border:1px solid #bbf7d0; }
.feedback.bad  { background:#fef2f2; color:#991b1b; border:1px solid #fecaca; }
.feedback.info { background:#fffbeb; color:#92400e; border:1px solid #fde68a; }

.answer-row { display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-top:10px; }

/* Parts explorer */
.parts-list { list-style:none; margin:0; padding:0; max-height:560px; overflow-y:auto; border:1px solid #e2e8f0; border-radius:10px; background:#f8fafc; }
.parts-list li {
  padding:8px 12px; cursor:pointer; border-bottom:1px solid #e2e8f0;
  font-size:.9rem; color:#334155; font-weight:600; min-height:44px;
  display:flex; align-items:center; gap:8px;
}
.parts-list li:last-child { border-bottom:none; }
.parts-list li:hover { background:#ecfdf5; color:#15803d; }
.parts-list li.selected { background:#dcfce7; color:#166534; }
.part-card {
  background:#f8fafc; border:1px solid #e2e8f0; border-radius:10px;
  padding:12px 14px; min-height:110px;
}
.part-card .pn { font-size:1.05rem; font-weight:800; color:#0f172a; margin-bottom:4px; }
.part-card .pf { font-size:.9rem; color:#334155; margin-bottom:6px; line-height:1.4; }
.part-card .pt { font-size:.85rem; color:#0369a1; font-style:italic; line-height:1.35; }

/* Label the parts drill */
.name-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap:6px; margin-top:8px; }
.name-grid button {
  border:2px solid #cbd5e1; background:#fff; color:#334155;
  border-radius:9px; padding:8px 6px; min-height:44px; font-weight:600; font-size:.85rem;
}
.name-grid button:hover:not(:disabled) { border-color:#16a34a; background:#f0fdf4; }
.name-grid button.wrong { background:#fef2f2; border-color:#ef4444; color:#991b1b; }
.name-grid button.right { background:#dcfce7; border-color:#16a34a; color:#166534; }

/* Match part/function */
.match-grid { display:grid; grid-template-columns: 1fr 1fr; gap:8px; }
.match-col h4 { margin:0 0 8px; }
.match-btn {
  display:block; width:100%; text-align:left;
  background:#fff; border:2px solid #cbd5e1; color:#334155;
  border-radius:9px; padding:10px 12px; margin-bottom:6px; min-height:44px; font-weight:600; font-size:.88rem; line-height:1.3;
}
.match-btn[aria-pressed="true"] { border-color:#16a34a; background:#dcfce7; color:#15803d; }
.match-btn.paired { background:#f0f9ff; border-color:#38bdf8; color:#075985; }
.match-btn.correct { background:#dcfce7; border-color:#22c55e; color:#166534; }
.match-btn.wrong { background:#fef2f2; border-color:#ef4444; color:#991b1b; }
.match-btn:disabled { opacity:.85; cursor:default; }

/* Safety */
.safety {
  background:#fffbeb; border:1px solid #fde68a; color:#92400e;
  border-radius:10px; padding:10px 14px; font-size:.88rem;
}
.safety ul { margin:6px 0 0; padding-left:20px; }
.safety li { margin-bottom:3px; }

/* Guided practice */
.gp-step {
  display:flex; gap:10px; margin-bottom:12px; padding:12px;
  border:1px solid #e2e8f0; border-radius:12px; background:#f8fafc;
}
.gp-step.done { background:#f0fdf4; border-color:#86efac; }
.gp-num {
  flex:0 0 auto; width:32px; height:32px; border-radius:50%;
  background:#dcfce7; color:#15803d; font-weight:800;
  display:flex; align-items:center; justify-content:center;
}
.gp-step.done .gp-num { background:#16a34a; color:#fff; }
.gp-body { flex:1; min-width:0; }
.gp-title { font-weight:700; color:#0f172a; margin-bottom:4px; }
.gp-instr { font-size:.9rem; color:#334155; margin-bottom:6px; }
.gp-q { background:#eef2ff; border:1px solid #c7d2fe; border-radius:9px; padding:8px 10px; font-size:.88rem; color:#3730a3; margin-top:6px; }
.gp-q label { display:block; margin-bottom:6px; font-weight:600; }
.gp-q input[type="text"], .gp-q input[type="number"], .gp-q textarea, .gp-q select {
  padding:6px 8px; border-radius:6px; border:1px solid #c7d2fe; min-height:36px; background:#fff;
}
.gp-q textarea { width:100%; min-height:60px; }
.gp-q .opts { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:6px; }
.gp-q .opts button {
  background:#fff; border:2px solid #c7d2fe; color:#334155;
  border-radius:7px; padding:6px 10px; font-size:.85rem; min-height:36px; font-weight:600;
}
.gp-q .opts button[aria-pressed="true"] { background:#dcfce7; border-color:#16a34a; color:#15803d; }
.gp-q .opts button.correct { background:#dcfce7; border-color:#22c55e; color:#166534; }
.gp-q .opts button.wrong { background:#fef2f2; border-color:#ef4444; color:#991b1b; }
.gp-q .row { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.checklist-status {
  background:#f8fafc; border:1px solid #e2e8f0; border-radius:10px;
  padding:8px 12px; font-size:.85rem; color:#475569; margin:8px 0;
}
.crash-badge {
  background:#fef2f2; border:1px solid #fecaca; color:#991b1b;
  border-radius:8px; padding:4px 10px; font-size:.8rem; font-weight:700;
}

/* Specimen lab */
.slide-cards { display:grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap:10px; }
.slide-card {
  background:#f8fafc; border:2px solid #e2e8f0; border-radius:12px;
  padding:10px; text-align:left; cursor:pointer;
  display:flex; flex-direction:column; gap:6px; min-height:88px;
}
.slide-card:hover { border-color:#16a34a; }
.slide-card.selected { border-color:#16a34a; background:#dcfce7; }
.slide-card .sn { font-weight:800; color:#0f172a; font-size:.95rem; }
.slide-card .ss { font-size:.8rem; color:#475569; line-height:1.35; }
.find-it {
  background:#eef2ff; border:1px solid #c7d2fe; color:#3730a3;
  border-radius:10px; padding:10px 12px; font-size:.9rem;
  display:flex; justify-content:space-between; align-items:center; gap:8px; flex-wrap:wrap;
  margin-top:10px;
}
.find-it .score { font-weight:800; color:#075985; }
.notes-box {
  background:#f8fafc; border:1px solid #e2e8f0; border-radius:10px;
  padding:10px 14px; font-size:.88rem; color:#334155; margin-top:10px;
}

/* Record & measure */
.rule-list { list-style:none; margin:0; padding:0; }
.rule-list li {
  padding:8px 12px 8px 34px; border:1px solid #e2e8f0; border-radius:9px;
  background:#f8fafc; margin-bottom:6px; position:relative; font-size:.9rem;
  cursor:pointer; min-height:44px;
}
.rule-list li::before {
  content:''; position:absolute; left:10px; top:50%; transform:translateY(-50%);
  width:16px; height:16px; border-radius:4px; border:2px solid #cbd5e1; background:#fff;
}
.rule-list li.done { background:#f0fdf4; border-color:#86efac; }
.rule-list li.done::before {
  background:#22c55e; border-color:#16a34a;
  content:'✓'; color:#fff; text-align:center;
  font-size:12px; line-height:14px;
}
.rule-list .why { color:#64748b; font-size:.8rem; margin-top:3px; }

.calc-grid { display:grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap:12px; }
@media (max-width: 640px) { .calc-grid { grid-template-columns: 1fr; } }
.calc-box {
  background:#f8fafc; border:1px solid #e2e8f0; border-radius:10px; padding:10px 12px;
}
.calc-box label { display:block; font-weight:600; font-size:.85rem; color:#334155; margin-bottom:4px; }
.calc-box input, .calc-box select {
  width:100%; padding:6px 8px; border:1px solid #cbd5e1; border-radius:7px; min-height:38px; background:#fff;
}
.calc-result {
  background:#ecfdf5; border:1px solid #86efac; color:#166534;
  border-radius:9px; padding:8px 12px; font-size:.9rem; margin-top:8px; line-height:1.4;
}

/* ---------- Crash modal ---------- */
.modal-mask {
  position:fixed; inset:0; background:rgba(15,23,42,0.5);
  z-index:100; display:none; align-items:center; justify-content:center; padding:20px;
}
.modal-mask.show { display:flex; }
.modal {
  background:#fff; border-radius:14px; max-width:440px; width:100%;
  padding:22px; box-shadow:0 12px 36px rgba(15,23,42,0.35);
}
.modal h3 { color:#991b1b; margin-bottom:10px; font-size:1.1rem; }
.modal p { color:#334155; font-size:.95rem; line-height:1.4; margin:0 0 10px; }
.modal .modal-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:14px; }

/* Footer */
footer.app-footer {
  max-width:1300px; margin:0 auto; padding:16px 16px 24px;
  font-size:.8rem; color:#64748b; text-align:center;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  * { animation:none !important; transition:none !important; }
  button:active { transform:none; }
}

/* Small screens */
@media (max-width: 640px) {
  html, body { overflow-x: hidden; }
  .hd-inner h1 { font-size:1.2rem; }
  .hd-sub { font-size:.75rem; overflow-wrap:anywhere; }
  .prog-wrap { margin-left:0; width:100%; padding:4px 12px 8px; }
  .tab-btn { padding:8px 8px 10px; font-size:.85rem; flex:1 1 45%; min-width:0; text-align:left; }
  .ctrl-grid { grid-template-columns: 1fr; }
  .match-grid { grid-template-columns: 1fr; }
  .cam-chips { justify-content:flex-start; }
  #scope3d { min-height:280px; }
  .eyepiece-wrap { max-width:100%; }
  main.app-main { padding:12px 10px 40px; }
  .scope-panel, .eyepiece-panel { padding:10px; }
  .parts-list { max-height:none; }
  .name-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .hd-inner { padding:10px 12px 6px; }
  .tabbar { padding:0 4px; gap:2px; }
  .tab-btn { padding:6px 6px 8px; font-size:.78rem; flex-basis:calc(50% - 2px); }
  .readouts { padding:8px 10px; font-size:.8rem; }
  .slide-cards { grid-template-columns: 1fr; }
}

/* Specimen-lab notes ("what you can and can't see") */
.notes-list { margin:8px 0 0; padding-left:20px; font-size:0.92rem; color:#334155; }
.notes-list li { margin:3px 0; }

/* Guided practice: the bench condition of a step is met (before its question is answered) */
.gp-step.action-done .gp-num { background:#16a34a; color:#fff; border-color:#15803d; }
.gp-step.action-done .gp-title::after { content:" \2713 done on the bench"; color:#16a34a; font-size:0.8rem; font-weight:600; margin-left:6px; }
.gp-step.done .gp-title::after { content:" \2713 complete"; }


/* Drawing / Photo segmented toggle */
.toggle-row.seg .seg-btn[aria-pressed="true"] { background:#16a34a; color:#fff; border-color:#15803d; }
.toggle-row.seg .seg-btn:disabled { opacity:0.45; cursor:not-allowed; }
#view-hint { grid-column: 2 / -1; margin:-4px 0 6px; }

/* Photo credits */
.credits-wrap { max-width:1300px; margin:0 auto; padding:0 16px 8px; }
.credits summary { cursor:pointer; font-weight:700; color:#0f172a; }
.credits ul { margin:8px 0 0; padding-left:20px; font-size:0.9rem; color:#334155; }
.credits li { margin:4px 0; }
.credits a { color:#15803d; }

/* =========================================================================
   Compact bench — the interactive (header, tabs, 3D view, eyepiece, controls)
   should fit on one screen without scrolling. The bench claims the viewport
   height left under whatever sits above it; on chermistry.com that includes
   the injected site chrome bar, so main.js measures the top of <main> at
   runtime and writes it into --above-main.
   ========================================================================= */
:root {
  --above-main: 120px;                    /* set at runtime by main.js */
  --bench-h: clamp(400px, calc(100dvh - var(--above-main) - 24px), 720px);
}
@supports not (height: 100dvh) {
  :root { --bench-h: clamp(400px, calc(100vh - var(--above-main) - 24px), 720px); }
}

/* Denser page chrome so the bench gets more of the screen. */
.hd-inner { padding: 9px 20px 7px; }
.hd-inner h1 { font-size: 1.3rem; }
.hd-sub { font-size: .8rem; }
main.app-main { padding: 12px 16px 40px; }

@media (min-width: 1000px) {
  .bench { height: var(--bench-h); align-items: stretch; margin-bottom: 14px; }
  .bench > .card { height: 100%; min-height: 0; }

  /* Left: the 3D view takes whatever the chips and hint line leave. */
  .scope-panel { padding: 10px 12px; gap: 8px; }
  #scope3d { min-height: 0; }             /* was a hard 480px */
  .cam-chip { padding: 4px 10px; min-height: 30px; font-size: .8rem; }
  .scope-hint { font-size: .76rem; }

  /* Right: square eyepiece sized from the bench height, then readouts, then
     the controls — which scroll inside the panel rather than pushing the page. */
  .eyepiece-panel { padding: 10px 12px; gap: 8px; }
  .eyepiece-wrap {
    flex: 0 0 auto;
    width: auto; max-width: none;
    aspect-ratio: auto;
    height: clamp(150px, calc(var(--bench-h) * 0.38), 290px);
    display: flex; justify-content: center;
  }
  #eyepiece { width: auto; height: 100%; aspect-ratio: 1 / 1; }

  .readouts {
    flex: 0 0 auto;
    grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 4px 10px; padding: 8px 10px; font-size: .82rem;
  }
  .readouts .tot { padding-top: 4px; }

  .controls {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto; overscroll-behavior: contain;
    gap: 8px; padding-right: 2px;
  }
  .ctrl-grid { gap: 6px 8px; }
  .slide-row { gap: 6px; }
  .slide-blurb { font-size: .78rem; line-height: 1.3; }
  #view-hint { font-size: .75rem; line-height: 1.25; }
}

/* --- Denser control panel on desktop: pair two controls per row so the whole
   bench stays usable without scrolling inside it. Touch sizes are kept at the
   narrower widths below 1000px, where the layout stacks anyway. --- */
@media (min-width: 1000px) {
  .eyepiece-wrap { height: clamp(140px, calc(var(--bench-h) * 0.32), 262px); }

  .ctrl-grid {
    grid-template-columns: auto minmax(0, 1fr) auto auto minmax(0, 1fr) auto;
    column-gap: 10px; row-gap: 6px;
  }
  #view-hint { grid-column: 1 / -1; margin: -2px 0 0; }

  .controls .btn.small { min-height: 34px; padding: 4px 9px; font-size: .8rem; }
  .controls .obj-btn { min-height: 34px; min-width: 44px; padding: 4px 8px; font-size: .82rem; }
  .controls .stepper .btn { min-width: 36px; }
  .controls .stepper .hint { font-size: .72rem; }
  .controls .toggle-row { gap: 6px; }
  .slide-picker select { min-height: 34px; }
  .slide-blurb { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .condenser-row input[type="range"] { min-height: 24px; }

  .arrowpad { grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(3, 30px); gap: 3px; }
  .arrowpad button { min-height: 30px; min-width: 34px; font-size: 1rem; }
}
@media (min-width: 1000px) {
  .arrowpad .cent { font-size: .62rem; white-space: nowrap; letter-spacing: -.02em; }
}

/* =========================================================
   Explore station — inner tabs, callout overlay, diagram quiz
   ========================================================= */

/* Inner sub-tab strip inside the Meet-the-microscope card. */
.subtabbar {
  display: flex; flex-wrap: wrap; gap: 4px;
  border-bottom: 2px solid #e2e8f0;
  margin: 4px 0 12px;
}
.subtab-btn {
  border: none; background: transparent;
  padding: 8px 14px 9px;
  font-size: 0.9rem; font-weight: 600; color: #475569;
  border-bottom: 3px solid transparent;
  border-radius: 6px 6px 0 0;
  min-height: 40px; min-width: 44px;
}
.subtab-btn:hover { background: #ecfdf5; color: #15803d; }
.subtab-btn[aria-selected="true"] {
  color: #15803d; border-bottom-color: #22c55e;
  background: #f0fdf4;
}
.subtab-panel { display: block; }
.subtab-panel[hidden] { display: none; }
.labels-toggle { margin-top: 12px; }

/* Callout overlay inside #scope3d */
.callout-layer {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 3;
}
.callout-layer .callout-leaders {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
}
.callout-leader {
  stroke: #64748b; stroke-width: 1.3; fill: none;
  opacity: .85;
}
.callout-leader.selected { stroke: #16a34a; stroke-width: 2; opacity: 1; }
.callout-box {
  position: absolute;
  background: rgba(255,255,255,0.95);
  border: 1px solid #94a3b8;
  color: #0f172a;
  font-size: 0.78rem; font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(15,23,42,0.15);
  max-width: 42%;
  overflow: hidden; text-overflow: ellipsis;
}
.callout-box.selected {
  background: #dcfce7; border-color: #16a34a; color: #15803d;
  box-shadow: 0 2px 6px rgba(22,163,74,0.25);
}

/* --- Microscope diagram (js/diagram.js) --- */
.mscope-diagram {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px;
  margin: 8px 0;
  overflow: hidden;
}
.mscope-diagram .mscope-fig { display: block; width: 100%; height: auto; max-width: 100%; }
.mscope-diagram .ttl { font-size: 12.5px; font-weight: 800; letter-spacing: .06em; fill: #2a4058; }
.mscope-diagram .lbl-b { font-size: 12px; font-weight: 700; fill: #33506d; }
.mscope-diagram .lbl { font-size: 9.5px; fill: #5b6b7c; }
.mscope-diagram .lead-line { stroke: #8b95a1; stroke-width: 1.3; fill: none; }
.mscope-diagram .lead-dot { fill: #33506d; stroke: none; }
.mscope-diagram .metal { fill: #dfe7ee; stroke: #33506d; stroke-width: 2; }
.mscope-diagram .dark  { fill: #4a5a6a; stroke: #33506d; stroke-width: 1.5; }

/* Drop-box states in the quiz diagram */
.mscope-diagram .label-box .drop-rect {
  fill: #f8fafc; stroke: #94a3b8; stroke-width: 1.4;
  transition: fill 120ms, stroke 120ms;
}
.mscope-diagram.mscope-diagram-quiz .label-box:not([data-labelled]) .drop-rect {
  fill: #eef2f7; stroke-dasharray: 4 3;
}
.mscope-diagram.mscope-diagram-quiz .label-box.hover .drop-rect { fill: #dbeafe; stroke: #2563eb; stroke-dasharray: none; }
.mscope-diagram.mscope-diagram-quiz .label-box.wrong .drop-rect { fill: #fef2f2; stroke: #ef4444; stroke-dasharray: none; }
.mscope-diagram.mscope-diagram-quiz .label-box.filled .drop-rect,
.mscope-diagram.mscope-diagram-quiz .label-box.correct .drop-rect {
  fill: #dcfce7; stroke: #16a34a; stroke-dasharray: none;
}
.mscope-diagram .label-box.filled .box-text,
.mscope-diagram .label-box.correct .box-text { fill: #14532d; font-weight: 700; }
.mscope-diagram.mscope-diagram-quiz .label-box.revealed .drop-rect { fill: #fff7ed; stroke: #f59e0b; stroke-dasharray: none; }
.mscope-diagram .label-box.revealed .box-text { fill: #92400e; }

/* Fully labelled reference variant */
.mscope-diagram.mscope-diagram-ref .label-box .drop-rect {
  fill: #ffffff; stroke: #94a3b8; stroke-dasharray: none;
}
.mscope-diagram .label-box[data-labelled] .box-text { fill: #33506d; }

/* Quiz layout: diagram scrolls horizontally on narrow screens; tray below */
.quiz-area {
  overflow-x: auto;
  margin-top: 6px;
}
.mscope-diagram-quiz { min-width: 640px; }
.mscope-diagram-ref  { min-width: 640px; }
.quiz-status { margin: 6px 0; font-weight: 700; color: #0f172a; }
.quiz-tray-wrap { margin-top: 12px; }
.quiz-tray-title { font-size: .9rem; font-weight: 700; margin: 0 0 6px; color: #334155; }
.chip-tray { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: #fff; border: 1px solid #cbd5e1; color: #0f172a;
  padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: .88rem;
  cursor: grab; touch-action: none; user-select: none;
  min-height: 40px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.06);
  transition: transform 200ms, background 120ms, border-color 120ms, box-shadow 120ms;
}
.chip:hover { border-color: #16a34a; background: #f0fdf4; }
.chip.picked { border-color: #16a34a; background: #dcfce7; color: #15803d; box-shadow: 0 2px 6px rgba(22,163,74,.28); }
.chip.dragging { cursor: grabbing; pointer-events: none; box-shadow: 0 8px 18px rgba(15,23,42,0.25); z-index: 50; position: relative; }
.chip.wrong { animation: chip-shake 320ms; background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.chip.placed { background: #dcfce7; border-color: #16a34a; color: #15803d; }
.chip:disabled { cursor: default; }
@keyframes chip-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.diagram-caption { font-size: .88rem; color: #475569; margin: 8px 4px 4px; line-height: 1.45; }

/* Print reference-diagram tab cleanly */
@media print {
  header.app-header, .tabbar, .subtabbar, .cam-chips, .scope-hint,
  #scope3d, .eyepiece-panel, .quiz-tray-wrap, .quiz-area, .labels-toggle,
  .match-grid, .safety, .mission, .checklist-status, .answer-row,
  .parts-list, .part-card, .callout-layer {
    display: none !important;
  }
  .card { border: none; box-shadow: none; padding: 0; }
  .mscope-diagram-ref { min-width: 0; page-break-inside: avoid; }
}

/* --- Make the control panel FIT: the inner scrollbar should never appear at
   normal window sizes. (overflow-y:auto stays as a safety valve for very short
   windows, but nothing should reach it here.) --- */
@media (min-width: 1000px) {
  .eyepiece-wrap { height: clamp(130px, calc(var(--bench-h) * 0.27), 232px); }
  .readouts { gap: 3px 10px; padding: 6px 10px; font-size: .8rem; }
  .readouts .tot { padding-top: 3px; }
  .controls { gap: 6px; }
  .ctrl-grid { row-gap: 5px; }
  .slide-row { gap: 5px; }
  /* one line is enough here — the full blurb is on the slide cards in the lab */
  .slide-blurb { -webkit-line-clamp: 1; font-size: .76rem; }
  #view-hint { font-size: .72rem; }
  .controls .btn.small { min-height: 32px; }
  .controls .obj-btn { min-height: 32px; }
  .arrowpad { grid-template-rows: repeat(3, 28px); }
  .arrowpad button { min-height: 28px; }
}

/* --- Biological-drawing rules and the safety list: two compact columns on
   wide screens instead of one tall stack. --- */
@media (min-width: 900px) {
  .rule-list { columns: 2; column-gap: 12px; }
  .rule-list li { break-inside: avoid; }
  .safety ul { columns: 2; column-gap: 18px; }
  .safety li { break-inside: avoid; }
}
.rule-list li {
  padding: 5px 10px 5px 30px; margin-bottom: 5px;
  font-size: .84rem; min-height: 0; line-height: 1.3;
}
.rule-list li::before { left: 8px; width: 14px; height: 14px; }
.rule-list .why { font-size: .74rem; margin-top: 1px; line-height: 1.25; }
.safety li { margin-bottom: 2px; font-size: .84rem; line-height: 1.35; }

/* Full-screen toggle in the tab bar */
#btn-fullscreen { margin-left: auto; white-space: nowrap; }
#btn-fullscreen[aria-pressed="true"] { background: #dcfce7; border-color: #16a34a; color: #15803d; }
.tabbar .prog-wrap { margin-left: 10px; }
:fullscreen .app-header, :fullscreen body { background: #f0f6fb; }
@media print { #btn-fullscreen { display: none !important; } }

/* --- The eyepiece must never starve the controls: it absorbs the squeeze so
   the control panel always fits without an inner scrollbar. --- */
@media (min-width: 1000px) {
  .eyepiece-wrap {
    position: relative;
    height: clamp(110px, calc(var(--bench-h) - 470px), 232px);
  }
}

/* Message over a dark/empty field, so "nothing visible" explains itself. */
.eyepiece-note {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: 78%; text-align: center; pointer-events: none;
  color: #e2e8f0; font-size: .8rem; line-height: 1.35;
  background: rgba(15, 23, 42, .72); border: 1px solid rgba(226, 232, 240, .25);
  border-radius: 10px; padding: 7px 11px;
}

/* Expand affordance on the eyepiece */
.ep-expand {
  position: absolute; top: 4px; right: 4px; z-index: 3;
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255, 255, 255, .88); border: 1px solid #cbd5e1;
  color: #334155; font-size: .9rem; line-height: 1;
}
.ep-expand:hover { background: #fff; }

/* Expanded eyepiece: fills the window over a dim backdrop. */
body.ep-expanded::before {
  content: ''; position: fixed; inset: 0; z-index: 90; background: rgba(8, 12, 20, .82);
}
body.ep-expanded .eyepiece-wrap {
  position: fixed; z-index: 91; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  /* a definite square: with height:auto the circle collapsed to zero, because
     #eyepiece is sized as 100% of its parent */
  width: min(86vh, 92vw); height: min(86vh, 92vw);
  max-width: none;
}
body.ep-expanded #eyepiece { width: 100%; height: 100%; aspect-ratio: auto; }
body.ep-expanded .ep-expand { top: -14px; right: -14px; width: 36px; height: 36px; }
body.ep-expanded .eyepiece-note { font-size: 1rem; }
@media print { .ep-expand { display: none !important; } }

/* Focus row: coarse and fine share one line but keep their own labels, which
   is the distinction the syllabus cares about. */
.focus-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.focus-row .mini { font-size: .72rem; color: #64748b; font-weight: 600; }
.focus-row .btn { min-width: 32px; padding: 4px 8px; }
@media (min-width: 1000px) {
  #view-hint { grid-column: auto; margin: 0; }
  .eyepiece-wrap { height: clamp(120px, calc(var(--bench-h) - 510px), 232px); }
}

/* --- Controls as a wrapping flow of labelled items. A fixed multi-column grid
   kept forcing rows too wide for the panel (horizontal scrollbar, wrapped
   focus buttons); flow items simply re-wrap to whatever width there is. --- */
.ctrl-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.ctrl-item { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.ctrl-item.grow { flex: 1 1 190px; min-width: 170px; }
.ctrl-item .ctrl-label { margin: 0; white-space: nowrap; }
.ctrl-item .condenser-row, .ctrl-item input[type="range"] { flex: 1 1 auto; min-width: 90px; }
@media (min-width: 1000px) {
  .ctrl-grid { gap: 7px 12px; }
  #view-hint { display: none; }   /* the Drawing/Photo buttons say it themselves */
}
