:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1b1b1d;
  background: #f5f4f1;
  font-synthesis: none;
  --surface: #ffffff;
  --surface-soft: #f7f6f3;
  --line: rgba(27, 27, 29, 0.10);
  --line-strong: rgba(27, 27, 29, 0.16);
  --muted: rgba(27, 27, 29, 0.58);
  --shadow: 0 10px 32px rgba(27, 27, 29, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background: #f5f4f1;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="search"] {
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
}

.stage {
  min-width: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow,
.question-label {
  margin: 0 0 5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 11px;
  font-weight: 760;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: clamp(20px, 2vw, 26px);
  line-height: 1.05;
  letter-spacing: -0.018em;
}

.brand {
  display: grid;
  gap: 3px;
}

.brand-author {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .02em;
}

.score {
  display: none !important;
}

.mode-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 13px;
  background: rgba(27, 27, 29, .055);
}

.mode-switch button {
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 650;
}

.mode-switch button.active {
  background: #fff;
  box-shadow: 0 1px 6px rgba(27, 27, 29, .12);
}

.viewer-wrap {
  --display-panel-width: clamp(340px, 36vw, 410px);
  position: relative;
  flex: 1;
  min-height: 640px;
  overflow: hidden;
  border-radius: 24px;
  background: #dedbd4;
  box-shadow:
    inset 0 0 0 1px rgba(27, 27, 29, .06),
    0 8px 28px rgba(27, 27, 29, .055);
}

#viewer {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: rgba(245, 244, 241, .9);
  font-weight: 680;
  z-index: 7;
}

.loading.is-hidden {
  display: none;
}

.viewer-tools {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  z-index: 5;
  pointer-events: none;
}

.viewer-tools button,
.viewer-tools > select,
.display-panel-toggle {
  pointer-events: auto;
  min-height: 36px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(27, 27, 29, .11);
  background: rgba(255, 255, 255, .90);
  color: inherit;
  backdrop-filter: blur(12px);
  font-size: 12px;
  font-weight: 620;
  box-shadow: 0 2px 10px rgba(27, 27, 29, .055);
}

.viewer-tools button:disabled {
  display: none;
}

.viewer-quick-toggle[aria-pressed="true"] {
  background: rgba(255, 255, 255, .98);
  border-color: rgba(72, 96, 71, .34);
  box-shadow: 0 2px 10px rgba(27, 27, 29, .055), inset 0 0 0 1px rgba(72, 96, 71, .12);
}

.viewer-quick-toggle[aria-pressed="true"]::before {
  content: "✓";
  margin-right: 5px;
  font-size: 11px;
}

.display-panel-toggle {
  pointer-events: auto;
}

.display-panel {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 8;
  width: var(--display-panel-width);
  height: 100%;
  min-width: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0;
  border-right: 1px solid var(--line);
  background: rgba(250, 249, 247, .99);
  box-shadow: 10px 0 30px rgba(27,27,29,.10);
  scrollbar-width: thin;
}

.display-panel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 16px 18px 13px;
  background: rgba(250,249,247,.98);
  border-bottom: 1px solid var(--line);
}

.display-panel-head > div {
  display: grid;
  gap: 2px;
}

.display-panel-head strong {
  font-size: 15px;
}

.display-panel-head span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.display-panel-close {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}

.display-section {
  display: grid;
  gap: 10px;
  padding: 15px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.display-section:last-child {
  border-bottom: 0;
}

.display-section h3 {
  margin: 0;
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: .01em;
}

.display-section-head {
  display: grid;
  gap: 3px;
}

.display-section-head > span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.display-layer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.display-layer-actions button {
  min-height: 38px;
  padding: 8px 9px;
  font-size: 11px;
}

body:not(.motion-mode) .viewer-wrap.display-panel-open .comparison-pane-static {
  left: var(--display-panel-width);
  right: 0;
  width: auto;
  margin: 0;
}

.viewer-wrap.display-panel-open .viewer-tools {
  left: calc(var(--display-panel-width) + 12px);
}

.viewer-wrap.display-panel-open .viewer-hint {
  left: calc(var(--display-panel-width) + 12px);
}

.viewer-setting-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  font-weight: 680;
  color: var(--muted);
}

.viewer-setting-field select,
.viewer-setting-field input[type="range"] {
  width: 100%;
}

.viewer-setting-field select {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: #1b1b1d;
  padding: 7px 9px;
}

.viewer-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(10px);
  color: rgba(27,27,29,.66);
  font-size: 11px;
  line-height: 1.25;
  pointer-events: none;
}

.panel {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.question-card,
.debug {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  padding: 18px;
}

.question-card {
  box-shadow: 0 3px 16px rgba(27,27,29,.035);
}

.question-card h2 {
  margin: 0;
  font-size: clamp(23px, 2.25vw, 31px);
  line-height: 1.08;
  letter-spacing: -0.018em;
  overflow-wrap: anywhere;
}

.feedback {
  min-height: 2.9em;
  line-height: 1.45;
  margin: 12px 0 0;
  color: rgba(27,27,29,.78);
}

.feedback.correct {
  font-weight: 680;
}

.feedback.wrong {
  font-weight: 650;
}

.structure-reference {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}

.structure-reference-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.structure-reference-head strong {
  font-size: 12px;
}

.structure-reference-head span {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.structure-reference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.structure-reference-grid > div {
  min-width: 0;
  padding: 8px;
  border-radius: 10px;
  background: #fff;
}

.structure-reference-grid dt {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.structure-reference-grid dd {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.structure-reference-media {
  display: grid;
  gap: 4px;
  padding-top: 2px;
  color: rgba(27,27,29,.76);
  font-size: 11px;
  line-height: 1.4;
}

.structure-reference-media strong {
  color: #1b1b1d;
}

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

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 16px;
}

.actions.next-only {
  grid-template-columns: 1fr;
}

button {
  border: 1px solid var(--line-strong);
  background: #f4f3f0;
  color: inherit;
  border-radius: 11px;
  padding: 10px 13px;
  cursor: pointer;
}

button.primary,
.learning-start {
  background: #1b1b1d;
  color: #fff;
  border-color: #1b1b1d;
  font-weight: 720;
}

button:disabled {
  opacity: .42;
  cursor: default;
}

.learning-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
  margin-bottom: 8px;
}

.learning-field,
.learning-mode-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.learning-field > span,
.learning-mode-field > span,
.search-field > span {
  font-size: 11px;
  font-weight: 720;
  color: var(--muted);
}

.explore-start-hint {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.explore-start-hint strong {
  color: var(--text);
  font-weight: 760;
}

.learning-mode-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.learning-mode-buttons button {
  min-height: 40px;
  padding: 8px 9px;
  background: #fff;
  border-color: var(--line);
  font-size: 12px;
  font-weight: 680;
}

.learning-mode-buttons button.active {
  background: #1b1b1d;
  border-color: #1b1b1d;
  color: #fff;
}

.display-panel-toggle.active,
.display-panel-toggle[aria-expanded="true"] {
  background: #1b1b1d;
  border-color: #1b1b1d;
  color: #fff;
  box-shadow: 0 4px 14px rgba(27, 27, 29, .16);
}

.learning-mode-buttons button:disabled {
  opacity: .34;
}

.learning-field select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  padding: 8px 9px;
}

.learning-start {
  min-height: 40px;
  align-self: end;
}

.learning-summary {
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.session-active .scope-controls,
.session-active .learning-controls,
.session-active .learning-summary,
.session-active #model-source-field {
  display: none;
}

.session-progress {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin: 0 0 13px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(27,27,29,.045);
  color: rgba(27,27,29,.7);
  font-size: 11px;
  line-height: 1.35;
}

.session-progress::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 auto 0 0;
  width: var(--session-progress, 0%);
  background: rgba(27,27,29,.055);
  transition: width .2s ease;
}

.session-exit {
  width: fit-content;
  min-height: 36px;
  margin: -6px 0 9px;
  padding: 7px 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 12px;
  font-weight: 620;
  text-decoration: none;
}

.session-exit:hover {
  color: #1b1b1d;
}

.name-choices {
  display: grid;
  gap: 7px;
  margin: 12px 0 2px;
}

.name-choice {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 10px 11px;
  color: inherit;
  cursor: pointer;
}

.name-choice:hover {
  background: #f8f7f4;
}

.name-choice.correct {
  border-color: rgba(22,129,72,.38);
  background: rgba(22,129,72,.07);
}

.name-choice.wrong {
  border-color: rgba(117,29,40,.35);
  background: rgba(117,29,40,.06);
}

#reveal-deeper {
  grid-column: 1 / -1;
}

