/* Dojo de Arquitetura — caderno de engenharia.
   Papel quadriculado frio, tinta grafite, um azul ultramar para o que é ação.
   O elemento ousado é a trilha desenhada como linha de metrô com estações hexagonais. */

:root {
  --paper: #edf0f3;
  --grid: rgba(47, 69, 200, 0.055);
  --sheet: #f9fafb;
  --ink: #18202b;
  --graphite: #566173;
  --rule: #cdd3db;
  --rule-soft: #e0e5eb;
  --accent: #2f45c8;
  --accent-ink: #ffffff;
  --accent-soft: #e2e6fa;
  --pass: #1d7f51;
  --pass-soft: #dcefe4;
  --fail: #b93b28;
  --fail-soft: #f7e0db;
  --warn: #8d5a0c;
  --warn-soft: #f4e8cf;
  --shadow: 0 1px 0 rgba(24, 32, 43, 0.06), 0 8px 24px -16px rgba(24, 32, 43, 0.25);

  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", monospace;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.25rem;
  --step-4: clamp(2.4rem, 5vw, 3.6rem);

  --radius-s: 6px;
  --radius-m: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12161c;
    --grid: rgba(130, 147, 255, 0.05);
    --sheet: #1a1f27;
    --ink: #e7ebf1;
    --graphite: #9aa4b4;
    --rule: #2e3540;
    --rule-soft: #252b34;
    --accent: #8696ff;
    --accent-ink: #0d1020;
    --accent-soft: #232a4d;
    --pass: #56c68f;
    --pass-soft: #173226;
    --fail: #f07a64;
    --fail-soft: #3a1d18;
    --warn: #e2ab52;
    --warn-soft: #36290f;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -18px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #12161c;
  --grid: rgba(130, 147, 255, 0.05);
  --sheet: #1a1f27;
  --ink: #e7ebf1;
  --graphite: #9aa4b4;
  --rule: #2e3540;
  --rule-soft: #252b34;
  --accent: #8696ff;
  --accent-ink: #0d1020;
  --accent-soft: #232a4d;
  --pass: #56c68f;
  --pass-soft: #173226;
  --fail: #f07a64;
  --fail-soft: #3a1d18;
  --warn: #e2ab52;
  --warn-soft: #36290f;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -18px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 24px 64px; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.9em; }
:not(pre) > code { background: var(--rule-soft); padding: 0.1em 0.35em; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.01em; margin: 0; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--sheet); padding: 8px 12px; z-index: 10; }
.muted { color: var(--graphite); }

