/* ==========================================================================
   Next Step Anatomy – styles
   Clinical UI: dark 3D stage, light readable panels.
   ========================================================================== */

:root {
  --bg: #e9edf2;
  --panel: #ffffff;
  --panel-2: #f5f7fa;
  --panel-3: #eef2f7;
  --line: #e1e6ed;
  --line-strong: #cbd3de;
  --text: #0f1b2d;
  --text-2: #374559;
  --muted: #627189;
  --accent: #1464d6;
  --accent-ink: #0d4fae;
  --accent-soft: #e7effc;
  --ok: #12804a;
  --ok-soft: #e4f5eb;
  --bad: #c3332f;
  --bad-soft: #fcecec;
  --clinical: #b4461a;
  --clinical-soft: #fdf3ee;
  --stage: #0b1017;
  --glass: rgba(16, 24, 35, 0.78);
  --glass-line: rgba(255, 255, 255, 0.09);
  --on-dark: #e9eef6;
  --on-dark-muted: #9ba9bc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(9, 18, 32, 0.16), 0 2px 6px rgba(9, 18, 32, 0.08);
  --shadow-dark: 0 10px 30px rgba(0, 0, 0, 0.45);
  --sidebar-w: 322px;
  --info-w: 392px;
  --topbar-h: 58px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 5px; border: 1px solid var(--line-strong);
  border-bottom-width: 2px; border-radius: 5px; background: var(--panel); font: 600 11px/1.6 var(--font); text-align: center; color: var(--text-2);
}
code { font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--panel-3); padding: 1px 5px; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }
.only-mobile { display: none !important; }