.explore-controls {
  margin-top: 16px;
}

.search-field {
  display: grid;
  gap: 7px;
}

.search-field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  padding: 10px 11px;
  background: #fff;
  color: inherit;
}

.search-results {
  display: grid;
  gap: 5px;
  margin-top: 7px;
  max-height: 270px;
  overflow: auto;
}

.search-result {
  text-align: left;
  padding: 9px 10px;
  background: #faf9f7;
}

.search-empty {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.layer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 12px;
}

.debug summary {
  cursor: pointer;
  font-weight: 700;
}

.debug p,
.target-status,
.attribution {
  margin: 0;
  line-height: 1.45;
  font-size: 12px;
}

.target-status {
  margin: 10px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.debug pre {
  max-height: 230px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 10px;
}

.attribution {
  margin-top: auto;
  color: var(--muted);
}

.attribution a {
  color: inherit;
}

.embed-mode .stage,
.embed-mode .panel {
  padding-top: 12px;
  padding-bottom: 12px;
}

.embed-mode .eyebrow {
  display: none;
}

.embed-mode h1 {
  font-size: clamp(24px, 3vw, 36px);
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 14px;
  }

  .viewer-wrap {
    min-height: 56dvh;
  }

  .task-docked .viewer-wrap {
    min-height: 76dvh;
  }

  .task-docked .viewer-wrap > .question-card {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 6;
    max-height: min(52dvh, 58%);
    overflow: auto;
    border-radius: 16px;
    padding: 14px;
    background: rgba(255,255,255,.965);
    box-shadow: 0 12px 36px rgba(27,27,29,.18);
    backdrop-filter: blur(16px);
  }

  .task-docked:not(.session-active) .viewer-wrap > .question-card {
    max-height: min(46dvh, 52%);
  }

  .task-docked .viewer-hint {
    display: none;
  }

  .task-docked .viewer-tools {
    right: 10px;
  }

  .session-active.task-docked .question-card h2 {
    font-size: clamp(21px, 6vw, 27px);
  }
}

@media (max-width: 620px) {
  .stage,
  .panel {
    padding: 12px;
  }

  .stage {
    gap: 10px;
  }

  .topbar {
    align-items: flex-start;
    gap: 10px;
  }

  .topbar-tools {
    justify-content: flex-end;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: clamp(19px, 5.5vw, 23px);
  }

  .brand-author {
    font-size: 10px;
  }

  .viewer-wrap {
    --display-panel-width: min(92%, 380px);
  }

  .display-panel {
    width: var(--display-panel-width);
    min-width: 0;
  }

  body:not(.motion-mode) .viewer-wrap.display-panel-open .comparison-pane-static {
    left: 0;
    right: 0;
  }

  .viewer-wrap.display-panel-open .viewer-tools {
    opacity: 0;
    pointer-events: none;
  }

  .viewer-wrap.display-panel-open .viewer-hint {
    left: 12px;
  }

  .structure-reference-grid {
    grid-template-columns: 1fr;
  }

  .viewer-wrap {
    min-height: 54dvh;
    border-radius: 18px;
  }

  .task-docked .viewer-wrap {
    min-height: 78dvh;
  }

  .viewer-tools {
    top: 9px;
    left: 9px;
    right: 9px;
    gap: 5px;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  /* Mobile Atlas keeps the model as the primary workspace. Camera shortcuts
     remain available on larger screens; on touch screens they are redundant
     with direct rotate/zoom gestures and otherwise cover the anatomy. */
  body:not(.motion-mode) .viewer-tools #view-preset,
  body:not(.motion-mode) .viewer-tools #focus-shoulder,
  body:not(.motion-mode) .viewer-tools #focus-selected,
  body:not(.motion-mode) .viewer-tools #focus-full {
    display: none;
  }

  body:not(.motion-mode) .viewer-tools #toggle-skeleton,
  body:not(.motion-mode) .viewer-tools #display-panel-toggle {
    flex: 0 0 auto;
  }

  body:not(.motion-mode) .viewer-tools #display-panel-toggle[aria-expanded="true"] {
    min-width: 132px;
  }

  .viewer-tools button,
  .viewer-tools > select,
  .viewer-settings > summary {
    min-height: 36px;
    padding: 6px 9px;
    font-size: 11px;
  }

  .viewer-hint {
    left: 9px;
    bottom: 9px;
    max-width: calc(100% - 18px);
    border-radius: 12px;
    white-space: normal;
  }

  .learning-controls {
    grid-template-columns: 1fr 1fr;
  }

  .learning-start {
    width: 100%;
  }

  .session-exit {
    min-height: 40px;
  }

  .actions,
  .layer-actions {
    grid-template-columns: 1fr;
  }

  .panel {
    gap: 12px;
  }

  .attribution {
    font-size: 11px;
  }
}

