/* Geist e Geist Mono hospedadas no próprio site (licença SIL OFL, fonts/LICENSE-Geist-OFL.txt): nenhuma requisição externa */
@font-face {
  font-family: Geist; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(../fonts/geist-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Geist; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(../fonts/geist-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Geist Mono'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(../fonts/geist-mono-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* preto e branco, como um console de laudo: cinzas neutros e o branco como único destaque.
     Cor só onde ela é informação (cortes, estruturas, acerto/erro). */
  --bg: #121212;     /* grafite, não preto: as imagens de TC ficam sempre sobre preto próprio */
  --bg2: #161616;
  --panel: #1c1c1c;
  --panel2: #242424;
  --line: #2e2e2e;
  --line2: #3e3e3e;
  --text: #ededed;
  --muted: #a8a8a8;
  --dim: #8e8e8e;   /* ≥ 4,5:1 sobre --panel2 */
  --accent: #fff;
  --accent2: #bdbdbd;
  --accent-rgb: 255, 255, 255;
  --ok: #3ddc97;
  --warn: #ffc93c;
  --danger: #ff5c7a;
  --axial: #ff5c7a;
  --coronal: #ffc93c;
  --sagital: #3fc7ff;
  --radius: 6px;
  font-family: Geist, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; color: var(--text); font-size: 14px; }
html { -webkit-tap-highlight-color: transparent; }
/* fundo com grão leve (quebra o chapado); os painéis de imagem do visualizador têm fundo próprio e não recebem o grão */
body { background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .035 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E"); }
a, button, summary, label { touch-action: manipulation; }
h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }
code, kbd, .mono { font-family: var(--mono); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
a { color: var(--accent); text-decoration: none; }
/* links no meio do texto: sublinhados, já que a cor não os distingue mais */
p a, li a, .nota a, .legal a, small a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line2); }
p a:hover, li a:hover, .nota a:hover, .legal a:hover, small a:hover { text-decoration-color: currentColor; }
button.link, a.link { background: none; border: 0; padding: 6px 2px; color: var(--muted); cursor: pointer; font-weight: 500; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line2); }
button.link:hover, a.link:hover { color: var(--text); text-decoration-color: currentColor; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: 56px; display: flex; align-items: center; gap: 24px;
  padding: 0 max(18px, calc((100% - 1720px) / 2)); border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: rgba(18, 18, 18, .62); -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand b { display: block; font-size: 15px; letter-spacing: .2px; }
.brand small { display: block; color: var(--muted); font-size: 11px; margin-top: -1px; }
/* menu em pílula, centralizado; a rota atual é a pílula branca */
.nav { display: flex; gap: 2px; flex-wrap: wrap; margin-inline: auto; padding: 4px; border-radius: 999px;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); }
.nav a { color: var(--muted); padding: 6px 14px; border-radius: 999px; font-weight: 500; transition: color .15s ease, background-color .15s ease; }
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.nav a.active { color: #000; background: #fff; }
.top-right { margin-left: 0; }
/* vidro fosco: cartões sobre imagem ou texto grande; o que está atrás aparece desfocado */
.vidro { background: rgba(40, 40, 40, .42); -webkit-backdrop-filter: blur(22px) saturate(1.15); backdrop-filter: blur(22px) saturate(1.15);
  border: 1px solid rgba(255, 255, 255, .09); border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 24px 60px rgba(0, 0, 0, .35); }
.privacy { color: var(--dim); font-size: 12px; white-space: nowrap; }

#app { height: calc(100vh - 56px); }
.page { display: none; height: 100%; overflow: auto; }
.page.active { display: block; }
#page-visualizador.active { display: flex; overflow: hidden; }

/* ---------- botões e controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: #000; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: background-color .18s ease, border-color .18s ease, transform .12s ease;
}
.btn:hover { background: #d4d4d4; border-color: #d4d4d4; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.btn.ghost:hover { background: var(--panel2); border-color: var(--muted); }
.btn.ghost { background: transparent; border-color: var(--line2); color: var(--text); }
.btn.small { padding: 5px 9px; font-size: 12px; border-radius: 5px; }
.btn.danger { border-color: rgba(255, 92, 122, .5); background: rgba(255, 92, 122, .15); color: var(--text); }
.btn:disabled { opacity: .4; cursor: default; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 5px 10px; border-radius: 4px; cursor: pointer; font-weight: 500; font-size: 12.5px; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
select, input[type=text], input[type=number], input[type=search] {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 5px; padding: 7px 9px; outline: none; min-width: 0;
}
select:focus, input:focus { border-color: var(--accent); }
/* foco visível por teclado em tudo que é clicável */
a:focus-visible, button:focus-visible, .case-card:focus-visible, .mini-case:focus-visible, .area:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
/* títulos focados na troca de rota não mostram anel: não são clicáveis */
[tabindex="-1"]:focus { outline: none; }
.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; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 14px; border-radius: 8px; background: var(--panel2); color: var(--text); border: 1px solid var(--accent); }
.skip-link:focus { top: 8px; }
input[type=range] { accent-color: var(--accent); width: 100%; }
input[type=checkbox] { accent-color: var(--accent); }
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; color: var(--text); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
kbd { background: var(--panel2); border: 1px solid var(--line2); border-bottom-width: 2px; padding: 1px 5px; border-radius: 4px; font-size: 11px; }

