:root {
  --bg: #e4edf3;
  --surface: #f9fbfc;
  --surface-2: #f1f6f9;
  --surface-3: #d9e6ee;
  --text: #0f1f2d;
  --muted: #4f6475;
  --line: rgba(38,69,91,.13);
  --accent: #168f87;
  --accent-2: #497fd1;
  --success: #43b97c;
  --warning: #c58a19;
  --danger: #d65368;
  --shadow: 0 14px 38px rgba(50,72,89,.12);
  --radius: 22px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(22,143,135,.10), transparent 32%),
    radial-gradient(circle at 90% 5%, rgba(73,127,209,.09), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}

.page { padding: 24px 18px 34px; }
.page.lesson-page { padding-bottom: 32px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.brand-wrap { display:flex; align-items:center; gap:12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px;
  display:grid; place-items:center;
  color: #0d6f69;
  background: linear-gradient(145deg, rgba(22,143,135,.14), rgba(73,127,209,.14));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.brand-mark svg { width:26px; height:26px; }
.brand-copy { min-width: 0; }
.brand-kicker { color: var(--accent); font-size: 11px; line-height: 1.15; font-weight: 900; letter-spacing: .075em; text-transform: uppercase; margin-bottom: 2px; }
.brand-name { font-weight: 850; letter-spacing: .015em; line-height: 1.16; }
.brand-tagline { color: var(--muted); font-size: 11px; margin-top: 2px; }
.version-chip, .chip {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.72);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
}

h1,h2,h3,p { margin-top: 0; }
h1 { font-size: clamp(28px, 7vw, 38px); line-height: 1.07; letter-spacing: -.035em; margin-bottom: 10px; }
h2 { font-size: 22px; letter-spacing: -.02em; }
h3 { font-size: 17px; }
.eyebrow { color: var(--accent); font-weight: 800; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 8px; }
.lead { color: var(--muted); line-height: 1.6; font-size: 15px; }

.hero {
  padding: 4px 2px 8px;
  margin-bottom: 18px;
}

.stats-row { display:grid; grid-template-columns: repeat(3,1fr); gap:10px; margin: 18px 0 24px; }
.stat-card {
  background: rgba(255,255,255,.72);
  border:1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 12px;
}
.stat-value { font-size: 18px; font-weight: 850; }
.stat-label { color: var(--muted); font-size: 11px; margin-top:3px; }

.section-title { display:flex; align-items:end; justify-content:space-between; gap:12px; margin: 26px 0 12px; }
.section-title h2 { margin:0; }
.section-title small { color: var(--muted); }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(247,250,252,.98));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card + .card { margin-top: 12px; }
.card.clickable { transition: transform .18s ease, border-color .18s ease; }
.card.clickable:active { transform: scale(.99); }
@media (hover:hover) { .card.clickable:hover { transform: translateY(-2px); border-color: rgba(22,143,135,.34); } }

.continue-card { position:relative; overflow:hidden; }
.continue-card:after {
  content:""; position:absolute; width:180px; height:180px; border-radius:50%;
  background: rgba(22,143,135,.075); right:-80px; top:-90px;
}
.card-topline { display:flex; justify-content:space-between; gap:10px; align-items:center; margin-bottom:12px; }
.card-title { font-size: 21px; font-weight: 850; letter-spacing:-.02em; }
.card-subtitle { color: var(--muted); font-size: 14px; line-height:1.5; }

.progress-track {
  width: 100%; height: 8px; border-radius:99px; background: rgba(38,69,91,.10); overflow:hidden;
}
.progress-fill { height:100%; border-radius:inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition:width .25s ease; }
.progress-meta { display:flex; justify-content:space-between; color:var(--muted); font-size:12px; margin-top:7px; }

.btn {
  border:0; border-radius: 14px; padding: 13px 16px; font-weight: 800;
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  min-height: 48px;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), #72e7a9); color:#041916; }
.btn-secondary { background: rgba(255,255,255,.82); color:var(--text); border:1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--muted); border:1px solid var(--line); }
.btn-danger { color: var(--danger); background: rgba(214,83,104,.08); border:1px solid rgba(214,83,104,.20); }
.btn-block { width:100%; }
.btn:disabled { opacity:.45; cursor:not-allowed; }

.actions { display:flex; gap:10px; margin-top:16px; }
.actions > * { flex:1; }