@media (max-width: 430px) {
  .topbar {
    flex-direction: column;
  }

  .topbar-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .learning-controls {
    grid-template-columns: 1fr;
  }

  .task-docked .viewer-wrap > .question-card {
    max-height: 55dvh;
  }
}


.hint-touch { display: none; }
.hint-pointer { display: inline; }

.feedback {
  white-space: pre-line;
}

@media (pointer: coarse) {
  .hint-touch { display: inline; }
  .hint-pointer { display: none; }
}

@media (max-width: 620px) {
  .session-active.task-docked .topbar,
  .session-active.task-docked .attribution,
  .session-active.task-docked .panel {
    display: none;
  }

  .session-active.task-docked #focus-full {
    display: none;
  }

  .session-active.task-docked .stage {
    padding-top: 8px;
  }

  .session-active.task-docked .viewer-wrap {
    min-height: 88dvh;
  }
}


.session-active .viewer-settings,
.session-active .viewer-hint,
.session-active .attribution {
  display: none;
}


.today-start {
  width: 100%;
  min-height: 40px;
  margin: -4px 0 14px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-weight: 700;
  text-align: left;
}

.today-start:hover {
  background: #f8f7f4;
}

.session-active .today-start {
  display: none !important;
}


.learning-progress {
  margin: -2px 0 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.learning-progress > summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 720;
}

.learning-progress > summary::-webkit-details-marker {
  display: none;
}

.learning-progress-content {
  display: grid;
  gap: 14px;
  padding: 0 0 14px;
}

.progress-block {
  display: grid;
  gap: 7px;
}

.progress-block h3 {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
}

.progress-line,
.progress-history-line {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.progress-region-list {
  display: grid;
  gap: 5px;
}

.progress-region-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) 1fr;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid rgba(27,27,29,.065);
  font-size: 11px;
  line-height: 1.35;
}

.progress-region-row:first-child {
  border-top: 0;
}

.progress-region-name {
  font-weight: 650;
}

.progress-region-stats {
  color: var(--muted);
  text-align: right;
}

.progress-weak-list,
.progress-confusion-list {
  display: grid;
  gap: 6px;
}

.progress-weak-item {
  font-size: 12px;
  line-height: 1.4;
}

.progress-weak-item strong {
  font-weight: 680;
}

.progress-confusion {
  width: 100%;
  min-height: 38px;
  text-align: left;
  background: #fff;
  border-color: var(--line);
  font-size: 12px;
}

.session-active .learning-progress {
  display: none;
}

@media (max-width: 430px) {
  .progress-region-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .progress-region-stats {
    text-align: left;
  }
}


.learning-mode-buttons [data-learning-mode="exam"] {
  grid-column: 1 / -1;
}


.connective-layer-options {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 7px;
}

.connective-layer-options legend {
  margin: 0 0 2px;
  padding: 0;
  font-size: 11px;
  font-weight: 720;
  color: var(--muted);
}

.connective-layer-options label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(27,27,29,.78);
}

.connective-layer-options input {
  margin: 0;
  flex: 0 0 auto;
}

.viewer-setting-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}


.learning-summary {
  white-space: pre-line;
}

.learning-field select optgroup {
  font-weight: 700;
}

.learning-field select option {
  font-weight: 400;
}

.session-active .name-choice:disabled:not(.correct):not(.wrong) {
  opacity: .72;
}


.scope-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.scope-isolation {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1.25;
  color: var(--muted);
  white-space: nowrap;
}

.scope-isolation input {
  margin: 0;
}

@media (max-width: 700px) {
  .scope-controls {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .scope-isolation {
    min-height: 28px;
  }
}


#peel-surface-layer {
  white-space: normal;
}


.deeper-structures {
  margin: 13px 0 2px;
  padding: 12px;
  border: 1px solid rgba(36, 93, 168, .24);
  border-left-width: 3px;
  border-radius: 13px;
  background: rgba(36, 93, 168, .055);
}

.deeper-structures-head {
  display: grid;
  gap: 3px;
  margin-bottom: 9px;
}

.deeper-structures-head strong {
  font-size: 13px;
  line-height: 1.25;
  color: rgba(25, 69, 128, .98);
}

.deeper-structures-head span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.deeper-structure-list {
  display: grid;
  gap: 6px;
}

.deeper-structure {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(82px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  text-align: left;
  background: #fff;
  border-color: var(--line);
}

.deeper-structure:hover {
  border-color: var(--line-strong);
  background: #f9f8f5;
}

.deeper-structure-depth {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .045em;
}

.deeper-structure strong {
  min-width: 0;
  font-size: 12px;
  line-height: 1.3;
}

.deeper-focus-feedback {
  color: rgba(27,27,29,.72);
}

@media (max-width: 430px) {
  .deeper-structure {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}


.source-coverage-note {
  margin: 8px 0 0;
  padding: 10px 11px;
  border: 1px solid rgba(137, 92, 24, .28);
  border-radius: 11px;
  background: rgba(179, 119, 30, .08);
  color: rgba(77, 52, 17, .92);
  font-size: 12px;
  line-height: 1.45;
}

.source-coverage-note[hidden] {
  display: none;
}


.feedback.navigation {
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(154, 107, 24, .08);
  color: rgba(78, 53, 12, .92);
}

#reveal-deeper:not([hidden]) {
  font-weight: 720;
  border-color: rgba(154, 107, 24, .34);
  background: rgba(154, 107, 24, .08);
}


.topography-choice {
  border-left-width: 3px;
}

.learning-mode-buttons [data-learning-mode="topography"]:not(:disabled) {
  border-color: rgba(36, 93, 168, .26);
}


/* Six learning modes form three stable pairs. */
.learning-mode-buttons [data-learning-mode="exam"] {
  grid-column: auto;
}


/* Motion comparison: atlas stays single-pane; only Motion splits the viewer. */
.comparison-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.comparison-pane-static {
  width: 100%;
  height: 100%;
}

.comparison-pane-motion {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

#motion-viewer {
  grid-row: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  outline: none;
}

#motion-viewer:active {
  cursor: grabbing;
}

.motion-only-label {
  display: none;
}

.comparison-pane-label {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(27,27,29,.10);
  color: rgba(27,27,29,.74);
  backdrop-filter: blur(10px);
  font-size: 11px;
  font-weight: 720;
  pointer-events: none;
}

