/* Laboratório Virtual de Física — estilos comuns
   Tema claro: papel milimetrado. Tema escuro: lousa (bom para projetor). */

:root {
  --paper: #f6f9fb;
  --grid: #e1ebf1;
  --grid-strong: #c9dae5;
  --panel: #ffffff;
  --panel-2: #eef4f8;
  --ink: #13244a;
  --graphite: #56627a;
  --line: #cfdbe4;
  --accent: #1f4fd1;
  --accent-ink: #ffffff;
  --hl: #ffd84d;
  --c1: #d7263d;
  --c2: #1b6fd8;
  --c3: #11916a;
  --c4: #d97a00;
  --ok: #11916a;
  --bad: #d7263d;
  --shadow: 0 1px 0 rgba(19, 36, 74, .06), 0 6px 18px -10px rgba(19, 36, 74, .25);
  --r-sm: 6px;
  --r-md: 10px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --math: "STIX Two Text", "Cambria Math", Cambria, Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17251f; --grid: #1f3229; --grid-strong: #2a4236; --panel: #1d2f27; --panel-2: #24392f;
    --ink: #eef3ea; --graphite: #a7b7ab; --line: #35503f; --accent: #8cc4ff; --accent-ink: #0e1a14;
    --hl: #f0d25a; --c1: #ff6f7d; --c2: #7db8ff; --c3: #5fe0a9; --c4: #ffb547; --ok: #5fe0a9; --bad: #ff6f7d;
    --shadow: 0 8px 22px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #17251f; --grid: #1f3229; --grid-strong: #2a4236; --panel: #1d2f27; --panel-2: #24392f;
  --ink: #eef3ea; --graphite: #a7b7ab; --line: #35503f; --accent: #8cc4ff; --accent-ink: #0e1a14;
  --hl: #f0d25a; --c1: #ff6f7d; --c2: #7db8ff; --c3: #5fe0a9; --c4: #ffb547; --ok: #5fe0a9; --bad: #ff6f7d;
  --shadow: 0 8px 22px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-strong) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
  min-height: 100vh;
}
a { color: var(--accent); }
img, svg, canvas { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.m { font-family: var(--math); font-style: italic; font-size: 1.08em; }
.mu { font-family: var(--math); font-size: 1.08em; } /* símbolos sem itálico */

/* ---------- barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1320px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 18px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: -.01em;
  font-stretch: 90%; white-space: nowrap;
}
.brand svg { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--graphite); text-decoration: none; font-weight: 600; font-size: .95rem;
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
}
.nav a:hover { color: var(--ink); background: var(--panel-2); }
.nav a[aria-current="page"] { color: #13244a; background: var(--hl); }

.icon-btn {
  flex: none; width: 38px; height: 38px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- layout de laboratório ---------- */
.wrap { max-width: 1320px; margin: 0 auto; padding: 24px 16px 56px; }
.lab-head { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 24px; margin-bottom: 18px; }
.lab-head h1 {
  font-size: clamp(1.9rem, 4vw, 2.8rem); line-height: 1.05; font-weight: 800;
  letter-spacing: -.02em; font-stretch: 88%;
}
.lab-head p { color: var(--graphite); max-width: 62ch; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 18px; }
.tab {
  font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer;
  padding: 9px 16px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--panel); color: var(--graphite);
}
.tab:hover { color: var(--ink); border-color: var(--graphite); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tabpanel[hidden] { display: none; }

.bench {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start;
}
@media (max-width: 980px) { .bench { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow);
}
.panel-pad { padding: 16px; }
.panel h2, .panel h3 { font-size: 1.05rem; font-weight: 800; letter-spacing: -.005em; margin-bottom: 10px; }
.stage { position: relative; overflow: hidden; }
.stage canvas { width: 100%; touch-action: manipulation; }
.stage-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--line);
}
.stage-bar .spacer { flex: 1; }

.side { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 981px) { .side { position: sticky; top: 74px; } }

/* ---------- controles ---------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.field label, .field .lbl { font-weight: 600; font-size: .92rem; }
.field output, .val { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); white-space: nowrap; }
.hint { font-size: .82rem; color: var(--graphite); margin-top: 3px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--line); border-radius: 4px; }
input[type="range"]::-moz-range-track { height: 4px; background: var(--line); border-radius: 4px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; margin-top: -8px;
  background: var(--panel); border: 3px solid var(--accent);
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--panel); border: 3px solid var(--accent); }

select, input[type="number"] {
  font: inherit; width: 100%; padding: 8px 10px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--panel); color: var(--ink);
}
input[type="number"] { font-variant-numeric: tabular-nums; }
select:focus, input[type="number"]:focus { border-color: var(--accent); outline: none; }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-weight: 600; font-size: .95rem; margin-bottom: 10px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 3px; flex: none; }

.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--panel-2); border-radius: 999px; }
.seg button {
  flex: 1; font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; white-space: nowrap;
  padding: 6px 10px; border-radius: 999px; border: 0; background: transparent; color: var(--graphite);
}
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.18); }

.btn {
  font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 16px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--panel); color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: .88rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* objetos selecionáveis */
.picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pick {
  font: inherit; cursor: pointer; padding: 8px 4px 6px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--panel); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .74rem; font-weight: 600; line-height: 1.15;
  text-align: center;
}
.pick canvas { width: 34px; height: 34px; }
.pick:hover { border-color: var(--graphite); }
.pick[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }

/* leituras ao vivo */
.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px; background: var(--line); border-radius: var(--r-sm); overflow: hidden; }
.readout > div { background: var(--panel); padding: 8px 10px; }
.readout .k { font-size: .8rem; color: var(--graphite); }
.readout .v { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

/* ---------- seções abaixo da bancada ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 18px; margin-top: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 18px; margin-top: 18px; }
.chart-box canvas { width: 100%; height: 230px; }
.chart-box h3 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }

.tbl-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .92rem; }
table.data th, table.data td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { font-weight: 700; color: var(--graphite); font-size: .85rem; }
table.data tr.win td { background: color-mix(in srgb, var(--hl) 35%, transparent); }
.empty { color: var(--graphite); font-size: .92rem; padding: 6px 0; }

/* roteiros guiados */
.steps { list-style: none; display: grid; gap: 10px; counter-reset: s; }
.step {
  counter-increment: s; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: start;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel);
}
.step::before {
  content: counter(s); grid-row: span 2; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: .9rem; background: var(--panel-2);
}
.step h4 { font-size: .98rem; font-weight: 800; }
.step p { grid-column: 2 / 3; font-size: .92rem; color: var(--graphite); }
.step .btn { grid-row: span 2; align-self: center; }
@media (max-width: 560px) { .step { grid-template-columns: auto 1fr; } .step .btn { grid-column: 2; grid-row: auto; justify-self: start; margin-top: 6px; } }

/* teoria */
.theory { margin-top: 18px; }
.theory summary {
  cursor: pointer; list-style: none; font-weight: 800; font-size: 1.05rem; padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.theory summary::-webkit-details-marker { display: none; }
.theory summary::after { content: "+"; font-size: 1.4rem; font-weight: 400; line-height: 1; }
.theory[open] summary::after { content: "–"; }
.theory .body { padding: 0 16px 16px; max-width: 78ch; }
.theory .body p, .theory .body ul { margin-bottom: 10px; }
.theory .body ul { padding-left: 20px; }
.eq {
  font-family: var(--math); font-size: 1.35rem; padding: 10px 14px; margin: 10px 0 12px;
  background: var(--panel-2); border-left: 3px solid var(--hl); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  overflow-x: auto; white-space: nowrap;
}
.eq i { font-style: italic; }

/* quiz */
.quiz-q { font-weight: 700; margin-bottom: 10px; font-size: 1.02rem; }
.quiz-opts { display: grid; gap: 6px; }
.quiz-opt {
  font: inherit; text-align: left; cursor: pointer; padding: 10px 12px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--panel); color: var(--ink); font-size: .95rem;
}
.quiz-opt:hover:not([disabled]) { border-color: var(--accent); }
.quiz-opt.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--panel)); }
.quiz-opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--panel)); }
.quiz-opt[disabled] { cursor: default; }
.quiz-exp { margin-top: 10px; font-size: .93rem; padding: 10px 12px; border-radius: var(--r-sm); background: var(--panel-2); }
.quiz-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; }
.quiz-score { font-size: .88rem; color: var(--graphite); font-variant-numeric: tabular-nums; }
.quiz-num { display: flex; gap: 8px; }
.quiz-num input { max-width: 160px; }

/* aviso flutuante */
.toast-zone { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 460px); pointer-events: none; }
.toast {
  background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: var(--r-md);
  font-size: .93rem; font-weight: 600; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  animation: toastIn .2s ease-out;
}
.toast.ok { border-left: 5px solid var(--ok); }
.toast.warn { border-left: 5px solid var(--hl); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.callout { font-size: .9rem; padding: 10px 12px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--hl) 28%, var(--panel)); }
.muted { color: var(--graphite); }
.small { font-size: .88rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.foot { border-top: 1px solid var(--line); margin-top: 40px; }
.foot-in { max-width: 1320px; margin: 0 auto; padding: 20px 16px 28px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; color: var(--graphite); font-size: .9rem; }

/* tela cheia da bancada */
.stage:fullscreen { background: var(--panel); display: flex; flex-direction: column; justify-content: center; }
.stage:fullscreen canvas { height: calc(100vh - 64px) !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .stage-bar, .tabs, .toast-zone { display: none; }
  body { background: #fff; }
}
.stage { scroll-margin-top: 72px; }
a.btn { text-decoration: none; }
@media (max-width: 560px) { .brand-txt { display: none; } .topbar-in { gap: 10px; } .nav a { padding: 7px 10px; } }
@media (max-width: 560px) { .hide-sm { display: none; } .nav a { font-size: .9rem; } }
