:root {
  color-scheme: light;
  --ink: #173a56;
  --navy: #063a76;
  --blue: #086dd9;
  --green: #5ebb48;
  --text: #27485f;
  --muted: #51697e;
  --line: #d6e5f1;
  --brand: #0863c1;
  --soft: #eff7ff;
  --paper: #f5f9fd;
  --white: #fff;
  --coral: #d86852;
  font-family: "Y Duc Tam An Sans", Arial, sans-serif;
  font-size: 115%;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button, a, select, input { outline-offset: 3px; }
:focus-visible { outline: 2px solid var(--blue); }
button { color: inherit; }
a { color: var(--brand); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
h1, h2, h3, p { margin: 0; }
.icon { display: block; width: 18px; height: 18px; flex: none; }
[data-icon] { display: inline-grid; place-items: center; }
.shell { width: min(1920px, calc(100% - 56px)); margin-inline: auto; }
.topbar { color: var(--navy); background: var(--white); border-top: 4px solid var(--navy); border-bottom: 1px solid var(--line); }
.topbar-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: flex; align-items: center; gap: 17px; }
.brand-logo { display: block; width: 137px; height: auto; flex: none; }
.brand-app { border-left: 1px solid var(--line); padding-left: 17px; color: var(--navy); font-size: 1.125rem; font-weight: 700; }
.main { padding: 25px 0 19px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 21px; }
h1 { font-weight: 700; font-size: clamp(1.75rem, 2.99vw, 2.75rem); line-height: 1.16; letter-spacing: -.032em; }
.intro p { margin-top: 9px; font-size: 1rem; color: var(--muted); line-height: 1.6; }
.help-button { display: flex; gap: 7px; align-items: center; border: 1px solid var(--line); background: #fff; padding: 10px 13px; border-radius: 8px; color: var(--text); font-weight: 700; font-size: .9375rem; flex: none; }
.help-button:hover { background: var(--soft); }
.help-button .icon { width: 16px; height: 16px; }
.workspace { display: grid; grid-template-columns: minmax(216px, 242px) minmax(0, 1fr) minmax(340px, 390px); align-items: start; gap: 16px; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 15px; min-width: 0; box-shadow: 0 2px 5px #173a5609; }
.panel h2 { font-size: 1.1875rem; letter-spacing: -.015em; line-height: 1.32; }
.navigation { display: flex; flex-direction: column; }
.navigation-head { padding: 19px 15px 7px; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; margin-top: 15px; background: #f8fbff; color: #52728f; }
.search:focus-within { outline: 2px solid var(--blue); }
.search .icon { width: 16px; height: 16px; }
.search input { padding: 11px 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: .875rem; width: 100%; min-width: 0; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.atlas-search input::-webkit-search-cancel-button { display: none; }
.search-clear { display: grid; flex: none; place-items: center; width: 29px; height: 29px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--navy); }
.search-clear:hover { background: #e3f0ff; }
.search-status { padding: 4px 15px 0; color: var(--muted); font-size: .8125rem; }
.region-list { padding: 0 9px 12px; }
.region-list.is-searching { display: block; max-height: min(55vh, 510px); overflow: auto; overscroll-behavior: contain; }
.region-list.is-searching .region-group { display: block; margin-top: 12px; }
.region-list.is-searching .region-label { display: block; }
.region-list.is-searching .region-button { width: 100%; }
.result-text { display: grid; min-width: 0; gap: 2px; overflow-wrap: anywhere; }
.result-text small { color: var(--muted); font-size: .75rem; font-weight: 400; }
.region-group { margin-top: 11px; }
.region-label { margin: 0 8px 7px; color: #526e83; text-transform: uppercase; font-weight: 700; font-size: .75rem; letter-spacing: .09em; }
.region-button { display: flex; width: 100%; gap: 9px; align-items: center; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 7px; min-height: 46px; color: var(--text); font-size: .9375rem; font-weight: 700; }
.region-button:hover { background-color: #f0f7fe; }
.region-button[aria-pressed="true"], .region-button[data-current] { color: var(--navy); background-color: #e7f2ff; border-color: #c8e0f7; }
.region-button[aria-selected="true"] { color: var(--navy); border-color: var(--blue); background: #d9ebff; }
.region-icon, .case-icon { display: grid; place-items: center; border-radius: 8px; background: #f0f6fc; height: 31px; width: 31px; color: #426b91; flex: none; }
.region-button[aria-pressed="true"] .region-icon { color: var(--navy); background: #d4e9ff; }
.region-icon .icon { width: 19px; height: 19px; }
.case-icon { width: 43px; height: 43px; color: var(--brand); background: #e6f2ff; border-radius: 11px; }
.case-icon .icon { height: 25px; width: 25px; }
.region-button > .icon { margin-left: auto; width: 14px; height: 14px; opacity: .65; }
.empty-result { margin: 15px 8px; color: var(--muted); font-size: .9375rem; line-height: 1.6; }
.atlas { container: atlas / inline-size; overflow: hidden; }
.atlas-head { display: grid; grid-template: "title" auto "subtitle" auto "controls" auto / minmax(0, 1fr); align-items: center; gap: 5px 12px; padding: 12px 17px; }
#atlas-title { grid-area: title; }
#atlas-subtitle { grid-area: subtitle; min-block-size: 1.45em; font-size: .875rem; color: var(--muted); line-height: 1.45; }
.atlas-sidebar { display: grid; gap: 16px; min-width: 0; }
.pose-panel { display: grid; gap: 10px; padding: 14px 15px; background: #f4f9ff; scroll-margin-block-start: 12px; }
.pose-panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.pose-close { padding: 5px 10px; font-size: .8125rem; }
.pose-panel-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; }
.pose-panel-tools > button { min-height: 34px; padding: 5px 8px; font-size: .8125rem; }
.pose-modes { width: fit-content; }
.manual-controls, .movement-controls { display: grid; gap: 9px; }
.manual-actions { display: grid; gap: 8px; }
.manual-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.5rem), 1fr)); gap: 8px; min-width: 0; }
.manual-fields > label, .manual-field { display: grid; min-width: 0; align-content: start; gap: 5px; color: var(--navy); font-size: .875rem; font-weight: 700; }
.manual-fields > :has(input[type="range"]) { grid-column: 1 / -1; }
.manual-field-label { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 8px; }
.manual-fields output { color: var(--brand); font-variant-numeric: tabular-nums; }
.manual-fields input[type="range"] { width: 100%; min-width: 0; height: 42px; margin: 0; accent-color: var(--blue); cursor: pointer; }
.manual-fields select { min-width: 0; }
.manual-fields input:disabled, .manual-fields select:disabled, #manual-reset:disabled { opacity: .55; cursor: default; }
.manual-actions > button { justify-self: start; min-height: 42px; padding: 6px 10px; font-size: .875rem; }
.manual-hint { color: var(--muted); font-size: .8125rem; line-height: 1.45; }
.manual-anatomy { color: var(--text); font-size: .8125rem; line-height: 1.5; }
.manual-anatomy summary { width: fit-content; cursor: pointer; color: var(--navy); font-weight: 700; }
.manual-anatomy p { margin: 5px 0 3px; max-width: 74ch; }
.manual-feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; }
.manual-feedback:has(> [hidden]:first-child + [hidden]) { display: none; }
.manual-phase { color: var(--navy); font-size: .8125rem; font-weight: 700; }
.manual-steps { display: flex; flex-wrap: wrap; gap: 5px; }
.manual-steps button { padding: 5px 9px; font-size: .8125rem; }
.manual-steps button[aria-pressed="true"] { border-color: var(--blue); background: #e5f1ff; color: var(--navy); }
.movement-actions, .movement-buttons { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; }
.movement-picker { display: grid; gap: 5px; flex: 1 1 220px; min-width: 0; max-width: 390px; color: var(--navy); font-size: .875rem; font-weight: 700; }
.movement-picker select, .manual-fields select { width: 100%; min-height: 42px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--ink); }
.movement-buttons button { min-height: 42px; }
.movement-buttons .primary-button { min-width: 7rem; }
.movement-buttons button:disabled { opacity: .55; cursor: default; }
.movement-timeline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.movement-timeline input { flex: 1 1 180px; min-width: 0; margin: 0; height: 27px; accent-color: var(--blue); cursor: pointer; }
.movement-timeline span { min-width: min(15rem, 100%); color: var(--text); font-size: .8125rem; }
.segmented { display: flex; padding: 3px; gap: 2px; border-radius: 8px; background: #f0f6fc; border: 1px solid var(--line); }
.segmented button { border: 1px solid transparent; border-radius: 5px; min-height: 34px; padding: 5px 9px; font-size: .875rem; font-weight: 700; color: #395973; background: transparent; white-space: nowrap; }
.segmented button[aria-pressed="true"] { border-color: #cddff1; background: #fff; color: var(--navy); box-shadow: 0 1px 2px #063a7611; }
.segmented button:hover:not([aria-pressed="true"]) { color: var(--navy); background-color: #e2effc; }
.pose-modes button[aria-pressed="true"], .drag-switch [data-drag="pose"][aria-pressed="true"] { background: #e2efff; border-color: #bad6f4; color: var(--navy); }
.atlas-stage { display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); position: relative; block-size: clamp(665px, 75vh, 890px); isolation: isolate; overflow: hidden; border-block: 1px solid var(--line); background-color: #f4f9fe; background-image: radial-gradient(#a3c4e36b .7px, transparent .8px); background-size: 18px 18px; }
.viewer-frame { position: absolute; inset: 12px 0; z-index: 1; }
.viewer-frame > canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.viewer-frame > canvas:active { cursor: grabbing; }
.viewer-frame > canvas:focus-visible { outline-offset: -3px; }
.viewer-frame .hotspots { pointer-events: none; }
.viewer-frame .hotspot { pointer-events: auto; }
.pose-handle-layer { position: absolute; z-index: 4; inset: 0; overflow: hidden; pointer-events: none; }
.pose-axis { position: absolute; inset: 0; width: 100%; height: 100%; }
.pose-axis line { stroke: var(--blue); stroke-width: 3; stroke-linecap: round; filter: drop-shadow(0 0 1px white); }
.pose-axis line:first-child { stroke: #46596f; stroke-width: 2; stroke-dasharray: 6 5; }
.pose-handle { position: absolute; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; transform: translate(-50%, -50%); background: transparent; pointer-events: auto; touch-action: none; user-select: none; cursor: ns-resize; }
.pose-handle::before { content: ""; width: 27px; height: 27px; border: 2px solid var(--white); border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 1px var(--navy), 0 2px 5px #063a7666; }
.pose-handle::after { content: ""; position: absolute; width: 12px; height: 10px; background: repeating-linear-gradient(to bottom, var(--white) 0 2px, transparent 2px 4px); border-radius: 1px; }
.pose-handle:hover::before, .pose-handle.is-grabbed::before, .pose-handle:focus-visible::before { background: var(--navy); box-shadow: 0 0 0 4px #086dd933; }
.pose-handle[data-axis="horizontal"] { cursor: ew-resize; }
.pose-handle[data-axis="horizontal"]::after { transform: rotate(90deg); }
.viewer-frame[data-drag="pose"] > canvas { cursor: default; }
.viewer-message { position: absolute; z-index: 2; left: 50%; top: 48%; transform: translate(-50%,-50%); width: max-content; max-width: calc(100% - 32px); text-align: center; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 10px 14px; color: var(--muted); font-size: .9375rem; box-shadow: 0 3px 12px #173a5610; }
.zoom-toolbar { position: absolute; z-index: 3; top: 50%; right: 12px; transform: translateY(-50%); display: grid; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 3px; box-shadow: 0 2px 7px #173a5615; }
.zoom-toolbar button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; background: transparent; border: 0; border-radius: 5px; color: var(--brand); }
.zoom-toolbar button + button { margin-top: 2px; }
.zoom-toolbar button:hover { background: #e9f4ff; }
.zoom-toolbar .icon { width: 17px; height: 17px; }
.body-view { width: 100%; display: grid; justify-items: center; align-items: center; padding: 12px 0; position: relative; }
.rings { position: absolute; width: min(72%, 520px); aspect-ratio: 1; border-radius: 50%; border: 1px solid #c6dcf1; top: 46%; left: 50%; transform: translate(-50%,-50%); opacity: .7; background: radial-gradient(circle at center, #e2f0fba8 45%, #e8f3fd30 63%, transparent 70%); pointer-events: none; }
.rings::before, .rings::after { content: ""; position: absolute; inset: 12%; border: 1px solid #c9ddf0; border-radius: inherit; }
.rings::after { inset: 25%; }
.body-figure { height: min(100%, clamp(470px, 66vh, 735px)); aspect-ratio: 1 / 2; position: relative; }
.body-image { position: absolute; inset: 0; background: url("./assets/anatomy.webp") 20% 0 / 600% 200% no-repeat; mix-blend-mode: multiply; }
.body-figure[data-view="back"] .body-image { background-position-x: 80%; }
.body-figure[data-layer="bone"] .body-image { background-position-y: 100%; }
.hotspots { position: absolute; inset: 0; }
.hotspot { position: absolute; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; transform: translate(-50%, -50%); background: #e8f4ffdf; border: 1px solid #2376b9; border-radius: 50%; }
.hotspot::before { display: block; content: ""; width: 7px; height: 7px; background: #086dd9; border-radius: 50%; box-shadow: 0 0 0 2px #fff; }
.hotspot.active { background: #fbe0d0ac; border-color: #cc6048; box-shadow: 0 0 0 5px #e2795b3a; z-index: 2; }
.hotspot.active::before { background: #d66751; }
.hotspot.active[data-stage="healthy"], .hotspot.active[data-stage="recovery"] { background: #e3f4dedf; border-color: #367541; box-shadow: 0 0 0 5px #3688db36; }
.hotspot.active[data-stage="healthy"]::before, .hotspot.active[data-stage="recovery"]::before { background: #367541; }
.hotspot:hover { z-index: 3; box-shadow: 0 0 0 5px #3688db36; }
.hotspot-label { position: absolute; left: calc(100% + 15px); top: 50%; transform: translateY(-50%); padding: 5px 8px; background: #fff; border: 1px solid var(--line); color: var(--ink); box-shadow: 0 2px 6px #173a5612; border-radius: 5px; white-space: nowrap; font-size: .8125rem; font-weight: 700; pointer-events: none; visibility: hidden; }
.hotspot-label::before { content: ""; position: absolute; right: 100%; top: 50%; width: 16px; height: 1px; background: #7191ad; }
.hotspot[data-label-side="left"] .hotspot-label { left: auto; right: calc(100% + 15px); }
.hotspot[data-label-side="left"] .hotspot-label::before { right: auto; left: 100%; }
.hotspot.active .hotspot-label, .hotspot:hover .hotspot-label, .hotspot:focus-visible .hotspot-label { visibility: visible; }
.atlas-toolbar { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 7px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #f4f9ff; }
.view-switch { background: #fff; box-shadow: 0 2px 7px #173a560e; }
.view-switch button { padding: 6px 9px; }
.view-switch button[aria-pressed="true"] { background: #e3f0ff; border-color: #e3f0ff; box-shadow: none; }
.nerve-isolate, .fiber-toggle { padding: 6px 10px; color: var(--navy); font-size: .8125rem; }
.nerve-isolate[aria-pressed="true"] { background: #fff4d8; border-color: #d9ae5c; color: #754b15; }
.fiber-toggle[aria-pressed="true"] { background: #fff1e9; border-color: #e0b497; color: #873a25; }
.atlas-foot { min-height: 39px; padding: 8px 15px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; color: var(--muted); font-size: .8125rem; }
.atlas-foot span:first-child { display: inline-flex; align-items: center; gap: 7px; }
.atlas-foot span:nth-child(2) { margin-left: auto; }
.atlas-foot a { color: var(--brand); text-underline-offset: 2px; white-space: nowrap; }
.atlas-pose-jump { display: none; grid-area: pose-jump; justify-self: end; font-size: .8125rem; font-weight: 700; text-underline-offset: 2px; }
.atlas-foot i { width: 8px; height: 8px; background: var(--key, #d86852); border-radius: 50%; }
.is-3d .detail-view { z-index: 2; pointer-events: none; }
.is-3d .detail-view .mobile-stages { pointer-events: auto; }
.detail-heading { display: grid; gap: 5px; text-align: center; }
.detail-heading span { font-size: .875rem; color: var(--brand); font-weight: 700; }
.detail-heading strong { font-size: 1.25rem; letter-spacing: -.03em; }
#diagram { width: min(100%, 625px); height: auto; display: block; }
.diagram-legend { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 7px 12px; font-size: .8125rem; color: var(--text); line-height: 1.4; }
.diagram-legend span { display: flex; align-items: center; gap: 6px; }
.diagram-legend i { width: 8px; height: 8px; border-radius: 100%; flex: none; }
.inspector { display: flex; flex-direction: column; padding: 17px; }
.case-heading { display: flex; gap: 10px; align-items: center; margin-bottom: 19px; }
.case-heading h2 { font-size: 1.3125rem; }
.case-region { color: var(--brand); font-size: .8125rem; font-weight: 700; margin-bottom: 4px; }
.field label, .inspector h3 { font-size: .875rem; font-weight: 700; display: block; margin-bottom: 7px; }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; width: 100%; padding: 10px 30px 10px 10px; border: 1px solid var(--line); border-radius: 7px; background: #f8fbff; color: var(--ink); font-weight: 700; font-size: .875rem; }
.select-wrap > span { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); pointer-events: none; color: #466a8a; }
.select-wrap .icon { width: 15px; height: 15px; }
.stages { margin-top: 17px; }
.stage-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.stage-buttons button { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 44px; padding: 6px 5px; line-height: 1.25; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: .8125rem; font-weight: 700; color: var(--muted); }
.stage-buttons button::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #52856b; flex: none; }
.stage-buttons button[data-stage="affected"]::before { background: #d86852; }
.stage-buttons button[aria-pressed="true"] { border-color: #b8dcb1; background: #eff9ec; color: #285f34; }
.stage-buttons button[data-stage="affected"][aria-pressed="true"] { border-color: #f0c4b7; background: #fbefe9; color: #9d4131; }
.stage-buttons button:hover:not([aria-pressed="true"]) { background: #f2f7fd; }
.stage-buttons.mobile-stages { display: none; }
#case-content { margin-top: 15px; }
.state-card { background: #eff9ec; border: 1px solid #d9eace; border-radius: 9px; padding: 12px 11px; }
.state-card.affected { background: #fcf3ee; border-color: #f4e2d7; }
.state-card h3 { margin-bottom: 6px; font-size: .9375rem; color: #30653a; }
.state-card.affected h3 { color: #9f4937; }
.state-card p, .clinical p { font-size: 1rem; line-height: 1.65; color: var(--text); }
.clinical { padding-top: 13px; }
.clinical h3 { margin-bottom: 5px; }
.clinical + .clinical { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.anatomy-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.anatomy-tags span { padding: 3px 6px; font-size: .8125rem; color: #3c5d78; background: #edf5fc; border-radius: 4px; }
.inspector-foot { padding-top: 14px; margin-top: auto; }
.inspector-foot a { display: inline-flex; align-items: center; gap: 5px; font-size: .8125rem; font-weight: 700; text-decoration: none; padding: 3px 0; }
.inspector-foot a:hover { text-decoration: underline; }
.inspector-foot .icon { height: 13px; width: 13px; }
.footer { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; color: var(--muted); font-size: .8125rem; line-height: 1.55; text-align: center; }
.footer .icon { height: 14px; width: 14px; }
dialog { width: min(440px, calc(100vw - 36px)); border: 1px solid var(--line); border-radius: 15px; padding: 25px; color: var(--ink); box-shadow: 0 20px 80px #1637564a; }
dialog::backdrop { background: #132f4c77; }
dialog h2 { font-size: 1.5rem; }
dialog ol { padding-left: 21px; color: var(--text); font-size: 1rem; line-height: 1.7; }
dialog li + li { margin-top: 7px; }
.dialog-close { border: 0; background: transparent; position: absolute; top: 13px; right: 12px; padding: 4px; }
.primary-button { background: var(--brand); color: #fff; border: 0; border-radius: 7px; padding: 8px 13px; font-size: .9375rem; font-weight: 700; }
@media (max-width: 1390px) {
  .shell { width: calc(100% - 36px); }
  .workspace { grid-template-columns: 215px minmax(0, 1fr) 342px; gap: 13px; }
  .inspector { padding: 15px; }
  .atlas-head { padding-inline: 12px; }
}
@media (max-width: 1140px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .navigation { grid-column: 1 / -1; }
  .navigation-head { padding: 10px 12px 4px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .navigation-head .search { margin-top: 0; width: min(300px, 60%); }
  .region-list { display: flex; gap: 10px; overflow-x: auto; padding: 6px 10px 10px; }
  .region-group { display: flex; align-items: center; margin: 0; gap: 4px; }
  .region-label, .region-button > .icon { display: none; }
  .region-button { width: max-content; min-height: 40px; padding-inline: 6px 9px; }
  .region-list.is-searching { max-height: min(38vh, 300px); }
}
@media (max-width: 840px) {
  .shell { width: calc(100% - 24px); }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .navigation { grid-column: auto; }
  .atlas-stage { block-size: clamp(600px, 75vh, 740px); }
  .body-figure { height: min(100%, clamp(375px, 59vh, 600px)); }
  .stage-buttons.mobile-stages { display: grid; width: min(100%, 430px); }
}
@media (max-width: 630px) {
  .shell { width: calc(100% - 20px); }
  .topbar-inner { flex-wrap: wrap; gap: 2px 9px; padding-block: 8px; }
  .brand { gap: 10px; }
  .brand-logo { width: 106px; }
  .brand-app { font-size: 1rem; padding-left: 10px; }
  .main { padding-top: 17px; }
  .intro { margin-bottom: 14px; align-items: start; flex-wrap: wrap; gap: 9px; }
  .intro p { margin-top: 6px; }
  .help-button { padding: 7px 10px; }
  .zoom-toolbar { right: 7px; }
  .zoom-toolbar button { width: 34px; height: 37px; }
  .detail-view { padding-inline: 8px; }
  .inspector { padding: 14px; }
  .footer { padding-inline: 10px; margin-bottom: 7px; }
}

.page-switch { display: flex; align-items: stretch; gap: 4px; }
.page-switch button { display: flex; align-items: center; gap: 7px; background: transparent; border: 1px solid transparent; border-radius: 7px; color: var(--navy); padding: 9px 13px; font-size: .9375rem; font-weight: 700; white-space: nowrap; }
.page-switch button[aria-current="page"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.page-switch button:hover:not([aria-current]) { background: var(--soft); }
.page-switch .icon { height: 15px; width: 15px; }
.atlas-header-controls { grid-area: controls; display: flex; flex-wrap: wrap; gap: 5px; max-width: 100%; }
.drag-switch { flex-wrap: wrap; max-width: 100%; }
.drag-switch button { display: flex; align-items: center; gap: 4px; }
.drag-switch .icon { width: 13px; height: 13px; }
.viewer-frame[data-drag="pan"] > canvas { cursor: move; }
.viewer-frame[data-drag="pan"] > canvas:active { cursor: grabbing; }
.nerve-toggle { display: flex; align-items: center; gap: 5px; }
.nerve-toggle i { width: 7px; height: 7px; border-radius: 50%; background: #d49529; }
.view-switch .nerve-toggle[aria-pressed="true"] { background: #fbedc8; border-color: #ebcf8d; color: #704d12; }
.view-switch .nerve-toggle:disabled { opacity: 0.55; cursor: default; }
.compare-toggle { display: flex; align-items: center; gap: 7px; width: 100%; margin-top: 7px; padding: 8px; border: 1px solid var(--line); background: #fff; border-radius: 7px; color: var(--muted); font-size: .875rem; font-weight: 700; text-align: left; }
.compare-toggle[aria-pressed="true"] { background: #eff7ff; border-color: #c5dcf4; color: var(--navy); }
.compare-toggle .icon, .text-button .icon { width: 14px; height: 14px; }
.compare-toggle:hover { background: #f1f7fe; }
.atlas-stage.is-detail .viewer-frame { inset: 79px 0 120px; }
.atlas-stage.is-comparing .viewer-frame { top: 126px; }
.atlas-stage.is-comparing.is-3d::after { content: ""; position: absolute; z-index: 1; top: 122px; bottom: 125px; left: 50%; height: auto; width: 1px; background: #c9ddef; pointer-events: none; }
.detail-view { display: grid; grid-template: auto auto minmax(0, 1fr) auto auto auto / minmax(0, 1fr); gap: 5px; align-items: center; justify-items: center; padding: 15px 13px 13px; }
.detail-heading { grid-row: 1; gap: 4px; }
.compare-labels { grid-row: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; text-align: center; padding-top: 4px; }
.compare-labels span { justify-self: center; min-height: 34px; padding: 5px 9px; font-size: .875rem; font-weight: 700; border: 1px solid var(--line); color: #355775; border-radius: 6px; background: #fff; }
.compare-labels [data-stage="affected"] { background: #fff0e9; border-color: #efc9bb; color: #944331; }
.compare-labels [data-stage="recovery"] { background: #edf8e8; border-color: #bdddb4; color: #2c6334; }
.compare-labels .current { box-shadow: 0 0 0 2px #448b432e; }
.diagram-row { grid-row: 3; display: flex; align-items: center; justify-content: center; min-width: 0; width: 100%; }
.diagram-row #diagram, .diagram-row #diagram-alternate { display: block; width: min(100%, 625px); height: auto; }
.is-comparing .diagram-row #diagram, .is-comparing .diagram-row #diagram-alternate { width: min(50%, 540px); }
.detail-view > .diagram-legend { grid-row: 4; }
.diagram-observation { grid-row: 5; max-width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fcfdff; color: #2f506a; font-size: .8125rem; line-height: 1.45; text-align: center; }
.is-detail.is-comparing .zoom-toolbar { top: auto; bottom: 127px; transform: none; }
.inspector-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 11px; }
.text-button { display: inline-flex; align-items: center; gap: 5px; padding: 3px 0; border: 0; background: none; color: var(--brand); font-size: .8125rem; font-weight: 700; }
.text-button:hover { text-decoration: underline; }
.catalog-filters { display: grid; grid-template-columns: minmax(215px, 1.8fr) minmax(120px, 1.15fr) minmax(120px, 1.1fr) minmax(120px, 1fr) auto; align-items: end; gap: 12px; padding: 16px; }
.catalog-filters label { display: grid; gap: 7px; color: var(--text); font-size: .875rem; font-weight: 700; min-width: 0; }
.catalog-filters .search { margin: 0; }
.catalog-filters .search input { font-size: .9375rem; padding: 10px 0; }
.catalog-filters select { border: 1px solid var(--line); border-radius: 8px; min-width: 0; width: 100%; padding: 9px 10px; background: #f8fbff; color: var(--text); font-size: .9375rem; font-weight: 400; }
.catalog-filters .catalog-clear { height: 36px; padding: 0 10px; }
.catalog-body { display: grid; grid-template-columns: minmax(275px, 0.9fr) minmax(0, 1.45fr); align-items: stretch; gap: 16px; margin-top: 15px; }
.catalog-list { overflow: hidden; }
.catalog-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line); }
.catalog-list-head > span { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.catalog-items { height: clamp(400px, 64vh, 720px); overflow: auto; padding: 7px; scrollbar-color: #b6d0e8 #f7fbff; }
.catalog-item { display: grid; width: 100%; align-items: start; gap: 9px; grid-template-columns: minmax(52px, max-content) minmax(0, 1fr); text-align: left; padding: 9px 8px; margin-bottom: 3px; border: 1px solid transparent; border-radius: 8px; background: transparent; }
.catalog-item:hover { background: #f2f7fd; }
.catalog-item[aria-pressed="true"] { border-color: #c8e0f7; background: #e7f2ff; }
.catalog-code { display: inline-block; justify-self: start; padding: 5px 7px; border-radius: 5px; background: #edf6ff; color: var(--navy); font-size: .875rem; line-height: 1.3; font-weight: 700; font-variant-numeric: tabular-nums; }
.catalog-item[aria-pressed="true"] .catalog-code { background: #d4e8fc; }
.catalog-item-text { display: grid; gap: 4px; line-height: 1.35; }
.catalog-item-text strong { font-size: .9375rem; font-weight: 700; }
.catalog-item-text small { font-size: .8125rem; color: var(--muted); }
.catalog-detail { padding: 21px; display: flex; flex-direction: column; align-items: start; gap: 14px; }
.catalog-detail h2 { font-size: clamp(1.375rem, 2.53vw, 1.9rem); line-height: 1.25; max-width: 38ch; }
.catalog-detail h3 { font-size: 1rem; margin-bottom: 7px; }
.catalog-detail p { font-size: 1rem; max-width: 68ch; line-height: 1.65; color: var(--text); }
.catalog-entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: #3c5f7b; font-size: .8125rem; font-weight: 700; }
.catalog-definition { width: 100%; padding: 14px; background: var(--soft); border: 1px solid var(--line); border-radius: 9px; }
.catalog-meta-section { padding: 2px 0; }
.catalog-models { display: flex; flex-wrap: wrap; gap: 6px; }
.catalog-models button { border: 1px solid #ccdef0; background: #f3f8fe; color: var(--navy); border-radius: 6px; padding: 7px 8px; font-size: .875rem; text-align: left; }
.catalog-models button:hover { background: #e4f1ff; }
.catalog-source { margin-top: auto; font-size: .875rem; color: var(--brand); text-underline-offset: 2px; }
.catalog-scope { color: var(--muted); margin: 12px 2px 0; font-size: .875rem; line-height: 1.65; }
@media (max-width: 835px) {
  .catalog-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .catalog-query { grid-column: span 2; }
  .catalog-clear { grid-column: 3; grid-row: 1; justify-self: end; }
}
@media (max-width: 840px) {
  .atlas-stage.is-detail .viewer-frame { bottom: 173px; }
  .atlas-stage.is-comparing.is-3d::after, .is-detail.is-comparing .zoom-toolbar { bottom: 176px; }
  .detail-view .mobile-stages { grid-row: 6; margin-top: 3px; }
}
@media (max-width: 630px) {
  .page-switch { width: 100%; flex-wrap: wrap; padding-top: 3px; }
  .page-switch button { padding: 7px 9px; }
  .atlas-stage.is-detail .viewer-frame { bottom: 195px; }
  .atlas-stage.is-comparing.is-3d::after, .is-detail.is-comparing .zoom-toolbar { bottom: 198px; }
  .detail-view { padding: 11px 7px 8px; gap: 4px; }
  .compare-labels span { padding: 4px 5px; font-size: .8125rem; }
  .atlas-toolbar { gap: 4px; padding-inline: 6px; }
  .view-switch button { padding-inline: 6px; }
  .atlas-tabs button, .drag-switch button { padding-inline: 6px; }
  .pose-panel { padding-inline: 11px; }
  .manual-actions .manual-picker { max-width: 100%; }
  .catalog-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 11px; gap: 8px; }
  .catalog-query { grid-column: 1 / -1; }
  .catalog-clear { grid-column: auto; grid-row: auto; }
  .catalog-body { grid-template-columns: 1fr; gap: 10px; margin-top: 10px; }
  .catalog-items { height: min(34vh, 300px); }
  .catalog-detail { padding: 14px; }
}

.case-definition { margin-top: 12px; padding: 10px 11px; border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 8px; background: #f4f9ff; }
.case-definition h3 { margin-bottom: 5px; color: var(--navy); }
.case-definition p { color: var(--text); font-size: 1rem; line-height: 1.6; }
.definition-reading { border-top: 1px solid var(--line); margin-top: .6rem; }
.definition-reading summary { width: fit-content; padding-block: .45rem 0; color: var(--brand); font-size: .875rem; font-weight: 700; cursor: pointer; }
.definition-reading summary:hover { text-decoration: underline; text-underline-offset: 3px; }
.definition-reading-body { display: grid; gap: .65rem; padding-top: .6rem; }
.definition-reading-body a { justify-self: start; font-size: .875rem; line-height: 1.4; overflow-wrap: anywhere; text-underline-offset: 3px; }
.compare-labels > span { max-width: 100%; align-self: start; }
.compare-labels small { display: block; margin-top: 3px; font-size: .91em; line-height: 1.32; font-weight: 400; }
.atlas-stage.is-treatment-example.is-comparing .viewer-frame { top: 147px; }
.atlas-stage.is-treatment-example.is-comparing.is-3d::after { top: 143px; }
.annotation-layer { position: absolute; z-index: 3; inset: 0; overflow: hidden; pointer-events: none; }
.model-annotation { --annotation-color: #365b7f; position: absolute; width: 0; height: 0; }
.model-annotation[data-tone="affected"] { --annotation-color: #a74635; }
.model-annotation[data-tone="recovery"] { --annotation-color: #30653a; }
.model-annotation::before { content: ""; position: absolute; top: -3px; left: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--annotation-color); box-shadow: 0 0 0 2px #fffffff0; }
.model-annotation::after { content: ""; position: absolute; left: 0; top: -13px; height: 11px; border-left: 1px solid var(--annotation-color); }
.model-annotation span { position: absolute; top: -13px; left: var(--label-offset, 0); transform: translate(-50%, -100%); display: block; width: max-content; max-width: var(--label-width, 152px); padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: #fff; box-shadow: 0 2px 4px #173a5615; color: var(--annotation-color); font-size: .8125rem; font-weight: 700; line-height: 1.35; text-align: center; }
.model-annotation[data-below="true"]::after { top: 3px; }
.model-annotation[data-below="true"] span { top: 13px; transform: translateX(-50%); }
@media (max-width: 630px) {
  .atlas-stage.is-treatment-example.is-comparing .viewer-frame { top: 154px; }
  .atlas-stage.is-treatment-example.is-comparing.is-3d::after { top: 150px; }
  .model-annotation span { font-size: .75rem; padding: 2px 4px; }
}
@container atlas (min-width: 52rem) {
  .atlas-head { grid-template: "title controls" auto "subtitle subtitle" auto / minmax(0, 1fr) auto; }
  .atlas-header-controls { justify-content: end; }
}
@container atlas (max-width: 28rem) {
  #atlas-subtitle { min-block-size: 2.9em; }
}
@media (max-width: 840px) {
  .atlas-head { grid-template: "title pose-jump" auto "subtitle subtitle" auto "controls controls" auto / minmax(0, 1fr) auto; }
  .atlas-header-controls { justify-content: start; }
  .atlas-pose-jump { display: inline-flex; visibility: hidden; }
  .workspace:has(#pose-panel:not([hidden])) .atlas-pose-jump { visibility: visible; }
}
@media (max-width: 365px) {
  .navigation-head { align-items: stretch; flex-direction: column; }
  .navigation-head .search { width: 100%; }
}