/* ---------- topo ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1240px; width: 100%; margin: 0 auto; padding: 18px 24px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none;
  font: 700 var(--step-1)/1 var(--font-display); }
.brand-mark { width: 30px; height: 30px; color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.belt-chip {
  display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 10px; row-gap: 4px;
  align-items: center; padding: 6px 12px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--sheet); color: var(--ink); text-decoration: none; font-size: var(--step--1);
}
.belt-swatch { grid-row: 1 / 3; width: 26px; height: 10px; border-radius: 3px; background: var(--belt);
  box-shadow: inset 0 0 0 1px var(--graphite); }
.belt-name { font-weight: 600; line-height: 1; }
.belt-xp { display: none; }
.belt-meter { height: 3px; border-radius: 2px; background: var(--rule-soft); overflow: hidden; }
.belt-meter span { display: block; height: 100%; background: var(--accent); }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--rule); background: var(--sheet);
  color: var(--graphite); cursor: pointer; display: grid; place-items: center; padding: 0; font: inherit; list-style: none; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn::-webkit-details-marker { display: none; }
.logout { margin: 0; }
.mainnav { display: flex; gap: 4px; margin-right: auto; margin-left: 24px; }
.mainnav a { padding: 8px 12px; border-radius: var(--radius-s); color: var(--graphite); text-decoration: none; font-weight: 600; font-size: var(--step--1); }
.mainnav a:hover { color: var(--ink); background: var(--rule-soft); }
.mainnav a[aria-current="page"] { color: var(--ink); background: var(--sheet); box-shadow: inset 0 0 0 1px var(--rule); }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 var(--step-0)/1 var(--font-body); padding: 12px 18px; border-radius: var(--radius-s);
  border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: transform .08s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-ghost:hover { border-color: var(--graphite); }
.btn[disabled], .btn.htmx-request { opacity: .7; cursor: progress; }
.btn .spinner { display: none; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite; }
.htmx-request .spinner, .htmx-request.spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; padding: 40px 0 48px; align-items: end; }
.hero-label { color: var(--graphite); margin: 0 0 12px; }
.hero h1 { font-size: var(--step-4); font-weight: 800; max-width: 18ch; }
.hero-track { margin: 14px 0 26px; color: var(--graphite); font-size: var(--step-1); max-width: 52ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.belt-card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 22px; box-shadow: var(--shadow); }
.belt-band { height: 18px; border-radius: 4px; background: var(--belt); margin-bottom: 18px;
  box-shadow: inset 0 0 0 1px var(--graphite); position: relative; }
.belt-band::after { content: ""; position: absolute; right: 22%; top: -4px; bottom: -4px; width: 10px; background: inherit;
  border-radius: 2px; box-shadow: inherit; }
.belt-card h2 { font-size: var(--step-2); }
.belt-card p { margin: 6px 0 0; color: var(--graphite); }
.meter { height: 8px; background: var(--rule-soft); border-radius: 4px; overflow: hidden; margin-top: 14px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.section-title { font-size: var(--step-2); margin: 8px 0 18px; }
.track-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 24px; align-items: center;
  padding: 22px 24px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-m);
  color: var(--ink); text-decoration: none; margin-bottom: 12px;
}
.track-row:hover { border-color: var(--accent); }
.track-row h3 { font-size: var(--step-1); }
.track-row p { margin: 4px 0 0; color: var(--graphite); }
.minimap { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.minimap i { width: 18px; height: 16px; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: var(--rule); }
.minimap i.is-completed { background: var(--pass); }
.minimap i.is-regressed { background: var(--warn); }
.minimap i.is-in_progress { background: var(--accent); }
.minimap i.is-available { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.track-count { font: 700 var(--step-2)/1 var(--font-display); }
.track-count small { font: 400 var(--step--1) var(--font-body); color: var(--graphite); display: block; text-align: right; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.badge { padding: 14px 16px; border: 1px dashed var(--rule); border-radius: var(--radius-m); background: var(--sheet); }
.badge strong { display: block; }
.badge span { color: var(--graphite); font-size: var(--step--1); }
.empty { padding: 20px; border: 1px dashed var(--rule); border-radius: var(--radius-m); color: var(--graphite); }

/* ---------- trilha: linha de metrô ---------- */
.track-head { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; padding: 36px 0 28px; }
.crumbs { font-size: var(--step--1); color: var(--graphite); margin-bottom: 10px; }
.crumbs a { color: var(--graphite); }
.track-head h1 { font-size: var(--step-4); font-weight: 800; max-width: 20ch; }
.track-head .lede { font-size: var(--step-1); color: var(--graphite); max-width: 56ch; margin: 14px 0 0; }
.prose { max-width: 72ch; }
.prose p, .prose li { max-width: 72ch; }
.track-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; align-items: start; }
.aside-card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 20px; margin-bottom: 16px; }
.aside-card h2 { font-size: var(--step-1); margin-bottom: 10px; }
.aside-card ul { list-style: none; margin: 0; padding: 0; }
.aside-card li + li { border-top: 1px solid var(--rule-soft); }
.aside-card li a { display: block; padding: 10px 0; text-decoration: none; color: var(--ink); }
.aside-card li a span { display: block; color: var(--graphite); font-size: var(--step--1); }
.stat-big { font: 800 var(--step-3)/1 var(--font-display); }

