:root {
  color-scheme: light;
  --ink: #172029;
  --muted: #66717d;
  --paper: #f3f5f7;
  --panel: #fff;
  --line: #d9dfe4;
  --accent: #7a164f;
  --accent-dark: #5b0c39;
  --accent-soft: #f7eaf1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }
button { font: inherit; box-shadow: none; cursor: pointer; }
button:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app-shell { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(260px, 30vw, 360px); align-items: start; }
.atlas-header { position: sticky; top: 0; z-index: 10; grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 76px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; color: white; background: var(--accent); font-size: .8rem; font-weight: 800; letter-spacing: .04em; }
h1, h2, h3, p { margin: 0; }
.brand-block h1 { font-size: 1.1rem; }
.eyebrow { margin-bottom: 5px; color: var(--muted); font-size: .75rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.organ-picker { position: relative; z-index: 10; }
.organ-picker > summary { display: flex; align-items: center; gap: 12px; min-width: 210px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px; list-style: none; cursor: pointer; font-size: .9rem; background: #fff; }
.organ-picker summary::-webkit-details-marker { display: none; }
.organ-picker > summary::after { content: '⌄'; margin-left: auto; }
.organ-picker[open] > summary { border-color: var(--accent); }
.picker-caption { color: var(--muted); }
.organ-nav { position: absolute; top: calc(100% + 8px); right: 0; width: min(360px, calc(100vw - 32px)); max-height: min(640px, calc(100dvh - 88px)); display: block; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #c5abb9 transparent; padding: 6px; background: white; border: 1px solid #dec9d5; border-radius: 10px; }
.organ-group { min-width: 0; }
.organ-group + .organ-group { border-top: 1px solid #eee6ea; }
.organ-group-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; margin: 0; padding: 10px 12px; list-style: none; border-radius: 6px; cursor: pointer; color: #59434f; font-size: .875rem; line-height: 1.4; font-weight: 650; }
.organ-group-title::after { content: ''; flex: 0 0 6px; width: 6px; height: 6px; margin-right: 3px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); }
.organ-group[open] > .organ-group-title { color: var(--accent); background: #faf4f7; }
.organ-group[open] > .organ-group-title::after { transform: rotate(45deg); }
.organ-group-title:hover { background: #faf4f7; }
.organ-list { display: grid; gap: 2px; padding: 4px 5px 8px 16px; }
.organ-button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 34px; padding: 7px 10px; border: 1px solid transparent; border-radius: 5px; color: #58434f; background: transparent; text-align: left; font-size: .875rem; line-height: 1.4; }
.organ-button:hover { color: var(--accent); background: #faf4f7; }
.organ-button[aria-current="page"] { color: var(--accent-dark); border-color: #e7c4d7; background: var(--accent-soft); font-weight: 700; }
.organ-button[aria-current="page"]::after { content: '✓'; color: var(--accent); font-size: .9rem; }
.workspace { min-width: 0; padding: 0 20px 24px; }
.workspace-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 90px; padding: 18px 0; }
.workspace-header h2 { font-size: 1.5rem; line-height: 1.2; }
.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.slide-code { padding: 4px 8px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: #fff; font-size: .75rem; font-weight: 650; white-space: nowrap; }
.secondary-button { min-height: 38px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; font-size: .875rem; white-space: nowrap; }
.secondary-button:hover { color: var(--accent); border-color: var(--accent); }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.secondary-button:disabled { cursor: default; color: #8f8289; border-color: var(--line); background: #f8f7f8; }
.viewer-card { width: 100%; min-width: 0; }
.viewer-stage { position: relative; width: 100%; aspect-ratio: 1060 / 693; overflow: hidden; border-radius: 8px; background: #fff; outline: 1px solid var(--line); isolation: isolate; }
/* The original 1280 × 720 gallery has a 220px sidebar and 27px header.
   Scale the complete original viewport uniformly, then crop only those margins.
   The navigator and the field of view keep the same proportions at any width. */
#slide-frame { position: absolute; top: 0; left: 0; width: 1280px; height: 720px; max-width: none; border: 0; transform-origin: top left; background: #fff; }
.viewer-mask { position: absolute; z-index: 3; top: 0; right: 0; width: 36%; min-height: 32px; padding: 8px 10px; border-radius: 0 0 0 7px; color: var(--accent-dark); background: #fff; font-size: .875rem; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.viewer-loading { position: absolute; z-index: 5; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); background: #f6f7f8; }
.viewer-loading.is-hidden { display: none; }
.viewer-loading { flex-wrap: wrap; padding: 20px; text-align: center; }
.viewer-loading.is-updating { inset: 6px auto auto 6px; max-width: 60%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: .875rem; }
.viewer-loading.is-error .loader { display: none; }
.viewer-recovery { flex-basis: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.viewer-recovery[hidden] { display: none; }
.viewer-recovery a { color: var(--accent); font-size: .875rem; }
.study-image-caption { margin: 0 0 16px; color: var(--accent-dark); font-weight: 650; line-height: 1.5; overflow-wrap: anywhere; }
.study-image-review { margin: 0 0 16px; padding: 12px; border-left: 3px solid var(--accent); background: #f7f2f6; font-size: .875rem; line-height: 1.5; }
.loader { width: 18px; height: 18px; border: 2px solid #ddd; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.view-dock { min-width: 0; width: 100%; padding-top: 20px; }
.dock-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 12px; }
.dock-heading h3 { font-size: 1rem; }
.view-count { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.view-buttons { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; min-width: 0; width: 100%; }
.view-button { max-width: 100%; min-height: 36px; padding: 8px 11px; border: 1px solid #d0d7dd; border-radius: 7px; color: #4e5963; background: #fff; font-size: .875rem; font-weight: 550; line-height: 1.35; text-align: left; overflow-wrap: anywhere; }
.view-button:hover { color: var(--accent); border-color: #b75e8e; }
.view-button[aria-pressed="true"] { color: white; border-color: var(--accent); background: var(--accent); }
.study-panel { position: sticky; top: 76px; align-self: start; min-width: 0; height: calc(100dvh - 76px); min-height: 420px; display: flex; flex-direction: column; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); }
.study-header { padding: 22px 20px 19px; min-height: 90px; border-bottom: 1px solid var(--line); }
.study-header h2 { font-size: 1.1rem; line-height: 1.4; }
.study-content { flex: 1; min-width: 0; padding: 20px; }
.empty-notes { padding: 16px; border: 1px dashed #c8cfd5; border-radius: 8px; background: #fafbfc; }
.empty-notes h3 { margin-bottom: 8px; font-size: 1rem; }
.empty-notes p { color: var(--muted); font-size: 1rem; line-height: 1.55; }
.note-list { display: grid; gap: 10px; }
.note-card { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; text-align: left; }
.note-card:hover { border-color: #b75e8e; background: #fffafd; }
.note-card strong { display: block; margin-bottom: 5px; color: var(--accent-dark); font-size: 1rem; }
.note-card span { display: block; color: #59646e; font-size: 1rem; line-height: 1.5; }
.note-card::after { content: 'Apri la vista'; display: block; margin-top: 9px; color: var(--accent); font-size: .875rem; font-weight: 700; }
.study-section { min-width: 0; border: 1px solid var(--line); border-radius: 7px; overflow: clip; }
.study-section > summary { cursor: pointer; padding: 12px; color: var(--accent-dark); background: var(--accent-soft); font-size: 1rem; font-weight: 700; line-height: 1.4; }
.study-section-summary { margin: 0; padding: 10px 12px; color: #715464; background: #fcf9fb; font-size: .875rem; line-height: 1.5; }
.study-note { padding: 13px 12px; border-top: 1px solid #eee4ea; }
.study-note h4 { margin: 0 0 8px; color: var(--accent-dark); font-size: 1rem; line-height: 1.4; }
.study-note p, .study-note li { margin: 0; color: #42464b; font-size: 1rem; line-height: 1.6; overflow-wrap: anywhere; }
.study-note p + p { margin-top: 10px; }
.study-note ul { margin: 10px 0; padding-left: 20px; }
.study-note li + li { margin-top: 8px; }
.study-view-link { padding: 0; border: 0; border-radius: 3px; background: transparent; color: var(--accent); font: inherit; font-weight: 700; line-height: inherit; text-align: left; text-decoration: underline; text-decoration-color: #ceb3c2; text-underline-offset: 3px; }
.study-view-link:hover { color: var(--accent-dark); text-decoration-color: currentColor; }
.study-view-link[aria-pressed="true"] { background: var(--accent-soft); outline: 3px solid var(--accent-soft); }
.study-extra-views { display: grid; justify-items: start; gap: 8px; margin-top: 12px; }
.study-detail-link { font-size: .875rem; line-height: 1.5; font-weight: 600; }
.study-note .note-availability { margin-top: 10px; padding-left: 9px; border-left: 2px solid #ccb5c2; color: #76606d; font-size: .8rem; line-height: 1.5; }
.note-precision { margin-top: 10px; }
.note-precision > summary { color: #79556a; font-size: .875rem; line-height: 1.5; cursor: pointer; }
.note-precision p { margin-top: 7px; font-size: .875rem; }
.study-sources { margin-top: 8px; color: var(--muted); font-size: .875rem; line-height: 1.5; }
.study-sources summary { cursor: pointer; color: var(--accent); }
.study-sources p { margin: 12px 0; }
.study-sources ul { padding-left: 18px; }
.study-sources li + li { margin-top: 8px; }
.study-sources a { color: var(--accent); overflow-wrap: anywhere; }
.study-footer[hidden] { display: none; }
.study-footer { display: flex; gap: 10px; margin: 0 20px 20px; padding: 13px; border-radius: 8px; color: #6d5361; background: var(--accent-soft); font-size: .875rem; line-height: 1.5; }
.footer-icon { color: var(--accent); }
@media (min-width: 1500px) { .app-shell { max-width: 1600px; margin: 0 auto; } }
@media (max-width: 800px) {
  .app-shell { grid-template-columns: minmax(0, 1fr) 250px; }
  .atlas-header { padding: 12px 14px; gap: 10px; }
  .brand-block { gap: 8px; }
  .brand-block h1 { font-size: 1rem; }
  .brand-mark { display: none; }
  .workspace { padding: 0 12px 20px; }
  .workspace-header { flex-wrap: wrap; gap: 8px; }
  .study-header, .study-content { padding: 16px; }
  .study-footer { margin: 0 16px 16px; }
  .viewer-mask { font-size: .75rem; padding: 5px; width: 39%; }
}
@media (max-width: 620px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .study-panel { position: static; height: auto; min-height: 250px; border-left: 0; border-top: 1px solid var(--line); }
  .organ-picker > summary { min-width: 160px; }
  .picker-caption { display: none; }
  .organ-nav { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .loader { animation: none; } }

/* Compact study layout: the slide and the expanded anatomical groups share
   the available height. Only the structure list scrolls when it is very long. */
.atlas-header { min-height: 64px; height: 64px; padding: 8px 20px; }
.workspace { height: calc(100dvh - 64px); min-height: 540px; padding: 0 16px 12px; display: grid; grid-template-rows: 64px minmax(210px, 1fr) auto; gap: 0; }
.workspace-header { min-height: 0; padding: 10px 0; }
.workspace-header h2 { font-size: 1.3rem; }
.workspace-header .eyebrow { font-size: .65rem; margin-bottom: 3px; }
.secondary-button { min-height: 30px; padding: 5px 10px; font-size: .8rem; }
.secondary-button[aria-pressed="true"] { background: var(--accent-soft); border-color: #dfbdd0; color: var(--accent); }
.viewer-card { min-height: 0; display: grid; place-items: center; padding-bottom: 10px; }
.viewer-stage { max-width: 100%; border-radius: 6px; }
.viewer-mask { min-height: 24px; padding: 5px 8px; font-size: .75rem; }
.view-dock { padding-top: 0; max-height: min(43dvh, 400px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #b8a5b0 transparent; overscroll-behavior: contain; }
.dock-heading { position: sticky; top: 0; z-index: 4; align-items: center; margin: 0; padding: 7px 0; background: var(--paper); }
.dock-heading h3 { font-size: .8rem; font-weight: 700; }
.view-count { font-size: .72rem; }
.view-dock.has-overflow .view-count::after { content: ' · scorri ↕'; }
.view-buttons { display: grid; gap: 4px; padding: 1px 3px 3px 1px; }
.region-group { --region-bg: #faf8f9; --region-edge: #c7b5bf; --region-ink: #604954; display: grid; grid-template-columns: 142px minmax(0, 1fr); align-items: start; gap: 7px; min-width: 0; padding: 5px 7px; border: 1px solid color-mix(in srgb, var(--region-edge) 38%, white); border-left: 3px solid var(--region-edge); border-radius: 5px; background: var(--region-bg); }
.tone-cortex { --region-bg: #f8eaf2; --region-edge: #c58aa9; --region-ink: #71344f; }
.tone-medulla { --region-bg: #f0eaf4; --region-edge: #a28aaf; --region-ink: #63456c; }
.tone-boundary { --region-bg: #fcf6f9; --region-edge: #bd97aa; --region-ink: #6d4e5d; border-left-style: dashed; }
.tone-muscle { --region-bg: #f3e2eb; --region-edge: #b3698e; --region-ink: #7a164f; }
.tone-violet { --region-bg: #ece5f0; --region-edge: #9c80ac; --region-ink: #60436e; }
.tone-outer { --region-bg: #f2eef0; --region-edge: #b2a0aa; --region-ink: #5d4b55; }
.region-heading { margin: 0; padding: 4px 2px; font-size: .76rem; line-height: 1.35; font-weight: 720; color: var(--region-ink); overflow-wrap: anywhere; }
.region-heading:has(.region-link) { padding: 0; }
.region-link { display: block; width: 100%; min-height: 26px; padding: 4px 6px; border: 1px solid transparent; border-radius: 4px; font: inherit; text-align: left; line-height: inherit; color: inherit; background: transparent; }
.region-link::after { content: ' ↗'; font-size: .65rem; opacity: .6; }
.region-link:hover { border-color: var(--region-edge); background: #ffffff70; }
.region-link[aria-pressed="true"] { color: #fff; background: var(--accent); border-color: var(--accent); }
.region-items { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }
.region-heading-only { grid-template-columns: 1fr; }
.region-heading-only .region-link { width: auto; }
.view-button { min-height: 26px; padding: 3px 7px; border-color: color-mix(in srgb, var(--region-edge) 55%, white); border-radius: 4px; color: #4d3945; background: #ffffffa8; font-size: .76rem; line-height: 1.35; font-weight: 500; }
.view-cluster { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px; max-width: 100%; min-height: 26px; padding: 1px 2px 1px 6px; border: 1px solid color-mix(in srgb, var(--region-edge) 50%, white); border-radius: 4px; background: #ffffff70; }
.cluster-label { color: #4d3945; padding-right: 4px; font-size: .76rem; line-height: 1.4; }
.view-variant { min-width: 26px; min-height: 24px; padding: 2px 5px; text-align: center; background: #fff; }
.region-nested { width: 100%; grid-template-columns: 125px minmax(0, 1fr); padding: 3px 5px; gap: 5px; }
.region-nested .region-heading { font-size: .72rem; }
.region-nested.region-heading-only { padding: 0; background: transparent; border: 0; }
.study-panel { top: 64px; height: calc(100dvh - 64px); }
.study-header { min-height: 64px; padding: 13px 20px; }
.study-header h2 { font-size: 1rem; }
@media (max-width: 1100px) {
  .region-group { grid-template-columns: 116px minmax(0, 1fr); gap: 5px; }
  .region-heading-only { grid-template-columns: 1fr; }
  .region-nested { grid-template-columns: 103px minmax(0, 1fr); }
}
@media (max-width: 800px) {
  .workspace { padding: 0 10px 10px; }
  .region-group { grid-template-columns: 1fr; gap: 3px; }
  .region-heading { padding-top: 1px; padding-bottom: 1px; }
  .workspace-header { flex-wrap: nowrap; }
}
@media (max-width: 620px) {
  .atlas-header { padding: 8px 12px; }
  .workspace { height: auto; min-height: 0; display: block; padding-bottom: 16px; }
  .workspace-header { min-height: 64px; }
  .viewer-card { height: auto; display: block; padding-bottom: 10px; }
  .viewer-stage { width: 100% !important; }
  .view-dock { max-height: none; overflow: visible; }
  .dock-heading { position: static; }
  .study-panel { height: auto; }
  .region-group { grid-template-columns: 110px minmax(0, 1fr); }
  .region-nested { grid-template-columns: 1fr; }
  .region-heading-only { grid-template-columns: 1fr; }
}

/* Collection changes keep the same organ, notes and slide area. */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.header-selectors { display: flex; align-items: center; gap: 10px; min-width: 0; }
.collection-picker { position: relative; display: inline-flex; min-width: 0; max-width: 240px; }
.collection-trigger { display: inline-flex; align-items: center; justify-content: space-between; gap: 18px; width: 240px; max-width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--panel); font: inherit; font-size: .875rem; line-height: 1.4; text-align: left; }
.collection-trigger > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collection-trigger > svg { flex: 0 0 16px; color: var(--muted); }
.collection-trigger:hover { background: #faf7f9; }
.collection-trigger[aria-expanded=true] { border-color: var(--accent); }
.collection-trigger[aria-expanded=true] > svg { transform: rotate(180deg); }
.collection-options { position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; width: max(100%, 240px); max-width: calc(100vw - 24px); max-height: min(320px, calc(100dvh - 100px)); overflow-y: auto; overscroll-behavior: contain; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 8px 24px #1720291a; }
.collection-options[hidden] { display: none; }
.collection-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; font-size: .875rem; line-height: 1.4; }
.collection-option::after { content: ''; flex: 0 0 16px; }
.collection-option[aria-selected=true] { color: var(--accent); font-weight: 600; }
.collection-option[aria-selected=true]::after { content: '✓'; text-align: center; }
.collection-option:hover, .collection-option:focus { color: var(--accent); background: var(--accent-soft); outline: none; }
.collection-option:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

.personal-viewer { position: absolute; inset: 0; background: #fff; }
.image-surface { position: absolute; inset: 0 0 36px; overflow: hidden; touch-action: none; cursor: grab; }
.image-surface.is-dragging { cursor: grabbing; }
#personal-image { position: absolute; top: 50%; left: 50%; max-width: none; max-height: none; transform-origin: center; user-select: none; pointer-events: none; }
.image-toolbar { position: absolute; bottom: 0; left: 0; right: 0; height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 3px 8px; background: #fff; border-top: 1px solid var(--line); font-size: .875rem; }
#image-caption { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.image-zoom-controls { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.image-zoom-controls button { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--accent); font-size: 1rem; }
#image-zoom-level { min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--muted); }
.collection-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; padding: 28px; text-align: center; }
.collection-empty strong { font-size: 1rem; color: var(--accent-dark); }
.collection-empty p { max-width: 360px; font-size: 1rem; line-height: 1.5; color: var(--muted); }
.collection-views { display: flex; flex-wrap: wrap; gap: 6px; }
.collection-views .view-button { font-size: .875rem; padding: 6px 10px; }
.collection-organ-count { color: var(--muted); font-size: .8rem; font-weight: 400; }
@media (max-width: 620px) {
  .header-selectors { flex: 1; gap: 7px; }
  .brand-block { display: none; }
  .collection-picker { flex: 1; min-width: 0; }
  .collection-trigger { width: 100%; max-width: none; }
  .collection-options { left: 0; right: auto; }
  .header-selectors .organ-picker { flex: 1; min-width: 0; }
  .header-selectors .organ-picker > summary { min-width: 0; }
}
/* Compact groups keep original photographic sets easy to distinguish. */
.collection-view-group {margin:0 0 .7rem;}
.collection-view-group h4 {margin:0 0 .35rem;color:var(--accent,#7a164f);font-size:.875rem;font-weight:600;}
.collection-views .view-button {max-width:100%;text-align:left;white-space:normal;}

/* Region navigation stays within the existing, annotated slide collection. */
.region-filters { display: grid; gap: 8px; margin: 4px 0 16px; }
.region-filters label { font-size: 12px; color: #65717d; }
.region-filters select, .region-filters input { font: inherit; font-size: 13px; color: #1c2731; background: #fff; border: 1px solid #d9dfe5; border-radius: 10px; padding: 9px 10px; width: 100%; min-width: 0; }
.region-filters :focus-visible { outline: 2px solid #817489; outline-offset: 2px; }
.region-group[hidden], .collection-view-group[hidden] { display: none; }

.region-filters > span { font-size: 12px; color: #65717d; }
.region-picker { position: relative; }
.region-picker summary { display: flex; justify-content: space-between; cursor: pointer; list-style: none; font-size: 13px; border: 1px solid #d9dfe5; background: white; border-radius: 10px; padding: 10px; }
.region-picker summary::-webkit-details-marker { display: none; }
#region-options { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; padding: 5px; border: 1px solid #d9dfe5; border-radius: 12px; background: #fff; box-shadow: 0 8px 24px #19212c14; }
#region-options button { display: block; width: 100%; text-align: left; font: inherit; font-size: 13px; border: 0; background: transparent; padding: 10px; border-radius: 7px; cursor: pointer; }
#region-options button:hover, #region-options button:focus-visible, #region-options button[aria-pressed=true] { background: #f2f3f5; }

/* Real micrographs use the full study surface; anatomical region filters remain
   available in the original whole-slide collections. */
.micrograph-collection .brand-mark,
.micrograph-collection .region-filters { display: none; }
.micrograph-collection .viewer-stage { aspect-ratio: auto; }
.micrograph-collection .view-buttons { display: flex; align-items: start; gap: 10px 20px; }
.micrograph-collection .collection-view-group { margin: 0; }
.micrograph-collection .collection-view-group h4 { margin: 4px 0 6px; font-size: .75rem; color: var(--muted); }
.micrograph-collection .view-button { min-height: 40px; padding: 8px 12px; border-radius: 8px; }
.micrograph-collection .view-dock { max-height: 170px; }
.micrograph-collection .image-toolbar { height: 44px; }
.micrograph-collection .image-surface { bottom: 44px; }
.micrograph-collection .image-zoom-controls button { min-width: 40px; min-height: 36px; }
@media (max-width: 620px) {
  .micrograph-collection .viewer-stage { height: min(60dvh, 480px) !important; }
}

.atlas-info-button{width:44px;min-width:44px;height:44px;border:0;border-radius:50%;background:transparent;color:#67717b;cursor:pointer;font:22px/1 system-ui}
.atlas-info-button:hover{background:#f7eaf1;color:#7a164f}
#atlas-info{position:fixed;inset:0;margin:auto;width:min(620px,calc(100vw - 32px));max-width:none;max-height:82dvh;border:1px solid #dfe2e5;padding:0;border-radius:16px;background:#fff;color:#20252b;box-shadow:0 24px 80px #17202930}
#atlas-info[open]{display:flex;flex-direction:column}
#atlas-info::backdrop{background:#17202955}
#atlas-info>header{display:flex;align-items:center;justify-content:space-between;padding:16px 16px 16px 24px;border-bottom:1px solid #dfe2e5;gap:12px;flex:none}
#atlas-info h2{font-size:17px;font-weight:500;margin:0}
#atlas-info-content{padding:24px;overflow:auto;overscroll-behavior:contain;font-size:13px;line-height:1.8}
#atlas-info-content h3{font-size:14px;margin:0 0 14px}
#atlas-info-content p{margin:0 0 16px}
#atlas-info-content a{display:block;color:#7a164f;text-decoration:underline;text-underline-offset:3px;margin-bottom:12px;overflow-wrap:anywhere}

/* Pathology: the catalogue, tissue and explanations have separate places. */
.pathology-catalog[hidden], [hidden].image-markers, .image-marker[hidden] { display:none; }
.micrograph-collection .app-shell { grid-template-columns: 232px minmax(0,1fr) 278px; max-width:none; }
.micrograph-collection .organ-picker { display:none; }
.micrograph-collection .brand-block h1 { font-size:.95rem; }
.micrograph-collection .pathology-catalog { height:calc(100dvh - 64px); position:sticky; top:64px; background:var(--panel); border-right:1px solid var(--line); padding:16px 12px; display:flex; flex-direction:column; gap:12px; min-width:0; }
.catalog-heading { display:flex; align-items:baseline; justify-content:space-between; gap:8px; }
.catalog-heading h2 { font-size:1rem; }
#catalog-count { font-size:.72rem; color:var(--muted); white-space:nowrap; }
.catalog-search input { width:100%; min-height:42px; padding:10px; border:1px solid var(--line); border-radius:8px; font:inherit; font-size:.8rem; background:var(--paper); color:var(--ink); }
.catalog-search input:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
#pathology-list { overflow-y:auto; scrollbar-width:thin; overscroll-behavior:contain; min-height:0; }
.pathology-area { border-bottom:1px solid var(--line); }
.pathology-area summary { display:flex; gap:8px; align-items:center; min-height:44px; font-size:.8rem; font-weight:650; line-height:1.4; padding:10px 4px; cursor:pointer; list-style:none; }
.pathology-area summary::-webkit-details-marker { display:none; }
.pathology-area summary::before { content:'›'; font-size:1rem; color:var(--muted); }
.pathology-area[open] summary::before { transform:rotate(90deg); }
.pathology-area summary small { margin-left:auto; font-size:.7rem; font-weight:500; color:var(--muted); }
.pathology-area button { width:100%; display:grid; gap:4px; text-align:left; min-height:50px; padding:10px 12px; border:1px solid transparent; background:transparent; border-radius:7px; font-size:.8rem; line-height:1.4; color:var(--ink); }
.pathology-area button small { font-size:.7rem; color:var(--muted); }
.pathology-area button:hover { background:var(--paper); }
.pathology-area button[aria-current=true] { background:var(--accent-soft); border-color:#e6c9d8; color:var(--accent); }
.catalog-empty { font-size:.85rem; line-height:1.6; color:var(--muted); padding:12px 0; }
.micrograph-collection #catalog-toggle { display:none; }
.micrograph-collection .workspace { min-height:500px; padding:0 14px 14px; grid-template-rows:78px minmax(220px,1fr) auto; }
.micrograph-collection .workspace-header { gap:6px; }
.micrograph-collection .workspace-header h2 { font-size:1.1rem; }
.micrograph-collection .workspace-header .eyebrow { letter-spacing:.04em; font-size:.62rem; }
.micrograph-collection .slide-code { display:none; }
.micrograph-collection .secondary-button { min-height:36px; }
.micrograph-collection .study-panel { width:auto; }
.micrograph-collection .study-header { padding:20px 18px 12px; }
.micrograph-collection .study-header h2 { font-size:1rem; }
.micrograph-collection .study-content { padding:0 18px 20px; }
.micrograph-collection .study-image-caption { font-size:1.1rem; line-height:1.4; color:var(--ink); font-weight:650; }
.micrograph-collection .study-note { padding:14px 0; }
.micrograph-collection .study-note p { font-size:.85rem; line-height:1.7; }
.micrograph-collection .view-dock { max-height:180px; }
.micrograph-collection .view-buttons { display:flex; flex-wrap:wrap; gap:6px; padding:4px 2px; }
.image-region-button { display:inline-flex; align-items:center; gap:8px; border:1px solid var(--line); border-radius:7px; background:var(--panel); color:var(--ink); padding:7px 10px 7px 7px; min-height:38px; font-size:.75rem; text-align:left; }
.image-region-button > span:first-child { display:grid; place-items:center; flex-shrink:0; width:21px; height:21px; border-radius:50%; background:var(--accent-soft); color:var(--accent); font-weight:650; }
.image-region-button[aria-pressed=true] { background:var(--accent-soft); border-color:var(--accent); }
.selected-region { padding:12px; margin:0 0 16px; border:1px solid #e6c9d8; border-radius:8px; background:var(--accent-soft); }
.selected-region h3 { font-size:.9rem; color:var(--accent); margin-bottom:6px; }
.selected-region p { font-size:.8rem; line-height:1.6; }
.image-markers { position:absolute; inset:0; pointer-events:none; overflow:hidden; }
.image-marker { position:absolute; transform:translate(-50%,-50%); width:44px; height:44px; display:grid; place-items:center; padding:0; border:0; background:transparent; pointer-events:auto; }
.marker-number { display:grid; place-items:center; width:24px; height:24px; border:2px solid white; border-radius:50%; background:var(--accent); color:#fff; box-shadow:0 1px 5px #0005; font-size:12px; font-weight:700; }
.image-marker[aria-pressed=true] .marker-number { outline:2px solid var(--accent); outline-offset:2px; }
.marker-label { display:none; position:absolute; left:36px; padding:5px 8px; max-width:180px; width:max-content; color:var(--ink); background:#fffffff2; border:1px solid #d8bbc9; border-radius:5px; font-size:12px; line-height:1.4; text-align:left; box-shadow:0 1px 5px #0002; pointer-events:none; }
.label-left .marker-label { left:auto; right:36px; }
.image-marker:hover .marker-label,.image-marker:focus-visible .marker-label,.image-marker[aria-pressed=true] .marker-label { display:block; }
.micrograph-collection .image-toolbar { font-size:.75rem; }
.micrograph-collection #image-caption { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
@media(max-width:1150px) and (min-width:1001px) {
 .micrograph-collection .app-shell { grid-template-columns:210px minmax(0,1fr) 240px; }
 .micrograph-collection .workspace-header { align-content:center; flex-wrap:wrap; }
}
@media(max-width:1000px) {
 .micrograph-collection .app-shell { grid-template-columns:minmax(0,1fr) 260px; }
 .micrograph-collection .pathology-catalog { display:none; }
 .micrograph-collection #catalog-toggle { display:inline-flex; }
 .micrograph-collection.catalog-open .pathology-catalog { display:flex; grid-column:1/-1; position:static; height:min(420px,65dvh); border-bottom:1px solid var(--line); }
 .micrograph-collection .workspace-header { flex-wrap:wrap; align-content:center; }
 .micrograph-collection .workspace { grid-template-rows:92px minmax(220px,1fr) auto; }
}
@media(max-width:700px) {
 .micrograph-collection .app-shell { grid-template-columns:minmax(0,1fr); }
 .micrograph-collection .atlas-header { padding:8px 12px; }
 .micrograph-collection .brand-block { min-width:0; }
 .micrograph-collection .brand-block h1 { font-size:.8rem; }
 .micrograph-collection .brand-block .eyebrow { font-size:.55rem; }
 .micrograph-collection .collection-trigger { max-width:145px; font-size:.75rem; }
 .micrograph-collection .workspace { height:calc(100dvh - 64px); min-height:540px; padding:0 12px 12px; }
 .micrograph-collection .study-panel { position:static; height:auto; min-height:0; border-top:1px solid var(--line); border-left:0; }
 .micrograph-collection .workspace-header { gap:4px; }
 .micrograph-collection .header-actions { gap:4px; }
 .micrograph-collection .header-actions .secondary-button { padding:5px 7px; font-size:.72rem; }
 .micrograph-collection .view-dock { max-height:160px; }
 .micrograph-collection .image-region-button { min-height:44px; }
}

#catalog-close { display:none; width:40px; height:40px; border:0; border-radius:7px; background:var(--paper); color:var(--ink); font-size:22px; }
@media(max-width:1000px) { #catalog-close { display:block; margin-left:auto; } }
@media(max-width:700px) { .micrograph-collection .collection-trigger { max-width:240px; } }

/* The endpoint marks the tissue; the number stays beside it so small cells remain visible. */
.image-marker::before { content:''; position:absolute; left:21px; top:0; height:22px; width:1px; background:white; box-shadow:0 0 1px #3c1635; transform:rotate(40deg); transform-origin:bottom; }
.image-marker::after { content:''; position:absolute; left:18px; top:18px; width:8px; height:8px; border:1px solid white; border-radius:50%; box-shadow:0 0 0 1px #7a164f; }
.image-marker .marker-number { transform:translate(17px,-20px); }
.image-marker .marker-label { left:53px; top:-13px; }
.image-marker.label-left .marker-label { left:auto; right:18px; }

/* Keep the label beside its tissue endpoint even at the viewport edge. */
.image-marker.marker-below .marker-number { transform: translate(17px,20px); }
.image-marker.marker-below::before { transform: rotate(140deg); }
.image-marker.marker-below .marker-label { top:27px; }
.image-marker.marker-left .marker-number { transform: translate(-17px,-20px); }
.image-marker.marker-left::before { transform: rotate(-40deg); }
.image-marker.marker-left .marker-label { left:auto; right:53px; }
.image-marker.marker-left.marker-below .marker-number { transform: translate(-17px,20px); }
.image-marker.marker-left.marker-below::before { transform: rotate(-140deg); }

/* Notebook cards foreground the captured tissue and its marker. */
body.notebook-embed .app-shell { display:flex; flex-direction:column; height:100dvh; min-height:0; }
body.notebook-embed:not(.notebook-show-catalog) .atlas-header,
body.notebook-embed:not(.notebook-show-catalog) .pathology-catalog,
body.notebook-embed:not(.notebook-show-regions) .view-dock,
body.notebook-embed:not(.notebook-show-description) .study-panel { display:none!important; }
body.notebook-embed .workspace { flex:1; width:100%; height:auto; min-height:0; padding:0 8px 8px; display:flex; flex-direction:column; overflow:auto; }
body.notebook-embed .workspace-header { min-height:48px; flex:none; gap:8px; padding:8px 4px; flex-wrap:nowrap; }
body.notebook-embed .workspace-header h2 { font-size:14px; }
body.notebook-embed .workspace-header .eyebrow,body.notebook-embed .slide-code { display:none; }
body.notebook-embed:not(.notebook-show-controls) #toggle-indications,
body.notebook-embed:not(.notebook-show-controls) #reset-view,
body.notebook-embed:not(.notebook-show-controls) .image-toolbar,
body.notebook-embed:not(.notebook-show-catalog) #catalog-toggle { display:none!important; }
body.notebook-embed .viewer-card { flex:1; min-height:220px; width:100%; }
body.notebook-embed .view-dock { flex:none; max-height:180px; margin-top:8px; }
body.notebook-embed .pathology-catalog:not([hidden]) { flex:none; position:static; width:100%; height:180px; display:flex; }
body.notebook-embed .study-panel { flex:none; position:static; width:100%; height:auto; min-height:0; max-height:200px; overflow:auto; border-top:1px solid var(--line); }
body.notebook-embed .atlas-header .brand-block { display:none; }
body.notebook-embed .atlas-header { flex:none; width:100%; padding:8px; height:auto; min-height:52px; }
body.notebook-embed .header-selectors { width:100%; }
body.notebook-embed .organ-nav { max-height:210px; }

body.notebook-embed .pathology-catalog[hidden] { display:none!important; }
body.notebook-embed .viewer-card { display:flex; align-items:center; justify-content:center; }

body.notebook-embed .viewer-stage { aspect-ratio:auto; }