/* ---------- início ---------- */
#page-inicio { padding: 0 0 60px; }
.hero h1 { font-size: clamp(26px, 3.4vw, 42px); margin: 0 0 10px; letter-spacing: -.5px; }
.hero p { color: var(--muted); max-width: 720px; font-size: 15px; line-height: 1.55; margin: 0 0 26px; }

/* ---------- atlas ---------- */
#page-atlas { padding: 36px max(clamp(16px, 4vw, 64px), calc((100% - 1760px) / 2)) 50px; }
.atlas-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.atlas-head h1 { margin: 0 0 6px; font-size: 30px; }
.atlas-head p { margin: 0; color: var(--muted); max-width: 640px; line-height: 1.5; }
.atlas-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.atlas-search { flex: 1 1 100%; min-width: 0; margin-bottom: 4px; background: var(--panel); border: 1px solid var(--line2); color: var(--text);
  border-radius: 6px; padding: 8px 12px; font: inherit; font-size: 13px; }
.atlas-search:focus { outline: none; border-color: var(--accent); }
.chip { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 5px 10px; border-radius: 5px; cursor: pointer; font-weight: 500; font-size: 12.5px; transition: color .15s ease, border-color .15s ease; }
.chip:hover { color: var(--text); border-color: var(--line2); }
.chip.on { color: var(--text); border-color: var(--muted); background: var(--panel2); }
a.chip { text-decoration: none; }
.atlas-sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
.atlas-select { background: var(--panel); border: 1px solid var(--line2); color: var(--text); border-radius: 5px; padding: 5px 8px;
  font: inherit; font-size: 12.5px; max-width: 100%; }
