/* Light theme by default, in the colors of the Brazilian flag. Dark theme at the end of the file (switch in the top bar). */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f6f3;
  --ink: #0f1c2e;
  --ink-2: #3b4a5c;
  --ink-3: #687586;
  --line: #e2e8ee;
  --green: #009c3b;
  --green-dark: #00762c;
  --yellow: #ffdf00;
  --yellow-soft: #fff7c2;
  --blue: #002776;
  --blue-soft: #e6ecf8;
  --accent: var(--green-dark);
  --accent-ink: #ffffff;
  --accent-soft: #e2f4e8;
  --good: #00762c;
  --good-soft: #e2f4e8;
  --bad: #c0392b;
  --bad-soft: #fde8e5;
  --paper: #fffef6;
  --paper-line: #e3eaf6;
  --c-genero: #1f4fb8;   --c-genero-bg: #e3ebfb;
  --c-papel: #7a4cc2;    --c-papel-bg: #efe7fb;
  --c-fonte: #00762c;    --c-fonte-bg: #e2f4e8;
  --c-coesao: #9a6a00;   --c-coesao-bg: #fff4bf;
  --c-registro: #c0336f; --c-registro-bg: #fce6ef;
  --c-lingua: #0f7f8c;   --c-lingua-bg: #ddf2f4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,39,118,.05), 0 4px 16px rgba(0,39,118,.06);
  --font-head: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-pt: 'Source Serif 4', Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.55 var(--font-body);
}
@media (max-width: 640px) { body { font-size: 18px; } }
a { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 800; margin-top: 1.8em; }
h3 { font-size: 1.05rem; font-weight: 700; margin-top: 1.4em; }
p { margin: 0 0 .8em; }
ul, ol { padding-left: 1.2em; margin: 0 0 1em; }
li { margin: .3em 0; }
em { font-style: italic; }
button { font: inherit; color: inherit; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 4px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.tb-back { font-size: 30px; line-height: 1; text-decoration: none; color: var(--ink-2); text-align: center; padding: 2px 0 6px; border-radius: 10px; }
.tb-back[hidden] { visibility: hidden; display: block; }
.tb-title { font-family: var(--font-head); font-weight: 800; text-decoration: none; color: var(--ink); font-size: 1rem; white-space: nowrap; }
.tb-title span { color: var(--accent); }
.tb-nav { display: flex; gap: 2px; }
.tb-nav a { text-decoration: none; color: var(--ink-2); font-family: var(--font-head); font-weight: 700; font-size: .85rem; padding: 7px 10px; border-radius: 999px; }
.tb-nav a.on { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 440px) {
  .topbar { grid-template-columns: 34px 1fr auto; padding-left: 8px; padding-right: 8px; }
  .tb-title span { display: none; }
  .tb-nav a { padding: 7px 8px; }
}

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 96px; }

