:root {
  --bg: #f3f1ec;
  --surface: #fbfaf7;
  --ink: #16181b;
  --ink-2: #4b4f55;
  --ink-3: #61656c;
  --rule: #d9d5cc;
  --grid: rgba(22, 24, 27, .055);
  --accent: #c2410c;
  --tension: #1f5fa8;
  --cool: #9fb3c2;
  --warn-bg: #f4e4cc;
  --warn-ink: #6b3a00;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #101214;
  --surface: #171a1d;
  --ink: #ebe8e1;
  --ink-2: #b6b2aa;
  --ink-3: #96928a;
  --rule: #2d3135;
  --grid: rgba(235, 232, 225, .05);
  --accent: #f07b3f;
  --tension: #74a9e6;
  --cool: #3c5566;
  --warn-bg: #36280f;
  --warn-ink: #f2cd92;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 1rem; top: -3rem; background: var(--ink); color: var(--bg); padding: .5rem .8rem; z-index: 10; }
.skip:focus { top: .75rem; }

/* topo */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .8rem clamp(1rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; font: 500 1rem/1 var(--mono); letter-spacing: .02em; }
.brand-mark { width: 40px; height: 33px; }
.top-nav { display: flex; gap: 1.4rem; margin-left: auto; font-size: .92rem; }
.top-nav a { text-decoration: none; color: var(--ink-2); white-space: nowrap; }
.top-nav a:hover { color: var(--ink); }
.theme {
  display: flex; align-items: center; gap: .45rem;
  font: 500 .8rem/1 var(--mono); color: var(--ink);
  background: none; border: 1px solid var(--rule); border-radius: 999px;
  padding: .45rem .75rem; cursor: pointer;
}
.theme svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme .moon, [data-theme="dark"] .theme .sun { display: none; }
[data-theme="dark"] .theme .moon { display: inline; }

/* hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  grid-template-areas: "text index" "string string";
  gap: 2.5rem clamp(2rem, 5vw, 5rem);
  padding: clamp(2.5rem, 6vw, 4.5rem) clamp(1rem, 4vw, 3rem) 0;
  max-width: 82rem; margin: 0 auto;
}
.hero-text { grid-area: text; }
.kicker, .ch-n, .plate-id, .tag, .ix-n, dt {
  font-family: var(--mono); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase;
}
.kicker { color: var(--accent); margin: 0 0 1.4rem; }
h1 {
  font: 400 clamp(2.8rem, 7.2vw, 6rem)/.98 var(--serif);
  letter-spacing: -.015em; margin: 0 0 1.6rem; max-width: 13ch;
}
h1 em { color: var(--accent); }
.lede { font-size: 1.12rem; color: var(--ink-2); max-width: 36rem; margin: 0; }

.index { grid-area: index; list-style: none; margin: 0; padding: 0; align-self: end; border-top: 1px solid var(--ink); }
.index li {
  display: grid; grid-template-columns: 2rem 2.4rem 1fr auto; grid-template-rows: auto auto;
  align-items: center; column-gap: .8rem;
  padding: .9rem 0; border-bottom: 1px solid var(--rule);
}
.ix-n { color: var(--ink-3); grid-row: span 2; }
.glyph { width: 2.2rem; height: 2.2rem; grid-row: span 2; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.index li:hover .glyph { stroke: var(--accent); }
.ix-t { display: flex; flex-direction: column; line-height: 1.3; grid-row: span 2; }
.ix-t strong { font-weight: 600; }
.ix-t span { color: var(--ink-3); font-size: .88rem; }
.ix-go {
  font: 500 .85rem/1 var(--mono); text-decoration: none; white-space: nowrap;
  background: var(--ink); color: var(--bg); padding: .5rem .7rem; border-radius: 3px;
}
.ix-go:hover { background: var(--accent); color: #fff; }
.ix-more { font-size: .8rem; color: var(--ink-3); text-align: right; margin-top: .35rem; }

.string-fig { grid-area: string; min-width: 0; overflow: hidden; margin: 0 calc(-1 * clamp(1rem, 4vw, 3rem)); }
#string { display: block; width: 100%; height: clamp(140px, 16vw, 190px); touch-action: pan-y; cursor: crosshair; }
.string-fig figcaption {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem;
  padding: .3rem clamp(1rem, 4vw, 3rem) 0; color: var(--ink-3); font-size: .9rem;
}

/* etiquetas */
.tag { display: inline-block; padding: .22rem .5rem; border-radius: 3px; font-size: .68rem; line-height: 1.3; white-space: nowrap; }
.tag-calc { background: var(--ink); color: var(--bg); }
.tag-ill { border: 1px dashed var(--ink-3); color: var(--ink-2); }

.btn, .btn-ghost {
  font: 500 .88rem/1 var(--sans); cursor: pointer; border-radius: 3px; padding: .6rem .9rem;
  border: 1px solid var(--ink); color: var(--ink); background: transparent;
}
.btn:hover, .btn-ghost:hover { background: var(--ink); color: var(--bg); }
.btn-ghost { border-color: var(--rule); padding: .45rem .75rem; }

.legend {
  max-width: 82rem; margin: 3.5rem auto 0; padding: 1.4rem clamp(1rem, 4vw, 3rem);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem 2.5rem;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-size: .9rem; color: var(--ink-2);
}
.legend p { margin: 0; }
.legend .tag { margin-right: .4rem; }

/* capítulos */
.chapter {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(2rem, 5vw, 5rem); align-items: start;
  max-width: 82rem; margin: 0 auto; padding: clamp(4rem, 9vw, 7.5rem) clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--rule);
}
.chapter.flip { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.chapter.flip .ch-text { order: 2; }
.ch-text { position: sticky; top: 6rem; }
.ch-n { display: flex; gap: .8rem; color: var(--ink-3); margin: 0 0 1rem; }
.ch-n span { color: var(--accent); }
h2 { font: 400 clamp(2.4rem, 4.6vw, 3.8rem)/1 var(--serif); margin: 0 0 1.2rem; letter-spacing: -.01em; }
.ch-lede { font-size: 1.08rem; margin: 0 0 1.8rem; }
.facts { margin: 0 0 1.8rem; display: grid; gap: 1.1rem; }
dt { color: var(--ink-3); margin-bottom: .25rem; }
dd { margin: 0; color: var(--ink-2); }
.warn { background: var(--warn-bg); color: var(--warn-ink); padding: .8rem 1rem; border-radius: 3px; font-size: .94rem; margin: 0 0 1.8rem; }
.cta {
  display: inline-flex; gap: .5rem; align-items: center; text-decoration: none; font-weight: 600;
  background: var(--ink); color: var(--bg); padding: .8rem 1.15rem; border-radius: 3px;
}
.cta:hover { background: var(--accent); color: #fff; }

/* pranchas */
.plate {
  margin: 0; min-width: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 4px;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; position: relative;
}
.plate::before, .plate::after { content: ""; position: absolute; width: 14px; height: 14px; border: 0 solid var(--ink-3); }
.plate::before { left: -1px; top: -1px; border-left-width: 2px; border-top-width: 2px; }
.plate::after { right: -1px; bottom: -1px; border-right-width: 2px; border-bottom-width: 2px; }
.plate-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .9rem 1.1rem; border-bottom: 1px solid var(--rule); }
.plate-id { color: var(--ink-2); }
.plate > svg, .plate > canvas { display: block; width: 100%; height: auto; }
#osc { height: 360px; touch-action: pan-y; cursor: grab; }
#fin { height: 300px; }
.controls { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem 1.6rem; padding: 1rem 1.1rem; border-top: 1px solid var(--rule); }
.field { display: grid; gap: .45rem; flex: 1 1 15rem; font-size: .9rem; color: var(--ink-2); }
.field span { display: flex; justify-content: space-between; gap: 1rem; }
output { font: 500 .9rem var(--mono); color: var(--ink); }
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 28px; }
.seg { border: 0; margin: 0; padding: 0; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.seg legend { font-size: .9rem; color: var(--ink-2); margin-bottom: .45rem; padding: 0; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; min-width: 3rem; text-align: center; font: 500 .9rem/1 var(--mono); padding: .6rem .7rem; border: 1px solid var(--rule); border-radius: 3px; }
.seg input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { flex: 1 1 100%; margin: 0; font-size: .84rem; color: var(--ink-3); }
.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); border-top: 1px solid var(--rule); }
.readout div { padding: .8rem 1.1rem; border-right: 1px solid var(--rule); display: grid; gap: .2rem; }
.readout div:last-child { border-right: 0; }
.readout span { font-size: .8rem; color: var(--ink-3); }
.readout strong { font: 500 1.05rem var(--mono); }
.plate figcaption { padding: .9rem 1.1rem 1.1rem; border-top: 1px solid var(--rule); font-size: .88rem; color: var(--ink-2); }