/* ------------------------------------------------------------------ layout */
.app { display: grid; grid-template-rows: var(--topbar-h) minmax(0, 1fr) auto; height: 100vh; height: 100dvh; }
.main { position: relative; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) auto; min-height: 0; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.brand-mark { width: 34px; height: 34px; display: block; border-radius: 50%; flex: none; box-shadow: 0 1px 3px rgba(9, 18, 32, .25); }
.brand-accent { color: #0a9c92; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: -0.01em; }
.brand-text > span { font-size: 11.5px; color: var(--muted); }
.search { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.search input {
  width: 100%; height: 38px; padding: 0 40px 0 38px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--panel-2); transition: border-color .15s, background .15s, box-shadow .15s;
}
.search input:focus { outline: none; background: var(--panel); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::-webkit-search-cancel-button { display: none; }
.search-ico { position: absolute; left: 11px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.search.is-focused kbd { display: none; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: min(70vh, 460px); overflow: auto; z-index: 60;
}
.search-results li {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.search-results li.is-active, .search-results li:hover { background: var(--accent-soft); }
.search-results li.empty { display: block; color: var(--muted); cursor: default; }
.search-results .sr-main { display: flex; flex-direction: column; min-width: 0; }
.search-results .sr-name { font-weight: 600; }
.search-results .sr-latin { font-size: 12px; color: var(--muted); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results .sr-sys { font-size: 11.5px; color: var(--text-2); background: var(--panel-3); padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.search-results mark { background: #fff1a8; color: inherit; border-radius: 2px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel); color: var(--text);
  font-weight: 500; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: var(--panel-2); border-color: #b8c2d0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--panel-3); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; gap: 5px; border-radius: 8px; }
.btn.small .ico { width: 16px; height: 16px; }
.btn.block { width: 100%; height: 42px; }
.btn.on-dark { color: var(--on-dark); }
.btn.on-dark:hover { background: rgba(255,255,255,.08); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--text-2); flex: none;
}
.icon-btn svg, .icon-btn .ico { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small .ico { width: 17px; height: 17px; }
.icon-btn.tiny { width: 28px; height: 28px; }
.icon-btn.tiny .ico { width: 16px; height: 16px; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; text-align: left; }
.link:hover { text-decoration: underline; }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--panel-3); border: 1px solid var(--line); border-radius: 10px; }
.seg-btn { border: 0; background: transparent; height: 30px; padding: 0 11px; border-radius: 7px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.seg-btn:hover { color: var(--text); background: rgba(255,255,255,.6); }
.seg-btn[aria-pressed="true"] { background: var(--panel); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(10,20,40,.14); }
.seg.small .seg-btn { height: 28px; font-size: 13px; }
.seg.dark { background: var(--glass); border-color: var(--glass-line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.seg.dark .seg-btn { color: var(--on-dark); height: 32px; min-width: 38px; justify-content: center; }
.seg.dark .seg-btn:hover { background: rgba(255,255,255,.1); }
.seg.dark .seg-btn .ico { width: 16px; height: 16px; }

/* inputs */
.input { width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.switch {
  appearance: none; -webkit-appearance: none; position: relative; width: 36px; height: 21px; margin: 0; border-radius: 99px;
  background: #c5cdd9; flex: none; transition: background .15s; cursor: pointer;
}
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(15px); }
.switch.small { width: 30px; height: 18px; }
.switch.small::after { width: 14px; height: 14px; }
.switch.small:checked::after { transform: translateX(12px); }
input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; height: 22px; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--line-strong); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line-strong); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: #fff; border: 2px solid var(--c, var(--accent)); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 2px solid var(--c, var(--accent)); }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; background: var(--panel-3); color: var(--text-2); font-size: 12px; font-weight: 500; }
.chip.sys { background: var(--accent-soft); color: var(--accent-ink); }
.chip.ghost { background: transparent; border: 1px solid var(--line); }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }

/* ----------------------------------------------------------------- sidebar */
.sidebar { position: relative; z-index: 20; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); flex: none; }
.tabs [role="tab"] {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 50px; padding: 0 2px;
  border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 11.5px; letter-spacing: .01em;
  border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0;
}
.tabs [role="tab"] svg { width: 19px; height: 19px; }
.tabs [role="tab"] span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tabs [role="tab"]:hover { color: var(--text); }
.tabs [role="tab"][aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tab-panel { flex: 1; min-height: 0; overflow: auto; padding: 14px 14px 24px; scrollbar-gutter: stable; }
.panel-intro p { margin: 0 0 12px; color: var(--text-2); font-size: 13px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

/* systems & layers */
.systems { display: flex; flex-direction: column; gap: 8px; }
.system { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.system-head { display: flex; align-items: center; gap: 9px; padding: 9px 12px 2px; font-weight: 600; }
.system-head .swatches { display: inline-flex; gap: 3px; }
.layer-row { padding: 8px 12px 6px; }
.layer-row + .layer-row { border-top: 1px dashed var(--line); }
.layer-row.is-child { padding-left: 16px; }
.layer-main { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.layer-name { flex: 1; font-weight: 600; }
.layer-row.is-child .layer-name { font-weight: 500; }
.layer-opacity { display: flex; align-items: center; gap: 8px; padding-left: 20px; }
.layer-opacity input { flex: 1; }
.opacity-val { width: 38px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.layer-row.is-off .layer-opacity { opacity: .45; }
.layer-status { width: 14px; height: 14px; flex: none; }
.layer-status.is-loading { border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.layer-status.is-error { display: grid; place-items: center; background: var(--bad); color: #fff; border-radius: 50%; font-size: 10px; font-weight: 700; }
.layer-status.is-lazy::before { content: ""; display: block; width: 6px; height: 6px; margin: 4px; border-radius: 50%; background: var(--line-strong); }
.sex-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px 10px 32px; font-size: 13px; }

/* tree */
.tree-filter { margin-bottom: 10px; }
.tree details { border-radius: 8px; }
.tree summary { display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: 8px; cursor: pointer; list-style: none; user-select: none; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary:hover { background: var(--panel-2); }
.tree .caret { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.tree details[open] > summary .caret { transform: rotate(90deg); }
.tree-system > summary { font-weight: 600; }
.tree-region { margin-left: 14px; }
.tree-region > summary { font-weight: 500; color: var(--text-2); font-size: 13px; }
.tree .tree-label { flex: 1; }
.tree .count { font-size: 11.5px; color: var(--muted); background: var(--panel-3); padding: 0 7px; border-radius: 99px; }
.tree ul { list-style: none; margin: 0 0 4px 22px; padding: 0; border-left: 1px solid var(--line); }
.tree-item { display: flex; align-items: center; gap: 4px; padding-left: 6px; border-radius: 0 8px 8px 0; }
.tree-item:hover { background: var(--panel-2); }
.tree-item.is-active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.tree-item.is-hidden .tree-name { color: var(--muted); }
.tree-item.nested { padding-left: 20px; position: relative; }
.tree-item.nested::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 0; border-left: 1px solid var(--line); }
.tree-item.is-group .tree-name { font-weight: 600; }
.chip.link { cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--text-2); font: inherit; font-size: 12px; }
.chip.link:hover { border-color: var(--accent); color: var(--accent-ink); }
.chip.link strong { font-weight: 600; margin-left: 3px; }
.part-list { display: flex; flex-wrap: wrap; gap: 6px; }
.group-tag { font-size: 10.5px; font-weight: 600; color: var(--muted); background: var(--panel-3); border-radius: 999px; padding: 1px 6px; font-variant-numeric: tabular-nums; }
.tree-name { flex: 1; min-width: 0; border: 0; background: none; padding: 6px 4px; text-align: left; font-size: 13px; color: var(--text); }
.tree-item.is-active .tree-name { font-weight: 600; color: var(--accent-ink); }
.sides { display: inline-flex; gap: 2px; }
.side-chip { width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font-size: 11px; font-weight: 600; color: var(--muted); padding: 0; }
.side-chip:hover { border-color: var(--accent); color: var(--accent); }
.side-chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sex-tag { font-size: 12px; color: var(--muted); }
.tree-item .eye { color: var(--muted); }

/* quiz panel */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.field .seg { align-self: flex-start; }
.check { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; font-size: 13px; }
.quiz-stats { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; color: var(--text-2); }
.quiz-stats b { font-variant-numeric: tabular-nums; color: var(--text); font-size: 14px; }
.progress { height: 5px; border-radius: 9px; background: var(--panel-3); overflow: hidden; margin: 8px 0 12px; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.history { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.history li { display: flex; align-items: center; gap: 6px; }
.history li.ok .ico { color: var(--ok); }
.history li.bad .ico { color: var(--bad); }
.missed { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; background: var(--panel-2); }
.missed h4 { margin: 0 0 6px; font-size: 13px; }
.missed ul { margin: 0; padding-left: 18px; font-size: 13px; }
.missed li { margin: 3px 0; }
.summary .big-score { display: flex; flex-direction: column; align-items: center; padding: 18px 0 14px; }
.summary .big-score span { font-size: 44px; font-weight: 700; letter-spacing: -.02em; color: var(--accent-ink); line-height: 1; }
.summary .big-score small { color: var(--muted); margin-top: 6px; }

/* ------------------------------------------------------------------- stage */
.stage {
  position: relative; min-width: 0; overflow: hidden; isolation: isolate;
  background: radial-gradient(120% 90% at 50% 30%, #1d2a3a 0%, #111a25 45%, #0a0f15 100%);
}
.viewport { position: absolute; inset: 0; }
.viewport canvas { display: block; width: 100% !important; height: 100% !important; outline: none; touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.viewport canvas.is-dragging { cursor: grabbing; }
.stage-top { position: absolute; top: 12px; left: 12px; right: 76px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; z-index: 5; pointer-events: none; }
.stage-top > * { pointer-events: auto; }
.regions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.region-picker { display: flex; align-items: center; gap: 2px; padding: 3px; background: var(--glass); border: 1px solid var(--glass-line); border-radius: 10px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.region-picker.is-focused { border-color: rgba(90, 160, 255, .6); }
.region-select {
  height: 32px; padding: 0 28px 0 10px; border: 0; border-radius: 7px; color: var(--on-dark); background-color: transparent; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c8d3e2' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 14px;
}
.region-select:hover { background-color: rgba(255,255,255,.1); }
.region-select option { color: #0f1b2d; background: #fff; }
.region-chips { display: flex; gap: 4px; padding: 3px; background: var(--glass); border: 1px solid var(--glass-line); border-radius: 10px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.region-chip { height: 30px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--on-dark); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.region-chip:hover { background: rgba(255,255,255,.1); }
.region-chip.is-active { background: rgba(255,255,255,.16); }
.chip-toggle { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; margin-left: 2px; border-radius: 7px; border-left: 1px solid var(--glass-line); color: var(--on-dark-muted); font-size: 12.5px; white-space: nowrap; cursor: pointer; }
.chip-toggle:hover { color: var(--on-dark); background: rgba(255,255,255,.08); }
.chip-toggle input { accent-color: #5aa0ff; margin: 0; }

.toolrail {
  position: absolute; top: 12px; right: 12px; z-index: 6; display: flex; flex-direction: column; gap: 4px; padding: 5px;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.rail-btn { position: relative; display: grid; place-items: center; gap: 2px; width: 52px; padding: 7px 0 5px; border: 0; border-radius: 10px; background: transparent; color: var(--on-dark); }
.rail-btn .ico { width: 20px; height: 20px; }
.rail-label { font-size: 10px; line-height: 1.1; color: var(--on-dark-muted); text-align: center; }
.rail-btn:hover { background: rgba(255,255,255,.09); }
.rail-btn[aria-pressed="true"] { background: rgba(80, 150, 255, .24); color: #fff; }
.rail-btn[aria-pressed="true"] .rail-label { color: #cfe1ff; }
.rail-btn:disabled { opacity: .38; cursor: default; }
.rail-btn.attention::after { content: ""; position: absolute; top: 6px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: #ffb347; }
.rail-sep { height: 1px; margin: 3px 6px; background: var(--glass-line); }

.clip-panel {
  position: absolute; top: 12px; right: 80px; z-index: 7; width: 320px; padding: 12px 14px; background: var(--panel); color: var(--text);
  border-radius: var(--radius); box-shadow: var(--shadow-dark);
}
.clip-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.clip-head strong { flex: 1; }
.clip-row { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); }
.clip-label { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 13px; cursor: pointer; }
.clip-ctl { display: flex; align-items: center; gap: 6px; }
.clip-ctl input { flex: 1; }
.clip-val { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.clip-panel p { margin: 6px 0 0; }

.tooltip {
  position: absolute; left: 0; top: 0; z-index: 8; pointer-events: none; display: grid; grid-template-columns: auto 1fr; column-gap: 7px; align-items: center;
  max-width: 280px; padding: 7px 10px; border-radius: 9px; background: rgba(9, 14, 21, .92); border: 1px solid var(--glass-line); color: var(--on-dark); box-shadow: var(--shadow-dark);
}
.tt-dot { width: 9px; height: 9px; border-radius: 50%; grid-row: span 2; }
.tt-name { font-weight: 600; font-size: 13px; }
.tt-sub { grid-column: 2; font-size: 11.5px; color: var(--on-dark-muted); }

.labels-layer { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.pin { position: absolute; left: 0; top: 0; padding: 0; border: 0; background: none; pointer-events: auto; color: var(--on-dark); will-change: transform; }
.pin-dot { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(10,16,24,.75); }
.pin-text {
  position: absolute; left: 6px; bottom: 6px; padding: 2px 7px; border-radius: 6px; white-space: nowrap; max-width: 210px; overflow: hidden; text-overflow: ellipsis;
  font-size: 11.5px; font-weight: 500; background: rgba(9, 14, 21, .78); border: 1px solid var(--glass-line);
}
.pin:hover .pin-text { background: rgba(20, 100, 214, .9); }
.pin .pin-text { transform: translateY(var(--dy, 0px)); }
.pin.left .pin-text { left: auto; right: 6px; }
.pin.has-leader::before { content: ""; position: absolute; left: 0; top: var(--lt, 0px); width: 1px; height: var(--lh, 0px); background: rgba(255,255,255,.75); box-shadow: 0 0 0 .5px rgba(10,16,24,.6); }
.pin.is-selected .pin-dot { background: #6aa8ff; }
.pin.is-selected .pin-text { background: var(--accent); font-weight: 600; }

.orient { position: absolute; left: 12px; bottom: 12px; z-index: 3; display: flex; align-items: center; gap: 8px; color: var(--on-dark-muted); font-size: 11px; pointer-events: none; }
.orient span:not(.orient-mid) { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--glass); border: 1px solid var(--glass-line); color: var(--on-dark); font-weight: 700; }
.hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3; margin: 0; padding: 6px 12px; border-radius: 99px;
  background: var(--glass); border: 1px solid var(--glass-line); color: var(--on-dark-muted); font-size: 12px; white-space: nowrap; transition: opacity .5s; pointer-events: none;
}
.hint.gone { opacity: 0; }

.loading { position: absolute; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 14px; background: #0b1017; color: var(--on-dark); transition: opacity .45s; }
.loading.done { opacity: 0; pointer-events: none; }
.loading.error .spinner { display: none; }
.loading-logo { width: 132px; height: 132px; border-radius: 50%; box-shadow: 0 10px 40px rgba(9, 226, 212, .12); }
.loading-text { margin: 0; color: var(--on-dark-muted); max-width: 420px; text-align: center; padding: 0 20px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.14); border-top-color: #5aa0ff; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* quiz HUD */
.quiz-hud {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 9; width: min(600px, calc(100% - 140px));
  padding: 12px 14px 14px; border-radius: 14px; background: rgba(10, 16, 24, .9); border: 1px solid var(--glass-line); color: var(--on-dark);
  box-shadow: var(--shadow-dark); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.quiz-hud .hud-head { display: flex; align-items: center; gap: 10px; }
.quiz-hud .hud-mode { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #9cc3ff; }
.quiz-hud .quiz-stats { flex: 1; color: var(--on-dark-muted); }
.quiz-hud .quiz-stats b { color: #fff; }
.quiz-hud .quiz-stats .muted { color: var(--on-dark-muted); }
.quiz-hud .progress { background: rgba(255,255,255,.1); margin: 8px 0 10px; }
.quiz-hud .progress span { background: #5aa0ff; }
.hud-q { margin: 0 0 10px; font-size: 16px; }
.hud-q strong { color: #fff; }
.hud-sub { margin: -6px 0 8px; font-size: 12px; color: var(--on-dark-muted); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice {
  min-height: 42px; padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06);
  color: var(--on-dark); text-align: left; font-weight: 500; counter-increment: ch;
}
.choices { counter-reset: ch; }
.choice::before { content: counter(ch); display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 8px; border-radius: 6px; background: rgba(255,255,255,.12); font-size: 11px; }
.choice:hover:not(:disabled) { background: rgba(90,160,255,.18); border-color: rgba(90,160,255,.5); }
.choice:disabled { cursor: default; opacity: .75; }
.choice.is-correct { background: rgba(31,191,98,.22); border-color: #1fbf62; opacity: 1; }
.choice.is-wrong { background: rgba(239,68,68,.2); border-color: #ef4444; opacity: 1; }
.type-answer { display: flex; gap: 8px; }
.type-answer .input { background: rgba(255,255,255,.95); }
.feedback { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; }
.feedback > div { flex: 1; font-size: 14px; }
.feedback.ok { background: rgba(31,191,98,.16); }
.feedback.bad { background: rgba(239,68,68,.16); }
.feedback .fb-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none; }
.feedback.ok .fb-icon { background: #1fbf62; color: #fff; }
.feedback.bad .fb-icon { background: #ef4444; color: #fff; }
.feedback .latin { color: var(--on-dark-muted); font-style: italic; margin-top: 2px; }
.hud-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
body.quiz-running .hint, body.quiz-running .labels-layer, body.has-info .hint { display: none; }

/* ------------------------------------------------------------------- info */
.info { position: relative; z-index: 20; width: var(--info-w); min-height: 0; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.info-inner { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.info-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); box-shadow: inset 0 3px 0 var(--accent); flex: none; }
.sheet-handle { display: none; }
.info-title-row { display: flex; align-items: flex-start; gap: 8px; }
.info-titles { flex: 1; min-width: 0; }
.info-head h2 { margin: 0; font-size: 20px; line-height: 1.25; letter-spacing: -.01em; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.side-badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 6px; background: var(--panel-3); color: var(--text-2); }
.latin { margin: 3px 0 0; color: var(--muted); font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 12px; }
.info-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.info-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 18px 28px; }
.info-sec { padding: 14px 0 4px; }
.info-sec + .info-sec { border-top: 1px solid var(--line); }
.info-sec h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.info-sec p { margin: 0 0 8px; color: var(--text); }
.deflist { display: grid; grid-template-columns: 118px 1fr; gap: 8px 12px; margin: 4px 0 8px; }
.deflist dt { font-weight: 600; font-size: 12.5px; color: var(--text-2); padding-top: 1px; }
.deflist dd { margin: 0; }
.oia { display: grid; gap: 8px; }
.oia > div { padding: 8px 10px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); }
.oia-k { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-ink); margin-bottom: 2px; }
.oia p { margin: 0; }
.info-sec.clinical { margin-top: 10px; padding: 12px 14px; border: 0; border-radius: 10px; background: var(--clinical-soft); box-shadow: inset 3px 0 0 var(--clinical); }
.info-sec.clinical h3 { color: var(--clinical); }
.info-sec.clinical h3 .ico { width: 15px; height: 15px; }
.info-sec.clinical ol { margin: 0; padding-left: 20px; }
.info-sec.clinical li { margin: 0 0 7px; }
.info-sec.clinical li::marker { color: var(--clinical); font-weight: 700; }
.synonyms { font-size: 12px; margin: 14px 0 0; }
.xref { display: inline; padding: 0; margin: 0; border: 0; background: none; font: inherit; color: var(--accent-ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 2px; cursor: pointer; text-align: left; }
.xref:hover, .xref:focus-visible { text-decoration-color: currentColor; background: var(--accent-soft); border-radius: 3px; }
.glance { display: grid; gap: 1px; margin: 12px 0 2px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--line); }
.glance-row { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 8px 11px; background: var(--panel-2); font-size: 13px; line-height: 1.45; }
.glance-k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-ink); padding-top: 2px; }
.glance-v .part-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.empty-state { padding: 18px 0; }

/* ------------------------------------------------------------------ footer */
.footer { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 14px; background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; color: var(--text-2); }
.footer .sep { color: var(--line-strong); }

/* ------------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(8, 13, 20, .55); }
.modal-card { width: min(760px, 100%); max-height: 90vh; overflow: auto; padding: 18px 20px; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); }
.modal-card header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-card h2 { margin: 0; font-size: 18px; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px 22px; }
.help-grid h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 6px; }
.help-grid ul { margin: 0; padding-left: 18px; }
.help-grid li { margin: 3px 0; }
.help-grid p { margin: 0 0 8px; }

.toast { position: fixed; left: 50%; bottom: 64px; transform: translate(-50%, 20px); z-index: 120; padding: 9px 14px; border-radius: 10px; background: #111a25; color: #fff; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.has-actions { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.toast-btn { height: 28px; padding: 0 10px; border: 1px solid rgba(255,255,255,.25); border-radius: 7px; background: rgba(255,255,255,.08); color: #fff; font-weight: 600; font-size: 12.5px; }
.toast-btn:hover { background: rgba(255,255,255,.18); }
@media (max-width: 860px) { .toast { bottom: auto; top: 64px; max-width: calc(100% - 24px); flex-wrap: wrap; } }
.scrim { display: none; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  :root { --sidebar-w: 290px; --info-w: 350px; }
  .rail-label { display: none; }
  .rail-btn { width: 40px; padding: 8px 0; }
  .clip-panel { right: 66px; }
  .stage-top { right: 64px; }
  .quiz-hud { width: min(600px, calc(100% - 110px)); }
}
@media (max-width: 860px) {
  :root { --topbar-h: 54px; }
  .only-mobile { display: inline-grid !important; }
  .only-wide { display: none !important; }
  .topbar { gap: 8px; padding: 0 8px; }
  .brand-text { display: none; }
  .brand-mark { width: 30px; height: 30px; }
  .search input { height: 38px; padding-right: 10px; font-size: 16px; }
  .top-actions .btn.primary { width: 38px; padding: 0; }
  .top-actions .btn.primary span { display: none; }
  .main { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: min(90vw, 370px); z-index: 50;
    transform: translateX(-104%); transition: transform .25s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 45; background: rgba(8, 13, 20, .45); }
  .scrim[hidden] { display: none; }
  .stage-top { top: 8px; left: 8px; right: 56px; flex-wrap: nowrap; flex-direction: column; align-items: stretch; gap: 6px; }
  #views { overflow-x: auto; scrollbar-width: none; }
  #views::-webkit-scrollbar, .regions::-webkit-scrollbar { display: none; }
  .seg.dark { display: flex; width: max-content; }
  .regions { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .region-chips { flex: none; }
  .toolrail { top: 8px; right: 8px; padding: 4px; border-radius: 12px; }
  .rail-btn { width: 38px; padding: 7px 0; }
  .clip-panel { top: auto; bottom: 10px; left: 8px; right: 8px; width: auto; }
  .orient-mid { display: none; }
  .orient { bottom: 10px; left: 8px; }
  .hint { bottom: 46px; font-size: 11px; white-space: normal; text-align: center; width: max-content; max-width: calc(100% - 24px); }
  .info {
    position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: 46dvh; z-index: 48; border-left: 0; border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px rgba(9, 18, 32, .28); transition: height .25s ease;
  }
  .info[data-sheet="full"] { height: 88dvh; }
  .info.is-dragging { transition: none; }
  .info-head { padding-top: 8px; border-radius: 16px 16px 0 0; box-shadow: none; touch-action: none; }
  .sheet-handle { display: block; width: 42px; height: 5px; margin: 0 auto 10px; border-radius: 99px; background: var(--line-strong); }
  .info-head h2 { font-size: 18px; }
  .deflist { grid-template-columns: 1fr; gap: 2px; }
  .deflist dd { margin-bottom: 8px; }
  .quiz-hud { left: 8px; right: 8px; bottom: 8px; transform: none; width: auto; padding: 10px 12px 12px; }
  .choices { grid-template-columns: 1fr; }
  .hud-q { font-size: 15px; }
  body.has-info .toolrail { display: none; }
  .footer { padding: 4px 10px; font-size: 11px; }
  .footer .edu { flex-basis: 100%; }
  .footer .edu + .sep { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; }
}

/* ------------------------------------------------------------- study tools */
.study-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 10px; margin: 0 0 12px; background: var(--panel); }
.study-card h3 { margin: 0 0 6px; font-size: 14px; }
.study-card h4 { margin: 10px 0 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.study-card p { margin: 0 0 8px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.fine-print { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-row { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 2px 0 6px; font-size: 12px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-item .swatch { border-radius: 50%; }
.derm-legend { margin-top: 6px; }
.derm-group { margin: 0 0 8px; }
.derm-group-name { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.derm-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.derm-chip { min-width: 34px; height: 24px; padding: 0 6px; border-radius: 6px; border: 1px solid rgba(0,0,0,.08); background: var(--c); color: #0b1220; font: 600 11.5px/1 var(--font); cursor: pointer; }
.derm-chip:hover { filter: brightness(1.06); box-shadow: 0 0 0 2px rgba(20,100,214,.25); }
.derm-chip.is-on { box-shadow: 0 0 0 2px var(--accent); }
.derm-note { margin: 4px 0 8px; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); font-size: 13px; }
.derm-note .link { margin-top: 4px; }
.myo-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.myo-table th, .myo-table td { text-align: left; vertical-align: top; padding: 6px 6px; border-bottom: 1px solid var(--line); }
.myo-table thead th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.myo-table tbody tr { cursor: pointer; }
.myo-table tbody tr:hover { background: var(--panel-2); }
.myo-table tbody tr.is-on { background: #fff1e3; box-shadow: inset 3px 0 0 #ff8a1f; }
.myo-table tbody th { font-weight: 700; white-space: nowrap; }
.myo-table td:last-child { color: var(--text-2); min-width: 74px; }
.btn.danger, .btn.ghost.danger { color: var(--bad); border-color: var(--bad); }

/* key-point markers on the skin */
.kp { position: absolute; left: 0; top: 0; will-change: transform; pointer-events: auto; }
.kp-dot { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%; background: var(--kp); box-shadow: 0 0 0 2px #0b1220, 0 0 0 3px rgba(255,255,255,.7); }
.kp-text { position: absolute; left: 8px; top: -9px; padding: 1px 5px; border-radius: 5px; background: rgba(11,18,32,.82); color: #fff; font: 600 11px/16px var(--font); white-space: nowrap; }
body.quiz-running .kp-layer { display: none; }
.att-pin .kp-text { font-weight: 600; }
.att-pin .kp-dot { width: 12px; height: 12px; left: -6px; top: -6px; }

/* info panel: course, attachments, quiz record */
.info-sec.course .course-row { margin: 2px 0 10px; }
.info-sec.course .info-actions { margin: 4px 0 6px; }
.info-sec.course .btn .swatch { border-radius: 50%; }
.attach-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; }
.attach-box .legend-row { margin: 0; }
.srs-line { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; }
.srs-boxes { display: inline-flex; gap: 2px; }
.srs-boxes span { width: 8px; height: 8px; border-radius: 2px; background: var(--line-strong); }
.srs-boxes span.on { background: var(--ok); }

/* quiz: spaced repetition progress */
.srs-card { margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.srs-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.srs-head h4 { margin: 0 0 8px; font-size: 13.5px; }
.srs-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--line); margin-bottom: 8px; }
.srs-bar span { display: block; height: 100%; }
.srs-bar .m, .srs-legend .m { background: #12804a; }
.srs-bar .r, .srs-legend .r { background: #5bbf7a; }
.srs-bar .l, .srs-legend .l { background: #f0b429; }
.srs-legend .n { background: var(--line-strong); }
.srs-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--text-2); margin-bottom: 8px; }
.srs-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.srs-card .trouble { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 6px 0 8px; }
.srs-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.fb-box { color: var(--on-dark-muted); margin-top: 2px; }

/* trace bar */
.trace-bar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 9; width: min(720px, calc(100% - 140px));
  padding: 10px 12px 12px; border-radius: 14px; background: rgba(10, 16, 24, .9); border: 1px solid var(--glass-line); color: var(--on-dark);
  box-shadow: var(--shadow-dark); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.trace-head { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.trace-head strong { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.25; }
.trace-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 10px currentColor; }
.trace-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.icon-btn.on-dark { color: var(--on-dark-muted); }
.icon-btn.on-dark:hover { background: rgba(255,255,255,.1); color: #fff; }
.trace-path { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin: 8px 0 0; padding: 0; list-style: none; }
.trace-path li { display: inline-flex; align-items: center; opacity: .45; transition: opacity .25s; }
.trace-path li + li::before { content: ""; width: 14px; height: 2px; margin: 0 3px; background: currentColor; opacity: .5; }
.trace-path li.lit { opacity: 1; }
.crumb { height: 24px; padding: 0 8px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--c) 70%, transparent); background: color-mix(in srgb, var(--c) 18%, transparent); color: #fff; font: 500 12px/1 var(--font); cursor: pointer; white-space: nowrap; }
.crumb:hover { background: color-mix(in srgb, var(--c) 35%, transparent); }
.trace-path li.current .crumb { background: var(--c); color: #0b1220; font-weight: 700; }
.trace-sub { margin: 6px 0 0; font-size: 12px; color: var(--on-dark-muted); }
body.quiz-running .trace-bar { display: none; }
.help-study { margin-top: 6px; }
.help-study h3 { margin: 0 0 6px; font-size: 14px; }
.help-study ul { margin: 0 0 10px; padding-left: 18px; font-size: 13.5px; }
.help-study li { margin: 3px 0; }
@media (max-width: 1180px) { .trace-bar { width: min(720px, calc(100% - 110px)); } }
@media (max-width: 860px) {
  .trace-bar { left: 8px; right: 8px; top: 92px; bottom: auto; transform: none; width: auto; padding: 8px 10px 10px; }
  .trace-path { max-height: 64px; overflow: auto; }
  .kp-text { font-size: 10px; }
}

/* --------------------------------------------------------------- doc pages */
.doc-page { overflow: auto; background: var(--bg); }
.doc { max-width: 860px; margin: 0 auto; padding: 28px 18px 60px; }
.doc header.doc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.doc h1 { font-size: 26px; margin: 0; letter-spacing: -.01em; }
.doc h2 { font-size: 18px; margin: 28px 0 8px; }
.doc .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 10px 0; }
.doc table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.doc th, .doc td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.doc p, .doc li { color: var(--text-2); }


/* ------------------------------------------------------------ explore tab */
.explore-hero { padding: 12px 12px 12px; margin: 0 0 14px; border-radius: 12px; background: linear-gradient(135deg, #eef4ff 0%, #e9f8f6 100%); border: 1px solid var(--line); }
.explore-hero p { margin: 0 0 10px; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.explore-hero p strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }
.explore-cat { margin: 0 0 14px; }
.explore-cat h3, .explore-recent h3 { margin: 0 0 8px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.explore-head { display: flex; align-items: baseline; justify-content: space-between; }
.explore-recent { margin: 0 0 16px; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 92px; padding: 10px 10px 9px; text-align: left;
  border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--text); font: inherit; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.preset:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(20, 100, 214, .12); }
.preset:active { transform: scale(.985); }
.preset.is-active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.preset.is-busy::after { content: ""; position: absolute; top: 9px; right: 9px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.preset-swatches { display: inline-flex; gap: 3px; }
.preset-swatches .swatch { width: 9px; height: 9px; border-radius: 50%; }
.preset-title { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.preset-blurb { font-size: 11.5px; line-height: 1.35; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- help extra */
.help-settings { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.help-settings h3 { margin: 12px 0 8px; font-size: 14px; }
.help-settings h3:first-child { margin-top: 0; }
.help-settings .seg { flex-wrap: wrap; }
.help-foot { display: flex; justify-content: flex-start; margin: 14px 0 6px; }

/* --------------------------------------------------------------------- tour */
.tour { position: fixed; inset: 0; z-index: 300; }
.tour-spot {
  position: fixed; border-radius: 12px; pointer-events: none; opacity: 0;
  box-shadow: 0 0 0 9999px rgba(6, 11, 20, .62), 0 0 0 2px rgba(255,255,255,.85), 0 0 24px rgba(90,160,255,.55);
  transition: left .3s ease, top .3s ease, width .3s ease, height .3s ease;
}
.tour-spot.round { border-radius: 40%; }
.tour-card {
  position: fixed; z-index: 1; padding: 16px 16px 12px; border-radius: 14px; background: var(--panel); color: var(--text);
  box-shadow: 0 18px 50px rgba(0,0,0,.45); transition: left .3s ease, top .3s ease;
}
.tour-card h2 { margin: 0 0 6px; font-size: 17px; letter-spacing: -.01em; }
.tour-count { margin: 0 0 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #0a9c92; }
.tour-text { margin: 0 0 14px; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.tour-actions { display: flex; align-items: center; gap: 6px; }
.tour-actions .btn.ghost { margin-right: auto; }
.tour-dots { display: inline-flex; gap: 4px; margin-right: 6px; }
.tour-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.tour-dots i.on { background: var(--accent); }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-card { transition: none; } }

/* ---------------------------------------------------------- phone bottom nav */
.bottom-nav { display: none; }
@media (max-width: 860px) {
  :root { --bnav-h: 58px; }
  .app { grid-template-rows: var(--topbar-h) minmax(0, 1fr) calc(var(--bnav-h) + env(safe-area-inset-bottom)); }
  .footer { display: none; }
  #btn-menu { display: none !important; }
  .top-actions #btn-quiz { display: none; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(6, 1fr); align-items: stretch; padding: 0 2px env(safe-area-inset-bottom);
    background: var(--panel); border-top: 1px solid var(--line); position: relative; z-index: 60;
  }
  .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 44px; border: 0; background: none;
    color: var(--muted); font: inherit; font-size: 10.5px; font-weight: 600; border-radius: 10px; margin: 5px 1px; min-width: 0;
  }
  .bottom-nav button svg { width: 22px; height: 22px; }
  .bottom-nav button[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-soft); }
  .sidebar { bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)); }
  .sidebar .tabs { display: none; }
  .scrim { bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)); }
  .info { bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)); height: 44dvh; }
  .info[data-sheet="full"] { height: calc(88dvh - var(--bnav-h) - var(--topbar-h)); }
  .preset-grid { grid-template-columns: 1fr 1fr; }
  .rail-btn { width: 44px; min-height: 44px; }
  .seg.dark .seg-btn { height: 38px; min-width: 40px; }
  .region-select { height: 38px; font-size: 14px; }
  .chip-toggle { height: 38px; }
  .btn.small { min-height: 36px; }
  .xref { padding: 2px 0; }
  .tour-card { padding: 14px 14px 10px; }
}

.search-results .sr-head { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); cursor: default; }

/* ------------------------------------------------------------- body tabs */
.body-tabs { display: inline-flex; flex: none; padding: 3px; gap: 2px; border-radius: 11px; background: var(--panel-3); border: 1px solid var(--line); }
.body-tabs [role="tab"] {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text-2); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s;
}
.body-tabs [role="tab"] svg { width: 17px; height: 17px; }
.body-tabs [role="tab"]:hover { color: var(--text); }
.body-tabs [role="tab"][aria-selected="true"] { background: var(--panel); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(10,20,40,.16); }
.body-tabs [data-body="female"][aria-selected="true"] { color: #b4235a; }
.body-tabs.is-busy { opacity: .7; pointer-events: none; }

/* ------------------------------------------------- pull-down controls drawer */
.pull-tab {
  --pull: 0px;
  position: absolute; z-index: 9; top: 0; left: 50%; transform: translate(-50%, var(--pull));
  display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 14px 2px; border: 1px solid var(--glass-line); border-top: 0;
  border-radius: 0 0 14px 14px; background: var(--glass); color: var(--on-dark); font: inherit; font-size: 12px; font-weight: 600;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); cursor: grab; touch-action: none; transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.pull-tab svg { width: 15px; height: 15px; transition: transform .25s; }
.pull-tab .pull-grip { position: absolute; top: 4px; left: 50%; width: 28px; height: 3px; margin-left: -14px; border-radius: 3px; background: rgba(255,255,255,.35); }
.pull-tab.open { --pull: var(--drawer-h, 0px); }
.pull-tab.open svg { transform: rotate(180deg); }
.pull-tab.dragging, .control-drawer.dragging { transition: none; }
.pull-tab:focus-visible { outline: 2px solid #5aa0ff; outline-offset: 2px; }
.control-drawer {
  --pull: 0px;
  position: absolute; z-index: 8; top: 0; left: 50%; width: min(760px, calc(100% - 16px)); max-height: calc(100% - 60px); overflow: auto;
  transform: translate(-50%, calc(-100% + var(--pull))); padding: 10px 12px 8px; border-radius: 0 0 16px 16px;
  background: rgba(16, 24, 35, 0.9); border: 1px solid var(--glass-line); border-top: 0; color: var(--on-dark);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 14px 40px rgba(0,0,0,.4);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.control-drawer[hidden] { display: block !important; visibility: hidden; }
.control-drawer.open { transform: translate(-50%, 0); }
.control-drawer:not(.open):not(.dragging) { visibility: hidden; transition: transform .28s cubic-bezier(.2,.8,.2,1), visibility 0s .28s; }
.drawer-slot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.drawer-slot > * { flex: none; }
.drawer-slot #views .seg, .drawer-slot .region-picker { background: rgba(255,255,255,.06); }
.drawer-slot .body-tabs { background: rgba(255,255,255,.08); border-color: var(--glass-line); }
.drawer-slot .body-tabs [role="tab"] { color: var(--on-dark); }
.drawer-slot .body-tabs [role="tab"][aria-selected="true"] { background: rgba(255,255,255,.92); }
.toolrail.in-drawer { position: static; flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 3px; gap: 2px; background: rgba(255,255,255,.06); }
.toolrail.in-drawer .rail-sep { width: 1px; height: auto; align-self: stretch; margin: 6px 3px; }
.toolrail.in-drawer .rail-btn { width: 64px; }
.toolrail.in-drawer .rail-label { display: block; }
.drawer-foot { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 8px; }
.drawer-foot .btn { background: rgba(255,255,255,.1); color: var(--on-dark); border-color: var(--glass-line); }
.drawer-hint { font-size: 11.5px; color: var(--on-dark-muted); }

/* ----------------------------------------------------------- immersive view */
body.immersive .app { grid-template-rows: minmax(0, 1fr); }
body.immersive .topbar, body.immersive .footer, body.immersive .bottom-nav, body.immersive .sidebar, body.immersive .scrim { display: none !important; }
body.immersive .main { grid-template-columns: minmax(0, 1fr); }
body.immersive .stage-top, body.immersive .hint { display: none; }
body.immersive .stage { padding-top: env(safe-area-inset-top); }
body.immersive .pull-tab { top: env(safe-area-inset-top); }
body.immersive .control-drawer { top: env(safe-area-inset-top); }
@media (min-width: 861px) {
  body.immersive .info {
    position: absolute; top: 14px; right: 14px; bottom: 14px; width: min(var(--info-w), 40vw); z-index: 10;
    border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-dark);
  }
  body.immersive .main { position: relative; }
}

/* --------------------------------------------------------- phone controls */
@media (max-width: 860px) {
  .stage-top { display: none; }
  .body-tabs { padding: 2px; }
  .body-tabs [role="tab"] { height: 34px; padding: 0 9px; }
  .body-tabs [role="tab"] span { display: none; }
  .control-drawer { width: calc(100% - 12px); padding: 10px 8px 8px; }
  .drawer-slot { gap: 6px; }
  .drawer-slot #views { width: 100%; display: flex; justify-content: center; }
  .drawer-slot .region-picker { width: 100%; justify-content: center; }
  .drawer-slot .region-select { flex: 1; }
  .toolrail.in-drawer { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); }
  .toolrail.in-drawer .rail-sep { display: none; }
  .toolrail.in-drawer .rail-btn { width: auto; min-height: 52px; }
  body.has-info .toolrail.in-drawer { display: grid; }
  .drawer-hint { display: none; }
}
@media (pointer: coarse) {
  .seg-btn, .chip.link, .region-select { min-height: 40px; }
  .rail-btn { min-height: 46px; }
}
.credit { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
.drawer-slot .body-tabs [role="tab"][aria-selected="true"] { color: var(--accent-ink); }
.drawer-slot .body-tabs [data-body="female"][aria-selected="true"] { color: #b4235a; }
.tone-row { display: flex; align-items: center; gap: 10px; padding: 2px 12px 10px 32px; }
.tone-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.tone { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--panel); background: var(--tone); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; padding: 0; }
.tone[aria-checked="true"] { box-shadow: 0 0 0 2px var(--accent); }
@media (pointer: coarse) { .tone { width: 30px; height: 30px; } }

/* ----------------------------------------------------------------- ask (anatomy Q&A) */
#panel-ask:not([hidden]) { display: flex; flex-direction: column; padding-bottom: 10px; overflow: hidden; }
.ask { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ask-head h2 { margin: 0; font-size: 15px; }
.ask-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 2px 0 8px; }
.ask-mode .link-btn { margin-left: auto; }
.ask-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: none; }
.ask-dot.on { background: var(--ok); }
.link-btn { padding: 0; border: 0; background: none; font: inherit; color: var(--accent-ink); text-decoration: underline; cursor: pointer; }
.ask-log { flex: 1; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 8px; overscroll-behavior: contain; }
.ask-empty p { margin: 4px 0 10px; color: var(--text-2); font-size: 13px; }
.ask-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-suggest .chip { height: auto; min-height: 28px; padding: 5px 10px; border: 1px solid var(--line); background: var(--panel); text-align: left; cursor: pointer; line-height: 1.3; }
.ask-suggest .chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.ask-msg { max-width: 100%; font-size: 13.5px; line-height: 1.5; }
.ask-msg.user { align-self: flex-end; max-width: 88%; padding: 7px 11px; border-radius: 14px 14px 4px 14px; background: var(--accent); color: #fff; white-space: pre-wrap; overflow-wrap: anywhere; }
.ask-msg.bot { align-self: stretch; padding: 9px 11px; border-radius: 14px 14px 14px 4px; background: var(--panel-2); border: 1px solid var(--line); }
.ask-msg.bot p { margin: 0 0 7px; }
.ask-msg.bot p:last-child { margin-bottom: 0; }
.ask-msg.bot ul, .ask-msg.bot ol { margin: 4px 0 8px; padding-left: 18px; }
.ask-msg.bot li { margin: 2px 0; }
.ask-thinking { animation: askPulse 1.2s ease-in-out infinite; }
@keyframes askPulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .ask-thinking { animation: none; } }
.ask-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; margin: 0 0 8px; }
.ask-card:last-child { margin-bottom: 0; }
.ask-card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-bottom: 4px; }
.ask-card-head .btn { margin-left: auto; }
.ask-card .deflist { grid-template-columns: 1fr; gap: 1px; margin: 0; }
.ask-card .deflist dt { margin-top: 5px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.ask-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 8px; }
.ask-chips .chip .ico svg { width: 13px; height: 13px; }
.ask-form { display: flex; align-items: flex-end; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.ask-form textarea { flex: 1; min-height: 38px; max-height: 140px; resize: none; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 10px; font: inherit; font-size: 14px; line-height: 1.4; color: var(--text); background: var(--panel); }
.ask-form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.ask-send { width: 38px; height: 38px; padding: 0; flex: none; justify-content: center; }
.ask-send.is-stop { background: var(--text-2); border-color: var(--text-2); }
.ask-note { margin: 6px 0 0; font-size: 11.5px; }
@media (max-width: 760px) { .ask-form textarea { font-size: 16px; } }

/* ----------------------------------------------------------------- spotlight pill */
.spot-pill { position: absolute; right: 12px; bottom: 12px; z-index: 6; display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 280px); padding: 5px 6px 5px 12px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-line);
  color: var(--on-dark); font-size: 12.5px; box-shadow: var(--shadow-dark); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.spot-pill .ico svg { width: 15px; height: 15px; color: #8fc1ff; }
.spot-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.spot-btn { flex: none; border: 0; border-radius: 999px; padding: 5px 10px; background: rgba(255,255,255,.12); color: var(--on-dark); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.spot-btn:hover { background: rgba(255,255,255,.2); }
@media (max-width: 760px) { .spot-pill { bottom: auto; left: 0; right: 0; margin-inline: auto; width: max-content; top: 50px; max-width: calc(100% - 24px); } }


/* Region view colour key (femoral triangle…) */
.space-legend { position: absolute; right: 12px; bottom: 12px; z-index: 6; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
  max-width: calc(100% - 280px); padding: 6px 6px 6px 12px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-line);
  color: var(--on-dark); font-size: 12.5px; box-shadow: var(--shadow-dark); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.space-legend .sl-name { font-weight: 650; margin-right: 2px; }
.sl-key { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; color: rgba(255,255,255,.86); }
.sl-sw { width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
@media (max-width: 760px) { .space-legend { bottom: auto; left: 0; right: 0; margin-inline: auto; width: max-content; top: 50px; max-width: calc(100% - 24px); justify-content: center; padding: 5px 6px 5px 10px; gap: 4px 10px; font-size: 12px; } }
.space-kinds { display: grid; gap: 10px; }
.space-kind h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.space-kind .sl-sw { box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