.motion-state {
  position: relative;
  grid-row: 2;
  left: auto;
  right: auto;
  bottom: auto;
  z-index: 4;
  display: grid;
  gap: 3px;
  max-height: min(32vh, 260px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 11px;
  border-radius: 0;
  background: rgba(255,255,255,.98);
  border: 0;
  border-top: 1px solid rgba(27,27,29,.12);
  backdrop-filter: none;
  pointer-events: auto;
  scrollbar-width: thin;
}

.motion-state strong {
  font-size: 12px;
  line-height: 1.25;
}

.motion-state span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.motion-mode .viewer-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  background: rgba(27,27,29,.12);
}

.motion-mode .comparison-pane {
  background: #dedbd4;
}

.motion-mode .motion-only-label {
  display: block;
}

.motion-mode .viewer-tools {
  right: calc(50% + 12px);
}

.motion-mode .layer-actions {
  display: none;
}

.motion-mode .viewer-hint {
  max-width: calc(50% - 24px);
}

@media (max-width: 760px) {
  .motion-mode .viewer-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(46dvh, 1fr) minmax(46dvh, 1fr);
    min-height: 96dvh;
  }

  .motion-mode .viewer-tools {
    right: 10px;
  }

  .motion-mode .viewer-hint {
    max-width: calc(100% - 24px);
  }

  .motion-mode .comparison-pane-label {
    top: 9px;
    right: 9px;
  }
}


/* Outside Motion the wrapper must behave exactly like the original single canvas. */
body:not(.motion-mode) .comparison-pane-static {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
}

.motion-mode .comparison-pane-static {
  position: relative;
  inset: auto;
  width: auto;
  height: auto;
}


/* Primary workspaces must never collapse into a submenu. */
@media (max-width: 620px) {
  .mode-switch {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mode-switch button {
    min-width: 0;
    padding-inline: 8px;
    text-align: center;
  }
}

@media (max-width: 430px) {
  .topbar-tools .mode-switch {
    width: 100%;
  }
}


.motion-state {
  pointer-events: auto;
}

.motion-controls {
  display: grid;
  gap: 7px;
  margin-top: 7px;
  padding-top: 8px;
  border-top: 1px solid rgba(27,27,29,.10);
}

.motion-angle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  font-weight: 700;
}

.motion-angle-row output {
  font-variant-numeric: tabular-nums;
}

#motion-angle {
  width: 100%;
  margin: 0;
  accent-color: currentColor;
}

.motion-control-buttons,
.motion-button-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.motion-button-row button,
.motion-control-buttons button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 11px;
}


.motion-movement-row {
  display: grid;
  gap: 5px;
}

.motion-movement-row > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.motion-movement-row select {
  width: 100%;
}

.motion-range-note {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}


.motion-role-summary {
  display: grid;
  gap: 4px;
  font-size: 10px;
  line-height: 1.4;
}

.motion-role-summary span {
  color: var(--muted);
}

.motion-role-summary strong {
  color: var(--ink);
}


/* Mobile Motion Lab: movement is the primary workspace.
   The static atlas becomes a compact context preview instead of a second
   full-height viewport. */
.motion-atlas-return {
  font: inherit;
  cursor: pointer;
}

@media (max-width: 760px) {
  body.motion-mode {
    overflow-x: hidden;
  }

  body.motion-mode .app-shell {
    min-height: 100dvh;
    grid-template-columns: 1fr;
  }

  body.motion-mode .panel {
    display: none;
  }

  body.motion-mode .stage {
    min-height: 100dvh;
    padding: 8px;
    gap: 8px;
  }

  body.motion-mode .topbar > div:first-child {
    display: none;
  }

  body.motion-mode .topbar,
  body.motion-mode .topbar-tools {
    width: 100%;
  }

  body.motion-mode .topbar-tools {
    justify-content: stretch;
  }

  body.motion-mode .mode-switch {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.motion-mode .mode-switch button {
    min-width: 0;
    min-height: 40px;
  }

  body.motion-mode .viewer-wrap {
    display: block;
    flex: none;
    width: 100%;
    height: calc(100dvh - 64px);
    min-height: 620px;
    border-radius: 18px;
    overflow: hidden;
    background: #dedbd4;
  }

  body.motion-mode .comparison-pane-motion {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  body.motion-mode .comparison-pane-static {
    position: absolute;
    inset: 12px auto auto 12px;
    width: min(32vw, 138px);
    height: min(23dvh, 180px);
    z-index: 7;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(27,27,29,.14);
    background: #dedbd4;
    box-shadow: 0 8px 26px rgba(27,27,29,.18);
  }

  body.motion-mode .comparison-pane-static #viewer {
    pointer-events: none;
  }

  body.motion-mode .motion-atlas-return {
    display: block;
    top: auto;
    right: 7px;
    bottom: 7px;
    min-height: 32px;
    padding: 5px 9px;
    border: 1px solid rgba(27,27,29,.12);
    background: rgba(255,255,255,.94);
    color: rgba(27,27,29,.82);
    pointer-events: auto;
    font-size: 11px;
    font-weight: 720;
  }

  body.motion-mode .comparison-pane-motion > .comparison-pane-label {
    top: 10px;
    right: 10px;
  }

  body.motion-mode .viewer-tools,
  body.motion-mode .viewer-hint {
    display: none;
  }

  body.motion-mode .motion-state {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    max-height: min(28dvh, 220px);
    overflow-y: auto;
    overscroll-behavior: contain;
    gap: 4px;
    padding: 8px 10px;
    border-radius: 0;
    box-shadow: none;
    scrollbar-width: thin;
  }

  body.motion-mode .motion-state.motion-state-controls {
    max-height: min(26dvh, 205px);
  }

  body.motion-mode .motion-state > strong {
    padding-right: 68px;
    font-size: 12px;
    line-height: 1.2;
  }

  body.motion-mode .motion-state.motion-state-controls > span,
  body.motion-mode .motion-state.motion-state-controls > small,
  body.motion-mode .motion-state.motion-state-controls > .motion-role-summary {
    display: none;
  }

  body.motion-mode .motion-controls {
    position: static;
    margin-top: 2px;
    padding: 4px 0 0;
    gap: 4px;
    border-top: 0;
    border-bottom: 0;
    background: transparent;
  }

  body.motion-mode .motion-movement-row {
    gap: 2px;
  }

  body.motion-mode .motion-movement-row > span {
    display: none;
  }

  body.motion-mode .motion-movement-row select {
    min-height: 34px;
  }

  body.motion-mode .motion-angle-row {
    font-size: 10px;
  }

  body.motion-mode #motion-angle {
    min-height: 22px;
    touch-action: pan-x;
  }

  body.motion-mode .motion-control-buttons button,
  body.motion-mode .motion-button-row button {
    min-height: 34px;
    padding-block: 5px;
  }
}