/* treliça */
#truss .node { cursor: pointer; }
#truss .node circle.hit { fill: transparent; }
#truss .node circle.dot { fill: var(--surface); stroke: var(--ink); stroke-width: 2; transition: r .2s; }
#truss .node:hover circle.dot, #truss .node:focus-visible circle.dot { stroke: var(--accent); r: 8; }
#truss .node.on circle.dot { fill: var(--accent); stroke: var(--accent); }
#truss .node:focus { outline: none; }
#truss .node:focus-visible circle.hit { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 3 3; }
#truss text { font: 500 15px var(--mono); fill: var(--ink-3); }
.truss-legend { display: flex; gap: 1.2rem; flex-wrap: wrap; padding: 0 1.1rem .8rem; font-size: .8rem; color: var(--ink-3); }
.sw { display: inline-block; width: 18px; height: 4px; margin-right: .4rem; vertical-align: middle; border-radius: 2px; }
.sw-t { background: var(--tension); }
.sw-c { background: var(--accent); }

/* ciclo térmico */
#cycle text { font: 500 11px var(--mono); fill: var(--ink-3); }
#cycle text.comp-lbl { font: 600 11px var(--sans); fill: var(--ink); text-anchor: middle; }
#cycle text.sec-label { font: 600 9.5px var(--mono); fill: var(--ink-3); letter-spacing: 0.05em; }
#cycle text.diag-lbl { font: 500 9.5px var(--mono); fill: var(--ink-3); }
#cycle text.state-badge { font: 700 10.5px var(--mono); fill: var(--bg); text-anchor: middle; dominant-baseline: central; }
#cycle text.heat-lbl { font: 600 10.5px var(--mono); text-anchor: middle; }

