/* ═══════════════ Explore ═══════════════ */
.view.explore { display: grid; grid-template-columns: 290px minmax(0, 1fr); height: 100%; overflow: hidden; }
.rail {
  display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-2) 70%, transparent);
}
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.rail-head h2 { display: flex; align-items: center; gap: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-dim); }
.rail-close { display: none; }
.presets { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px 14px 12px; border-bottom: 1px solid var(--line-soft); }
.presets .pill { font-size: 12px; padding: 4px 10px; }
.layers { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.layer { border-radius: 12px; transition: background .2s; }
.layer + .layer { margin-top: 2px; }
.layer-row { display: flex; align-items: center; gap: 2px; padding-right: 4px; }
.layer-toggle { flex: 1; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; min-width: 0; text-align: left; transition: background .2s; }
.layer-toggle:hover { background: var(--surface-2); }
.swatch {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; flex: none; color: var(--ink-faint);
  border: 1px solid var(--line-soft); background: var(--surface); transition: all .3s var(--ease);
}
.swatch .ico { width: 17px; height: 17px; }
.layer.on .swatch { color: var(--c); border-color: color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 16%, transparent); box-shadow: 0 0 14px -4px var(--c); }
.layer-name { flex: 1; font-size: 14px; font-weight: 550; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .2s; }
.layer.on .layer-name { color: var(--ink); }
.eye { color: var(--ink-faint); opacity: 0; transition: opacity .2s; }
.layer-toggle:hover .eye, .layer.on .eye { opacity: 1; }
.layer.on .eye { color: var(--c); }
.layer-row .icon-btn.mini { opacity: .55; }
.layer-row:hover .icon-btn.mini { opacity: 1; }
[data-expand] .ico { transition: transform .3s var(--ease); }
.layer.expanded [data-expand] .ico { transform: rotate(180deg); }
.layer-items-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s var(--ease); }
.layer.expanded .layer-items-wrap { grid-template-rows: 1fr; }
.layer-items { overflow: hidden; list-style: none; margin: 0; padding: 0 6px 0 48px; }
.layer.expanded .layer-items { padding-bottom: 8px; }
.layer-items li {
  position: relative; padding: 4px 8px; border-radius: 7px; font-size: 13px; color: var(--ink-dim); cursor: pointer; transition: background .15s, color .15s;
}
.layer-items li::before { content: ''; position: absolute; left: -10px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--c); opacity: .5; }
.layer-items li:hover { background: var(--surface-2); color: var(--ink); }
.layer-items li.active { background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--ink); }
.rail-foot { padding: 12px 14px; border-top: 1px solid var(--line-soft); display: flex; justify-content: center; }

