:root {
  --brand: #4f46e5;
  --brand2: #7c3aed;
  --top-h: 112px;
  --soft: #f1f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --pastel0: #e0e7ff; --pastel1: #fef3c7; --pastel2: #dcfce7; --pastel3: #fee2e2; --pastel4: #e0f2fe; --pastel5: #f3e8ff;
}
[data-bs-theme="dark"] {
  --soft: #0f172a;
  --card: #1e293b;
  --line: #334155;
  --pastel0: #312e81; --pastel1: #78350f; --pastel2: #14532d; --pastel3: #7f1d1d; --pastel4: #0c4a6e; --pastel5: #581c87;
}
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top-h) + 12px); }
body { background: var(--soft); }

/* ---------- topo ---------- */
#top { position: sticky; top: 0; z-index: 1030; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); }
.topbar { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; }
.brand { color: #fff; font-weight: 800; text-decoration: none; font-size: 1.15rem; white-space: nowrap; }
.brand:hover { color: #fff; opacity: .9; }
.search { width: min(420px, 100%); }
.results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card); color: var(--bs-body-color); border: 1px solid var(--line); border-radius: .75rem; max-height: 70vh; overflow: auto; display: none; z-index: 1050; }
.results.show { display: block; }
.results a { display: block; padding: .6rem .85rem; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.results a:hover, .results a.active { background: var(--soft); }
.results .r-t { font-weight: 700; font-size: .92rem; }
.results .r-p { font-size: .78rem; color: var(--bs-secondary-color); }
.results .r-s { font-size: .82rem; color: var(--bs-secondary-color); }
mark { background: #fde047; color: #111; padding: 0 2px; border-radius: 3px; }

#tabs { background: var(--card); border-bottom: 1px solid var(--line); display: flex; gap: .35rem; overflow-x: auto; padding: .45rem .75rem; scrollbar-width: thin; }
.tab { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; padding: .4rem .8rem; border-radius: 999px; text-decoration: none; color: var(--bs-body-color); font-weight: 600; font-size: .9rem; border: 1px solid transparent; }
.tab:hover { background: var(--soft); }
.tab.active { color: #fff; background: var(--c, var(--brand)); }
.tab .cnt { font-size: .7rem; opacity: .8; font-weight: 500; }

/* ---------- home ---------- */
.hero { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; border-radius: 1.25rem; padding: 2rem; }
.hero h1 { font-weight: 800; }
.count { background: rgba(255, 255, 255, .16); border-radius: 1rem; padding: .8rem 1.1rem; text-align: center; min-width: 150px; }
.count b { font-size: 2rem; display: block; line-height: 1; }
.subj { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: 1rem; padding: 1rem 1.1rem; height: 100%; transition: transform .15s, box-shadow .15s; }
.subj:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0, 0, 0, .1); color: inherit; }
.subj .ic { font-size: 1.8rem; }
.subj h3 { font-size: 1.05rem; font-weight: 700; margin: .3rem 0; }
.subj p { font-size: .85rem; color: var(--bs-secondary-color); margin-bottom: .6rem; }
.progress { height: 6px; }
.progress-bar { background: var(--c, var(--brand)); }

/* ---------- barra lateral ---------- */
.sidebar { position: sticky; top: calc(var(--top-h) + 14px); max-height: calc(100vh - var(--top-h) - 28px); overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 1rem; padding: .85rem; }
.side-head { font-weight: 800; display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.grp { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 800; color: var(--bs-secondary-color); margin: .9rem 0 .25rem; }
.tlink { display: flex; gap: .45rem; align-items: flex-start; padding: .35rem .5rem; border-radius: .5rem; text-decoration: none; color: var(--bs-body-color); font-size: .88rem; line-height: 1.25; }
.tlink:hover { background: var(--soft); }
.tlink.active { background: var(--c); color: #fff; font-weight: 600; }
.tlink .ck { flex: 0 0 auto; width: 1rem; text-align: center; opacity: .35; }
.tlink.done .ck { opacity: 1; color: #16a34a; }
.tlink.active.done .ck { color: #fff; }

/* ---------- artigo ---------- */
.article { background: var(--card); border: 1px solid var(--line); border-radius: 1rem; padding: 1.5rem 1.75rem; }
.crumbs { font-size: .8rem; color: var(--bs-secondary-color); }
.topic-title { font-size: 1.7rem; font-weight: 800; margin: .15rem 0 .75rem; border-bottom: 4px solid var(--c); padding-bottom: .5rem; }
.content { font-size: 1.02rem; line-height: 1.65; }
.content h1, .content h2, .content h3 { font-weight: 700; margin-top: 1.6rem; }
.content h2 { font-size: 1.35rem; color: var(--c); }
.content h3 { font-size: 1.12rem; }
.content blockquote { border-left: 5px solid var(--c); background: var(--soft); padding: .7rem 1rem; border-radius: 0 .75rem .75rem 0; margin: 1rem 0; }
.content blockquote p:last-child { margin-bottom: 0; }
.content table { width: 100%; font-size: .92rem; }
.content pre { background: var(--soft); border: 1px solid var(--line); border-radius: .6rem; padding: .8rem; overflow: auto; }
.content code { color: var(--brand2); }
.content img { max-width: 100%; }
.content hr { opacity: .25; }
.content .tag { border-radius: .5rem; padding: .35rem .7rem; margin-bottom: .5rem; list-style-position: inside; }
.content .tag-warn { background: rgba(220, 38, 38, .1); border-left: 4px solid #dc2626; }
.content .tag-tip { background: rgba(22, 163, 74, .1); border-left: 4px solid #16a34a; }
.content .tag-ex { background: rgba(37, 99, 235, .1); border-left: 4px solid #2563eb; }
.content li { margin-bottom: .25rem; }
.pager { display: flex; justify-content: space-between; gap: .75rem; margin-top: 2rem; }
.pager a { flex: 1; text-decoration: none; border: 1px solid var(--line); border-radius: .75rem; padding: .7rem .9rem; color: inherit; background: var(--soft); font-size: .9rem; }
.pager a:hover { border-color: var(--c); }
.pager a small { display: block; color: var(--bs-secondary-color); }
.pager a.next { text-align: right; }

/* ---------- figuras ---------- */
.fig { margin: 0 0 1.5rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--soft); padding: .9rem; }
.fig-title { font-weight: 700; margin-bottom: .6rem; }
.fig figcaption { font-size: .85rem; color: var(--bs-secondary-color); margin-top: .6rem; line-height: 1.5; }
.fig svg { width: 100%; height: auto; display: block; }
.fig svg text { fill: var(--bs-body-color); font-family: inherit; font-size: 13px; }
.fig svg .t-sm { font-size: 11px; }
.fig svg .t-b { font-weight: 700; }
.fig svg .ln { stroke: var(--bs-body-color); stroke-width: 1.4; fill: none; stroke-linejoin: round; }
.fig svg .ln.thin { stroke-width: .6; opacity: .35; }
.fig svg .ln.thick { stroke-width: 2.4; }
.fig svg .ln.dash { stroke-dasharray: 6 4; }
.fig svg .ln.rain { stroke: #2563eb; stroke-width: 1.6; }
.fig svg .f1 { fill: var(--pastel0); } .fig svg .f2 { fill: var(--pastel1); } .fig svg .f3 { fill: var(--pastel2); }
.fig svg .f4 { fill: var(--pastel3); } .fig svg .f5 { fill: var(--pastel4); } .fig svg .f6 { fill: var(--pastel5); }
.fig svg .ln.f1, .fig svg .ln.f2, .fig svg .ln.f3, .fig svg .ln.f4, .fig svg .ln.f5, .fig svg .ln.f6 { stroke: var(--bs-body-color); }
.fig svg .fm { fill: #60a5fa; stroke: var(--bs-body-color); stroke-width: .5; } .fig svg .ff { fill: #f472b6; stroke: var(--bs-body-color); stroke-width: .5; }
.fig svg .cloud circle, .fig svg .cloud rect { fill: #cbd5e1; stroke: none; }
.fig svg .sun { fill: #fbbf24; stroke: #f59e0b; stroke-width: 2; }
.fig svg .fire { fill: #fb923c; stroke: #dc2626; stroke-width: 2; }
.fig svg .wall { fill: #94a3b8; stroke: var(--bs-body-color); }
.fig svg .shadow { fill: #0f172a; opacity: .7; }
.fig svg .head { fill: var(--pastel1); stroke: var(--bs-body-color); }
.fig svg .curve { fill: none; stroke: #4f46e5; stroke-width: 3; }
.fig svg .dotv { fill: #16a34a; } .fig svg .dotr { fill: #dc2626; }
.fig svg .pa { fill: #2563eb; } .fig svg .pk { fill: var(--bs-body-color); } .fig svg .py { fill: #f59e0b; } .fig svg .pr { fill: #dc2626; }
.fig svg .sunl { stroke: #f59e0b; } .fig svg .irl { stroke: #dc2626; }

.flow { display: flex; flex-wrap: wrap; gap: .4rem; align-items: stretch; }
.flow .arrow { align-self: center; color: var(--bs-secondary-color); font-weight: 700; }
.step { flex: 1 1 130px; border-radius: .8rem; padding: .55rem .7rem; border: 1px solid var(--line); }
.step-h { font-weight: 700; font-size: .9rem; }
.step-b { font-size: .8rem; opacity: .85; margin-top: .15rem; line-height: 1.35; }
.s0 { background: var(--pastel0); } .s1 { background: var(--pastel1); } .s2 { background: var(--pastel2); }
.s3 { background: var(--pastel3); } .s4 { background: var(--pastel4); } .s5 { background: var(--pastel5); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .6rem; }
.mini { border-radius: .8rem; padding: .7rem .8rem; border: 1px solid var(--line); }
.mini-h { font-weight: 800; margin-bottom: .2rem; }
.mini-b { font-size: .85rem; line-height: 1.4; }
.tri { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.tri .tr { text-align: center; padding: .5rem .6rem; border-radius: .6rem; border: 1px solid var(--line); font-weight: 700; }
.tri .tr small { display: block; font-weight: 400; font-size: .78rem; }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.vs .side { border-radius: .8rem; padding: .7rem .9rem; border: 1px solid var(--line); }
.vs h4 { font-size: 1rem; font-weight: 800; }
.vs ul { margin: 0; padding-left: 1.1rem; font-size: .88rem; }
.dice { border-collapse: collapse; margin: 0 auto; }
.dice th, .dice td { border: 1px solid var(--line); width: 2.4rem; height: 2.2rem; text-align: center; }
.dice th { background: var(--pastel0); }
.dice td.hit { background: #22c55e; color: #fff; font-weight: 800; }
.punnett { border-collapse: collapse; margin: 0 auto; }
.punnett th, .punnett td { border: 2px solid var(--line); width: 4rem; height: 3rem; text-align: center; font-size: 1.1rem; }
.punnett th { background: var(--pastel0); } .punnett td.rec { background: var(--pastel3); font-weight: 800; }
.spec { display: flex; border-radius: .5rem; overflow: hidden; font-size: .72rem; color: #fff; text-align: center; }
.spec > div { padding: .9rem .1rem; }
.spec-ax { display: flex; justify-content: space-between; font-size: .75rem; color: var(--bs-secondary-color); margin-top: .3rem; gap: .5rem; }
.ph-wrap { overflow-x: auto; }
.ph { width: 100%; min-width: 620px; border-collapse: collapse; }
.ph td { text-align: center; color: #fff; font-weight: 800; padding: .5rem 0; border: 1px solid rgba(255, 255, 255, .5); }
.ph tr.ex td { background: none; color: var(--bs-body-color); font-weight: 400; font-size: .68rem; padding: .3rem .1rem; border: none; line-height: 1.2; vertical-align: top; }

/* ---------- galeria de imagens ---------- */
.gallery { margin: 0 0 1.5rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--soft); padding: .9rem; }
.gal-strip { display: flex; gap: .75rem; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: .5rem; scrollbar-width: thin; }
.gal-item { flex: 0 0 240px; margin: 0; scroll-snap-align: start; background: var(--card); border: 1px solid var(--line); border-radius: .8rem; overflow: hidden; display: flex; flex-direction: column; }
.gal-btn { display: block; width: 100%; padding: 0; border: 0; background: #0f172a; cursor: zoom-in; }
.gal-btn img { width: 100%; height: 170px; object-fit: contain; display: block; }
.gal-item figcaption { font-size: .8rem; line-height: 1.35; padding: .5rem .65rem .6rem; }
.gal-item .credit { display: block; margin-top: .3rem; font-size: .68rem; color: var(--bs-secondary-color); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(2, 6, 23, .92); display: none; flex-direction: column; align-items: center; justify-content: center; padding: 1.2rem; cursor: zoom-out; }
.lightbox.show { display: flex; }
.lightbox img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: .5rem; background: #fff1; }
.lb-cap { color: #e2e8f0; text-align: center; margin-top: .8rem; max-width: 900px; font-size: .95rem; }
.lb-cap small { color: #94a3b8; }
.lb-cap a { color: #93c5fd; }
.lb-close { position: absolute; top: .8rem; right: 1rem; border: 0; background: rgba(255, 255, 255, .15); color: #fff; width: 2.4rem; height: 2.4rem; border-radius: 50%; font-size: 1.1rem; }

/* ---------- imagens dentro do texto ---------- */
.fig-inline { float: right; width: min(300px, 42%); margin: .2rem 0 1rem 1.4rem; background: var(--soft); border: 1px solid var(--line); border-radius: .8rem; overflow: hidden; }
.fig-inline { clear: right; }
.fig-inline.left { float: left; clear: left; margin: .2rem 1.4rem 1rem 0; }
.fig-inline.wide { float: none; width: 100%; max-width: 760px; margin: 1rem auto 1.2rem; }
.fig-inline .gal-btn img { width: 100%; max-height: 260px; object-fit: contain; display: block; }
.fig-inline.wide .gal-btn img { max-height: 420px; }
.fig-inline figcaption { font-size: .78rem; line-height: 1.35; padding: .45rem .6rem .55rem; }
.fig-inline .credit { display: block; margin-top: .25rem; font-size: .66rem; color: var(--bs-secondary-color); }
.fig-inline.small { width: 150px; margin: .2rem 0 .7rem 1.2rem; }
.fig-inline.small.left { margin: .2rem 1.2rem .7rem 0; }
.fig-inline.small .gal-btn img { max-height: 160px; }
.fig-inline.small figcaption { font-size: .7rem; padding: .35rem .45rem .45rem; }
.fig-inline.small .credit { font-size: .6rem; }
.fig-block { clear: both; margin: 1rem 0 1.2rem; }
.content h1, .content h2, .content h3, .content table, .content .qbase { clear: both; }
.content::after { content: ''; display: table; clear: both; }
@media (max-width: 575.98px) { .fig-inline, .fig-inline.left { float: none; width: 100%; margin: .8rem 0; } }

/* ---------- quiz e simulado ---------- */
.quiz-start { text-align: center; padding: 1rem .5rem; }
.quiz-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; margin: 1.2rem 0; }
.quiz-stats > div { background: var(--soft); border: 1px solid var(--line); border-radius: .8rem; padding: .7rem; }
.quiz-stats b { display: block; font-size: 1.5rem; color: var(--c); }
.quiz-stats span { font-size: .78rem; color: var(--bs-secondary-color); }
.quiz-top { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.qcard { background: var(--soft); border: 1px solid var(--line); border-radius: 1rem; padding: 1.1rem 1.2rem; }
.qbase { border-left: 5px solid var(--c, var(--brand)); background: var(--card); padding: .7rem 1rem; border-radius: 0 .7rem .7rem 0; margin: 0 0 .8rem; font-size: .95rem; }
.qcmd { font-weight: 600; margin-bottom: .9rem; }
.qopts { display: flex; flex-direction: column; gap: .5rem; }
.qopt { display: flex; gap: .7rem; align-items: flex-start; text-align: left; width: 100%; background: var(--card); color: var(--bs-body-color); border: 2px solid var(--line); border-radius: .8rem; padding: .6rem .8rem; transition: border-color .12s, background .12s; }
button.qopt:not(:disabled):hover { border-color: var(--c, var(--brand)); }
.qopt .qlet { flex: 0 0 1.7rem; height: 1.7rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--soft); font-weight: 700; font-size: .85rem; border: 1px solid var(--line); }
.qopt.sel { border-color: var(--c, var(--brand)); background: color-mix(in srgb, var(--c, var(--brand)) 12%, var(--card)); }
.qopt.sel .qlet { background: var(--c, var(--brand)); color: #fff; border-color: transparent; }
.qopt.ok { border-color: #16a34a; background: rgba(22, 163, 74, .13); }
.qopt.ok .qlet { background: #16a34a; color: #fff; border-color: transparent; }
.qopt.bad { border-color: #dc2626; background: rgba(220, 38, 38, .12); }
.qopt.bad .qlet { background: #dc2626; color: #fff; border-color: transparent; }
.qopt:disabled { opacity: 1; cursor: default; }
.qopt.static { cursor: default; padding: .4rem .7rem; font-size: .9rem; }
.qfeedback { margin-top: .9rem; padding: .7rem .9rem; border-radius: .7rem; font-size: .93rem; }
.qfeedback.ok { background: rgba(22, 163, 74, .13); border: 1px solid #16a34a; }
.qfeedback.bad { background: rgba(220, 38, 38, .1); border: 1px solid #dc2626; }
.quiz-result { text-align: center; padding: 1rem 0; }
.score { width: 130px; height: 130px; border-radius: 50%; margin: 0 auto 1rem; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; background: conic-gradient(var(--c, #4f46e5) calc(var(--p) * 1%), var(--line) 0); position: relative; }
.score::before { content: ''; position: absolute; inset: 10px; border-radius: 50%; background: var(--card); }
.score b, .score { z-index: 1; }
.score b { font-size: 2.2rem; position: relative; }
.qreview { border: 1px solid var(--line); border-radius: .7rem; padding: .5rem .8rem; margin-bottom: .5rem; background: var(--soft); }
.qreview summary { cursor: pointer; font-size: .92rem; }
.qreview .qopts { margin-top: .6rem; }
.sim-hero { background: linear-gradient(135deg, #dc2626, #7c3aed); }
.sim-day { display: flex; gap: .8rem; cursor: pointer; height: 100%; background: var(--card); border: 2px solid var(--line); border-radius: 1rem; padding: 1rem 1.2rem; }
.sim-day:has(input:checked) { border-color: #dc2626; background: color-mix(in srgb, #dc2626 8%, var(--card)); }
.sim-day h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: .3rem; }
.sim-day p { margin-bottom: .3rem; font-size: .92rem; }
.sim-banner { border-left-width: 8px; }
.sim-panel { position: sticky; top: calc(var(--top-h) + 14px); background: var(--card); border: 1px solid var(--line); border-radius: 1rem; padding: .9rem; max-height: calc(100vh - var(--top-h) - 28px); overflow: auto; }
.sim-timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.2rem; }
.sim-timer.low { color: #dc2626; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .45; } }
.qnav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; }
.qnav { border: 1px solid var(--line); background: var(--soft); color: var(--bs-body-color); border-radius: .4rem; padding: .2rem 0; font-size: .72rem; }
.qnav.done { background: #dc2626; color: #fff; border-color: #dc2626; }
.qnav.flag { box-shadow: inset 0 0 0 3px #f59e0b; }
.qnav.cur { outline: 3px solid #4f46e5; outline-offset: 1px; font-weight: 800; }
.qdot { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; vertical-align: -1px; border: 1px solid var(--line); }
.qdot.done { background: #dc2626; } .qdot.flag { box-shadow: inset 0 0 0 3px #f59e0b; }
.essay { font-family: Georgia, serif; line-height: 1.9; font-size: 1.02rem; }
.essay-view { white-space: pre-wrap; border: 1px solid var(--line); border-radius: .6rem; padding: .8rem; background: var(--soft); font-family: Georgia, serif; line-height: 1.7; margin-top: .5rem; }
@media (max-width: 991.98px) { .sim-panel { position: static; max-height: none; } }

footer { color: var(--bs-secondary-color); font-size: .82rem; }

@media (max-width: 991.98px) {
  :root { --top-h: 148px; }
  .sidebar { position: static; max-height: none; }
  .article { padding: 1.1rem; }
  .topic-title { font-size: 1.4rem; }
  .vs { grid-template-columns: 1fr; }
}
@media print {
  #top, .sidebar, .pager, .no-print, footer { display: none !important; }
  .article, .fig { border: none; }
}