.line { --hex: 54px; position: relative; }
.line + .line { margin-top: 8px; }
.line-head { display: grid; grid-template-columns: var(--hex) minmax(0, 1fr); gap: 18px; align-items: center; padding: 18px 0 10px; }
.line-head .interchange { width: var(--hex); height: 14px; display: grid; place-items: center; }
.line-head .interchange::before { content: ""; width: 26px; height: 14px; border-radius: 7px; background: var(--sheet);
  border: 3px solid var(--ink); }
.line-head h2 { font-size: var(--step-1); }
.line-head p { margin: 2px 0 0; color: var(--graphite); font-size: var(--step--1); }
.stations { list-style: none; margin: 0; padding: 0; position: relative; }
.stations::before { content: ""; position: absolute; left: calc(var(--hex) / 2 - 3px); top: 0; bottom: 0; width: 6px;
  background: var(--rule); border-radius: 3px; }
.line.is-done .stations::before { background: var(--pass); }
.station a {
  position: relative; display: grid; grid-template-columns: var(--hex) minmax(0, 1fr) auto; gap: 18px; align-items: center;
  padding: 10px 0; color: var(--ink); text-decoration: none;
}
.hex {
  width: var(--hex); height: calc(var(--hex) * 0.88); display: grid; place-items: center;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  font: 800 var(--step-0)/1 var(--font-display); background: var(--rule); color: var(--graphite); position: relative;
}
.hex::after { content: ""; position: absolute; inset: 3px; clip-path: inherit; background: var(--sheet); z-index: 0; }
.hex b { position: relative; z-index: 1; }
.is-completed .hex { background: var(--pass); }
.is-completed .hex::after { background: var(--pass); }
.is-completed .hex b { color: var(--sheet); }
.is-regressed .hex { background: var(--warn); }
.is-in_progress .hex { background: var(--accent); }
.is-in_progress .hex::after { background: var(--accent-soft); }
.is-in_progress .hex b { color: var(--accent); }
.is-available .hex { background: var(--accent); }
.is-available .hex b { color: var(--accent); }
.is-upcoming .hex b { color: var(--graphite); }
.station-body { padding: 14px 18px; border-radius: var(--radius-m); border: 1px solid transparent; }
.station a:hover .station-body { background: var(--sheet); border-color: var(--rule); }
.station-body strong { font: 700 var(--step-1)/1.25 var(--font-display); display: block; }
.station-body .summary { color: var(--graphite); display: block; margin-top: 2px; max-width: 64ch; }
.station-body .meta { font-size: var(--step--1); color: var(--graphite); display: block; margin-top: 6px; }
.status-pill { font-size: var(--step--1); font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--rule-soft); color: var(--graphite); }
.is-completed .status-pill { background: var(--pass-soft); color: var(--pass); }
.is-regressed .status-pill { background: var(--warn-soft); color: var(--warn); }
.is-in_progress .status-pill, .is-available .status-pill { background: var(--accent-soft); color: var(--accent); }

/* ---------- missão ---------- */
.mission-head { padding: 32px 0 24px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center; }
.mission-head .hex { --hex: 76px; width: 76px; height: 67px; font-size: var(--step-2); }
.mission-head h1 { font-size: var(--step-3); font-weight: 800; }
.mission-head .lede { margin: 6px 0 0; color: var(--graphite); font-size: var(--step-1); max-width: 60ch; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: var(--step--1); color: var(--graphite); }
.facts strong { color: var(--ink); font-weight: 600; }
.notice { padding: 12px 16px; border-radius: var(--radius-s); background: var(--warn-soft); color: var(--warn); margin-bottom: 18px; }
.notice a { color: inherit; font-weight: 600; }