.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; outline: none; }
.stage-grid {
  position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background:
    radial-gradient(60% 55% at 50% 45%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    linear-gradient(var(--line-soft) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px) 0 0 / 40px 40px;
  mask-image: radial-gradient(75% 70% at 50% 50%, #000 40%, transparent 100%);
}
.stage .body-svg { position: absolute; inset: 0; cursor: grab; }
.stage .body-svg.dragging { cursor: grabbing; }
.zoom-ctrls {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px;
  border-radius: 14px; background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--line-soft); backdrop-filter: blur(10px);
}
.zoom-level { font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; padding: 4px 0 2px; }
.stage-hint {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  border-radius: 999px; font-size: 12.5px; color: var(--ink-dim); background: color-mix(in srgb, var(--surface) 75%, transparent);
  border: 1px solid var(--line-soft); backdrop-filter: blur(8px); white-space: nowrap; pointer-events: none;
  animation: fade 1s 1.2s var(--ease) both;
}
.stage-hint .ico { width: 15px; height: 15px; color: var(--accent); }
.orient { position: absolute; left: 20px; top: 18px; display: flex; gap: 10px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); pointer-events: none; }
.orient span:first-child, .orient span:last-child { color: var(--accent); font-weight: 700; }
.welcome {
  position: absolute; left: 20px; bottom: 20px; max-width: 320px; box-shadow: var(--shadow); animation: rise .6s 1.4s var(--ease) both;
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.welcome h3 { font-size: 16px; margin-bottom: 6px; }
.welcome p { font-size: 13.5px; color: var(--ink-dim); }
.welcome.bye { animation: none; opacity: 0; transform: translateY(10px); transition: all .35s var(--ease); }
.view.explore .tip { position: fixed; z-index: 40; }
.view.explore .tip span { color: var(--c); }
.fab { display: none; }

@media (max-width: 900px) {
  .view.explore { grid-template-columns: 1fr; }
  .rail {
    position: absolute; z-index: 12; top: 0; bottom: 0; left: 0; width: min(320px, 88vw); box-shadow: var(--shadow);
    background: color-mix(in srgb, var(--bg-2) 94%, transparent); backdrop-filter: blur(16px);
    transform: translateX(-105%); transition: transform .45s var(--ease);
  }
  .rail-open .rail { transform: none; }
  .rail-close { display: inline-grid; }
  .fab {
    display: inline-flex; align-items: center; gap: 8px; position: absolute; left: 14px; top: 14px; z-index: 5; padding: 9px 14px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 13.5px; box-shadow: var(--shadow);
  }
  .orient { display: none; }
  .zoom-ctrls { top: auto; bottom: 64px; transform: none; left: auto; right: 12px; }
  .stage-hint { display: none; }
  .welcome { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ═══════════════ Shared page layout ═══════════════ */
.view.atlas-index, .view.gallery, .view.cell-view, .view.study, .view.study-mode { padding: 28px clamp(16px, 4vw, 48px) 80px; }
.hero { max-width: 1100px; margin: 10px auto 26px; }
.hero h1 { font-size: clamp(30px, 4.6vw, 52px); letter-spacing: -.025em; margin-bottom: 12px; animation: rise .7s var(--ease) both; }
.hero.compact h1 { font-size: clamp(28px, 3.8vw, 42px); }
.hero-sub { font-size: 17px; color: var(--ink-dim); max-width: 760px; animation: rise .7s .08s var(--ease) both; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.hero-stats div {
  display: flex; flex-direction: column; padding: 14px 18px; min-width: 150px; border-radius: 14px; border: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--surface) 75%, transparent); animation: rise .7s var(--ease) both;
}
.hero-stats div:nth-child(2) { animation-delay: .06s; }
.hero-stats div:nth-child(3) { animation-delay: .12s; }
.hero-stats div:nth-child(4) { animation-delay: .18s; }
.hero-stats b { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; background: linear-gradient(90deg, var(--ink), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-stats span { font-size: 13px; color: var(--ink-dim); }
.hero .pills, .hero .seg { margin-top: 18px; }

/* ═══════════════ Atlas index ═══════════════ */
.sys-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.sys-card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 8px; padding: 20px; min-height: 190px; border-radius: 18px; color: var(--ink);
  background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--line-soft);
  transition: transform .35s var(--ease), border-color .3s, box-shadow .35s;
  animation: rise .6s var(--ease) both; animation-delay: calc(var(--i) * 45ms + .1s);
}
.sys-card:hover { text-decoration: none; transform: translateY(-4px); border-color: color-mix(in srgb, var(--c) 55%, transparent); box-shadow: 0 18px 40px -18px color-mix(in srgb, var(--c) 55%, transparent); }
.sys-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); }
.sys-ico .ico { width: 26px; height: 26px; }
.sys-card h3 { font-size: 19px; margin-top: 6px; }
.sys-card p { color: var(--ink-dim); font-size: 14px; margin: 0; flex: 1; }
.sys-card-foot { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--ink-faint); }
.sys-card-glow { position: absolute; width: 220px; height: 220px; right: -90px; top: -90px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--c) 30%, transparent), transparent 70%); opacity: .5; transition: opacity .4s, transform .6s var(--ease); pointer-events: none; }
.sys-card:hover .sys-card-glow { opacity: 1; transform: scale(1.3); }