/* ---------- Rodapé Unificado InteraEnge ---------- */
.foot {
  max-width: 82rem;
  margin: 0 auto;
  padding: 4rem clamp(1rem, 4vw, 3rem) 3.5rem;
  color: var(--ink-2);
  font-size: .9rem;
}
.foot-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1.3fr;
  gap: 2.5rem 2rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2rem;
}
.foot-col {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.foot-brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  font: 500 1.05rem/1 var(--mono);
  color: var(--ink);
  letter-spacing: .02em;
}
.foot-desc {
  font-size: .88rem;
  color: var(--ink-3);
  line-height: 1.55;
  margin: 0;
  max-width: 32ch;
}
.foot-heading {
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 600;
  margin: 0 0 .2rem;
}
.foot-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.foot-links a {
  text-decoration: none;
  color: var(--ink-2);
  font-size: .88rem;
  transition: color .15s ease, transform .15s ease;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
}
.foot-links a:hover {
  color: var(--accent);
  transform: translateX(2px);
}
.foot-sim-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke .15s ease;
}
.foot-links a:hover .foot-sim-icon {
  stroke: var(--accent);
}
.foot-contact {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin-top: .15rem;
}
.foot-contact-label {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.foot-email-link {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--ink-2);
  text-decoration: none;
  word-break: break-all;
  line-height: 1.4;
  transition: color .15s ease;
}
.foot-email-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.foot-linkedin-link {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  color: var(--ink-3);
  text-decoration: none;
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.4;
  margin-top: .35rem;
  transition: color .15s ease;
}
.foot-linkedin-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.foot-linkedin-link svg {
  flex-shrink: 0;
  opacity: .85;
  transition: opacity .15s ease;
}
.foot-linkedin-link:hover svg {
  opacity: 1;
}
.foot-dev {
  font-size: .9rem;
  color: var(--ink);
  margin: 0;
  line-height: 1.4;
}
.foot-dev strong {
  color: var(--accent);
  font-weight: 600;
}
.foot-social {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  margin-top: .2rem;
}
.foot-social-btn {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .8rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--mono);
  font-size: .78rem;
  transition: all .18s cubic-bezier(0.16, 1, 0.3, 1);
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.foot-social-btn:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  transform: translateY(-1px);
}
.foot-social-btn svg {
  flex-shrink: 0;
}
.foot-bottom {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  font-size: .82rem;
  color: var(--ink-3);
  line-height: 1.5;
}
.foot-bottom p {
  margin: 0 0 .3rem;
}
.foot-copy {
  margin-top: .6rem !important;
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--ink-3);
}