/* Blocks */
.lede { color: var(--ink-2); font-size: 1.02rem; }
.eyebrow { font-family: var(--font-head); font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: .4em; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); margin: 0 0 12px;
}
.card h3:first-child, .card h2:first-child { margin-top: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
a.tile {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); transition: transform .08s ease, border-color .15s;
}
a.tile:hover { border-color: var(--accent); }
a.tile:active { transform: scale(.99); }
.tile-title { font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; }
.tile-sub { color: var(--ink-3); font-size: .9rem; margin-top: 2px; }
.tile-meta { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.hero-tiles { display: grid; gap: 12px; }
.hero-tiles a.tile { padding: 18px 20px; }
.hero-tiles .tile-title { font-size: 1.25rem; }

.chip {
  display: inline-block; font-family: var(--font-head); font-size: .72rem; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.done { background: var(--good-soft); color: var(--good); }

.countdown { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 20px; }
.countdown b { font-family: var(--font-head); font-size: 2.2rem; font-weight: 800; color: var(--accent); line-height: 1; }
.countdown span { color: var(--ink-2); }

/* Role box */
.role { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.role div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.role b { display: block; font-family: var(--font-head); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 2px; }

.checklist { list-style: none; padding: 0; }
.checklist li { position: relative; padding-left: 28px; }
.checklist li::before { content: '✓'; position: absolute; left: 4px; top: 0; color: var(--accent); font-weight: 800; }

.skeleton { list-style: none; padding: 0; counter-reset: sk; }
.skeleton li { counter-increment: sk; display: grid; grid-template-columns: 28px 1fr; gap: 4px 8px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.skeleton li:last-child { border-bottom: 0; }
.skeleton li::before { content: counter(sk); grid-row: span 3; font-family: var(--font-head); font-weight: 800; color: var(--accent); background: var(--accent-soft); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; }
.sk-part { font-family: var(--font-head); font-weight: 700; }
.sk-what { color: var(--ink-2); font-size: .95rem; }
.pt { font-family: var(--font-pt); font-size: 1.04em; }
.sk-ex { font-family: var(--font-pt); color: var(--ink); background: var(--paper); border-left: 3px solid var(--accent); padding: 4px 10px; border-radius: 0 8px 8px 0; }

table.words { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.words th { text-align: left; font-family: var(--font-head); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.words td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.words td.use { color: var(--good); font-family: var(--font-pt); font-weight: 600; }
table.words td.avoid { color: var(--bad); font-family: var(--font-pt); text-decoration: line-through; text-decoration-thickness: 1px; }
@media (max-width: 520px) {
  table.words thead { display: none; }
  table.words tr { display: grid; grid-template-columns: auto auto 1fr; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.words td { border: 0; padding: 0; }
  table.words td.why { grid-column: 1 / -1; color: var(--ink-2); }
}

/* Source + prompt */
.source { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.source-kind { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.source h4 { font-family: var(--font-pt); font-size: 1.15rem; font-weight: 600; margin: 0 0 .5em; }
.source p { font-family: var(--font-pt); }
.source .turn b { font-family: var(--font-body); font-size: .85rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.source-note { font-size: .9rem; color: var(--ink-3); font-style: italic; }
.enunciado { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 12px; font-family: var(--font-pt); font-size: 1.05rem; }
.enunciado b { font-family: var(--font-head); display: block; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }

/* Model answer */
.paper {
  background: var(--paper); border: 1px solid var(--line); border-radius: 6px;
  padding: 18px 20px; font-family: var(--font-pt); font-size: 1.06rem; line-height: 1.75;
  background-image: repeating-linear-gradient(transparent 0 calc(1.75em - 1px), var(--paper-line) calc(1.75em - 1px) 1.75em);
  background-position: 0 18px; box-shadow: var(--shadow);
}
.paper p { margin: 0 0 .5em; }
.paper p.line { margin: 0; }
mark.hl { background: var(--hl-bg); color: inherit; border-bottom: 2px solid var(--hl); border-radius: 3px; padding: 0 1px; cursor: pointer; }
mark.hl sup { color: var(--hl); font-family: var(--font-head); font-weight: 800; font-size: .62em; margin-left: 1px; }
mark.hl.flash { outline: 2px solid var(--hl); }
.cat-genero { --hl: var(--c-genero); --hl-bg: var(--c-genero-bg); }
.cat-papel { --hl: var(--c-papel); --hl-bg: var(--c-papel-bg); }
.cat-fonte { --hl: var(--c-fonte); --hl-bg: var(--c-fonte-bg); }
.cat-coesao { --hl: var(--c-coesao); --hl-bg: var(--c-coesao-bg); }
.cat-registro { --hl: var(--c-registro); --hl-bg: var(--c-registro-bg); }
.cat-lingua { --hl: var(--c-lingua); --hl-bg: var(--c-lingua-bg); }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.legend span { font-family: var(--font-head); font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--hl-bg); color: var(--hl); }
.notes { list-style: none; padding: 0; }
.notes li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.notes li.active { background: var(--hl-bg); border-radius: 10px; }
.note-n { width: 26px; height: 26px; border-radius: 50%; background: var(--hl); color: var(--bg); font-family: var(--font-head); font-weight: 800; font-size: .8rem; display: grid; place-items: center; }
.note-cat { font-family: var(--font-head); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--hl); }
.why5 { border-left: 4px solid var(--good); background: var(--good-soft); border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 16px; margin-top: 14px; }
.why5 b { font-family: var(--font-head); }
.notesbook { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .9rem; background: var(--paper); border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; }

/* Bottom sheet */
.sheet[hidden] { display: none; }
.sheet { position: fixed; inset: auto 0 0 0; z-index: 30; display: flex; justify-content: center; pointer-events: none; }
.sheet-inner {
  pointer-events: auto; width: min(760px, 100%); background: var(--surface); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.15); padding: 16px 18px calc(18px + env(safe-area-inset-bottom)); position: relative;
  max-height: 55vh; overflow: auto;
}
.sheet-close { position: absolute; top: 8px; right: 10px; border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 50%; font-size: 20px; cursor: pointer; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-family: var(--font-head); font-weight: 700; font-size: .95rem;
  padding: 11px 18px; border-radius: 12px; cursor: pointer; text-decoration: none; min-height: 46px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.btn-row.stretch .btn { flex: 1; }

details.reveal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
details.reveal summary { cursor: pointer; font-family: var(--font-head); font-weight: 700; }

/* Timer */
.timer { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; position: sticky; top: calc(var(--tb-h, 62px) + 6px); z-index: 5; }
.timer-digits { font-family: var(--font-head); font-weight: 800; font-size: 1.9rem; font-variant-numeric: tabular-nums; min-width: 5ch; }
.timer-digits.low { color: var(--bad); }
.timer .btn { min-height: 40px; padding: 8px 14px; }

/* Pager */
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 28px; }
.pager a { flex: 1; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; color: var(--ink); font-size: .9rem; }
.pager a small { display: block; color: var(--ink-3); font-size: .75rem; font-family: var(--font-head); text-transform: uppercase; letter-spacing: .06em; }
.pager a.next { text-align: right; }

/* Bands */
table.bands { width: 100%; border-collapse: collapse; }
table.bands td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.bands tr.target td { background: var(--accent-soft); font-weight: 700; }
table.bands td:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* Drill */
.modes { display: grid; gap: 10px; }
a.mode { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; }
a.mode.mix { border: 2px solid var(--accent); }
.acc-bar { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.acc-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.mode-stat { font-family: var(--font-head); font-weight: 800; color: var(--accent); font-size: 1.1rem; text-align: right; }
.mode-stat small { display: block; color: var(--ink-3); font-weight: 600; font-size: .72rem; }

.round-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.drill { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px 18px; box-shadow: var(--shadow); text-align: center; }
.drill-sentence { font-family: var(--font-pt); font-size: 1.35rem; line-height: 1.5; margin: 6px 0 22px; }
.blank { display: inline-block; min-width: 3.2em; border-bottom: 2px solid var(--ink-3); color: var(--accent); font-weight: 600; padding: 0 4px; }
.blank.good { color: var(--good); border-color: var(--good); }
.blank.bad { color: var(--bad); border-color: var(--bad); }
.options { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.opt { font-family: var(--font-pt); font-size: 1.2rem; padding: 14px 10px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; min-height: 56px; }
.opt:active { transform: scale(.98); }
.opt.good { border-color: var(--good); background: var(--good-soft); color: var(--good); font-weight: 600; }
.opt.bad { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.opt:disabled { cursor: default; }
.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 4px 0 14px; }
.tl {
  width: 46px; height: 58px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2);
  font-family: var(--font-pt); font-size: 1.7rem; display: grid; place-items: center; padding: 0; color: var(--ink-3);
}
.tl.can { background: var(--surface); color: var(--ink); cursor: pointer; border-color: var(--ink-3); }
.tl.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tl.changed { color: var(--accent); }
.tl.good { border-color: var(--good); color: var(--good); }
.tl.bad { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
@media (max-width: 400px) { .tl { width: 38px; height: 50px; font-size: 1.45rem; } }
.tray { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; min-height: 58px; margin-bottom: 8px; }
.tray button { width: 52px; height: 52px; border-radius: 12px; border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent); font-family: var(--font-pt); font-size: 1.6rem; cursor: pointer; }
.tray button.cur { background: var(--accent); color: var(--accent-ink); }
.tray-hint { color: var(--ink-3); font-size: .9rem; align-self: center; }
.feedback { margin-top: 18px; border-radius: 14px; padding: 14px 16px; text-align: left; }
.feedback.good { background: var(--good-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback > b { font-family: var(--font-head); display: block; margin-bottom: 4px; }
.feedback.good > b { color: var(--good); }
.feedback.bad > b { color: var(--bad); }
.feedback .again { font-size: .85rem; color: var(--ink-3); margin-top: 6px; }
.drill-actions { margin-top: 16px; }
.drill-actions .btn { width: 100%; }
.mode-tag { font-family: var(--font-head); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

.score-big { font-family: var(--font-head); font-size: 3rem; font-weight: 800; color: var(--accent); line-height: 1; }
.miss { text-align: left; padding: 10px 0; border-bottom: 1px solid var(--line); }
.miss .pt { font-size: 1.05rem; }
.miss small { color: var(--ink-3); display: block; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-family: var(--font-head); font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.stat span { font-size: .8rem; color: var(--ink-3); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-family: var(--font-head); font-weight: 700; font-size: .9rem; z-index: 50; }
.muted { color: var(--ink-3); }
.small { font-size: .9rem; }
.empty { color: var(--ink-3); font-style: italic; }

/* Brazil accents */
h1 { color: var(--blue); }
h2, h3 { color: var(--blue); }
.eyebrow { color: var(--green-dark); }
a { color: var(--blue); }
.topbar { background: rgba(255,255,255,.94); border-bottom: 0; }
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px;
  background: linear-gradient(90deg, var(--green) 0 45%, var(--yellow) 45% 70%, var(--blue) 70% 100%); }
.tb-title { color: var(--blue); }
.tb-title span { color: var(--green-dark); }
.tb-nav a { color: var(--ink-2); }
.tb-nav a.on { background: var(--yellow); color: var(--blue); }
.countdown b { color: var(--blue); box-shadow: inset 0 -.28em 0 var(--yellow); padding: 0 .08em; }
a.tile:hover { border-color: var(--blue); }
.hero-tiles a.tile { border-left: 6px solid var(--green); }
.hero-tiles a.tile:nth-child(2) { border-left-color: var(--yellow); }
.hero-tiles a.tile:nth-child(3) { border-left-color: var(--blue); }
.chip.accent { background: var(--blue-soft); color: var(--blue); }
.enunciado { background: var(--yellow-soft); border-left: 5px solid var(--yellow); }
.enunciado b { color: var(--blue); }
.skeleton li::before { background: var(--yellow); color: var(--blue); }
.checklist li::before { color: var(--green); }
.btn.primary { background: var(--green-dark); border-color: var(--green-dark); }
a.mode.mix { border-color: var(--yellow); box-shadow: 0 0 0 1px var(--yellow), var(--shadow); }
.mode-stat { color: var(--blue); }
.acc-bar i, .progress i { background: var(--green); }
.stat b, .score-big { color: var(--blue); }
table.bands tr.target td { background: var(--yellow-soft); }
.tray button { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.tray button.cur { background: var(--blue); color: #fff; }
.tl.sel { border-color: var(--blue); box-shadow: 0 0 0 3px var(--yellow); }
.tl.changed { color: var(--blue); }
.blank { color: var(--blue); }
.timer-digits { color: var(--blue); }
.sk-ex { border-left-color: var(--green); }
.reveal.model summary { color: var(--blue); }
.reveal.model[open] summary { margin-bottom: 10px; }

/* Openings and closings */
.options.stack { grid-template-columns: 1fr; }
.options.stack .opt { font-size: 1.08rem; text-align: left; padding: 12px 16px; }
ol.ladder { list-style: none; padding: 0; margin: 0; }
ol.ladder li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
ol.ladder li:last-child { border-bottom: 0; }
ol.ladder li .small { grid-column: 1 / -1; }
details.op summary { color: var(--blue); font-size: 1.02rem; }
details.op[open] summary { margin-bottom: 6px; }
.op-row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
.op-label { font-family: var(--font-head); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--green-dark); padding-top: 3px; }
.op-item { margin-bottom: 3px; }
.op-ex { font-size: 1rem; }
table.phrases td.pt { width: 55%; }
@media (max-width: 520px) {
  .op-row { grid-template-columns: 1fr; gap: 2px; }
  table.phrases tr { grid-template-columns: 1fr; }
}

/* ---------- Trilha ---------- */
.chip.warn { background: var(--yellow-soft); color: #7a5b00; }
.path-top { margin: 0 0 8px; }
.path-count { font-family: var(--font-head); font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.path-count b { color: var(--accent); font-size: 1.2rem; }
.path-top .progress { margin-bottom: 8px; }
.unit-head { display: flex; flex-direction: column; gap: 2px; margin-top: 1.6em; }
.unit-head span { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
ol.nodes { list-style: none; padding: 0; margin: 0; position: relative; }
ol.nodes::before { content: ''; position: absolute; left: 31px; top: 22px; bottom: 22px; width: 3px; background: var(--line); border-radius: 3px; }
ol.nodes li { margin: 0; }
a.node { display: grid; grid-template-columns: 46px 1fr; gap: 12px; align-items: start; padding: 10px; text-decoration: none; color: var(--ink); border-radius: var(--radius); position: relative; }
a.node .dot { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 3px solid var(--line); font-family: var(--font-head); font-weight: 800; color: var(--ink-3); position: relative; z-index: 1; }
a.node.done .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
a.node.current .dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
a.node.current { background: var(--accent-soft); }
a.node:hover .node-title { color: var(--accent); }
.node-body { display: block; padding-top: 2px; }
.node-title { display: block; font-family: var(--font-head); font-weight: 800; font-size: 1.02rem; }
.node-sub { display: block; color: var(--ink-3); font-size: .88rem; }
.node-body .tile-meta { margin-top: 6px; }

/* Player */
.step-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px 18px; box-shadow: var(--shadow); }
.step-card.left { text-align: left; }
.step-h { margin: .3em 0 .6em; font-size: 1.25rem; }
.q { font-weight: 600; margin: 8px 0 14px; }
.passage { background: var(--paper); border: 1px solid var(--paper-line); border-radius: 12px; padding: 12px 14px; margin: 8px 0 12px; font-size: 1.05rem; line-height: 1.55; }
.passage p { margin: 0 0 .5em; } .passage p:last-child { margin: 0; }
.examples { display: grid; gap: 8px; margin: 12px 0; }
.ex { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.ex .pt { font-family: var(--font-pt); font-size: 1.05rem; }
.step-card .options.stack .opt { text-align: left; font-size: 1.05rem; line-height: 1.4; }
.step .feedback { text-align: left; }
ol.order-built { list-style: decimal; padding-left: 1.4em; margin: 6px 0 12px; min-height: 40px; }
ol.order-built li.placeholder { list-style: none; margin-left: -1.4em; color: var(--ink-3); font-size: .9rem; border: 2px dashed var(--line); border-radius: 12px; padding: 10px 12px; }
.order-pool { display: grid; gap: 8px; }
button.ord { display: block; width: 100%; text-align: left; font-family: var(--font-pt); font-size: 1rem; line-height: 1.4; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.order-pool button.ord { border-style: dashed; }
button.ord.good { border-color: var(--good); background: var(--good-soft); }
button.ord.bad { border-color: var(--bad); background: var(--bad-soft); }
.fixtext { font-size: 1.12rem; line-height: 1.9; background: var(--paper); border: 1px solid var(--paper-line); border-radius: 12px; padding: 12px 14px; margin: 8px 0 4px; }
.fixtext .fw { display: inline; font: inherit; color: inherit; background: none; border: 0; padding: 1px 1px; margin: 0; border-radius: 4px; cursor: pointer; }
.fixtext span.fw { cursor: default; }
.fixtext .fw.flag { background: var(--yellow-soft); box-shadow: inset 0 -2px 0 #d4a900; }
.fixtext .fw.hit { background: var(--good-soft); color: var(--good); font-weight: 600; }
.fixtext .fw.miss { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.fixtext .fw.false { text-decoration: underline dotted var(--ink-3); background: var(--surface-2); }
.fixtext sup { font-family: var(--font-head); font-size: .65em; margin-left: 1px; }
ol.fix-notes { padding-left: 1.4em; margin: 12px 0 0; }
ol.fix-notes li { margin: 0 0 10px; }
ol.fix-notes li.miss::marker { color: var(--bad); font-weight: 800; }
ol.fix-notes li.hit::marker { color: var(--good); font-weight: 800; }
ol.fix-notes s { color: var(--bad); }
textarea.write { width: 100%; font-size: 1.1rem; line-height: 1.5; padding: 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); resize: vertical; color: var(--ink); }
textarea.write:focus { outline: none; border-color: var(--accent); }
ul.selfcheck { list-style: none; padding: 0; }
ul.selfcheck label { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: start; cursor: pointer; }
ul.selfcheck input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--accent); }
.btn.small { min-height: 38px; padding: 7px 14px; font-size: .88rem; }

/* Leitner box bar */
.acc-bar.boxes { display: flex; }
.acc-bar.boxes i { border-radius: 0; }
.acc-bar i.b1 { background: #b9e4c7; } .acc-bar i.b2 { background: #7fcf98; } .acc-bar i.b3 { background: #2fae5a; }
.acc-bar i.b4 { background: var(--green-dark); } .acc-bar i.b5 { background: var(--blue); }
.mode-foot { grid-column: 1 / -1; font-size: .8rem; color: var(--ink-3); margin-top: 4px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.legend-row span { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--ink-2); }
.legend-row i { display: inline-block; width: 14px; height: 8px; border-radius: 3px; }
.legend-row i.b1 { background: #b9e4c7; } .legend-row i.b2 { background: #7fcf98; } .legend-row i.b3 { background: #2fae5a; } .legend-row i.b4 { background: var(--green-dark); } .legend-row i.b5 { background: var(--blue); }
.card .acc-bar.boxes { margin-top: 8px; }

/* Today: streak and review */
.today { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 16px; box-shadow: var(--shadow); }
.today-streak { font-family: var(--font-head); font-weight: 700; }
.today-streak b { color: var(--accent); font-size: 1.2rem; }
.today-streak .small { font-family: var(--font-body); font-weight: 400; }

/* Ditado */
.dict-result { font-size: 1.15rem; line-height: 2.3; margin: 12px 0 4px; }
.dw { display: inline-block; position: relative; padding: 0 3px; border-radius: 5px; line-height: 1.5; vertical-align: top; text-align: center; }
.dw small { display: block; font-family: var(--font-body); font-size: .72rem; line-height: 1.2; }
.dw.ok { color: var(--good); }
.dw.acc { background: var(--yellow-soft); color: #7a5b00; font-weight: 600; }
.dw.bad { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.dw.bad small, .dw.acc small { text-decoration: line-through; opacity: .8; }
.dw.miss { border: 2px dashed var(--bad); color: var(--bad); }
.dw.extra { color: var(--ink-3); text-decoration: line-through; }

/* Passe para o formal */
.passage.said { font-style: italic; }
ul.fchecks { list-style: none; padding: 0; margin: .6em 0 0; }
ul.fchecks li { padding: 6px 0 6px 26px; position: relative; border-top: 1px solid rgba(0,0,0,.06); }
ul.fchecks li::before { position: absolute; left: 2px; top: 6px; font-weight: 800; font-family: var(--font-head); }
ul.fchecks li.hit::before { content: '✓'; color: var(--good); }
ul.fchecks li.miss::before { content: '✗'; color: var(--bad); }
ul.fchecks s { color: var(--bad); }
mark.fm { background: var(--good-soft); color: var(--good); font-weight: 600; padding: 0 2px; border-radius: 4px; }

/* The lesson or round header and its progress bar stay frozen under the top bar. */
.run-head { position: sticky; top: var(--tb-h, 60px); z-index: 6; background: var(--bg); margin: -20px -16px 14px; padding: 12px 16px 10px; border-bottom: 1px solid var(--line); }
.run-head .round-head { margin-bottom: 8px; }
.run-head .round-head .eyebrow { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-head .round-head > :last-child { flex-shrink: 0; }
.run-head .progress { margin-bottom: 0; }

/* ---------- Dark theme (html[data-theme="dark"], set by the moon/sun switch in the top bar) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141a;
  --surface: #161d25;
  --surface-2: #1d2630;
  --ink: #e8edf2;
  --ink-2: #b9c4cf;
  --ink-3: #8a97a5;
  --line: #2a3542;
  --green: #2fbf62;
  --green-dark: #3ccf74;
  --yellow: #ffdf00;
  --yellow-soft: #3a3410;
  --blue: #7aa2ff;
  --blue-soft: #1b2a4a;
  --accent: #3ccf74;
  --accent-ink: #0b1a10;
  --accent-soft: #16301f;
  --good: #4ade80;
  --good-soft: #15301e;
  --bad: #ff8a7a;
  --bad-soft: #3a1d1a;
  --paper: #1a2129;
  --paper-line: #2a3542;
  --c-genero: #8fb0ff;   --c-genero-bg: #1c2a48;
  --c-papel: #c4a3ff;    --c-papel-bg: #2a2142;
  --c-fonte: #4ade80;    --c-fonte-bg: #15301e;
  --c-coesao: #f2c94c;   --c-coesao-bg: #3a3210;
  --c-registro: #ff8fbd; --c-registro-bg: #3d1c2b;
  --c-lingua: #5fd3df;   --c-lingua-bg: #12343a;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 4px 16px rgba(0,0,0,.35);
}
:root[data-theme="dark"] .topbar { background: rgba(15,20,26,.94); }
:root[data-theme="dark"] .tray button.cur { color: #0f141a; }
:root[data-theme="dark"] .chip.warn,
:root[data-theme="dark"] .dw.acc { color: #ffe680; }
:root[data-theme="dark"] .fixtext .fw.flag { box-shadow: inset 0 -2px 0 #b38f00; }
:root[data-theme="dark"] ul.fchecks li { border-top-color: rgba(255,255,255,.08); }
:root[data-theme="dark"] .sheet-inner { box-shadow: 0 -8px 30px rgba(0,0,0,.6); }
.tb-theme { border: 0; background: transparent; cursor: pointer; font-size: 1.05rem; line-height: 1; padding: 7px 8px; border-radius: 999px; color: var(--ink-2); }
.tb-theme:hover { background: var(--surface-2); }
/* Text that sits ON the flag yellow keeps the dark ink in both themes. */
:root[data-theme="dark"] .tb-nav a.on,
:root[data-theme="dark"] .skeleton li::before { color: #0f1c2e; }
/* Four tabs plus the switch must fit a 375 px phone without a sideways scroll. */
@media (max-width: 420px) {
  .tb-nav { gap: 0; }
  .tb-nav a { padding: 7px 7px; font-size: .8rem; }
  .tb-theme { padding: 6px 4px; font-size: .95rem; }
  .tb-title { font-size: .92rem; }
}
@media (max-width: 360px) { .tb-title { display: none; } .topbar { grid-template-columns: 30px 1fr auto; } }