.mission-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); gap: 36px; align-items: start; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 26px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button {
  font: 600 var(--step--1)/1 var(--font-body); padding: 12px 14px; background: none; border: 0; color: var(--graphite);
  border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button .count { font-weight: 500; color: var(--graphite); }
.tabs button[disabled] { opacity: .45; cursor: not-allowed; }
.tabpanel[hidden] { display: none; }

.prose h2 { font-size: var(--step-2); margin: 34px 0 12px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: var(--step-1); margin: 24px 0 8px; }
.prose table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: var(--step--1); display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose th { font-weight: 600; color: var(--graphite); }
.prose blockquote { margin: 16px 0; padding: 10px 16px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; }
.prose blockquote p { margin: 0; }
.hl, .prose pre { border-radius: var(--radius-s); }
.hl { border: 1px solid var(--rule); margin: 16px 0; overflow-x: auto; }
.hl pre { margin: 0; padding: 14px 16px; line-height: 1.5; font-size: 0.86rem; }
.hl { background: var(--sheet) !important; }

.hint { border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--sheet); margin-bottom: 12px; overflow: hidden; }
.hint-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; }
.hint-head h3 { font-size: var(--step-0); }
.hint-body { padding: 0 18px 16px; border-top: 1px solid var(--rule-soft); }
.hint.is-locked .hint-head h3 { color: var(--graphite); }
.cost { font-size: var(--step--1); color: var(--graphite); }

.refs { list-style: none; padding: 0; margin: 0; }
.refs li { padding: 14px 0; border-bottom: 1px solid var(--rule-soft); }
.refs a { font-weight: 600; }
.refs span { display: block; font-size: var(--step--1); color: var(--graphite); }

textarea.journal {
  width: 100%; min-height: 320px; padding: 16px; border-radius: var(--radius-m); border: 1px solid var(--rule);
  background: var(--sheet); color: var(--ink); font: 400 0.95rem/1.6 var(--font-mono); resize: vertical;
}
.save-state { font-size: var(--step--1); color: var(--graphite); min-height: 1.4em; margin-top: 6px; }

.question { border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--sheet); padding: 18px 20px; margin-bottom: 14px; }
.question h3 { font: 600 var(--step-0)/1.4 var(--font-body); margin-bottom: 12px; }
.options { display: grid; gap: 8px; }
.option { display: block; width: 100%; text-align: left; font: 400 var(--step-0)/1.4 var(--font-body);
  padding: 10px 14px; border-radius: var(--radius-s); border: 1px solid var(--rule); background: var(--paper);
  color: var(--ink); cursor: pointer; }
.option:hover:not([disabled]) { border-color: var(--accent); }
.option[disabled] { cursor: default; }
.option.is-right { border-color: var(--pass); background: var(--pass-soft); }
.option.is-wrong { border-color: var(--fail); background: var(--fail-soft); }
.explanation { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rule-soft); color: var(--graphite); }
.locked-panel { padding: 28px; border: 1px dashed var(--rule); border-radius: var(--radius-m); color: var(--graphite); }

/* ---------- bancada (painel de verificação) ---------- */
.bench { position: sticky; top: 16px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-m);
  box-shadow: var(--shadow); overflow: hidden; }