@media (max-width: 430px) {
  body.motion-mode .viewer-wrap {
    height: calc(100dvh - 62px);
    min-height: 560px;
  }

  body.motion-mode .comparison-pane-static {
    width: min(30vw, 112px);
    height: min(16dvh, 120px);
  }

  body.motion-mode .motion-state,
  body.motion-mode .motion-state.motion-state-controls {
    max-height: min(27dvh, 198px);
  }
}


/* User-facing Motion reset: one independent motion workspace. */
@media (min-width: 761px) {
  body.motion-mode .viewer-wrap {
    display: block;
    background: #dedbd4;
  }

  body.motion-mode .comparison-pane-static {
    display: none !important;
  }

  body.motion-mode .comparison-pane-motion {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
  }

  body.motion-mode #motion-viewer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  body.motion-mode .viewer-tools,
  body.motion-mode .viewer-hint,
  body.motion-mode .motion-atlas-return {
    display: none !important;
  }

  body.motion-mode.motion-controls-docked .motion-state {
    position: relative;
    inset: auto;
    display: grid;
    max-height: none;
    overflow: visible;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid rgba(27,27,29,.10);
    border-radius: 14px;
    background: rgba(255,255,255,.92);
    box-shadow: none;
  }

  body.motion-mode.motion-controls-docked .motion-state strong {
    font-size: 13px;
  }

  body.motion-mode.motion-controls-docked .motion-state span,
  body.motion-mode.motion-controls-docked .motion-state small {
    font-size: 11px;
    line-height: 1.4;
  }
}

@media (max-width: 760px) {
  body.motion-mode .comparison-pane-static {
    display: none !important;
  }

  body.motion-mode .comparison-pane-motion {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
}


.structure-reference-facts {
  display: grid;
  gap: 8px;
}

.structure-reference-facts > div {
  display: grid;
  gap: 3px;
}

.structure-reference-facts strong {
  font-size: 10px;
  color: var(--muted);
}

.structure-reference-facts span,
.structure-reference-facts li {
  font-size: 11px;
  line-height: 1.42;
}

.structure-reference-facts ul {
  margin: 0;
  padding-left: 17px;
}

.structure-reference-source-list {
  display: grid;
  gap: 3px;
}

.structure-reference-source-item {
  display: grid;
  gap: 1px;
  padding: 6px 8px;
  border-radius: 9px;
  background: #fff;
}

.structure-reference-source-item strong {
  font-size: 10px;
}

.structure-reference-source-item span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.structure-reference-figure {
  display: grid;
  gap: 5px;
  margin: 7px 0 0;
}

.structure-reference-figure img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.structure-reference-figure figcaption {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}


/* Full muscle reference card: learner-facing hierarchy and progressive disclosure. */
.structure-reference {
  gap: 12px;
  padding: 14px;
  border-color: rgba(27,27,29,.16);
  background: #fff;
  box-shadow: 0 5px 18px rgba(27,27,29,.055);
  scroll-margin-top: 12px;
}

.structure-reference-head {
  align-items: flex-start;
  padding-bottom: 2px;
}

.structure-reference-head strong {
  font-size: 14px;
  line-height: 1.25;
}

.structure-reference-head span {
  max-width: 68%;
  font-size: 11px;
  line-height: 1.35;
  font-style: italic;
}

.structure-reference-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.structure-reference-grid > div {
  padding: 8px 9px;
}

.structure-reference-grid dd {
  font-size: 11.5px;
  line-height: 1.38;
}

.structure-reference-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.structure-reference-badges > span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(27,27,29,.065);
  color: rgba(27,27,29,.72);
  font-size: 10px;
  font-weight: 680;
  line-height: 1.2;
}

.structure-reference-context {
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.42;
}


.structure-reference-primary-art {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.structure-reference-primary-art-image {
  width: min(100%, 330px);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: #f5f4ef;
  background-repeat: no-repeat;
  background-size: 600% 100%;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.42);
}

.structure-reference-primary-art figcaption {
  display: grid;
  gap: 2px;
  margin: 0;
  text-align: center;
}

.structure-reference-primary-art figcaption strong {
  font-size: 11.5px;
  line-height: 1.35;
}