.atlas-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.atlas-mais { grid-column: 1 / -1; justify-self: center; margin-top: 8px; }
.atlas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.case-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; transition: border-color .15s ease; display: flex; flex-direction: column; color: var(--text); }
.case-card:hover { border-color: var(--accent); }
.case-thumb { aspect-ratio: 16/10; background: #000 center/cover no-repeat; position: relative; filter: grayscale(1) contrast(1.05); transition: filter .35s ease; }
.case-card:hover .case-thumb, .case-card:focus-visible .case-thumb { filter: none; }
.case-thumb .tag { position: absolute; left: 10px; top: 10px; background: rgba(8, 10, 16, .78); padding: 2px 7px; border-radius: 3px; font-size: 11.5px; font-weight: 500; }
.case-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.case-body h3 { margin: 0; font-size: 15.5px; font-weight: 600; line-height: 1.3; }
.case-body p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.case-meta { margin-top: auto; padding-top: 8px; color: var(--dim); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.credits { color: var(--dim); font-size: 12px; margin-top: 26px; line-height: 1.5; }

/* ---------- visualizador ---------- */
.vw-empty { margin: auto; text-align: center; color: var(--muted); }
.viewer { display: grid; grid-template-columns: 320px 1fr; width: 100%; height: 100%; }
.viewer.collapsed { grid-template-columns: 0 1fr; }
/* painel lateral: cabeçalho do caso, abas e corpo com rolagem própria */
.side { background: var(--bg2); border-right: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.case-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.case-head h2 { margin: 0; font-size: 17px; line-height: 1.3; letter-spacing: -.2px; }
.case-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.case-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.case-tags span { font-size: 11px; font-weight: 600; color: var(--text); background: var(--panel2); border: 1px solid var(--line2); border-radius: 3px; padding: 1px 6px; }
.side-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.side-tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 4px 9px;
  font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.side-tabs button:hover { color: var(--text); }
.side-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.side-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.side-sec { border-bottom: 1px solid var(--line); padding: 14px 16px; }
.side-sec:last-child { border-bottom: 0; }
.side-sec > h4 { margin: 0 0 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.side-sec > * + label.switch, .side-sec > * + .row { margin-top: 8px; }
.resumo { font-size: 13.5px; line-height: 1.6; color: var(--text); }
.resumo b { color: #fff; }
.finding { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin-bottom: 10px; }
.finding:last-child { margin-bottom: 0; }
.finding-h { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 6px; }
.finding-h b { color: #ffe79a; font-size: 13.5px; line-height: 1.35; }
.finding-n { flex: 0 0 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800;
  color: #1a1400; background: #ffd84a; margin-top: 1px; }
.finding-t { margin: 0 0 10px; color: var(--muted); line-height: 1.5; font-size: 12.5px; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.stack select { width: 100%; }
.atalhos { margin: 0; padding-left: 16px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.atalhos li { margin-bottom: 5px; }
.atalhos b { color: var(--text); font-weight: 600; }
.teach.aviso { color: var(--warn); margin: 0 0 8px; }
.fonte-caso { margin: 0; padding: 12px 16px 16px; color: var(--dim); font-size: 11.5px; line-height: 1.5; }
.teach { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.teach p { margin: 0; }
.teach ul { padding-left: 18px; margin: 6px 0; }
.teach li { margin-bottom: 3px; }
.search-box { position: relative; }
.search-box input { width: 100%; padding-left: 30px; }
.search-box::before { content: '⌕'; position: absolute; left: 10px; top: 5px; color: var(--muted); font-size: 16px; }
.search-results { margin-top: 6px; max-height: 220px; overflow: auto; }
.sr { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; width: 100%; text-align: left;
  background: none; border: 0; color: var(--text); font-size: 12.5px; }
.sr:hover, .sr.on { background: var(--panel2); }
.sr i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sr span { flex: 1; }
.sr em { color: var(--dim); font-style: normal; font-size: 11px; }
.group { margin-bottom: 4px; }
.group-h { display: flex; align-items: center; gap: 8px; padding: 5px 2px; }
.group-h label { flex: 1; display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.group-h .count { color: var(--dim); font-size: 11px; font-weight: 500; background: var(--panel); border-radius: 999px; padding: 0 7px; }
.group-h .exp { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 6px; }
.group-items { padding-left: 22px; display: none; max-height: 240px; overflow: auto; }
.group.open .group-items { display: block; }
.gi { display: flex; align-items: center; gap: 7px; padding: 3px 0; font-size: 12.5px; cursor: pointer; }
.gi i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.gi span { flex: 1; }
.op { display: grid; grid-template-columns: 90px 1fr 36px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin: 8px 0; }
.op .seg button { padding: 4px 10px; font-size: 12px; }
.op output { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg2); flex-wrap: wrap; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); }
.toolbar .grow { flex: 1; }
.stage { flex: 1; display: grid; gap: 6px; padding: 6px; min-height: 0; background: #0b0b0b; }
.stage.l-main { grid-template-columns: 1.15fr 1fr; grid-template-rows: 1fr 0.55fr; grid-template-areas: "v3d main" "v3d thumbs"; }
.stage.l-3d { grid-template-columns: 1fr; grid-template-rows: 1fr; grid-template-areas: "v3d"; }
.stage.l-3d .pane.p2d, .stage.l-3d .thumbs { display: none; }

.stage.l-2d { grid-template-columns: 1fr; grid-template-rows: 1fr 0.4fr; grid-template-areas: "main" "thumbs"; }
.stage.l-2d .p3d { display: none; }
.pane { position: relative; background: #000; border-radius: 10px; border: 1px solid var(--line); overflow: hidden; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.pane canvas { flex: 1; width: 100%; height: 100%; display: block; min-height: 0; touch-action: none; }
.p3d { grid-area: v3d; }
.pmain { grid-area: main; }
.thumbs { grid-area: thumbs; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; min-height: 0; }
.pane-h { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; z-index: 2; pointer-events: none; background: linear-gradient(rgba(0, 0, 0, .55), transparent); }
.pane-h > * { pointer-events: auto; }
.pane-h .ttl { font-weight: 700; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.pane-h .ttl::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--accent)); }
.pane-h .badge { font-size: 10px; font-weight: 800; letter-spacing: .6px; color: var(--c); border: 1px solid var(--c); border-radius: 4px; padding: 1px 5px; }
.pane-h .sp { flex: 1; }
.pane.axial { --c: var(--axial); } .pane.coronal { --c: var(--coronal); } .pane.sagital { --c: var(--sagital); }
.pane.p2d.is-main { box-shadow: inset 0 0 0 1px var(--c); }
.pane-f { position: absolute; left: 8px; right: 8px; bottom: 6px; z-index: 2; display: flex; gap: 8px; align-items: center; }
.pane-f input[type=range] { accent-color: var(--c); }
.iconbtn { background: rgba(12, 16, 24, .8); border: 1px solid var(--line2); color: var(--text); border-radius: 7px; padding: 4px 9px; min-height: 24px; min-width: 24px; cursor: pointer; font-size: 11.5px; font-weight: 600; }
.iconbtn:hover { border-color: var(--accent); }
.iconbtn.on { border-color: var(--accent); background: rgba(var(--accent-rgb), .2); }

.info-card { position: absolute; right: 10px; bottom: 44px; z-index: 3; background: rgba(10, 13, 20, .9); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; min-width: 190px; max-width: 260px; backdrop-filter: blur(8px); }
.info-card b { display: block; font-size: 14px; }
.info-card .muted { font-size: 12px; }
.info-card { max-height: calc(100% - 64px); overflow-y: auto; }
.info-card .nota { font-size: 12px; }
.info-card .close { position: absolute; right: 8px; top: 6px; background: none; border: 0; color: var(--muted); cursor: pointer; }
.btn.on { border-color: var(--accent); background: rgba(var(--accent-rgb), .2); color: var(--text); }
/* marcador da cruz no 3D (vínculo 2D → 3D): anel com mira, centrado no ponto projetado */
.cursor3d { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; z-index: 2; pointer-events: none; border-radius: 50%;
  border: 2px solid #ffe14d; box-shadow: 0 0 0 1px rgba(0, 0, 0, .7), 0 0 8px rgba(255, 225, 77, .6); will-change: transform; }
.cursor3d::before, .cursor3d::after { content: ''; position: absolute; background: #ffe14d; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); }
.cursor3d::before { left: 9px; top: -7px; width: 2px; height: 32px; }
.cursor3d::after { top: 9px; left: -7px; height: 2px; width: 32px; }
.legend3d { position: absolute; left: 10px; bottom: 10px; z-index: 2; color: var(--muted); font-size: 11px; line-height: 1.5; pointer-events: none; text-shadow: 0 1px 2px #000; }
.busy3d { position: absolute; right: 10px; bottom: 10px; z-index: 3; display: flex; gap: 7px; align-items: center; font-size: 11px; color: var(--muted);
  background: rgba(10, 13, 20, .78); border: 1px solid var(--line2); border-radius: 999px; padding: 4px 11px; pointer-events: none; }
.busy3d .spin { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line2); border-top-color: var(--accent2); animation: sp3d .8s linear infinite; }
@keyframes sp3d { to { transform: rotate(360deg); } }
.flow-hud { position: absolute; left: 50%; transform: translateX(-50%); top: 40px; z-index: 3; background: rgba(10, 13, 20, .88); border: 1px solid var(--line2); border-radius: 999px; padding: 6px 14px; display: flex; gap: 10px; align-items: center; font-size: 12px; }
.flow-hud .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.timeline { height: 5px; width: 160px; background: var(--line); border-radius: 3px; overflow: hidden; }
.timeline i { display: block; height: 100%; background: linear-gradient(90deg, #ff3b4d, #ffb04d); width: 0; }
.timeline i.ven { background: linear-gradient(90deg, #3b6bff, #4dc9ff); }

.placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; color: var(--muted); text-align: center; padding: 20px; background: var(--bg); }

/* ---------- carregamento e avisos ---------- */
#busy { position: fixed; inset: 0; z-index: 100; background: rgba(4, 6, 10, .8); display: flex; align-items: center; justify-content: center; }
.busy-box { background: var(--panel); border: 1px solid var(--line2); border-radius: 8px; padding: 24px 28px; min-width: 300px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy-bar { width: 100%; height: 4px; background: var(--line); border-radius: 3px; overflow: hidden; }
.busy-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel2); border: 1px solid var(--line2); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px; max-width: 380px; box-shadow: 0 6px 18px rgba(2, 6, 14, .5); transition: opacity .35s ease, transform .35s ease; line-height: 1.4; }
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
.toast.out { opacity: 0; transform: translateX(20px); }

@media (max-width: 900px) {
  .nav a { padding: 6px 8px; font-size: 12.5px; }
  .privacy { display: none; }
  .viewer { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .stage.l-main, .stage.l-2x2 { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr 0.6fr; grid-template-areas: "v3d" "main" "thumbs"; }
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  #app { height: auto; min-height: calc(100vh - 100px); }
  /* aqui quem rola é a janela: sem altura fixa no body (o topo sticky sumia) e sem rolagem própria nas páginas */
  html, body { height: auto; }
  .page { overflow: visible; }
  .nav { margin-inline: 0; }
  #page-visualizador.active { height: calc(100vh - 100px); }
}

/* ---------- modo estudo ---------- */
.chip.study { color: var(--text); margin-left: auto; }
.chip.study:hover { border-color: var(--accent); }
.case-meta .score { color: var(--ok); }
.study-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 10px; }
.study-head .sp { flex: 1; }
.study-exam { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }
.study-prog { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.study-q { font-size: 13.5px; line-height: 1.45; font-weight: 600; }
.study-tip { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 8px 0 0; }
.study-text { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 8px 0 0; }
.study-fb { margin-top: 10px; padding: 8px 10px; border-radius: 9px; font-size: 12.5px; line-height: 1.4; border: 1px solid var(--line2); background: var(--panel); }
.study-fb.ok { border-color: rgba(61, 220, 151, .5); background: rgba(61, 220, 151, .12); color: #b6f5d8; }
.study-fb.bad { border-color: rgba(255, 92, 122, .45); background: rgba(255, 92, 122, .1); color: #ffc2cd; }
.study-opts { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.study-opt { text-align: left; background: var(--panel); border: 1px solid var(--line2); color: var(--text); border-radius: 9px; padding: 8px 10px; cursor: pointer; font-size: 12.5px; line-height: 1.35; }
.study-opt:hover:not(:disabled) { border-color: var(--accent); }
.study-opt:disabled { opacity: .55; cursor: default; }
.study-opt.ok { border-color: rgba(61, 220, 151, .6); background: rgba(61, 220, 151, .15); opacity: 1; }
.study-opt.bad { border-color: rgba(255, 92, 122, .5); background: rgba(255, 92, 122, .12); }
.study-score { font-size: 20px; font-weight: 700; margin: 10px 0 2px; }
.study-form { display: flex; gap: 6px; margin-top: 10px; }
.study-input { flex: 1; min-width: 0; font-size: 13.5px; padding: 9px 11px; background: var(--panel); border: 1px solid var(--line2); border-radius: 9px; }
.study-input:focus { border-color: var(--accent); }
.study-fb.quase { border-color: rgba(255, 201, 60, .45); background: rgba(255, 201, 60, .1); color: #ffe7a6; }
/* revisão depois da resposta: diagnóstico, fisiopatologia, como achar na TC e tratamento */
.revisao { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.rev-dx { padding: 10px 12px; border-radius: 6px; background: rgba(var(--accent-rgb), .08); border: 1px solid rgba(var(--accent-rgb), .35); }
.rev-dx span { display: block; font-size: 12px; font-weight: 500; color: var(--accent); margin-bottom: 3px; }
.rev-dx b { font-size: 14px; line-height: 1.35; }
.rev-sec { padding: 10px 12px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); }
.rev-sec h5 { margin: 0 0 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.rev-sec p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--text); }
.rev-sec b { color: #ffe79a; font-weight: 600; }

/* ---------- medidas ---------- */
.meas { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; }
.meas > b { display: block; margin-bottom: 6px; font-size: 12.5px; }
.meas.abc { border-color: rgba(255, 201, 60, .35); background: rgba(255, 201, 60, .07); }
.meas-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 2px 0; }
.meas-row span { flex: 1; }
.meas-row em { font-style: normal; color: var(--text); font-variant-numeric: tabular-nums; }
.meas-row em.ok { color: var(--ok); }
.meas-row em.warn { color: var(--warn); }
.meas-list { max-height: 180px; overflow: auto; }

/* ---------- fontes e licenças ---------- */
#page-fontes { padding: 30px clamp(16px, 4vw, 56px) 60px; }
.fontes { max-width: 1000px; }
.fontes h1 { margin: 0 0 10px; font-size: 30px; }
.fontes h2 { margin: 30px 0 12px; font-size: 18px; }
.fontes .lead { color: var(--muted); line-height: 1.6; max-width: 760px; margin: 0; }
.fontes-aviso { margin-top: 18px; border: 1px solid rgba(255, 201, 60, .35); background: rgba(255, 201, 60, .08); border-radius: 6px; padding: 12px 14px; color: var(--muted); line-height: 1.55; font-size: 13px; }
.fontes-aviso b { color: var(--warn); }
.fontes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.fonte-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.fonte-card h3 { margin: 0; font-size: 15px; }
.fonte-card p { margin: 0; font-size: 12.5px; line-height: 1.45; }
.fonte-card .lic { margin-top: auto; padding-top: 8px; color: var(--ok); font-size: 12px; font-weight: 600; }
.fonte-card .lic.nc { color: var(--warn); }
.fontes-p { color: var(--muted); line-height: 1.6; font-size: 13.5px; max-width: 840px; }
.fontes-p code { background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-size: 12px; }
.fontes-lista { color: var(--muted); line-height: 1.6; font-size: 13.5px; max-width: 840px; padding-left: 20px; }
.fontes-lista b { color: var(--text); }
.fontes-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.fontes-tab { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.fontes-tab th, .fontes-tab td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.fontes-tab th { color: var(--muted); font-size: 12px; font-weight: 600; background: var(--bg2); position: sticky; top: 0; }
.fontes-tab tr:last-child td { border-bottom: 0; }
.fontes-tab .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--muted); }

/* ícones (js/icones.js): traço fino, herdam a cor do texto */
.ico { display: inline-block; width: 1.05em; height: 1.05em; vertical-align: -.16em; flex: none; }
.ico svg { width: 100%; height: 100%; display: block; }
.study-fb:empty { display: none; }

/* Contraste AA sobre vidro: o fundo atrás é claro em alguns pontos (letras do título, ossos do topograma,
   miniaturas rolando sob a barra). Opacidade maior + cinza mais claro mantêm o efeito e passam de 4,5:1. */
.topbar { background: rgba(18, 18, 18, .86); }
.privacy { color: var(--muted); }

/* Visualizador em tela estreita ou zoom alto: a página rola em vez de cortar painéis e ferramentas */
@media (max-width: 900px) {
  #page-visualizador.active { height: auto; min-height: calc(100vh - 100px); overflow: visible; }
  .viewer { height: auto; }
  .stage { min-height: 70vh; }
  .side { max-height: none; }
}

/* No celular, desfoque de fundo em camadas que se movem na rolagem custa um passe de blur por quadro */
@media (max-width: 800px), (pointer: coarse) {
  .topbar, .vidro { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .topbar { background: rgba(18, 18, 18, .95); }
  .vidro { background: rgba(26, 26, 26, .94); }
}

/* ---------- Anatomia 3D (js/anatomia.js, js/anatomia-painel.js) ---------- */
#page-anatomia { overflow: hidden; }
#anatomia, .anat { height: 100%; }
.anat { display: grid; grid-template-columns: 360px 1fr; }
.anat-painel { overflow: auto; padding: 14px 14px 24px; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 10px; }
.anat-painel h1 { font-size: 1.2rem; margin: 0; }
.anat-painel h2 { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin: 6px 0 0; font-weight: 600; }
.anat-busca { width: 100%; box-sizing: border-box; }
.anat-lista { list-style: none; margin: 0; padding: 0; }
.anat-resultados { max-height: 220px; overflow: auto; }
.anat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.anat-chip { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.anat-chip:hover { color: var(--text); border-color: var(--dim); }
.anat-chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.anat-arvore { display: flex; flex-direction: column; gap: 2px; }
.anat-painel summary { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 2px; border-radius: var(--radius); list-style: none; }
.anat-painel summary::-webkit-details-marker { display: none; }
.anat-painel summary::before { content: '▸'; color: var(--dim); font-size: 11px; width: 10px; transition: transform .12s; }
.anat-painel details[open] > summary::before { transform: rotate(90deg); }
.anat-painel summary:hover { background: rgba(255,255,255,.04); }
.anat-sis > summary { font-weight: 600; }
.anat-sis-nome { flex: 1; min-width: 0; }
.anat-sis-corpo { padding-left: 14px; }
.anat-grupo > summary { font-weight: 500; color: var(--muted); }
.anat-grupo > .anat-lista { padding-left: 14px; max-height: 320px; overflow: auto; }
.anat-linha { display: flex; align-items: center; gap: 4px; border-radius: var(--radius); }
.anat-linha small { margin-left: auto; padding-right: 6px; font-size: 11px; white-space: nowrap; }
.anat-linha.sel { background: rgba(63, 199, 255, .16); }
.anat-nome-btn { all: unset; flex: 1; min-width: 0; padding: 4px 4px; cursor: pointer; font-size: 13.5px; overflow-wrap: anywhere; }
.anat-nome-btn:hover, .anat-nome-btn:focus-visible { color: #fff; text-decoration: underline; }
.anat-olho { all: unset; flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; cursor: pointer; color: var(--text); }
.anat-olho:hover, .anat-olho:focus-visible { background: rgba(255,255,255,.1); }
.anat-olho[data-estado="nada"] { color: var(--dim); }
.anat-olho[data-estado="algum"] { color: var(--muted); }
.anat-olho .ico, .anat-olho svg { width: 18px; height: 18px; display: block; }
.anat-nome { font-weight: 600; font-size: 1.05rem; margin: 0; }
/* nome da estrutura: cartão no canto superior direito do 3D */
.anat-info { position: absolute; top: 12px; right: 12px; z-index: 2; max-width: min(300px, calc(100% - 24px)); background: rgba(10, 13, 20, .82); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; backdrop-filter: blur(8px); }
.anat-info p { margin: 2px 0; }
.anat-info { max-height: calc(100% - 24px); overflow-y: auto; }
/* notas de fisiologia, fisiopatologia e curiosidade (js/notas.js), abaixo do nome da estrutura */
.nota { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line2); font-size: 12.5px; line-height: 1.45; }
.nota-linha { margin: 0 0 6px; color: var(--muted); }
.nota-linha b { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text); margin-bottom: 1px; }
.nota-c b { color: #f2a28c; }
.nota-q b { color: #8fd3ff; }
.nota-fonte { margin: 4px 0 0; font-size: 10.5px; color: var(--dim); }
.anat-ferr { flex-wrap: wrap; }
.anat-opcao { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.anat-texturas { display: grid; gap: 7px; }
.anat-texturas-intensidade { flex-wrap: wrap; }
.anat-texturas-intensidade > span { flex: 1; }
.anat-texturas .anat-texturas-intensidade input[type=range] { flex: 1 1 100%; }
.anat-texturas-intensidade input:disabled { opacity: .45; }
.anat-texturas-status, .anat-texturas-nota { margin: 0; line-height: 1.45; }
.anat-texturas-status[data-estado="erro"] { color: var(--warn); }
.anat-palco { position: relative; min-width: 0; min-height: 0; background: radial-gradient(ellipse at 50% 35%, #2a2f38 0%, #16181d 55%, #0c0d10 100%); }
.anat-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
.anat-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.anat-canvas:active { cursor: grabbing; }
.anat-erro { padding: 24px; }
/* Trip: micro câmera pelos canais do corpo (js/trip-painel.js) */
.trip { position: absolute; top: 12px; left: 12px; z-index: 3; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; width: min(340px, calc(100% - 24px)); max-height: calc(100% - 24px); pointer-events: none; }
.trip > * { pointer-events: auto; }
.trip-painel { background: rgba(10, 13, 20, .88); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; backdrop-filter: blur(8px); overflow-y: auto; width: 100%; box-sizing: border-box; }
.trip-painel[hidden], .trip-hud[hidden], .trip-hud-parada[hidden], .trip-vinheta[hidden] { display: none; }
.trip-corpo { display: flex; flex-direction: column; gap: 8px; }
.trip-titulo { font-size: .95rem; margin: 0; }
.trip-aviso { margin: 0; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.trip-aviso p { margin: 0; }
.trip-abas, .trip-acoes { display: flex; flex-wrap: wrap; gap: 6px; }
.trip-roteiros { display: flex; flex-direction: column; gap: 6px; }
.trip-roteiro { all: unset; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--muted); }
.trip-roteiro b { color: var(--text); font-size: 13.5px; }
.trip-roteiro small { color: var(--dim); font-size: 11.5px; }
.trip-roteiro:hover:not(:disabled), .trip-roteiro:focus-visible { border-color: var(--dim); }
.trip-roteiro:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.trip-roteiro[aria-checked="true"] { border-color: var(--text); background: rgba(255, 255, 255, .06); }
.trip-roteiro:disabled { opacity: .55; cursor: not-allowed; }
.trip-linha { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.trip-linha > :first-child { flex: none; width: 74px; }
.trip-linha > :nth-child(2) { flex: 1; min-width: 0; }
.trip-sel { width: 100%; }
.trip-chip { padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; color: var(--text); }
.trip-prog { width: 100%; }
.trip-video { width: 100%; border-radius: 8px; background: #000; }
.trip-resultado { display: flex; flex-direction: column; gap: 6px; }
.trip-resultado:empty { display: none; }
.anat-palco.trip-ativa { background: #000; }
/* na tela, a mesma vinheta e as mesmas legendas que vão para o vídeo (js/trip/gravador.js) */
.trip-vinheta { position: absolute; inset: 0; z-index: 1; pointer-events: none; background: radial-gradient(circle at 50% 50%, transparent 38%, rgba(0, 0, 0, .55) 62%, rgba(0, 0, 0, .95) 100%); }
.trip-hud { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.trip-hud-orgao { position: absolute; right: 12px; bottom: 12px; margin: 0; padding: 4px 12px; border-radius: 999px; background: rgba(0, 0, 0, .6); color: #fff; font-weight: 600; font-size: 13px; }
.trip-hud-parada { position: absolute; left: 50%; bottom: 52px; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); box-sizing: border-box; padding: 10px 14px; border-radius: 10px; background: rgba(0, 0, 0, .66); color: #fff; }
.trip-hud-parada b { display: block; font-size: 15px; }
.trip-hud-parada p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.45; }
@media (max-width: 760px) { .trip-hud-parada { bottom: 44px; } .trip-hud-parada p { font-size: 12.5px; } }
@media (prefers-reduced-motion: reduce) { .trip-roteiro { transition: none; } }
@media (max-width: 900px) { #page-anatomia.active { height: calc(100vh - 100px); } .anat { grid-template-columns: 300px 1fr; } }
@media (max-width: 760px) {
  #page-anatomia, #page-anatomia.active { overflow: visible; height: auto; }
  .anat { grid-template-columns: 1fr; grid-template-rows: 60vh auto; height: auto; }
  .anat-palco { grid-row: 1; height: 60vh; }
  .anat-painel { grid-row: 2; border-right: 0; border-top: 1px solid var(--line); overflow: visible; }
}
.anat-opcao input[type="range"] { flex: 1; }