.bench-head { padding: 18px 20px; border-bottom: 1px solid var(--rule-soft); }
.bench-head h2 { font-size: var(--step-1); }
.bench-status { margin: 6px 0 14px; color: var(--graphite); font-size: var(--step--1); }
.bench-status.is-pass { color: var(--pass); font-weight: 600; }
.bench-status.is-fail { color: var(--fail); }
.bench-run { width: 100%; }
.bench-body { max-height: calc(100vh - 260px); overflow-y: auto; }
.objective { padding: 14px 20px; border-bottom: 1px solid var(--rule-soft); }
.objective:last-child { border-bottom: 0; }
.objective-head { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; }
.mark { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  border: 2px solid var(--rule); color: var(--graphite); }
.mark.is-passed, .mark.is-manual_done { background: var(--pass); border-color: var(--pass); color: #fff; }
.mark.is-failed { background: var(--fail-soft); border-color: var(--fail); color: var(--fail); }
.objective-head strong { display: block; line-height: 1.35; }
.objective-head .tag { font-size: 0.75rem; font-weight: 600; color: var(--graphite); border: 1px solid var(--rule);
  border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: 2px; }
.objective-desc { font-size: var(--step--1); color: var(--graphite); margin-top: 2px; }
.objective-desc p { margin: 0; }
.manual-toggle { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: var(--step--1); cursor: pointer; }
.manual-toggle input { width: 18px; height: 18px; accent-color: var(--pass); }
.checks { list-style: none; padding: 0; margin: 10px 0 0 32px; font-size: var(--step--1); }
.checks > li { padding: 3px 0; }
.check-ok { color: var(--graphite); }
.check-ok::before { content: "✓ "; color: var(--pass); font-weight: 700; }
.check-bad summary { cursor: pointer; color: var(--fail); font-weight: 600; list-style: none; }
.check-bad summary::-webkit-details-marker { display: none; }
.check-bad summary::before { content: "✗ "; }
.check-warn summary { color: var(--warn); }
.check-warn summary::before { content: "! "; }
.check-bad .why { color: var(--graphite); margin: 6px 0; }
.check-bad pre.msg { white-space: pre-wrap; word-break: break-word; background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--radius-s); padding: 10px 12px; margin: 6px 0; font-size: 0.8rem; color: var(--ink); }
.check-bad details.trace summary { color: var(--graphite); font-weight: 400; }
.check-bad details.trace summary::before { content: "▸ "; }
.check-bad details.trace pre { max-height: 240px; overflow: auto; font-size: 0.75rem; background: var(--paper);
  padding: 10px; border-radius: var(--radius-s); border: 1px solid var(--rule); }
.cases { color: var(--graphite); font-weight: 400; }
.crash { margin: 14px 20px; padding: 12px; background: var(--fail-soft); color: var(--fail); border-radius: var(--radius-s);
  white-space: pre-wrap; font-family: var(--font-mono); font-size: 0.8rem; }
.attempts { padding: 14px 20px; border-top: 1px solid var(--rule-soft); }
.attempts-label { font-size: var(--step--1); color: var(--graphite); margin-bottom: 8px; }
.dots { display: flex; flex-wrap: wrap; gap: 4px; flex-direction: row-reverse; justify-content: flex-end; }
.dots i { width: 12px; height: 12px; border-radius: 3px; background: var(--fail); opacity: .75; }
.dots i.ok { background: var(--pass); opacity: 1; }
.earned { padding: 14px 20px; background: var(--pass-soft); color: var(--pass); border-top: 1px solid var(--rule-soft); font-weight: 600; }
.earned ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; }

.celebrate { padding: 18px 20px; background: var(--pass); color: #fff; }
.celebrate h3 { font-size: var(--step-1); }
.celebrate p { margin: 4px 0 0; }
.celebrate a { color: #fff; font-weight: 600; }
@media (prefers-reduced-motion: no-preference) {
  .celebrate { animation: rise .5s cubic-bezier(.2,.8,.2,1); }
  @keyframes rise { from { transform: translateY(8px); opacity: 0; } }
}

.next-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--rule); }
.next-nav a { text-decoration: none; }
.next-nav span { display: block; font-size: var(--step--1); color: var(--graphite); }

.regression-table { width: 100%; border-collapse: collapse; font-size: var(--step--1); margin-top: 12px; }
.regression-table td { padding: 8px 0; border-bottom: 1px solid var(--rule-soft); }
.regression-table .ok { color: var(--pass); font-weight: 600; }
.regression-table .bad { color: var(--fail); font-weight: 600; }