/* ═══════════════ Atlas system page ═══════════════ */
.view.atlas { display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.atlas-side { position: sticky; top: 0; align-self: start; height: calc(100vh - 60px); overflow-y: auto; padding: 18px 10px; border-right: 1px solid var(--line-soft); }
.atlas-side .back, .dg-head .back, .study-bar .back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-dim); padding: 6px 8px; border-radius: 8px; }
.atlas-side .back:hover, .dg-head .back:hover, .study-bar .back:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.atlas-side ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; }
.atlas-side li a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--ink-dim); font-size: 14px; font-weight: 550; }
.atlas-side li a .ico { color: var(--c); }
.atlas-side li a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.atlas-side li a.active { background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--ink); }
.atlas-main { padding: 26px clamp(16px, 3.5vw, 44px) 90px; min-width: 0; }
.sys-hero { display: flex; gap: 22px; align-items: flex-start; max-width: 1000px; }
.sys-hero-ico {
  display: grid; place-items: center; flex: none; width: 76px; height: 76px; border-radius: 22px; color: var(--sys);
  background: color-mix(in srgb, var(--sys) 14%, transparent); border: 1px solid color-mix(in srgb, var(--sys) 40%, transparent);
  box-shadow: 0 0 40px -10px var(--sys); animation: rise .6s var(--ease) both;
}
.sys-hero-ico .ico { width: 40px; height: 40px; }
.sys-hero h1 { font-size: clamp(28px, 3.6vw, 40px); margin-bottom: 10px; animation: rise .6s .05s var(--ease) both; }
.sys-hero .eyebrow { color: var(--sys); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.keyfacts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 24px 0 8px; max-width: 1100px; }
.keyfacts .fact { animation: rise .5s var(--ease) both; animation-delay: calc(var(--i) * 40ms + .1s); border-left: 3px solid var(--sys); }
.tabs { position: sticky; top: 0; z-index: 4; display: flex; gap: 4px; margin: 22px 0 18px; padding: 8px 0 0; border-bottom: 1px solid var(--line-soft); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); overflow-x: auto; scrollbar-width: none; }
.tabs button { padding: 10px 14px; font-weight: 600; font-size: 14.5px; color: var(--ink-dim); white-space: nowrap; transition: color .2s; }
.tabs button[aria-selected="true"] { color: var(--ink); }
.tab-ink { position: absolute; left: 0; bottom: -1px; height: 2.5px; border-radius: 2px; background: var(--sys); transition: transform .4s var(--ease), width .4s var(--ease); }
.tab-panel.swap { animation: rise .45s var(--ease) both; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; max-width: 1150px; }
.two-col aside .card { position: sticky; top: 70px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card-grid .card { animation: rise .5s var(--ease) both; animation-delay: calc(var(--i) * 45ms); }
.refs { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-dim); }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 6px; }
.filter { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; min-width: 260px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.filter:focus-within { border-color: var(--accent); box-shadow: var(--glow); }
.filter .ico { color: var(--ink-faint); }
.filter input { flex: 1; border: 0; outline: none; background: none; }
.filter-bar .pills { flex: 1; }
.s-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.s-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 14px 16px; border-radius: 14px; min-height: 120px;
  background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--line-soft);
  transition: transform .3s var(--ease), border-color .25s, box-shadow .3s;
  animation: rise .45s var(--ease) both; animation-delay: calc(var(--i) * 25ms);
}
.s-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--c, var(--sys)) 55%, transparent); box-shadow: 0 14px 30px -18px var(--c, var(--sys)); }
.s-type { display: flex; align-items: center; gap: 5px; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--c, var(--sys)); font-weight: 700; }
.s-type .ico { width: 13px; height: 13px; }
.s-card h4 { font-size: 15.5px; }
.s-card p { margin: 0; font-size: 13.5px; color: var(--ink-dim); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.s-group h3.section-h, .s-group h2.section-h { margin-top: 26px; }

/* ═══════════════ Diagrams ═══════════════ */
.dg-sec { max-width: 1200px; margin: 0 auto; }
.dg-sec .section-h { scroll-margin-top: 20px; }
.dg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.dg-card {
  display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; color: var(--ink); background: var(--surface); border: 1px solid var(--line-soft);
  transition: transform .35s var(--ease), border-color .3s, box-shadow .35s; animation: rise .5s var(--ease) both; animation-delay: calc(var(--i) * 40ms);
}
.dg-card:hover { text-decoration: none; transform: translateY(-4px); border-color: color-mix(in srgb, var(--c) 55%, transparent); box-shadow: 0 18px 36px -18px var(--c); }
.dg-thumb { height: 190px; display: grid; place-items: center; padding: 10px; background: radial-gradient(70% 70% at 50% 50%, color-mix(in srgb, var(--c) 10%, transparent), transparent 70%), var(--bg-2); border-bottom: 1px solid var(--line-soft); }
.dg-thumb .dg { opacity: 0; transition: opacity .6s var(--ease), transform .6s var(--ease); transform: scale(.97); }
.dg-thumb.ready .dg { opacity: 1; transform: none; }
.dg-card:hover .dg-thumb .dg { transform: scale(1.03); }
.dg-meta { padding: 12px 14px 14px; display: grid; gap: 4px; }
.dg-meta .chip { justify-self: start; --c: inherit; }
.dg-meta h4 { font-size: 15.5px; margin-top: 4px; }
.dg-meta p { margin: 0; font-size: 13px; color: var(--ink-dim); }
.dg-badges { display: flex; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--ink-faint); }
.dg-badges span { display: inline-flex; align-items: center; gap: 4px; }
.dg-badges .ico { width: 12px; height: 12px; }
.jump { margin-top: 16px; }

