/* Human Anatomy app. Scoped under .an so nothing leaks into the site shell;
   colours reuse the site's tokens (style.css) so light/dark mode match. */

.an {
  --an-accent: #c2410c;
  --an-accent-soft: #ffedd5;
  --an-bone: #d9ccb0;
  --an-muscle: #b5483f;
  --an-cart: #9fc1cc;
  --an-stage: radial-gradient(ellipse at 50% 35%, #ffffff 0%, var(--bg-soft) 70%);
}
@media (prefers-color-scheme: dark) {
  .an {
    --an-accent: #fb923c;
    --an-accent-soft: #3b2412;
    --an-stage: radial-gradient(ellipse at 50% 35%, #232733 0%, var(--bg) 75%);
  }
}

.an-wrap { max-width: 1320px; margin: 0 auto; padding: 0 1.25rem; }
.an .back { margin: 1.75rem 0 0.75rem; font-size: 0.95rem; }
.an-head h1 { margin: 0 0 0.25rem; }
.an-head .lede { margin: 0 0 1.25rem; max-width: 70ch; }
.an .eyebrow { display: block; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; }

.an-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 330px;
  grid-template-areas: "side stage detail";
  gap: 20px;
  align-items: start;
}
@media (max-width: 1150px) {
  .an-layout { grid-template-columns: 250px minmax(0, 1fr); grid-template-areas: "stage stage" "side detail"; }
}
@media (max-width: 720px) {
  .an-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "detail" "side"; }
}
.an-side { grid-area: side; display: grid; gap: 16px; min-width: 0; }
.an-stage { grid-area: stage; min-width: 0; }
.an-detail { grid-area: detail; min-width: 0; }

/* ---- Sidebar */
.an .seg { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.an .seg button {
  flex: 1; font: inherit; font-size: 0.9rem; font-weight: 500; padding: 7px 4px;
  background: var(--card-bg); color: var(--muted); border: 0; border-radius: 0; cursor: pointer; align-self: stretch;
}
.an .seg button + button { border-left: 1px solid var(--border); }
.an .seg button:hover { opacity: 1; color: var(--text); }
.an .seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.an .check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 0.9rem; color: var(--text); cursor: pointer; }
.an .check input { width: 16px; height: 16px; accent-color: var(--an-accent); }
.an .check.disabled { color: var(--muted); cursor: not-allowed; }
.an input[type="search"] {
  width: 100%; font: inherit; font-size: 0.95rem; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--bg); color: var(--text);
}
.an input[type="search"]:focus { outline: none; border-color: var(--an-accent); }

.browse { display: grid; gap: 4px; max-height: 62vh; overflow-y: auto; padding-right: 4px; }
@media (max-width: 720px) { .browse { max-height: none; } }
.browse details { border-bottom: 1px solid var(--border); }
.browse summary { cursor: pointer; padding: 7px 2px; font-weight: 600; font-size: 0.92rem; display: flex; justify-content: space-between; gap: 8px; list-style: none; }
.browse summary::-webkit-details-marker { display: none; }
.browse summary::after { content: "+"; color: var(--muted); font-weight: 400; }
.browse details[open] summary::after { content: "–"; }
.browse summary .ct { color: var(--muted); font-weight: 400; font-size: 0.82rem; margin-left: auto; }
.browse ul { list-style: none; margin: 0 0 8px; padding: 0; display: grid; }
.browse li button {
  width: 100%; text-align: left; font: inherit; font-size: 0.88rem; font-weight: 400; padding: 4px 8px 4px 10px;
  background: none; color: var(--text); border: 0; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; align-items: center;
}
.browse li button:hover { background: var(--bg-soft); opacity: 1; }
.browse li button[aria-current="true"] { background: var(--an-accent-soft); color: var(--text); font-weight: 600; }
.browse .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.bone { background: var(--an-bone); }
.dot.muscle { background: var(--an-muscle); }
.dot.cart { background: var(--an-cart); }
.browse .empty { color: var(--muted); font-size: 0.9rem; padding: 8px 2px; }

/* ---- Viewer */
.viewer {
  position: relative; height: clamp(460px, calc(100vh - 170px), 820px); border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--an-stage); overflow: hidden; touch-action: none;
}
@media (max-width: 720px) { .viewer { height: 64vh; min-height: 380px; } }
.viewer canvas { display: block; width: 100%; height: 100%; outline: none; }
.viewer.hovering canvas { cursor: pointer; }
.loading {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 0.95rem;
  pointer-events: none; text-align: center; padding: 1rem;
}
.loading.error { color: #dc2626; }
.an [hidden] { display: none !important; }
.hover-label {
  position: absolute; pointer-events: none; transform: translate(12px, -50%); background: var(--text); color: var(--bg);
  font-size: 0.82rem; font-weight: 500; padding: 3px 8px; border-radius: 6px; white-space: nowrap; z-index: 2;
}
.views { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 4px; flex-wrap: wrap; }
.views button, .show-all {
  font: inherit; font-size: 0.8rem; font-weight: 500; padding: 5px 10px; border-radius: 8px; cursor: pointer;
  background: color-mix(in srgb, var(--card-bg) 88%, transparent); color: var(--text); border: 1px solid var(--border); align-self: auto;
}
.views button:hover, .show-all:hover { border-color: var(--an-accent); opacity: 1; }
.show-all { position: absolute; top: 10px; right: 10px; background: var(--an-accent); color: #fff; border-color: transparent; }

/* ---- Detail panel */
.an-detail {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px;
  display: grid; gap: 14px; max-height: clamp(460px, calc(100vh - 170px), 820px); overflow-y: auto;
}
@media (max-width: 1150px) { .an-detail { max-height: none; } }
.an-detail h2 { margin: 0; font-size: 1.35rem; line-height: 1.25; }
.an-detail .sub { color: var(--muted); font-size: 0.92rem; margin: 2px 0 0; }
.an-detail .placeholder p { color: var(--muted); margin: 6px 0 0; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--bg-soft); color: var(--muted); border: 1px solid var(--border); }
.facts { display: grid; gap: 10px; margin: 0; }
.facts dt { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 0.94rem; line-height: 1.5; }
.an-detail .desc { margin: 0; line-height: 1.55; }
.note { background: var(--an-accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; line-height: 1.5; }
.note b { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions button, .chips button {
  font: inherit; font-size: 0.84rem; font-weight: 500; padding: 5px 12px; border-radius: 8px; cursor: pointer;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); align-self: auto;
}
.actions button:hover, .chips button:hover { border-color: var(--an-accent); color: var(--an-accent); opacity: 1; }
.actions button[aria-pressed="true"] { background: var(--an-accent-soft); border-color: var(--an-accent); }
.actions button:disabled { opacity: 0.5; cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button[aria-pressed="true"] { background: var(--an-accent-soft); border-color: var(--an-accent); }

.an .credit { font-size: 0.82rem; color: var(--muted); margin: 18px 0 0; max-width: 95ch; line-height: 1.5; }