.footer { max-width: 1240px; width: 100%; margin: 0 auto; padding: 20px 24px 32px; color: var(--graphite); font-size: var(--step--1); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: var(--radius-s); font-size: var(--step--1); opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.is-on { opacity: 1; }

/* ---------- responsivo ---------- */
@media (min-width: 720px) { .belt-xp { display: inline; color: var(--graphite); } .belt-chip { grid-template-columns: auto auto auto; } .belt-meter { grid-column: 2 / 4; } }
@media (max-width: 980px) {
  .hero, .track-head, .track-layout, .mission-layout { grid-template-columns: minmax(0, 1fr); }
  .bench { position: static; }
  .bench-body { max-height: none; }
  .mission-layout .bench-col { order: -1; }
}
@media (max-width: 600px) {
  main, .topbar, .footer { padding-left: 16px; padding-right: 16px; }
  .brand span { display: none; }
  .line { --hex: 42px; }
  .station a { grid-template-columns: var(--hex) minmax(0, 1fr); gap: 12px; }
  .station .status-pill { grid-column: 2; justify-self: start; margin-left: 18px; }
  .station-body { padding: 8px 10px; }
  .mission-head { grid-template-columns: minmax(0, 1fr); }
  .track-row { grid-template-columns: minmax(0, 1fr); }
}


/* ---------- itens de ação gerais ---------- */
.btn-s { padding: 7px 12px; font-size: var(--step--1); }
.head-actions { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.ai-btn { margin-top: 8px; }
.ai-btn code { font-size: .8em; }
.ai-reply { margin-top: 12px; padding: 14px 16px; border-radius: var(--radius-m); border: 1px solid var(--accent-soft);
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--sheet)); }
.ai-reply .prose { font-size: var(--step--1); }
.ai-reply .prose > :first-child { margin-top: 0; }
.ai-reply.is-error { border-color: var(--fail-soft); background: var(--fail-soft); color: var(--fail); }
.ai-meta { margin: 0 0 8px; font-size: .78rem; color: var(--graphite); }
.ai-approved { margin: 10px 0 0; color: var(--pass); font-weight: 600; }
#reviews { margin-top: 16px; }

/* ---------- barra inferior (celular) ---------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  .mainnav { display: none; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--sheet); border-top: 1px solid var(--rule); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 4px 0; color: var(--graphite); text-decoration: none;
    font-size: 0.72rem; font-weight: 600; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .belt-name { display: none; }
  .belt-chip { grid-template-columns: auto; padding: 8px 10px; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* ---------- login ---------- */
.login-body { justify-content: center; align-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 360px; margin: 0 auto; flex: 0; padding: 0; text-align: center; }
.login-mark { width: 48px; height: 48px; color: var(--accent); }
.login h1 { font-size: var(--step-2); margin: 12px 0 24px; }
.login-form { display: grid; gap: 14px; text-align: left; background: var(--sheet); border: 1px solid var(--rule);
  border-radius: var(--radius-m); padding: 22px; box-shadow: var(--shadow); }
.login-form label { display: grid; gap: 6px; font-weight: 600; font-size: var(--step--1); }
.login-form input { font: 400 var(--step-0)/1.4 var(--font-body); padding: 12px; border-radius: var(--radius-s);
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink); }
.login-error { margin: 0; color: var(--fail); font-size: var(--step--1); }