.bottom-nav {
  position: fixed;
  left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 760px);
  display:grid; grid-template-columns:repeat(4,1fr);
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background: rgba(242,247,250,.94);
  border-top:1px solid var(--line);
  backdrop-filter: blur(16px);
  z-index:20;
}
.nav-item {
  border:0; background:transparent; color: var(--muted);
  display:flex; flex-direction:column; align-items:center; gap:4px;
  padding:7px 4px; border-radius:12px; font-size:11px; font-weight:700;
}
.nav-icon { font-size:19px; line-height:1; }
.nav-item.active { color: var(--accent); background: rgba(22,143,135,.09); }

.trail-grid { display:grid; gap:12px; }
.home-trail-grid { display:grid; gap:12px; margin-bottom: 6px; }
.home-trail-card { display:flex; flex-direction:column; }
.home-trail-card .btn { margin-top:auto; }

.trail-icon { width:48px; height:48px; border-radius:16px; display:grid; place-items:center; font-size:24px; background:rgba(38,69,91,.06); margin-bottom:14px; }
.trail-card.disabled { opacity:.62; }
.trail-meta { display:flex; gap:8px; flex-wrap:wrap; margin:12px 0 14px; }

.lesson-list { position:relative; }
.lesson-item {
  display:grid; grid-template-columns:42px 1fr auto; gap:12px; align-items:center;
  padding:15px 0; border-bottom:1px solid var(--line);
}
.lesson-item:last-child { border-bottom:0; }
.lesson-status {
  width:36px; height:36px; border-radius:50%; display:grid; place-items:center;
  border:1px solid var(--line); color:var(--muted); font-weight:800;
  background:rgba(255,255,255,.78);
}
.lesson-item.completed .lesson-status { color:#103528; background:rgba(67,185,124,.30); border-color:rgba(67,185,124,.42); }
.lesson-item.current .lesson-status { color:#ffffff; background:var(--accent); border-color:transparent; }
.lesson-item.locked { opacity:.5; }
.lesson-name { font-weight:800; margin-bottom:4px; }
.lesson-small { color:var(--muted); font-size:12px; }
.lesson-arrow { color:var(--muted); }

.lesson-header { margin-bottom:18px; }
.lesson-meta { display:flex; gap:8px; flex-wrap:wrap; margin:12px 0; }
.back-btn { width:42px; height:42px; padding:0; border-radius:14px; }
.lesson-step-card { min-height: 330px; display:flex; flex-direction:column; }
.step-body { flex:1; }
.step-title { font-size:26px; margin-bottom:14px; }
.step-text { color:#24394b; line-height:1.75; }
.formula-box {
  margin: 24px 0; padding: 24px 16px; text-align:center;
  border-radius:18px; border:1px solid rgba(22,143,135,.25);
  background:rgba(22,143,135,.07);
  font-size: clamp(25px, 8vw, 38px); font-weight:900; letter-spacing:.02em;
}
.note-list, .summary-list, .solution-list { margin:14px 0 0; padding-left:22px; color:#24394b; line-height:1.75; }

.lesson-figure {
  margin: 20px 0 4px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.88);
  overflow: hidden;
}
.lesson-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
  border-radius: 12px;
}
.lesson-figure figcaption {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
  padding: 9px 6px 2px;
}


.options { display:grid; gap:10px; margin-top:18px; }
.option {
  width:100%; text-align:left; padding:14px 15px; border-radius:14px;
  color:var(--text); background:rgba(255,255,255,.82); border:1px solid var(--line);
  transition:.15s ease;
}
.option.selected { border-color:var(--accent-2); background:rgba(120,168,255,.09); }
.option.correct { border-color:var(--success); background:rgba(67,185,124,.12); }
.option.incorrect { border-color:var(--danger); background:rgba(214,83,104,.09); }
.feedback {
  margin-top:14px; padding:14px; border-radius:14px; line-height:1.55; font-size:14px;
  border:1px solid var(--line); background:rgba(255,255,255,.72);
}
.feedback.ok { border-color:rgba(67,185,124,.32); }
.feedback.no { border-color:rgba(214,83,104,.28); }

.challenge-box { border-left:3px solid var(--warning); padding-left:14px; margin:16px 0; }
.challenge-list { display:grid; gap:12px; }
.challenge-actions { margin-top:22px; }
textarea.answer-input, input.answer-input {
  width:100%; margin-top:14px; padding:14px; border-radius:14px; resize:vertical; min-height:92px;
  border:1px solid var(--line); background:#ffffff; color:var(--text); outline:none;
}
input.answer-input { min-height:48px; }
textarea.answer-input:focus, input.answer-input:focus { border-color:var(--accent-2); }
.reference-answer { margin-top:14px; padding:14px; border-radius:14px; background:rgba(197,138,25,.08); border:1px solid rgba(197,138,25,.22); }

.level-badge {
  width:116px; height:116px; border-radius:50%; margin:8px auto 18px;
  display:grid; place-items:center; text-align:center;
  background: radial-gradient(circle at 35% 25%, rgba(22,143,135,.24), rgba(73,127,209,.08));
  border:1px solid rgba(22,143,135,.24);
}
.level-badge strong { display:block; font-size:24px; }
.level-badge span { font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.08em; }
.profile-center { text-align:center; }

.empty-state { text-align:center; padding:34px 18px; color:var(--muted); }
.error-box { margin:40px 18px; padding:20px; border:1px solid rgba(214,83,104,.25); border-radius:18px; background:rgba(214,83,104,.07); }

.toast {
  position:fixed; left:50%; transform:translateX(-50%); top:18px; z-index:100;
  background:#172534; color:#ffffff; padding:12px 16px; border-radius:14px; font-weight:800;
  box-shadow:var(--shadow); animation:toastIn .2s ease;
}
@keyframes toastIn { from { opacity:0; transform:translate(-50%,-8px); } }

@media (min-width: 680px) {
  .page { padding-left:28px; padding-right:28px; }
  .trail-grid { grid-template-columns: repeat(2,1fr); }
  .home-trail-grid { grid-template-columns: repeat(2,1fr); }
  .trail-grid .card:first-child { grid-column: 1 / -1; }
  .lesson-step-card { min-height: 390px; padding:26px; }
}

@media (max-width: 420px) {
  .brand-kicker { font-size: 9.5px; letter-spacing: .055em; }
  .brand-name { font-size: 14px; }
  .brand-tagline { display: none; }
  .version-chip { padding: 6px 8px; }
}


.module-stack { display:grid; gap:14px; }
.module-block { padding-top:20px; }
.module-kicker { color:var(--accent); font-size:11px; font-weight:900; letter-spacing:.08em; text-transform:uppercase; margin-bottom:5px; }
.module-title { font-size:20px; margin-bottom:6px; }
.module-block .lesson-list { margin-top:12px; }
.checkpoint-item { margin:7px -8px 0; padding-left:8px; padding-right:8px; border-radius:14px; background:rgba(197,138,25,.055); }
.checkpoint-item .lesson-name { color:#715514; }
.checkpoint-item.current .lesson-status { background:var(--warning); }
.deep-dive { margin-top:18px; border:1px solid var(--line); border-radius:16px; background:rgba(255,255,255,.55); overflow:hidden; }
.deep-dive summary { cursor:pointer; list-style:none; padding:14px 16px; color:var(--accent); font-size:12px; font-weight:900; letter-spacing:.045em; }
.deep-dive summary::-webkit-details-marker { display:none; }
.deep-dive summary::after { content:'＋'; float:right; color:var(--muted); }
.deep-dive[open] summary::after { content:'−'; }
.deep-dive-content { border-top:1px solid var(--line); padding:5px 16px 14px; }
.deep-block { padding:13px 0; border-bottom:1px solid rgba(93,119,138,.12); }
.deep-block:last-child { border-bottom:0; }
.deep-block strong { display:block; color:var(--text); margin-bottom:5px; }
.deep-block p { margin:0; color:#30475a; line-height:1.68; font-size:14px; white-space:pre-line; }
.context-callout { margin-top:14px; padding:14px 16px; border-radius:15px; border:1px solid rgba(22,143,135,.22); background:rgba(22,143,135,.055); }
.context-label { font-size:12px; font-weight:900; color:var(--accent); margin-bottom:5px; }
.context-callout p { margin:0; color:#30475a; line-height:1.62; font-size:14px; }

.math-formula {
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}
.math-formula math {
  display:inline-block;
  max-width:100%;
  font-family:"Cambria Math","STIX Two Math","Times New Roman",serif;
  font-size:clamp(24px, 6.7vw, 38px);
  font-weight:500;
  line-height:1.35;
}
.math-formula mtext { font-family:inherit; }
@media (max-width:420px) {
  .math-formula { padding-left:10px; padding-right:10px; }
  .math-formula math { font-size:clamp(20px, 5.9vw, 30px); }
}

/* V6 — estrutura multitrilhas */
.trail-group { display:grid; gap:14px; margin-top:18px; }
.trail-group + .trail-group { margin-top:32px; }
.group-header {
  padding: 4px 3px 0;
  border-top: 1px solid rgba(38,69,91,.11);
  padding-top: 22px;
}
.group-header h2 { margin-bottom:7px; font-size:24px; }
.trail-switcher { margin-top:18px; }
.trail-switcher-label { color:var(--muted); font-size:11px; font-weight:800; text-transform:uppercase; letter-spacing:.08em; margin-bottom:8px; }
.trail-switcher-row { display:flex; gap:8px; overflow-x:auto; padding-bottom:4px; scrollbar-width:thin; }
.trail-switch { white-space:nowrap; cursor:pointer; }
.trail-switch.active { color:var(--accent); border-color:rgba(22,143,135,.35); background:rgba(22,143,135,.08); }
.answer-math { margin-top:14px; margin-bottom:0; }
@media (min-width:680px) {
  .trail-grid { grid-template-columns: repeat(2,1fr); }
  .home-trail-grid { grid-template-columns: repeat(2,1fr); }
  .trail-grid .card:first-child { grid-column:auto; }
}


/* V6.5.1 — referências bibliográficas das trilhas */
.trail-card-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
}
.trail-card-head .trail-icon { margin-bottom:0; flex:0 0 auto; }
.reference-btn {
  min-height:36px;
  padding:8px 13px;
  border-radius:12px;
  border:1px solid rgba(22,143,135,.24);
  background:rgba(22,143,135,.075);
  color:#0b716c;
  font-size:12px;
  font-weight:850;
  line-height:1;
  letter-spacing:.01em;
  box-shadow:0 5px 14px rgba(50,72,89,.07);
  transition:background .16s ease, border-color .16s ease, transform .16s ease;
  position:relative;
  z-index:2;
}
.reference-btn:hover { background:rgba(22,143,135,.12); border-color:rgba(22,143,135,.38); }
.reference-btn:active { transform:scale(.98); }
.reference-btn:focus-visible { outline:3px solid rgba(73,127,209,.24); outline-offset:2px; }
body.modal-open { overflow:hidden; }
.references-overlay {
  position:fixed;
  inset:0;
  z-index:1000;
  display:grid;
  place-items:center;
  padding:20px;
  background:rgba(15,31,45,.48);
  backdrop-filter:blur(5px);
  -webkit-backdrop-filter:blur(5px);
  animation:referencesFade .16s ease;
}
.references-modal {
  width:min(100%, 700px);
  max-height:min(82vh, 760px);
  overflow:auto;
  border-radius:22px;
  border:1px solid rgba(38,69,91,.15);
  background:linear-gradient(180deg, #fbfdfe, #f3f8fa);
  box-shadow:0 28px 70px rgba(15,31,45,.25);
  padding:22px;
  color:var(--text);
  animation:referencesRise .18s ease;
}
.references-modal-head {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:18px;
  padding-bottom:14px;
  border-bottom:1px solid var(--line);
}
.references-modal-head h2 { margin:0; font-size:clamp(20px, 5vw, 27px); line-height:1.18; }
.references-close {
  width:38px;
  height:38px;
  flex:0 0 38px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.78);
  color:var(--muted);
  font-size:27px;
  line-height:1;
  display:grid;
  place-items:center;
}
.references-close:hover { color:var(--text); background:#fff; }
.references-close:focus-visible { outline:3px solid rgba(73,127,209,.24); outline-offset:2px; }
.references-intro { margin:16px 0 0; color:var(--muted); line-height:1.6; font-size:14px; }
.references-list { margin:16px 0 0; padding-left:24px; }
.references-list li { padding:0 0 14px 4px; color:#263d4f; line-height:1.62; font-size:14px; }
.references-list li + li { padding-top:14px; border-top:1px solid rgba(38,69,91,.09); }
.reference-authors { font-weight:760; color:var(--text); }
.reference-title { color:var(--text); }
@keyframes referencesFade { from { opacity:0; } }
@keyframes referencesRise { from { opacity:0; transform:translateY(8px) scale(.99); } }
@media (max-width:520px) {
  .references-overlay { padding:12px; align-items:end; }
  .references-modal { width:100%; max-height:88vh; border-radius:22px 22px 16px 16px; padding:18px; }
  .references-list { padding-left:21px; }
  .reference-btn { min-height:34px; padding:7px 11px; }
}