.view.diagram-view { display: flex; flex-direction: column; overflow: hidden; padding: 14px clamp(12px, 2.5vw, 28px) 16px; }
.dg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 12px; }
.dg-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; flex: 1; min-width: 260px; }
.dg-title h1 { font-size: 24px; }
.dg-title p { margin: 0; color: var(--ink-dim); font-size: 14px; }
.dg-title .chip { align-self: center; }
.dg-more { display: flex; flex-wrap: wrap; gap: 6px; }
.dg-host { flex: 1; min-height: 0; }

@media (max-width: 1000px) {
  .view.diagram-view { overflow-y: auto; display: block; }
  .two-col { grid-template-columns: 1fr; }
  .view.atlas { grid-template-columns: 1fr; }
  .atlas-side { position: static; height: auto; display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .atlas-side ul { display: flex; margin: 0; }
  .atlas-side li a span { white-space: nowrap; }
}

/* ═══════════════ Cell explorer ═══════════════ */
.cell-stage { max-width: 1400px; margin: 0 auto 10px; height: min(78vh, 760px); }
.cell-view .s-group { max-width: 1400px; margin: 0 auto; }
@media (max-width: 1000px) { .cell-stage { height: auto; } }

/* ═══════════════ Study ═══════════════ */
.rings { display: flex; flex-wrap: wrap; gap: 26px; margin-top: 22px; }
.ring { position: relative; width: 132px; height: 132px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring-bg { stroke: var(--surface-2); }
.ring-fg { stroke: var(--c); stroke-linecap: round; stroke-dasharray: var(--p) 100; animation: ring-in 1.4s var(--ease) both; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--c) 60%, transparent)); }
@keyframes ring-in { from { stroke-dasharray: 0 100; } }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-text b { font-size: 24px; font-variant-numeric: tabular-nums; }
.ring-text span { font-size: 11.5px; color: var(--ink-dim); max-width: 90px; line-height: 1.25; }
.study-scope { max-width: 1100px; margin: 0 auto 16px; }
.scope-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.scope-head div { display: flex; gap: 6px; }
.mode-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.mode-card {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 22px; border-radius: 18px; color: var(--ink); min-height: 220px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 12%, var(--surface)), var(--surface) 55%); border: 1px solid var(--line-soft);
  transition: transform .35s var(--ease), box-shadow .35s, border-color .3s; animation: rise .55s var(--ease) both; animation-delay: calc(var(--i) * 60ms + .15s);
}
.mode-card:hover { text-decoration: none; transform: translateY(-4px); border-color: color-mix(in srgb, var(--c) 55%, transparent); box-shadow: 0 20px 40px -20px var(--c); }
.mode-ico { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 15px; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }
.mode-ico .ico { width: 26px; height: 26px; }
.mode-card h3 { font-size: 20px; margin-top: 4px; }
.mode-card p { color: var(--ink-dim); font-size: 14px; margin: 0; flex: 1; }
.mode-foot { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--c); font-size: 14px; }