/* ---------- editor ---------- */
.is-editor main { max-width: none; padding: 0 16px 16px; }
.editor-shell {
  display: grid; grid-template-columns: 240px minmax(0, 1fr) minmax(320px, 400px); gap: 12px;
  height: calc(100dvh - 84px); min-height: 480px;
}
.files, .code, .results { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-m); min-height: 0; }
.files { display: flex; flex-direction: column; overflow: hidden; }
.files-head, .files-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; }
.files-head { border-bottom: 1px solid var(--rule-soft); }
.files-foot { border-top: 1px solid var(--rule-soft); }
.file-list { list-style: none; margin: 0; padding: 6px 0; overflow-y: auto; flex: 1; font-size: var(--step--1); }
.file-folder { padding: 8px 12px 2px; color: var(--graphite); font-family: var(--font-mono); font-size: .75rem; word-break: break-all; }
.file-link { display: block; padding: 5px 12px 5px 22px; color: var(--ink); text-decoration: none; font-family: var(--font-mono); font-size: .8rem; }
.file-link:hover { background: var(--rule-soft); }
.file-link.is-current { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.code { display: flex; flex-direction: column; overflow: hidden; }
.code-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--rule-soft); }
.files-toggle { display: none; }
.code-path { font-family: var(--font-mono); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.save-dot { font-size: .75rem; color: var(--graphite); white-space: nowrap; }
.save-dot.is-dirty { color: var(--warn); }
.save-dot.is-saved { color: var(--pass); }
.save-dot.is-error { color: var(--fail); }
.file-menu { position: relative; }
.file-menu summary { cursor: pointer; }
.file-menu .menu { position: absolute; right: 0; top: 40px; z-index: 5; background: var(--sheet); border: 1px solid var(--rule);
  border-radius: var(--radius-s); box-shadow: var(--shadow); display: grid; min-width: 180px; }
.file-menu .menu button { text-align: left; padding: 10px 14px; background: none; border: 0; color: var(--ink); font: inherit; cursor: pointer; }
.file-menu .menu button:hover { background: var(--rule-soft); }
.cm-host { flex: 1; min-height: 0; overflow: hidden; }
.cm-host .cm-editor { height: 100%; font-size: 14px; }
.cm-host .cm-scroller { font-family: var(--font-mono); }
.cm-empty { padding: 24px; color: var(--graphite); }
.keybar { display: none; gap: 6px; padding: 6px 8px; overflow-x: auto; border-top: 1px solid var(--rule-soft); scrollbar-width: none; }
.keybar button { flex: 0 0 auto; min-width: 40px; height: 36px; padding: 0 10px; border-radius: var(--radius-s); border: 1px solid var(--rule);
  background: var(--paper); color: var(--ink); font: 500 .9rem var(--font-mono); touch-action: manipulation; }
.code-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 8px 10px; border-top: 1px solid var(--rule-soft); }
.results { overflow-y: auto; }
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--rule-soft); }
.mission-pick { display: grid; gap: 4px; font-size: .75rem; color: var(--graphite); flex: 1; min-width: 0; }
.mission-pick select { font: 500 var(--step--1) var(--font-body); padding: 8px; border-radius: var(--radius-s); border: 1px solid var(--rule);
  background: var(--paper); color: var(--ink); max-width: 100%; }
.results-link { font-size: var(--step--1); }
.results .bench { position: static; border: 0; box-shadow: none; border-radius: 0; }
.results .bench-run { display: none; }
.results .bench-body { max-height: none; }
.mytests { margin: 12px 14px 0; padding: 10px 12px; border-radius: var(--radius-s); font-size: var(--step--1); }
.mytests.is-ok { background: var(--pass-soft); color: var(--pass); }
.mytests.is-bad { background: var(--fail-soft); color: var(--fail); }
.mytests p { margin: 0 0 6px; }
.mytests pre { margin: 0; max-height: 280px; overflow: auto; white-space: pre-wrap; font-size: .75rem; color: var(--ink); }
.mytests-wait { padding: 12px 14px; margin: 0; }