.structure-reference-primary-art figcaption span {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

.structure-reference-atlas-block {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.structure-reference-atlas-block > strong {
  font-size: 11.5px;
}

.structure-reference-atlas-block > span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.structure-reference-ambiguity {
  display: grid;
  gap: 6px;
  padding: 10px 11px;
  border: 1px solid rgba(146,95,24,.20);
  border-radius: 11px;
  background: rgba(168,119,46,.075);
}

.structure-reference-ambiguity strong {
  font-size: 12px;
}

.structure-reference-ambiguity p,
.structure-reference-ambiguity li {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.42;
}

.structure-reference-ambiguity ul {
  margin: 0;
  padding-left: 18px;
}

.structure-reference-facts {
  gap: 9px;
}

.structure-reference-primary {
  display: grid;
  gap: 5px;
  padding: 10px 11px;
  border-radius: 11px;
  background: #fff;
}

.structure-reference-primary > strong,
.structure-reference-study-cue > strong,
.structure-reference-fact > strong {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 730;
  line-height: 1.3;
}

.structure-reference-primary ul,
.structure-reference-fact ul {
  margin: 0;
  padding-left: 18px;
}

.structure-reference-primary li,
.structure-reference-fact li,
.structure-reference-fact > span {
  font-size: 12.5px;
  line-height: 1.45;
}

.structure-reference-primary li + li,
.structure-reference-fact li + li {
  margin-top: 3px;
}

.structure-reference-study-cue {
  display: grid;
  gap: 4px;
  padding: 9px 10px 9px 12px;
  border-left: 3px solid rgba(27,27,29,.28);
  border-radius: 8px;
  background: rgba(255,255,255,.62);
}

.structure-reference-study-cue > span {
  font-size: 12px;
  line-height: 1.45;
}

.structure-reference-details {
  border-top: 1px solid var(--line);
}

.structure-reference-details > summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
  color: rgba(27,27,29,.82);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.35;
}

.structure-reference-details > summary::-webkit-details-marker {
  display: none;
}

.structure-reference-details > summary::after {
  content: "⌄";
  margin-left: auto;
  padding-left: 10px;
  color: var(--muted);
  font-size: 14px;
  transition: transform .15s ease;
}

.structure-reference-details[open] > summary {
  color: #1b1b1d;
}

.structure-reference-details[open] > summary::after {
  transform: rotate(180deg);
}

.structure-reference-details-body {
  display: grid;
  gap: 9px;
  padding: 0 0 10px;
}

.structure-reference-fact {
  display: grid;
  gap: 4px;
}

.structure-reference-sources-details .structure-reference-media {
  padding: 0 0 10px;
}

.structure-reference-source-item {
  gap: 3px;
  padding: 7px 8px;
}

.structure-reference-source-item strong,
.structure-reference-source-link {
  color: #1b1b1d;
  font-size: 10.5px;
  font-weight: 690;
  line-height: 1.35;
}

.structure-reference-source-link {
  text-decoration: underline;
  text-decoration-color: rgba(27,27,29,.22);
  text-underline-offset: 2px;
}

.structure-reference-source-item span {
  font-size: 10px;
  line-height: 1.4;
}

.structure-reference-empty {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

@media (max-width: 620px) {
  .structure-reference {
    padding: 12px;
  }

  .structure-reference-head span {
    max-width: 62%;
  }

  .structure-reference-primary li,
  .structure-reference-fact li,
  .structure-reference-fact > span {
    font-size: 12px;
  }
}

/* Atlas controls: area selection, structure actions and display controls have separate roles. */
.scope-controls {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.explore-controls {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.selected-structure-actions {
  display: grid;
  gap: 6px;
}

.control-group-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
}

.restore-view-actions {
  padding-top: 2px;
}

.restore-view-actions button {
  width: 100%;
  min-height: 38px;
  background: #fff;
  border-color: var(--line);
}

@media (min-width: 621px) {
  .selected-structure-actions .layer-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.selected-structure-actions-primary {
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.7);
}

.selected-structure-actions-primary .layer-actions {
  margin-top: 2px;
}

.support-layer-toggle {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #1b1b1d;
  cursor: pointer;
}

.support-layer-toggle > input {
  margin: 2px 0 0;
  flex: 0 0 auto;
}

.support-layer-toggle > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.support-layer-toggle strong {
  font-size: 12px;
  line-height: 1.25;
}

.support-layer-toggle small,
.layer-control-note {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.secondary-display-action {
  width: 100%;
  min-height: 36px;
  background: #fff;
  border-color: var(--line);
  font-size: 11px;
}

.connective-layer-options {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.62);
}


.structure-reference-functional {
  display: grid;
  gap: 8px;
  padding: 0 0 10px;
}

.structure-reference-functional-row {
  display: grid;
  gap: 6px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255,255,255,.62);
}

.structure-reference-functional-row > strong {
  font-size: 11px;
  line-height: 1.35;
}

.structure-reference-functional-group {
  display: grid;
  grid-template-columns: minmax(92px, .7fr) minmax(0, 1.6fr);
  gap: 8px;
  align-items: start;
  font-size: 10.5px;
  line-height: 1.4;
}

.structure-reference-functional-label {
  color: var(--muted);
  font-weight: 680;
}

.structure-reference-functional-row-note {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.structure-reference-functional-note {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

@media (max-width: 620px) {
  .structure-reference-functional-group {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* Mobile training follows the same rule as Atlas: the 3D model stays clear.
   The task card is below the viewer; only the small tap-action bubble may overlay it. */
@media (max-width: 920px) {
  body.session-active:not(.motion-mode) .viewer-wrap {
    min-height: 70dvh;
  }

  body.session-active:not(.motion-mode) .viewer-tools {
    display: none;
  }

  body.session-active .panel .question-card {
    position: static;
    inset: auto;
    max-height: none;
    overflow: visible;
    margin: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  .quiz-muscle-actions {
    min-width: 146px;
    max-width: min(210px, calc(100% - 16px));
  }

  .quiz-muscle-actions-buttons button {
    min-height: 42px;
  }
}

/* Mobile Atlas: the information card must never cover the interactive anatomy. */
@media (max-width: 920px) {
  body:not(.session-active) .panel .question-card,
  body:not(.motion-mode):not(.session-active) .panel .question-card {
    position: static;
    inset: auto;
    max-height: none;
    overflow: visible;
    margin: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  body:not(.motion-mode):not(.session-active) .viewer-wrap {
    min-height: 68dvh;
  }
}

@media (max-width: 620px) {
  body:not(.motion-mode):not(.session-active) .viewer-wrap {
    min-height: 70dvh;
  }

  body:not(.motion-mode):not(.session-active) .panel {
    padding-top: 8px;
  }
}

/* Mobile Atlas quick card: immediate identification and layer actions stay with the 3D model. */
/* Training tap actions: a compact choice attached to the muscle that was tapped. */
.quiz-muscle-actions {
  position: absolute;
  z-index: 9;
  display: grid;
  gap: 7px;
  min-width: 150px;
  max-width: min(230px, calc(100% - 16px));
  padding: 9px;
  border: 1px solid rgba(27,27,29,.14);
  border-radius: 13px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 10px 30px rgba(27,27,29,.18);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}
.quiz-muscle-actions[hidden] { display: none; }
.quiz-muscle-actions > strong {
  min-width: 0;
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: normal;
  word-break: normal;
}
.quiz-muscle-actions-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.quiz-muscle-actions-buttons button {
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid rgba(27,27,29,.13);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
}
#quiz-muscle-select {
  background: #1b1b1d;
  border-color: #1b1b1d;
  color: #fff;
}

.mobile-muscle-card { display: none; }
@media (max-width: 920px) {
  body:not(.session-active):not(.motion-mode) .mobile-muscle-card:not([hidden]) {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 12px;
    z-index: 7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 11px;
    border: 1px solid rgba(27,27,29,.12);
    border-radius: 15px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 8px 28px rgba(27,27,29,.16);
    backdrop-filter: blur(14px);
    pointer-events: auto;
  }
  .mobile-muscle-card-copy { min-width: 0; display: grid; gap: 2px; }
  .mobile-muscle-card-copy span { font-size: 10px; color: rgba(27,27,29,.58); }
  .mobile-muscle-card-copy strong {
    font-size: 13px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  .mobile-muscle-actions { display: flex; flex: 0 0 auto; gap: 5px; }
  .mobile-muscle-actions button {
    min-height: 34px;
    padding: 6px 9px;
    border: 1px solid rgba(27,27,29,.12);
    border-radius: 10px;
    background: #fff;
    color: inherit;
    font: inherit;
    font-size: 11px;
    font-weight: 650;
  }
  .mobile-muscle-actions button:disabled { opacity: .45; }
}

@media (max-width: 920px) {
  body:not(.session-active):not(.motion-mode) .mobile-muscle-card:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
    padding: 9px 10px;
  }
  .mobile-muscle-card-copy { width: 100%; }
  .mobile-muscle-card-copy strong {
    font-size: 14px;
    line-height: 1.22;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
  }
  .mobile-muscle-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .mobile-muscle-actions button {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 5px 9px;
    font-size: 11px;
  }
  .mobile-muscle-actions .mobile-back-context {
    flex: 1 0 100%;
    justify-self: stretch;
    text-align: center;
    font-weight: 700;
  }
}

@media (max-width: 920px) {
  .mobile-context-trail:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 0;
    min-height: 12px;
    padding: 0 2px;
  }
  .mobile-context-step {
    display: flex;
    align-items: center;
    flex: 1 1 0;
  }
  .mobile-context-step:last-child { flex: 0 0 auto; }
  .mobile-context-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(27,27,29,.22);
    transition: transform .18s ease, background .18s ease;
  }
  .mobile-context-step.active .mobile-context-dot {
    transform: scale(1.55);
    background: #245da8;
  }
  .mobile-context-line {
    height: 2px;
    flex: 1 1 auto;
    margin: 0 4px;
    border-radius: 999px;
    background: rgba(36,93,168,.22);
  }
  .mobile-muscle-actions .mobile-back-context,
  .mobile-muscle-actions .mobile-root-context {
    flex: 1 1 auto;
    text-align: center;
    font-weight: 700;
  }
}

/* Interactive depth navigator: the thumb visibly travels as anatomy context changes. */
@media (max-width: 920px) {
  .mobile-context-trail:not([hidden]) {
    display: block;
    min-height: 26px;
    padding: 2px 5px 0;
  }
  .mobile-context-track {
    --context-depth: 1;
    position: relative;
    height: 24px;
    margin: 0 7px;
  }
  .mobile-context-rail {
    position: absolute;
    left: 7px;
    right: 7px;
    top: 11px;
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(27,27,29,.12);
  }
  .mobile-context-progress {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: rgba(36,93,168,.34);
  }
  .mobile-context-node {
    --context-index: 0;
    position: absolute;
    z-index: 2;
    top: 2px;
    left: calc((100% - 14px) * var(--context-index) / var(--context-depth));
    width: 20px;
    height: 20px;
    margin-left: -3px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    display: grid;
    place-items: center;
    touch-action: manipulation;
  }
  .mobile-context-node-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #fff;
    border: 2px solid rgba(36,93,168,.55);
    box-shadow: 0 1px 4px rgba(27,27,29,.14);
    transition: transform .2s ease, border-color .2s ease, background .2s ease;
  }
  .mobile-context-node:not(.active):active .mobile-context-node-dot {
    transform: scale(1.35);
    border-color: #245da8;
  }
  .mobile-context-node.active .mobile-context-node-dot {
    opacity: 0;
  }
  .mobile-context-thumb {
    position: absolute;
    z-index: 3;
    top: 5px;
    left: calc(100% - 10px);
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #245da8;
    box-shadow: 0 2px 9px rgba(36,93,168,.38), 0 0 0 4px rgba(36,93,168,.10);
    transform: translateX(0);
    transition: left .34s cubic-bezier(.22,.8,.3,1), transform .22s ease, box-shadow .22s ease;
    pointer-events: none;
  }
  .mobile-context-track:active .mobile-context-thumb {
    transform: scale(1.06);
  }
}
@media (prefers-reduced-motion: reduce) {
  .mobile-context-thumb,
  .mobile-context-node-dot {
    transition: none !important;
  }
}

@media (max-width: 920px) {
  .mobile-context-track { --context-active: 0; }
  .mobile-context-thumb {
    left: calc((100% - 14px) * var(--context-active) / var(--context-depth));
    transform: translateX(0);
    transition: left .42s cubic-bezier(.2,.75,.25,1), box-shadow .2s ease;
  }
  .mobile-context-progress {
    width: calc(100% * var(--context-active) / var(--context-depth));
    transition: width .42s cubic-bezier(.2,.75,.25,1);
  }
}

@media (max-width: 920px) {
  .mobile-context-thumb {
    margin-left: -7px;
    transition: left .48s cubic-bezier(.18,.78,.24,1), box-shadow .2s ease;
    will-change: left;
  }
  .mobile-context-node.active .mobile-context-node-dot {
    opacity: 1;
    transform: scale(1.25);
    background: rgba(36,93,168,.14);
  }
}

@media (max-width: 920px) {
  .mobile-context-trail:not([hidden]) {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .mobile-context-trail::-webkit-scrollbar { display: none; }
  .mobile-context-track {
    width: max-content;
    margin: 0;
  }
  .mobile-context-node {
    left: 0;
    margin-left: -10px;
  }
  .mobile-context-rail {
    right: auto;
  }
  .mobile-context-progress {
    width: 0;
    transition: width .48s cubic-bezier(.18,.78,.24,1);
  }
  .mobile-context-thumb {
    left: 12px;
    margin-left: -7px;
    transition: left .48s cubic-bezier(.18,.78,.24,1), box-shadow .2s ease;
  }
}

@media (max-width: 920px) {
  .mobile-context-thumb {
    left: 0 !important;
    margin-left: -7px;
    transition: transform .52s cubic-bezier(.16,.72,.24,1), box-shadow .2s ease !important;
    will-change: transform;
  }
  .mobile-context-progress {
    transition: width .52s cubic-bezier(.16,.72,.24,1) !important;
  }
}

@media (max-width: 920px) {
  .mobile-context-node-pending .mobile-context-node-dot {
    opacity: .35;
    transform: scale(.72);
    transition: opacity .42s ease, transform .52s cubic-bezier(.16,.72,.24,1);
  }
  .mobile-context-node-pending.arriving .mobile-context-node-dot {
    opacity: 1;
    transform: scale(1.15);
  }
}

.structure-reference-gallery-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.structure-reference-gallery-head>div{display:grid;gap:3px}
.structure-reference-gallery-count{white-space:nowrap;font-size:.78rem;opacity:.68}
.structure-reference-gallery-shell{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:6px}
.structure-reference-gallery{display:flex!important;overflow-x:auto;scroll-snap-type:x mandatory;scroll-behavior:smooth;scrollbar-width:none;gap:10px}
.structure-reference-gallery::-webkit-scrollbar{display:none}
.structure-reference-gallery>.structure-reference-source-item{flex:0 0 100%;scroll-snap-align:start;min-width:0}
.structure-reference-gallery-nav{width:34px;height:44px;padding:0;border-radius:999px;font-size:1.55rem;line-height:1}
.structure-reference-gallery-nav[hidden]{display:none}
.structure-reference-gallery .structure-reference-figure img{width:100%;max-height:430px;object-fit:contain}
@media(max-width:620px){
 .structure-reference-gallery-shell{grid-template-columns:30px minmax(0,1fr) 30px;gap:3px}
 .structure-reference-gallery-nav{width:30px;height:40px}
 .structure-reference-gallery .structure-reference-figure img{max-height:52vh}
}

.structure-reference-3d-slide > strong{display:block;margin-bottom:8px}
.structure-reference-3d-figure{margin:0}
.structure-reference-3d-figure img{
  display:block;
  width:100%;
  max-height:430px;
  object-fit:contain;
  border-radius:12px;
  background:#dedbd4;
}
.structure-reference-3d-figure figcaption{margin-top:8px}
@media(max-width:620px){
  .structure-reference-3d-figure img{max-height:52vh}
}

/* Gallery slides must keep a real viewport width even when an image is still loading. */
.structure-reference-gallery-shell,
.structure-reference-gallery,
.structure-reference-gallery > .structure-reference-source-item,
.structure-reference-3d-slide,
.structure-reference-3d-figure {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.structure-reference-gallery > .structure-reference-source-item {
  flex-basis: 100%;
  max-width: 100%;
}
.structure-reference-3d-figure img {
  width: 100% !important;
  min-width: 100%;
  aspect-ratio: 4 / 5;
  height: auto;
  object-fit: contain;
}
.structure-reference-3d-figure figcaption {
  width: 100%;
  overflow-wrap: normal;
  word-break: normal;
}
@media(max-width:620px){
  .structure-reference-gallery-shell{
    grid-template-columns:32px minmax(0,1fr) 32px;
    width:100%;
  }
  .structure-reference-gallery{
    width:100%;
    min-width:0;
  }
  .structure-reference-gallery > .structure-reference-source-item{
    flex:0 0 100%;
    width:100%;
  }
  .structure-reference-3d-figure img{
    min-height:320px;
    max-height:min(58vh,520px);
  }
}

.structure-reference-course-art-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  background-repeat: no-repeat;
  background-color: #f4f2ed;
}
.structure-reference-course-art-figure {
  margin: 0;
}

/* The unified illustration gallery is the muscle card's primary visual block. */
.structure-reference-atlas-block {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(27,27,29,.10);
  border-radius: 16px;
  background: var(--surface-soft);
}
.structure-reference-atlas-block[hidden] { display: none; }
.structure-reference-gallery .structure-reference-source-item {
  background: transparent;
}
.structure-reference-course-art-image {
  min-height: 280px;
  background-size: cover;
  background-position-y: center;
}
@media(max-width:620px){
  .structure-reference-atlas-block { padding: 8px 5px; }
  .structure-reference-course-art-image { min-height: min(62vw, 330px); }
}

/* Unified muscle gallery: every slide uses the same uncropped visual stage. */
.structure-reference-gallery > .structure-reference-source-item {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: start;
  gap: 7px;
  overflow: hidden;
}
.structure-reference-gallery > .structure-reference-source-item > strong,
.structure-reference-gallery > .structure-reference-source-item > .structure-reference-source-link,
.structure-reference-gallery > .structure-reference-source-item > span {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.structure-reference-gallery .structure-reference-figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin: 0;
}
.structure-reference-gallery .structure-reference-figure img,
.structure-reference-gallery .structure-reference-course-art-image {
  width: 100%;
  height: min(56vh, 520px);
  min-height: 320px;
  max-height: 520px;
  box-sizing: border-box;
  object-fit: contain !important;
  object-position: center;
  border-radius: 12px;
  background-color: #f4f2ed;
}
.structure-reference-gallery .structure-reference-course-art-image {
  aspect-ratio: auto;
  background-repeat: no-repeat;
  background-color: #f4f2ed;
}
.structure-reference-gallery .structure-reference-figure figcaption {
  position: static;
  width: 100%;
  min-height: 2.7em;
  margin: 0;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}
@media(max-width:620px){
  .structure-reference-gallery .structure-reference-figure img,
  .structure-reference-gallery .structure-reference-course-art-image {
    height: min(58vh, 470px);
    min-height: min(92vw, 360px);
    max-height: 470px;
  }
}

/* Interactive 3D skeletal view inside the reference gallery. */
.structure-reference-3d-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  min-height: 320px;
  overflow: hidden;
  border: 1px solid rgba(27, 27, 29, .12);
  border-radius: 18px;
  background: #e7e4dc;
}
.structure-reference-3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
.structure-reference-3d-canvas:active { cursor: grabbing; }
.structure-reference-3d-hint {
  position: absolute;
  left: 10px;
  bottom: 10px;
  max-width: calc(100% - 132px);
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(8px);
  font-size: 12px;
  line-height: 1.25;
  color: rgba(27,27,29,.72);
  pointer-events: none;
}
.structure-reference-3d-reset {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: auto;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
  font-size: 12px;
  line-height: 1.2;
}
@media (max-width: 620px) {
  .structure-reference-3d-stage {
    min-height: 360px;
    aspect-ratio: 3 / 4;
  }
  .structure-reference-3d-hint {
    max-width: calc(100% - 116px);
    font-size: 11px;
  }
  .structure-reference-3d-reset {
    font-size: 11px;
  }
}

/* Bone study uses the existing Atlas workspace and a compact card below the model. */
.bone-reference { font-size: 13px; line-height: 1.6; }
.bone-reference p { margin: 9px 0 12px; }
.bone-reference ul { margin: 6px 0 12px; padding-left: 19px; }
.bone-reference-latin { display: block; color: var(--muted, #697689); font-style: italic; }
.bone-reference-source { display: inline-block; font-size: 11px; color: #486b95; }
.mobile-bone-reference { grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid rgba(107, 124, 145, .18); }
.mobile-bone-reference summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
#atlas-bones-toggle[aria-pressed="true"] { background: #dce9f6; color: #244d78; border-color: #b9cfe6; }
body.bones-mode #display-layer-actions { display: none; }
@media (max-width: 920px) { #atlas-bones-toggle { flex: 0 0 auto; } }

#bone-reference .bone-reference-latin { display: none; }

.mobile-muscle-card .mobile-bone-reference { order: 2; }

body.bones-mode #toggle-skeleton { display: none; }
@media (max-width: 920px) { body.explore-mode #toggle-skeleton { display: none; } }

/* A selected bone has one reference card on each screen size. */
#structure-reference[data-reference-kind="bone"] .structure-reference-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#structure-reference[data-reference-kind="bone"] .structure-reference-grid > div:last-child { display: none; }
@media (max-width: 920px) {
  .question-card:has(#structure-reference[data-reference-kind="bone"]) #structure-reference,
  .question-card:has(#structure-reference[data-reference-kind="bone"]) #question-label,
  .question-card:has(#structure-reference[data-reference-kind="bone"]) #question,
  .question-card:has(#structure-reference[data-reference-kind="bone"]) #feedback { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .mobile-bone-reference[open] > :not(summary) { animation: reference-arrive var(--ui-motion-content, 160ms) ease-out; }
}