.view.study-mode { max-width: 1100px; margin: 0 auto; }
.study-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.study-bar h2 { font-size: 18px; }
.progress { flex: 1; height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s var(--ease); }
.count { font-size: 13px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.score-chip { font-size: 13px; font-weight: 650; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.kbd-hint { text-align: center; color: var(--ink-faint); font-size: 12.5px; margin-top: 18px; }
.kbd-hint kbd { margin: 0 2px; }

.flash-wrap { perspective: 1400px; display: grid; place-items: center; }
.flash { position: relative; width: min(640px, 100%); height: 380px; transform-style: preserve-3d; transition: transform .7s var(--ease); cursor: pointer; outline: none; }
.flash.enter { animation: rise .5s var(--ease) both; }
.flash.flipped { transform: rotateY(180deg); }
.flash.out-good, .flash.out-easy { transform: rotateY(180deg) translateX(-60px); opacity: 0; transition: all .26s ease-in; }
.flash.out-again { transform: rotateY(180deg) translateX(60px); opacity: 0; transition: all .26s ease-in; }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 22px; padding: 30px; overflow-y: auto;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 14%, var(--surface)), var(--surface) 60%); border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line-soft));
  box-shadow: var(--shadow);
}
.face.front { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; }
.face.front .chip { --c: inherit; }
.face.front h2 { font-size: clamp(26px, 4vw, 38px); }
.face.front .prompt { color: var(--ink-faint); font-size: 14px; margin: 10px 0 0; }
.face.back { transform: rotateY(180deg); display: flex; flex-direction: column; gap: 10px; }
.face.back h3 { font-size: 20px; color: var(--c); }
.face.back .lead { font-size: 15.5px; }
.face.back p { margin: 0; font-size: 14px; }
.face.back .fact { align-self: start; }
.face.back .link { align-self: start; margin-top: auto; }
.flash-ctrls { display: flex; justify-content: center; gap: 10px; margin-top: 22px; min-height: 48px; }
.btn.rate { height: 46px; padding: 0 22px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); box-shadow: none; }
.btn.rate kbd { background: transparent; }
.btn.rate.again:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, var(--surface-2)); }
.btn.rate.good:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface-2)); }
.btn.rate.easy:hover { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, var(--surface-2)); }
.done-card { display: grid; justify-items: center; text-align: center; gap: 14px; padding: 34px; max-width: 560px; margin: 0 auto; animation: rise .5s var(--ease) both; }

.quiz-card { max-width: 760px; margin: 0 auto; padding: 26px 28px; border-color: color-mix(in srgb, var(--c) 30%, var(--line-soft)); }
.quiz-card.enter { animation: rise .45s var(--ease) both; }
.quiz-card .chip { --c: inherit; }
.quiz-card h2 { font-size: 20px; line-height: 1.4; margin: 14px 0 18px; font-weight: 600; }
.options { display: grid; gap: 9px; }
.option {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 13px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-soft);
  transition: border-color .2s, background .2s, transform .15s; animation: rise .4s var(--ease) both; animation-delay: calc(var(--i) * 50ms + .1s);
}
.option:hover:not(:disabled) { border-color: var(--accent); transform: translateX(3px); }
.option:disabled { cursor: default; }
.option.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, var(--surface-2)); animation: pop .4s var(--ease); }
.option.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--surface-2)); animation: shake .4s; }
@keyframes pop { 50% { transform: scale(1.02); } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.explain { margin-top: 18px; padding: 16px 18px; border-radius: 12px; background: var(--surface-2); border-left: 3px solid var(--accent); animation: rise .4s var(--ease) both; }
.quiz-card.is-right .explain { border-left-color: var(--ok); }
.quiz-card.is-wrong .explain { border-left-color: var(--danger); }
.explain h4 { margin: 0 0 6px; }
.explain .btn, .explain .row { margin-top: 12px; }
.explain .row { justify-content: flex-start; }
.review { max-width: 760px; margin: 0 auto 12px; }
.review p.wrong-a, .review p.right-a { display: flex; align-items: center; gap: 6px; margin: 4px 0; font-weight: 600; }
.review .wrong-a { color: var(--danger); }
.review .right-a { color: var(--ok); }

.identify .ident-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; height: calc(100vh - 200px); min-height: 420px; }
.ident-stage { position: relative; border-radius: 18px; border: 1px solid var(--line-soft); background: radial-gradient(60% 60% at 50% 45%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 70%), var(--bg-2); overflow: hidden; }
.ident-stage .body-svg { position: absolute; inset: 0; }
.ident-stage .body-svg .part { pointer-events: none; }
.ident-stage .body-svg.has-sel .part.sel { animation: ident-pulse 1.6s ease-in-out infinite; }
@keyframes ident-pulse { 50% { filter: drop-shadow(0 0 7px currentColor) brightness(1.3); } }
.ident-side .quiz-card { padding: 20px; }
.ident-side .quiz-card h2 { font-size: 18px; }
@media (max-width: 900px) {
  .identify .ident-layout { grid-template-columns: 1fr; height: auto; }
  .ident-stage { height: 46vh; }
  .flash { height: 420px; }
}