@media (max-width: 1100px) {
  .editor-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .results { grid-column: 1 / -1; max-height: 50vh; }
}
@media (max-width: 760px), (pointer: coarse) {
  .keybar { display: flex; }
}
@media (max-width: 760px) {
  .is-editor main { padding: 0; }
  .is-editor .topbar { padding-top: 10px; padding-bottom: 10px; }
  .editor-shell { display: block; height: auto; min-height: 0; position: relative; }
  .files { position: fixed; inset: 0 25% 0 0; z-index: 30; border-radius: 0; transform: translateX(-102%); transition: transform .2s ease; }
  .editor-shell.files-open .files { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .files-toggle { display: grid; }
  .code { border-radius: 0; border-left: 0; border-right: 0; height: calc(100dvh - 56px - 64px - env(safe-area-inset-bottom)); }
  .cm-host .cm-editor { font-size: 15px; }
  .code-actions .btn { flex: 1; padding: 11px 8px; }
  .results { border-radius: 0; border-left: 0; border-right: 0; max-height: none; }
}

/* ---------- pílulas ---------- */
.pill-card { display: flex; align-items: center; gap: 16px; padding: 16px 20px; margin: -16px 0 36px; border-radius: var(--radius-m);
  background: var(--accent); color: var(--accent-ink); text-decoration: none; }
.pill-card:hover { filter: brightness(1.06); }
.pill-text strong { display: block; font-family: var(--font-display); font-size: var(--step-1); }
.pill-text span { opacity: .85; font-size: var(--step--1); }
.pill-goal, .goal { display: flex; gap: 5px; }
.pill-goal i, .goal i { width: 12px; height: 26px; border-radius: 6px; background: currentColor; opacity: .3; }
.pill-goal i.on, .goal i.on { opacity: 1; }

.is-drills main { max-width: 620px; }
.drills { padding-top: 8px; }
.drill-stats { display: flex; align-items: center; gap: 14px; padding: 12px 0 18px; color: var(--graphite); font-size: var(--step--1); }
.drill-stats p { margin: 0; }
.drill-stats strong { color: var(--ink); }
.goal { color: var(--pass); }
.drill { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 22px 20px; box-shadow: var(--shadow); }
.drill-kind { margin: 0 0 8px; font-size: var(--step--1); font-weight: 600; color: var(--accent); }
.drill.is-right .drill-kind { color: var(--pass); }
.drill.is-wrong .drill-kind { color: var(--fail); }
.drill-prompt { font: 700 var(--step-1)/1.3 var(--font-display); margin-bottom: 18px; }
.drill-options { display: grid; gap: 10px; }
.drill-options .option { padding: 14px 16px; font-size: var(--step-0); min-height: 52px; }
.drill-options span.option { display: block; }
.spot-code { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--paper);
  overflow-x: auto; }
.spot-code li + li { border-top: 1px solid var(--rule-soft); }
.spot-line { display: flex; width: 100%; min-width: max-content; align-items: stretch; background: none; border: 0; padding: 0; text-align: left;
  color: var(--ink); cursor: pointer; font: inherit; }
button.spot-line:hover:not([disabled]) { background: var(--accent-soft); }
.spot-line[disabled] { cursor: default; }
.spot-line .ln { flex: 0 0 34px; padding: 9px 0; text-align: center; color: var(--graphite); font: .75rem/1.6 var(--font-mono);
  border-right: 1px solid var(--rule-soft); user-select: none; }
.spot-line code { padding: 9px 12px; white-space: pre; background: none; font-size: .85rem; line-height: 1.6; }
.spot-line.is-right { background: var(--pass-soft); }
.spot-line.is-right .ln { color: var(--pass); font-weight: 700; }
.spot-line.is-wrong { background: var(--fail-soft); }
.drill-explanation { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule-soft); }
.drill-explanation p { margin: 0 0 8px; }
.drill-next { width: 100%; margin-top: 14px; min-height: 50px; }
.drill-done h1 { font-size: var(--step-2); margin-bottom: 8px; }
.drill-done p { color: var(--graphite); margin: 0 0 18px; }
@media (max-width: 600px) {
  .drill { padding: 18px 16px; border-radius: var(--radius-m); }
  .pill-card { margin: -24px 0 28px; }
}