@media (max-width: 860px) {
  .foot-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 520px) {
  .foot-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

/* ---------- Páginas Jurídicas (Termos & Privacidade) ---------- */
.legal-wrap {
  max-width: 54rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 5vw, 4.5rem) clamp(1rem, 4vw, 3rem) 5rem;
}
.legal-head {
  margin-bottom: 2.5rem;
}
.legal-head .kicker {
  font-family: var(--mono);
  font-size: .76rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 .8rem;
}
.legal-head h1 {
  font: 400 clamp(2.2rem, 5vw, 3.6rem)/1.05 var(--serif);
  letter-spacing: -.015em;
  margin: 0 0 1rem;
}
.legal-head h1 em {
  color: var(--accent);
  font-style: italic;
}
.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem 1.4rem;
  padding: .8rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--ink-2);
}
.legal-meta span b {
  color: var(--ink);
  font-weight: 600;
}
.legal-body {
  font-size: .98rem;
  line-height: 1.7;
  color: var(--ink-2);
}
.legal-body h2 {
  font: 400 1.65rem/1.25 var(--serif);
  color: var(--ink);
  margin: 2.4rem 0 .9rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: .4rem;
}
.legal-body h3 {
  font: 600 1.1rem/1.3 var(--sans);
  color: var(--ink);
  margin: 1.6rem 0 .6rem;
}
.legal-body p {
  margin: 0 0 1rem;
}
.legal-body strong {
  color: var(--ink);
}
.legal-body ul, .legal-body ol {
  margin: 0 0 1.2rem;
  padding-left: 1.4rem;
}
.legal-body li {
  margin-bottom: .4rem;
}
.legal-body .callout-didatico {
  padding: 1.1rem 1.3rem;
  background: color-mix(in srgb, var(--surface) 70%, var(--bg));
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
  margin: 1.4rem 0;
  font-size: .92rem;
  line-height: 1.6;
}
.legal-body .callout-didatico strong {
  color: var(--accent);
}
.legal-table-wrap {
  overflow-x: auto;
  margin: 1.4rem 0 1.8rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.legal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  text-align: left;
  background: var(--surface);
}
.legal-table th, .legal-table td {
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--rule);
}
.legal-table th {
  background: color-mix(in srgb, var(--surface) 65%, var(--bg));
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 2px solid var(--rule);
}
.legal-table tr:last-child td {
  border-bottom: none;
}
.foot p { margin: 0 0 .4rem; }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; grid-template-areas: "text" "string" "index"; gap: 1.5rem; }
  .chapter, .chapter.flip { grid-template-columns: 1fr; }
  .chapter.flip .ch-text { order: 0; }
  .ch-text { position: static; }
  .legend { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .top { gap: .8rem; }
  .top-nav { display: none; }
  .auth-wrap { margin-left: auto; }
  .theme { margin-left: 0; }
  .index li { grid-template-columns: 1.6rem 2rem 1fr auto; column-gap: .6rem; }
  #osc { height: 320px; }
  #fin { height: 260px; }
  .readout div { border-right: 0; border-bottom: 1px solid var(--rule); }
  .readout div:last-child { border-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* para professores: texto e lista lado a lado, sem figura */
.teachers .facts { margin: 0; padding-top: .4rem; }
.teachers dd { max-width: 38rem; }
.chapter[hidden] { display: none; }
.preview-access { display: inline-block; color: var(--accent); text-underline-offset: .25em; }
.preview-access[hidden] { display: none; }
.preview-experiments { gap: 0; }
.preview-experiments dt { font: 500 1.05rem/1.4 var(--sans); text-transform: none; letter-spacing: normal; color: var(--ink); }
.preview-experiments > div { padding: 1.1rem 0; border-bottom: 1px solid var(--rule); }
.preview-experiments > div:first-child { padding-top: 0; }
.preview-experiments > div:last-child { border-bottom: 0; padding-bottom: 0; }
.preview-experiments dt a { display: inline-block; padding: .25rem 0; text-decoration-thickness: 1px; text-underline-offset: .25em; }
.preview-experiments dt a:hover { color: var(--accent); }
.preview-status { display: block; margin-top: .3rem; font-size: .88rem; }

/* hipóteses recolhidas nas pranchas */
.cap-more { margin-top: .4rem; }
.cap-more summary { cursor: pointer; color: var(--ink-3); width: fit-content; }
.cap-more summary:hover { color: var(--accent); }
.cap-more p { margin: .4rem 0 0; }

/* no celular, o experimento vem logo após a apresentação; limites e link depois */
@media (max-width: 960px) {
  .chapter:not(.teachers) { row-gap: 0; }
  .chapter:not(.teachers) .ch-text { display: contents; }
  .chapter > .plate { order: 1; margin-bottom: 1.8rem; }
  .ch-text > .warn, .ch-text > .cta { order: 2; }
  .ch-text > .facts { order: 3; margin-top: 1.5rem; }
  .ch-text > .cta { justify-self: start; margin-top: 0; }
}

/* ---------- Autenticação & Meus Projetos (Supabase) ---------- */
.auth-wrap {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.btn-auth {
  /* mesmo "Entrar" dos simuladores (bancada-auth.js: .bb-btn--primary): sólido, neutro, sem brilho */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 9px;
  font: 600 13px/1 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  letter-spacing: .015em;
  color: var(--bg);
  background: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s ease;
}
.btn-auth svg { width: 15px; height: 15px; flex: none; }
.btn-auth:hover { opacity: .88; }
.btn-auth:active { opacity: .82; }
.btn-auth:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.user-menu {
  display: flex;
  align-items: center;
}

/* Botão do Perfil no topo (Foto + 3 Barras) */
.btn-profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  box-sizing: border-box;
  height: 34px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0 11px 0 3px;
  cursor: pointer;
  color: var(--ink);
  font: 600 13px/1 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  transition: background-color .15s ease, border-color .15s ease;
}
.btn-profile-trigger:hover { background: var(--surface); border-color: var(--ink); }
.btn-profile-trigger:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.avatar-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font: 600 .75rem/24px var(--mono);
  text-align: center;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.header-user-name {
  font: 500 .8rem/1 var(--sans);
  color: var(--ink);
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px) {
  .header-user-name {
    display: none;
  }
}
.icon-bars {
  color: var(--ink-2);
  flex-shrink: 0;
}

/* Gaveta Lateral Meu Perfil (Drawer) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 18, 20, .6);
  backdrop-filter: blur(4px);
  z-index: 120;
  display: flex;
  justify-content: flex-end;
}
.drawer-backdrop[hidden] {
  display: none !important;
}
.drawer-panel {
  background-color: var(--surface);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  width: 100%;
  max-width: 380px;
  height: 100%;
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 36px rgba(0, 0, 0, .22);
  animation: drawer-enter .2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
@keyframes drawer-enter {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.drawer-header {
  padding: 1.25rem 1.4rem;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  background: color-mix(in srgb, var(--surface) 80%, var(--bg));
}
.drawer-user-info {
  display: flex;
  align-items: center;
  gap: .85rem;
  min-width: 0;
}
.drawer-avatar-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--rule);
  font: 600 1.1rem/44px var(--mono);
  text-align: center;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.drawer-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.drawer-user-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.drawer-user-kicker {
  font: 500 .68rem/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  margin: 0;
}
.drawer-name {
  font: 600 1.02rem/1.2 var(--sans);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-email {
  font: 400 .76rem/1.25 var(--mono);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-since {
  font: 400 .72rem/1.2 var(--mono);
  color: var(--ink-3);
}
.drawer-close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-3);
  cursor: pointer;
  padding: .35rem;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.drawer-close:hover {
  color: var(--ink);
  border-color: var(--rule);
  background: var(--bg);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.3rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}
.drawer-section {
  display: flex;
  flex-direction: column;
}
.drawer-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .6rem;
}
.drawer-section-head .drawer-label {
  margin: 0;
}
.drawer-badge {
  font: 600 .7rem/1 var(--mono);
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--ink-2);
  padding: .15rem .45rem;
  border-radius: 3px;
}

.drawer-projects-list {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.drawer-project-card {
  padding: .85rem .95rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  transition: border-color .15s, box-shadow .15s;
}
.drawer-project-card:hover {
  border-color: var(--ink-2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}
.drawer-project-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.drawer-project-date {
  font: 400 .72rem/1 var(--mono);
  color: var(--ink-3);
}
.drawer-project-title {
  font: 600 .88rem/1.25 var(--sans);
  color: var(--ink);
  margin: 0;
}
.drawer-project-desc {
  font: 400 .78rem/1.3 var(--sans);
  color: var(--ink-2);
  margin: 0;
}
.drawer-project-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .2rem;
  padding-top: .4rem;
  border-top: 1px dashed var(--rule);
}
.btn-open-drawer {
  font: 500 .78rem/1 var(--mono);
  color: var(--accent);
  text-decoration: none;
}
.btn-open-drawer:hover {
  text-decoration: underline;
}
.btn-del-drawer {
  background: none;
  border: none;
  font: 500 .74rem/1 var(--mono);
  color: var(--ink-3);
  cursor: pointer;
  padding: .2rem .4rem;
  border-radius: 2px;
  transition: color .15s, background-color .15s;
}
.btn-del-drawer:hover {
  color: #dc2626;
  background: color-mix(in srgb, #dc2626 10%, transparent);
}
.drawer-empty-state {
  padding: 1.2rem 1rem;
  text-align: center;
  background: color-mix(in srgb, var(--surface) 60%, var(--bg));
  border: 1px dashed var(--rule);
  border-radius: 4px;
  color: var(--ink-2);
  font: 400 .82rem/1.45 var(--sans);
}
.drawer-empty-state strong {
  display: block;
  font: 600 .88rem/1.2 var(--sans);
  color: var(--ink);
  margin-bottom: .25rem;
}
.drawer-empty-state small {
  display: block;
  font-size: .76rem;
  color: var(--ink-3);
}

.drawer-label {
  font: 600 .74rem/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
  margin: 0 0 .6rem;
}
.drawer-sim-list {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.drawer-sim-list a {
  display: grid;
  grid-template-columns: 1.4rem 1fr auto;
  align-items: center;
  gap: .65rem;
  padding: .6rem .8rem;
  border-radius: 3px;
  border: 1px solid var(--rule);
  background: var(--surface);
  text-decoration: none;
  font-size: .85rem;
  color: var(--ink);
  transition: border-color .15s, background-color .15s;
}
.drawer-sim-list a:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.drawer-sim-list a svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke .15s ease;
}
.drawer-sim-list a:hover svg {
  stroke: var(--accent);
}
.drawer-sim-list .sim-n {
  font: 500 .74rem/1 var(--mono);
  color: var(--ink-3);
}
.drawer-sim-list .sim-name {
  font-weight: 600;
  color: var(--ink);
}
.drawer-sim-list small {
  font: 500 .74rem/1 var(--mono);
  color: var(--ink-3);
  transition: color .15s;
}
.drawer-sim-list a:hover small {
  color: var(--accent);
}

/* Plano e tema na gaveta */
.drawer-plan {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1.15rem;
  position: relative;
}
.drawer-plan::before, .drawer-plan::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 0 solid var(--ink-3);
}
.drawer-plan::before {
  left: -1px;
  top: -1px;
  border-left-width: 2px;
  border-top-width: 2px;
}
.drawer-plan::after {
  right: -1px;
  bottom: -1px;
  border-right-width: 2px;
  border-bottom-width: 2px;
}
.drawer-plan .drawer-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: .6rem;
}
.drawer-plan .drawer-label {
  color: var(--ink);
  font-weight: 600;
  font-size: .8rem;
  margin: 0;
}
.drawer-plan-quota {
  font: 500 .74rem/1 var(--mono);
  color: var(--accent);
}
.drawer-plan-track {
  height: 6px;
  background: var(--rule);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: .8rem;
}
.drawer-plan-track i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .3s;
}
.drawer-plan-feat {
  list-style: none;
  margin: .6rem 0 1rem;
  padding: 0;
  display: grid;
  gap: .45rem;
  font-size: .82rem;
  color: var(--ink-2);
}
.drawer-plan-feat li {
  display: flex;
  align-items: flex-start;
  gap: .45rem;
  line-height: 1.4;
}
.drawer-plan-feat li::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: .4rem;
  flex-shrink: 0;
}
.drawer-upgrade {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .75rem 1rem;
  border-radius: 3px;
  border: none;
  background: var(--ink);
  color: var(--bg);
  font: 600 .86rem/1 var(--sans);
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.drawer-upgrade:hover {
  background: var(--accent);
  color: #fff;
}

.drawer-theme {
  display: inline-flex;
  gap: 3px;
  border: 1px solid var(--rule);
  background: var(--bg);
  padding: 2px;
  border-radius: 3px;
}
.drawer-theme button {
  border: 0;
  background: transparent;
  padding: .4rem .7rem;
  font: 500 .78rem/1 var(--mono);
  color: var(--ink-3);
  cursor: pointer;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  transition: background-color .15s, color .15s;
}
.drawer-theme button svg {
  flex-shrink: 0;
}
.drawer-theme button.active {
  background: var(--ink);
  color: var(--bg);
}
#btn-forgot { align-self: center; }

.drawer-footer {
  padding: 1.1rem 1.4rem;
  border-top: 1px solid var(--rule);
  background: color-mix(in srgb, var(--surface) 80%, var(--bg));
}
.drawer-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .65rem 1rem;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font: 500 .82rem/1 var(--mono);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .15s, color .15s, background-color .15s;
}
.drawer-logout:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* Modais */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 18, 20, .6);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
}
.modal-backdrop[hidden] {
  display: none !important;
}
.modal-card {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .14);
  padding: 1.8rem;
  position: relative;
  animation: modal-enter .15s ease-out;
}
.modal-large {
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
@keyframes modal-enter {
  from { opacity: 0; transform: scale(.98) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-kicker {
  margin: 0 0 .35rem;
  font: 500 .78rem/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.3rem;
}
.modal-head h2 {
  font: 500 1.25rem/1.2 var(--sans);
  margin: 0;
}
.modal-subtitle {
  margin: .3rem 0 0;
  font-size: .82rem;
  color: var(--ink-2);
  font-family: var(--mono);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: .7;
  color: var(--ink-3);
  cursor: pointer;
  padding: .2rem;
}
.modal-close:hover {
  color: var(--ink);
}

/* Tabs do modal auth (Minimalista · Padrão .seg) */
.modal-tabs {
  display: flex;
  gap: .3rem;
  margin-bottom: 1.2rem;
}
.modal-tabs .tab-btn {
  flex: 1;
  font: 500 .85rem/1 var(--mono);
  padding: .55rem .7rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
  text-align: center;
  transition: background-color .15s, color .15s, border-color .15s;
}
.modal-tabs .tab-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
}
.modal-tabs .tab-btn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* Botão Google */
.btn-google {
  width: 100%;
  padding: .6rem .8rem;
  background: none;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font: 500 .86rem/1 var(--sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  transition: border-color .15s, background-color .15s;
}
.btn-google:hover {
  border-color: var(--ink);
  background: var(--bg);
}
.btn-google svg {
  flex-shrink: 0;
}

/* Divisor */
.auth-divider {
  text-align: center;
  margin: 1.1rem 0;
  position: relative;
}
.auth-divider::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 1px;
  background: var(--rule);
}
.auth-divider span {
  position: relative;
  background: var(--surface);
  padding: 0 .6rem;
  font-size: .78rem;
  color: var(--ink-3);
}

/* Formulário do modal */
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.modal-field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.modal-field label {
  font-size: .84rem;
  color: var(--ink-2);
}
.pw-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.btn-toggle-pw {
  background: none;
  border: none;
  padding: 0;
  font: 500 .75rem/1 var(--mono);
  color: var(--ink-3);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-toggle-pw:hover {
  color: var(--ink);
}
.modal-field input {
  width: 100%;
  padding: .55rem .75rem;
  font: 400 .9rem/1.4 var(--sans);
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
  transition: border-color .15s;
}
.modal-field input:focus {
  border-color: var(--ink);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.auth-msg {
  padding: .55rem .75rem;
  border-radius: 3px;
  font-size: .84rem;
  line-height: 1.4;
}
.auth-msg.msg-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #f87171;
}
.auth-msg.msg-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
[data-theme="dark"] .auth-msg.msg-error {
  background: #450a0a;
  color: #fca5a5;
  border-color: #991b1b;
}
[data-theme="dark"] .auth-msg.msg-success {
  background: #052e16;
  color: #86efac;
  border-color: #166534;
}

.btn-submit {
  width: 100%;
  padding: .65rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  border-radius: 3px;
  font: 500 .88rem/1 var(--sans);
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-submit:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-submit:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* Lista e Filtros de Projetos */
.project-filters {
  display: flex;
  gap: .45rem;
  margin-bottom: 1.1rem;
  overflow-x: auto;
  padding-bottom: .3rem;
}
.filter-chip {
  padding: .35rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--ink-2);
  font: 500 .78rem/1 var(--sans);
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
}
.filter-chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.projects-list {
  overflow-y: auto;
  max-height: 52vh;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding-right: .3rem;
}
.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.1rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  transition: border-color .2s;
}
.project-item:hover {
  border-color: var(--accent);
}
.project-info {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-width: 0;
}
.project-meta-line {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.project-date {
  color: var(--ink-3);
  font-size: .75rem;
  font-family: var(--mono);
}
.project-title {
  font: 600 .98rem/1.3 var(--sans);
  margin: 0;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-desc {
  font-size: .82rem;
  color: var(--ink-2);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.btn-open-proj {
  padding: .45rem .8rem;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  border-radius: 4px;
  font: 500 .8rem/1 var(--sans);
  white-space: nowrap;
  transition: background-color .2s;
}
.btn-open-proj:hover {
  background: var(--accent);
  color: #fff;
}
.btn-del-proj {
  padding: .45rem .6rem;
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink-3);
  border-radius: 4px;
  font: 500 .8rem/1 var(--sans);
  cursor: pointer;
  transition: all .2s;
}
.btn-del-proj:hover {
  color: #dc2626;
  border-color: #dc2626;
}
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--ink-3);
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.empty-state p {
  margin: 0;
  font: 500 .95rem/1.4 var(--sans);
  color: var(--ink-2);
}
.empty-state small {
  font-size: .82rem;
}

.tag-tension {
  background: color-mix(in srgb, var(--tension) 18%, transparent);
  color: var(--tension);
  border: 1px solid color-mix(in srgb, var(--tension) 40%, transparent);
}
.tag-accent {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.tag-warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