/* ═══════════════ Shared: utilities, footer, static pages ═══════════════ */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.h3 { font-size: 19px; }
.h4 { font-size: 15.5px; }
.sys-card h2 { margin-top: 6px; }
.dg-meta h3 { margin-top: 4px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-dim); margin-bottom: 14px; }
.crumbs a { color: var(--ink-dim); }
.crumbs a:hover { color: var(--ink); }
.crumbs i { font-style: normal; color: var(--ink-faint); }

.site-foot {
  max-width: 1200px; margin: 60px auto 0; padding: 26px clamp(16px, 4vw, 40px) 40px; border-top: 1px solid var(--line-soft);
  display: grid; gap: 12px; color: var(--ink-dim); font-size: 13.5px;
}
.foot-brand { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.foot-brand b { color: var(--ink); font-size: 15px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-foot nav a { color: var(--ink-dim); }
.site-foot nav a:hover { color: var(--accent); }
.foot-note { margin: 0; color: var(--ink-faint); font-size: 12.5px; }
.view.atlas .site-foot { grid-column: 1 / -1; }

.view.static-page { padding: 30px clamp(16px, 4vw, 48px) 60px; }
.page-wrap { max-width: 860px; margin: 0 auto; }
.page-wrap h1 { font-size: clamp(28px, 4vw, 40px); margin-bottom: 14px; }
.page-wrap h2 { font-size: 21px; margin: 28px 0 10px; }
.page-wrap.prose p, .page-wrap .prose p { color: var(--ink-dim); }
.link-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.link-list a { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-soft); background: var(--surface); color: var(--ink); }
.link-list a:hover { text-decoration: none; border-color: var(--c, var(--accent)); }
.link-list .ico { color: var(--c); width: 22px; height: 22px; }
.link-list span { display: flex; flex-direction: column; }
.link-list small { color: var(--ink-dim); }
.cols { columns: 3 200px; padding-left: 18px; }
.steps-list { display: grid; gap: 12px; padding-left: 20px; }
.page-ad { max-width: 1100px; margin: 22px auto; }

/* ═══════════════ Structure study page ═══════════════ */
.view.structure-page { padding: 24px clamp(16px, 4vw, 48px) 40px; }
.sp { max-width: 1240px; margin: 0 auto; }
.sp-head { max-width: 860px; margin-bottom: 26px; animation: rise .5s var(--ease) both; }
.sp-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sp-chips a.chip:hover { text-decoration: none; filter: brightness(1.15); }
.sp-head h1 { font-size: clamp(30px, 4.4vw, 46px); letter-spacing: -.02em; margin-bottom: 8px; }
.sp-latin { color: var(--ink-dim); font-size: 16px; margin: 0 0 4px; }
.sp-aka { color: var(--ink-faint); font-size: 13.5px; margin: 0 0 12px; }
.sp-head .lead { font-size: 18px; color: var(--ink); margin: 12px 0 18px; }
.sp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sp-actions [data-act="bookmark"][aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.sp-actions [data-act="bookmark"][aria-pressed="true"] .ico { fill: color-mix(in srgb, var(--accent) 40%, transparent); }
.sp-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 34px; align-items: start; }
.sp-main { min-width: 0; }
.sp-sec { margin-bottom: 34px; scroll-margin-top: 16px; }
.sp-sec > h2 { font-size: 22px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 10px; }
.sp-sec > h2::before { content: ''; width: 4px; height: 20px; border-radius: 3px; background: var(--sys); }
.sp-sec .prose { font-size: 16px; line-height: 1.75; }
.sp-sec .card { margin-bottom: 12px; }
.sp-sec .card h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; margin-bottom: 8px; }
.sp-sec .card.clinical h3 .ico { color: var(--danger); }
.sp-sec .card.mnemonic h3 .ico { color: var(--sys-nervous); }
.sp-sec .parts a, .sp-group a { font-weight: 650; }
.qa { border: 1px solid var(--line-soft); border-radius: 12px; background: var(--surface); margin-bottom: 10px; overflow: hidden; }
.qa summary { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none; position: relative; padding-right: 40px; }
.qa summary::-webkit-details-marker { display: none; }
.qa summary::after { content: '+'; position: absolute; right: 16px; top: 12px; font-size: 20px; color: var(--sys); transition: transform .3s var(--ease); }
.qa[open] summary::after { transform: rotate(45deg); }
.qa > *:not(summary) { margin: 0 16px 12px; }
.qa-opts { padding-left: 22px; color: var(--ink-dim); }
.qa-opts li.right { color: var(--ok); font-weight: 600; }
.qa-ans { margin-top: 6px; }
.rel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.rel { display: flex; flex-direction: column; gap: 2px; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line-soft); background: var(--surface); color: var(--ink); transition: border-color .2s, transform .2s var(--ease); }
.rel:hover { text-decoration: none; border-color: var(--c); transform: translateY(-2px); }
.rel span { font-size: 11.5px; color: var(--c); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.sp-sib { display: flex; justify-content: space-between; gap: 10px; margin: 10px 0 18px; }
.sp-sources { margin-top: 18px; }
.sp-side { position: sticky; top: 16px; display: grid; gap: 14px; }
.sp-side .card { padding: 14px 16px; }
.sp-side h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-dim); margin-bottom: 8px; }
.sp-map { padding: 10px !important; display: grid; gap: 8px; }
.sp-map-svg { aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; cursor: pointer; background: radial-gradient(60% 60% at 50% 45%, color-mix(in srgb, var(--sys) 12%, transparent), transparent 70%), var(--bg-2); }
.sp-map-svg .body-svg { width: 100%; height: 100%; }
.sp-map-svg .body-svg .part { pointer-events: none; }
.sp-map-svg .body-svg .sys.context .part:not(.sel) { opacity: .18 !important; }
.sp-map-link { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; justify-self: center; }
.sp-toc ol { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; }
.sp-toc a, .sp-group a { color: var(--ink-dim); }
.sp-toc a:hover, .sp-group a:hover { color: var(--ink); }
.sp-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 13.5px; max-height: 300px; overflow-y: auto; }
.sp-group b { color: var(--sys); }
@media (max-width: 1000px) {
  .sp-grid { grid-template-columns: 1fr; }
  .sp-side { position: static; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .sp-map-svg { aspect-ratio: 4 / 3; }
}

/* ═══════════════ Ad slots (space reserved to avoid layout shift) ═══════════════ */
.ad { display: grid; gap: 4px; margin: 24px 0; justify-items: center; }
.ad-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); }
.ad > ins, .ad-ph { width: 100%; }
.ad-article > ins, .ad-article .ad-ph { min-height: 280px; }
.ad-sidebar { margin: 0; }
.ad-sidebar > ins, .ad-sidebar .ad-ph { min-height: 600px; }
.ad-feed > ins, .ad-feed .ad-ph { min-height: 250px; }
.ad-panel > ins, .ad-panel .ad-ph { min-height: 250px; }
.ad-results { max-width: 760px; margin: 22px auto; }
.ad-results > ins, .ad-results .ad-ph { min-height: 250px; }
.ad-ph {
  display: grid; place-items: center; border-radius: 12px; font-size: 13px; color: var(--ink-faint);
  border: 1.5px dashed var(--line); background: repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in srgb, var(--line) 25%, transparent) 10px 11px);
}
.dgv-side .ad-sidebar > ins, .dgv-side .ad-sidebar .ad-ph { min-height: 250px; }
@media (max-width: 1000px) { .ad-sidebar > ins, .ad-sidebar .ad-ph { min-height: 250px; } }
