/* =========================================================================
   Wtech EduVerse — design system
   Tema escuro principal (azul-marinho profundo, roxo, azul elétrico, ciano)
   ========================================================================= */

:root {
  --bg-0: #050816;
  --bg-1: #0a1028;
  --bg-2: #0f1838;
  --surface: rgba(20, 30, 70, 0.55);
  --surface-strong: rgba(24, 36, 84, 0.85);
  --surface-hover: rgba(36, 52, 112, 0.6);
  --border: rgba(130, 150, 255, 0.14);
  --border-strong: rgba(140, 160, 255, 0.28);

  --text: #e8ecff;
  --text-muted: #9aa5d1;
  --text-faint: #7f8bbb;

  --violet: #8b5cf6;
  --violet-soft: #a78bfa;
  --blue: #3b82f6;
  --electric: #4f7cff;
  --cyan: #22d3ee;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;

  --grad-brand: linear-gradient(135deg, #8b5cf6 0%, #4f7cff 55%, #22d3ee 100%);
  --grad-soft: linear-gradient(135deg, rgba(139, 92, 246, .18), rgba(34, 211, 238, .10));

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .55);
  --shadow-glow: 0 0 0 1px rgba(139, 92, 246, .25), 0 10px 40px -10px rgba(79, 124, 255, .35);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", var(--font);
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --sidebar-w: 248px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(139, 92, 246, .18), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(79, 124, 255, .12), transparent 60%),
    radial-gradient(700px 400px at 50% 110%, rgba(34, 211, 238, .08), transparent 60%),
    var(--bg-0);
  background-attachment: fixed;
}
body::before { /* campo de estrelas sutil */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff8, transparent),
    radial-gradient(1px 1px at 70% 80%, #fff6, transparent),
    radial-gradient(1.5px 1.5px at 40% 70%, #c4b5fd88, transparent),
    radial-gradient(1px 1px at 90% 20%, #67e8f988, transparent),
    radial-gradient(1px 1px at 10% 85%, #fff5, transparent),
    radial-gradient(1px 1px at 55% 15%, #fff6, transparent);
  background-size: 600px 600px;
}
body > * { position: relative; z-index: 1; }

a { color: var(--violet-soft); text-decoration: none; }
a:hover { color: var(--cyan); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
::selection { background: rgba(139, 92, 246, .45); }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface-strong); padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

.gradient-text { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: .85rem; }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* minmax(0, 1fr): com "1fr" puro a coluna cresce até o maior conteúdo sem quebra e passa da largura da tela. */
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } .span-2 { grid-column: auto; } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  transition: border-color .25s var(--ease), transform .25s var(--ease), background .25s var(--ease);
}
.card.interactive:hover { border-color: var(--border-strong); transform: translateY(-2px); background: var(--surface-hover); }
.card.glow { box-shadow: var(--shadow-glow); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.card-title h2, .card-title h3 { margin: 0; font-size: 1rem; }
.card-title .icon { color: var(--violet-soft); }
.access-request-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.access-request { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.access-request-info { flex: 1 1 auto; min-width: min(16rem, 100%); overflow-wrap: anywhere; }
.access-request-info h2 { font-size: 1.05rem; margin: 0; }
.access-request-info p { margin: 6px 0 0; }
/* Encolhe e quebra em linhas antes de espremer os dados da conta. */
.access-request-actions { flex: 0 1 auto; justify-content: flex-end; }
@media (max-width: 900px) {
  .access-request { flex-direction: column; align-items: stretch; }
  .access-request-actions .btn { flex: 1; }
}
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 600; color: var(--cyan); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 .92rem var(--font); color: var(--text);
  padding: 10px 18px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, .04); cursor: pointer; text-decoration: none;
  transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s, opacity .2s;
  min-height: 42px; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad-brand); border-color: transparent; color: #fff; box-shadow: 0 8px 24px -10px rgba(139, 92, 246, .8); }
.btn-primary:hover { filter: brightness(1.08); color: #fff; background: var(--grad-brand); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { border-color: rgba(248, 113, 113, .4); color: #fecaca; }
.btn-danger:hover { background: rgba(248, 113, 113, .12); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: .84rem; border-radius: 10px; }
.btn-lg { padding: 14px 24px; font-size: 1rem; min-height: 52px; border-radius: 14px; }
.btn-icon { padding: 8px; min-width: 40px; }

/* ---------- Formulários ---------- */
label { font-weight: 500; font-size: .9rem; color: var(--text-muted); display: block; margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; font: inherit; color: var(--text);
  background: rgba(5, 8, 22, .55); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 11px 14px; transition: border-color .2s, box-shadow .2s;
}
.input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139, 92, 246, .25); }
textarea.input { resize: vertical; min-height: 90px; }
.field { margin-bottom: 16px; }
.help { font-size: .82rem; color: var(--text-faint); margin-top: 4px; }

.ask-box {
  display: flex; gap: 10px; align-items: flex-end; padding: 10px;
  background: rgba(5, 8, 22, .6); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glow); transition: border-color .2s;
}
.ask-box:focus-within { border-color: var(--violet); }
.ask-box textarea { flex: 1; background: transparent; border: 0; color: var(--text); font: 500 1.05rem var(--font); resize: none; padding: 10px; min-height: 52px; max-height: 200px; }
.ask-box textarea:focus { outline: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: .82rem; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: rgba(255, 255, 255, .03); color: var(--text-muted);
  transition: all .2s var(--ease); font-family: inherit;
}
.chip:hover, .chip[aria-pressed="true"] { border-color: var(--violet); color: var(--text); background: rgba(139, 92, 246, .15); }

.segmented { display: inline-flex; padding: 4px; border-radius: 12px; background: rgba(5, 8, 22, .6); border: 1px solid var(--border); flex-wrap: wrap; }
.segmented button { font: 500 .88rem var(--font); color: var(--text-muted); background: transparent; border: 0; padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--grad-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }

input[type="range"] { width: 100%; accent-color: var(--violet); }

/* ---------- Badges e progresso ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted); background: rgba(255, 255, 255, .03); }
.badge.green { color: var(--green); border-color: rgba(52, 211, 153, .35); background: rgba(52, 211, 153, .08); }
.badge.violet { color: var(--violet-soft); border-color: rgba(167, 139, 250, .35); background: rgba(139, 92, 246, .1); }
.badge.cyan { color: var(--cyan); border-color: rgba(34, 211, 238, .35); background: rgba(34, 211, 238, .08); }
.badge.amber { color: var(--amber); border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); }
.badge.red { color: var(--red); border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .08); }

.progress { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--grad-brand); transition: width .8s var(--ease); }
.progress.thin { height: 5px; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .value { font: 700 1.7rem var(--font-display); }
.stat .label { font-size: .8rem; color: var(--text-muted); }

/* ---------- Shell da aplicação ---------- */
/* z-index: auto — o shell não pode criar contexto de empilhamento, senão o menu lateral e o painel do tutor
   (que ficam dentro dele) abrem por baixo da camada escura e das barras fixas do celular. */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; z-index: auto; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px; display: flex; flex-direction: column; gap: 6px;
  background: rgba(5, 8, 22, .7); border-right: 1px solid var(--border); backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font: 700 1.08rem var(--font-display); color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--grad-brand); display: grid; place-items: center; box-shadow: 0 0 24px -4px rgba(139, 92, 246, .8); flex: none; }
.brand small { display: block; font: 500 .7rem var(--font); color: var(--text-faint); letter-spacing: .08em; text-transform: uppercase; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--text-muted); font-weight: 500; transition: all .2s var(--ease); }
.nav-link svg { width: 20px; height: 20px; flex: none; }
.nav-link:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--grad-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.nav-link[aria-current="page"] svg { color: var(--cyan); }
.nav-sep { margin: 12px 12px 4px; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, .03); border: 1px solid var(--border); }
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; background: var(--grad-soft); border: 1px solid var(--border-strong); flex: none; }
.user-chip .name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .meta { font-size: .75rem; color: var(--text-muted); }

.main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header p { margin: 0; }
.banner { padding: 10px 14px; border-radius: 12px; font-size: .86rem; border: 1px solid rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); color: #fde68a; margin-bottom: 18px; }
.banner.info { border-color: rgba(34, 211, 238, .3); background: rgba(34, 211, 238, .07); color: #a5f3fc; }

.mobile-top { display: none; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); z-index: 50; transform: translateX(-105%);
    transition: transform .3s var(--ease);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 30px 0 60px rgba(0, 0, 0, .6); }
  .mobile-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; position: sticky; top: 0; z-index: 40; background: rgba(5, 8, 22, .85); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
  .main { padding-top: 18px; }
}

/* ---------- Landing ---------- */
.public-nav { display: flex; justify-content: space-between; align-items: center; padding: 18px clamp(16px, 4vw, 56px); }
.hero { position: relative; text-align: center; padding: clamp(48px, 10vw, 120px) 20px 60px; max-width: 980px; margin: 0 auto; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 4.2rem); line-height: 1.05; margin-bottom: 18px; }
.hero .lead { font-size: clamp(1rem, 2vw, 1.2rem); color: var(--text-muted); max-width: 680px; margin: 0 auto 32px; }
.hero .ask-box { max-width: 720px; margin: 0 auto 18px; text-align: left; }
#starfield { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: .9; pointer-events: none; }
.section { max-width: 1140px; margin: 0 auto; padding: 50px 20px; }
.feature .icon-wrap { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--grad-soft); border: 1px solid var(--border-strong); margin-bottom: 14px; color: var(--cyan); }
.steps { counter-reset: step; }
.steps .card::before { counter-increment: step; content: counter(step); font: 700 .85rem var(--font-display); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-brand); margin-bottom: 12px; }
.footer { text-align: center; padding: 40px 20px; color: var(--text-faint); font-size: .85rem; border-top: 1px solid var(--border); margin-top: 40px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-faint); font-size: .8rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Trilhas ---------- */
.module { border: 1px solid var(--border); border-radius: var(--radius); background: rgba(10, 16, 40, .5); overflow: hidden; }
.module + .module { margin-top: 12px; }
.module-head { display: flex; align-items: center; gap: 14px; padding: 16px 18px; cursor: pointer; width: 100%; background: transparent; border: 0; color: inherit; font: inherit; text-align: left; }
.module-head:hover { background: rgba(255, 255, 255, .03); }
.module-index { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font: 700 .95rem var(--font-display); background: var(--grad-soft); border: 1px solid var(--border-strong); flex: none; }
.module.completed .module-index { background: rgba(52, 211, 153, .15); border-color: rgba(52, 211, 153, .4); color: var(--green); }
.module.locked { opacity: .65; }
.module-body { padding: 0 18px 16px; }
.lesson-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--text); }
.lesson-row:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.lesson-row .status-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; font-size: .7rem; flex: none; }
.lesson-row.completed .status-dot { background: var(--green); border-color: var(--green); color: #052e1f; }
.lesson-row.in_progress .status-dot { border-color: var(--cyan); box-shadow: 0 0 10px rgba(34, 211, 238, .6); }
.lesson-row.locked { pointer-events: none; opacity: .55; }
.lesson-row .title { flex: 1; min-width: 0; }
.lesson-row .title small { display: block; color: var(--text-faint); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { transition: transform .25s var(--ease); }
.module[data-open="true"] .chev { transform: rotate(180deg); }
ul.clean { list-style: none; padding: 0; margin: 0; }
ul.ticks { padding-left: 0; list-style: none; margin: 0; }
ul.ticks li { padding-left: 24px; position: relative; margin-bottom: 6px; color: var(--text-muted); }
ul.ticks li::before { content: "✦"; position: absolute; left: 2px; color: var(--violet-soft); font-size: .8rem; top: 2px; }

/* ---------- Aula ---------- */
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
.lesson-aside { position: sticky; top: 20px; height: calc(100vh - 40px); display: flex; flex-direction: column; }

.prose { font-size: 1.02rem; line-height: 1.75; color: #dfe4fb; }
.prose h1, .prose h2, .prose h3 { margin-top: 1.6em; }
.prose h2 { font-size: 1.35rem; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.prose code { font-family: var(--font-mono); font-size: .88em; background: rgba(139, 92, 246, .14); padding: 2px 6px; border-radius: 6px; }
.prose pre { background: #060a1c; border: 1px solid var(--border); border-radius: 12px; padding: 16px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; font-size: .86rem; }
.prose blockquote { margin: 1em 0; padding: 10px 16px; border-left: 3px solid var(--violet); background: rgba(139, 92, 246, .08); border-radius: 0 10px 10px 0; color: var(--text-muted); }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 10px; }
.prose a { text-decoration: underline; }
.prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.prose > :first-child { margin-top: 0; }

.exercise { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; background: rgba(10, 16, 40, .5); }
.exercise + .exercise { margin-top: 14px; }
.exercise.correct { border-color: rgba(52, 211, 153, .45); }
.exercise.incorrect { border-color: rgba(248, 113, 113, .4); }
.option { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; padding: 12px 14px; margin-top: 8px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255, 255, 255, .02); color: var(--text); font: inherit; cursor: pointer; transition: all .2s var(--ease); }
.option:hover:not(:disabled) { border-color: var(--violet); background: rgba(139, 92, 246, .08); }
.option[aria-pressed="true"] { border-color: var(--violet); background: rgba(139, 92, 246, .16); }
.option.is-correct { border-color: var(--green); background: rgba(52, 211, 153, .1); }
.option.is-wrong { border-color: var(--red); background: rgba(248, 113, 113, .08); }
.option:disabled { cursor: default; }
.option .letter { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: .8rem; background: rgba(255, 255, 255, .06); flex: none; }
.option .prose { font-size: .95rem; }
.option .prose p { margin: 0; }
.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, .03); border: 1px solid var(--border); font-size: .93rem; }
.feedback.ok { border-color: rgba(52, 211, 153, .35); }
.feedback.bad { border-color: rgba(248, 113, 113, .35); }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; backdrop-filter: blur(14px); }
.chat-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.chat-head select { width: auto; padding: 6px 10px; font-size: .85rem; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: 16px; font-size: .94rem; line-height: 1.6; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(139, 92, 246, .45), rgba(79, 124, 255, .4)); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: rgba(5, 8, 22, .55); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.assistant .prose { font-size: .94rem; line-height: 1.65; }
.msg.assistant .prose p:last-child { margin-bottom: 0; }
.msg.error { align-self: center; color: #fecaca; background: rgba(248, 113, 113, .1); border: 1px solid rgba(248, 113, 113, .35); font-size: .85rem; }
.chat-input { border-top: 1px solid var(--border); padding: 10px; display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { flex: 1; min-height: 44px; max-height: 160px; resize: none; }
.chat-empty { margin: auto; text-align: center; color: var(--text-muted); padding: 20px; }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--violet-soft); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-note { font-size: .74rem; color: var(--text-faint); padding: 0 14px 10px; }

.tutor-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 20px; height: calc(100vh - 150px); min-height: 520px; }
.conv-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.conv-item { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer; font: inherit; }
.conv-item:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.conv-item[aria-current="true"] { background: var(--grad-soft); border-color: var(--border-strong); color: var(--text); }
.conv-item .t { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
@media (max-width: 900px) { .tutor-layout { grid-template-columns: 1fr; height: auto; } .tutor-layout .chat { height: 70vh; } .conv-panel { max-height: 240px; } }

/* ---------- Estados ---------- */
.skeleton { background: linear-gradient(90deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .09), rgba(255, 255, 255, .04)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; min-height: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; padding: 30px 16px; color: var(--text-muted); }
.empty .big { font-size: 2.2rem; margin-bottom: 8px; }
.loader-orbit { width: 64px; height: 64px; border-radius: 50%; position: relative; margin: 0 auto 18px; border: 2px solid rgba(139, 92, 246, .25); }
.loader-orbit::before, .loader-orbit::after { content: ""; position: absolute; border-radius: 50%; }
.loader-orbit::before { inset: 22px; background: var(--grad-brand); box-shadow: 0 0 20px rgba(139, 92, 246, .8); }
.loader-orbit::after { width: 10px; height: 10px; background: var(--cyan); top: -5px; left: 27px; transform-origin: 5px 37px; animation: orbit 1.4s linear infinite; box-shadow: 0 0 12px var(--cyan); }
@keyframes orbit { to { transform: rotate(360deg); } }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface-strong); border: 1px solid var(--border-strong); box-shadow: var(--shadow); animation: toast-in .3s var(--ease); font-size: .92rem; }
.toast.success { border-color: rgba(52, 211, 153, .5); }
.toast.error { border-color: rgba(248, 113, 113, .5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.fade-in { animation: fade-in .45s var(--ease) both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } }

.wizard-step { max-width: 760px; margin: 0 auto; }
.question { margin-bottom: 18px; }
.question .q { font-weight: 600; margin-bottom: 6px; }

.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 4px; overflow-x: auto; padding-bottom: 6px; }
.heatmap span { width: 14px; height: 14px; border-radius: 4px; background: rgba(255, 255, 255, .05); }
.heatmap span[data-l="1"], .heat-legend span[data-l="1"] { background: rgba(139, 92, 246, .35); }
.heatmap span[data-l="2"], .heat-legend span[data-l="2"] { background: rgba(139, 92, 246, .6); }
.heatmap span[data-l="3"], .heat-legend span[data-l="3"] { background: rgba(79, 124, 255, .85); }
.heatmap span[data-l="4"], .heat-legend span[data-l="4"] { background: var(--cyan); }

table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.data td { padding: 10px; border-bottom: 1px solid rgba(255, 255, 255, .04); vertical-align: middle; }
.table-wrap { overflow-x: auto; }

dialog { background: var(--surface-strong); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 22px; max-width: min(460px, 92vw); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(2, 4, 12, .7); backdrop-filter: blur(4px); }

/* =========================================================================
   Refinamentos de interface
   ========================================================================= */
h1, h2, h3 { text-wrap: balance; }
.stat .value, table.data td, .badge, .tnum { font-variant-numeric: tabular-nums; }
* { scrollbar-width: thin; scrollbar-color: rgba(140, 160, 255, .28) transparent; }
table.data tbody tr:hover td { background: rgba(255, 255, 255, .025); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 28px -10px rgba(139, 92, 246, .9); }
.btn-block { width: 100%; }
.scrim { position: fixed; inset: 0; background: rgba(2, 4, 12, .6); z-index: 45; animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-width: 0; max-width: 100%; }
/* Botão com texto longo (ex.: título da aula): encurta com reticências em vez de estourar o cartão. */
.btn-clip { max-width: 100%; min-width: 0; }
.btn-clip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.stat .hint-ok { color: var(--green); }

/* ---------- Barra de ambiente (avisos de desenvolvimento, recolhida) ---------- */
.sysbar { margin-bottom: 18px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, .025); font-size: .82rem; color: var(--text-muted); }
.sysbar summary { cursor: pointer; padding: 8px 12px; list-style: none; display: flex; align-items: center; gap: 8px; border-radius: 12px; }
.sysbar summary::-webkit-details-marker { display: none; }
.sysbar summary::after { content: "Detalhes"; margin-left: auto; color: var(--text-faint); font-size: .76rem; }
.sysbar[open] summary::after { content: "Ocultar"; }
.sysbar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px rgba(251, 191, 36, .7); flex: none; }
.sysbar ul { margin: 0; padding: 0 12px 10px 32px; }
.sysbar li { margin-top: 4px; }

/* ---------- Usuário na barra lateral ---------- */
.user-chip .progress { margin-top: 6px; }

/* ---------- Navegação inferior (celular) ---------- */
.bottom-nav { display: none; }
@media (max-width: 900px) {
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 40;
    background: rgba(5, 8, 22, .92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 48px; padding: 4px 2px; border-radius: 10px; font-size: .68rem; font-weight: 600; color: var(--text-faint); }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a[aria-current="page"] { color: var(--text); }
  .bottom-nav a[aria-current="page"] svg { color: var(--cyan); }
  .main { padding-bottom: 96px; }
  .toast-host { bottom: 84px; right: 12px; left: 12px; max-width: none; }
}

/* ---------- Avisos (toasts) ---------- */
.toast-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .74rem; font-weight: 700; flex: none; background: rgba(79, 124, 255, .25); color: #c7d2fe; }
.toast.success .toast-icon { background: rgba(52, 211, 153, .2); color: var(--green); }
.toast.error .toast-icon { background: rgba(248, 113, 113, .2); color: var(--red); }
.toast-msg { flex: 1; min-width: 0; }
.toast-close { background: none; border: 0; color: var(--text-faint); cursor: pointer; font-size: 1.15rem; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.toast-close:hover { color: var(--text); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }

/* ---------- Diálogos ---------- */
dialog { position: fixed; inset: 0; margin: auto; }
dialog[open] { animation: modal-in .22s var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
dialog.modal { padding: 0; width: min(460px, 92vw); }
.modal-body { padding: 22px; }
.modal-title { font-size: 1.15rem; margin-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Passos do assistente ---------- */
.stepper { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 22px; }
.stepper li { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: .78rem; font-weight: 600; color: var(--text-faint); }
.stepper li::before { content: ""; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .08); }
.stepper li.done { color: var(--text-muted); }
.stepper li.done::before { background: var(--violet); }
.stepper li.current { color: var(--text); }
.stepper li.current::before { background: var(--grad-brand); }
.answered { display: flex; align-items: center; gap: 10px; font-size: .84rem; color: var(--text-muted); }
.answered .progress { flex: 1; max-width: 220px; }
.load-progress { max-width: 260px; margin: 14px auto 6px; }
.load-progress > span { transition: width 1s linear; }

/* ---------- Trilha ---------- */
.module-head .progress { margin-top: 6px; max-width: 220px; }

/* ---------- Aula: progresso de leitura, exercícios e tutor em painel ---------- */
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 70; pointer-events: none; }
.read-progress span { display: block; height: 100%; width: 0; background: var(--grad-brand); }
.ex-tracker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ex-dots { display: flex; gap: 6px; }
.ex-dots span { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, .08); border: 1px solid var(--border-strong); }
.ex-dots span.ok { background: var(--green); border-color: var(--green); }
.ex-dots span.bad { background: var(--red); border-color: var(--red); }
.ex-dots span.try { background: var(--amber); border-color: var(--amber); }
.celebrate { text-align: center; }
.celebrate .big { font-size: 2.6rem; line-height: 1; margin-bottom: 8px; animation: pop .5s var(--ease) both; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.15); } }
.celebrate .actions { justify-content: center; margin-top: 14px; }
.tutor-fab { display: none; }
.chat-close { display: none; }
@media (max-width: 1200px) {
  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-aside {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); height: auto; z-index: 60; padding: 10px;
    background: var(--bg-1); border-left: 1px solid var(--border-strong); box-shadow: -30px 0 60px rgba(0, 0, 0, .55);
    transform: translateX(105%); visibility: hidden; transition: transform .3s var(--ease), visibility .3s;
  }
  .lesson-aside.open { transform: none; visibility: visible; }
  .tutor-fab { display: inline-flex; position: fixed; right: 20px; bottom: 20px; z-index: 44; border-radius: 999px; padding: 12px 20px; }
  .chat-close { display: inline-flex; }
  #lesson-main { padding-bottom: 64px; }
}
@media (max-width: 900px) { .tutor-fab { right: 14px; bottom: 84px; } }

/* ---------- Chat ---------- */
.chat-input .btn { min-width: 44px; padding: 10px; }
.chat-input .btn svg { width: 18px; height: 18px; }
.chat-jump { position: absolute; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 2; box-shadow: var(--shadow); background: var(--surface-strong); }
.chat { position: relative; }

/* ---------- Progresso ---------- */
.heat-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; font-size: .74rem; color: var(--text-faint); margin-top: 6px; }
.heat-legend span { width: 12px; height: 12px; border-radius: 3px; background: rgba(255, 255, 255, .05); }

/* ---------- Login ---------- */
.segmented.block { display: flex; }
.segmented.block button { flex: 1; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 92px; }
.input-wrap .peek { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 30px; padding: 4px 10px; }
.field-error { color: #fecaca; font-size: .82rem; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Explicar com desenhos ---------- */
.draw-form { max-width: 820px; }
.draw-history { margin-top: 12px; }
.draw-item { display: flex; flex-direction: column; gap: 6px; color: var(--text); text-decoration: none; padding: 12px; transition: border-color .2s var(--ease); }
.draw-item:hover { border-color: var(--violet); }
.draw-thumb { aspect-ratio: 3 / 2; border-radius: 12px; overflow: hidden; display: grid; place-items: center; font-size: 2rem; background: var(--grad-soft); margin-bottom: 4px; }
.draw-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-badge { display: inline-flex; gap: 6px; align-items: center; color: var(--text-muted); margin: -8px 0 18px; }
.panels { list-style: none; padding: 0; margin: 0; display: grid; gap: 22px; }
.panel { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 22px; align-items: center; padding: 18px; }
.panel:nth-child(even) .panel-figure { order: 2; }
.panel-figure { margin: 0; aspect-ratio: 3 / 2; border-radius: 14px; overflow: hidden; background: rgba(255, 255, 255, .03); border: 1px solid var(--border); display: grid; place-items: center; }
.panel-figure.diagram.ready { background: #f8fafc; }
.panel-figure img { width: 100%; height: 100%; object-fit: contain; display: block; animation: fade-in .5s var(--ease); }
.panel-figure.illustration img { object-fit: cover; }
.panel-loading { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px; text-align: center; }
.panel-loading.failed span[aria-hidden] { font-size: 1.8rem; }
.panel-body h2 { font-size: 1.15rem; display: flex; gap: 10px; align-items: center; margin-top: 0; }
.panel-num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: .9rem; font-weight: 700; background: var(--grad-soft); border: 1px solid var(--border-strong); }
.takeaways { margin: 8px 0 0; padding-left: 20px; }
.takeaways li { margin: 6px 0; }

/* Modo crianças: letras maiores, cantos mais redondos, cores mais vivas. */
.storyboard.kids .panel { border-radius: 26px; border-width: 2px; }
.storyboard.kids .panel:nth-child(3n+1) { border-color: rgba(251, 191, 36, .45); }
.storyboard.kids .panel:nth-child(3n+2) { border-color: rgba(52, 211, 153, .45); }
.storyboard.kids .panel:nth-child(3n) { border-color: rgba(34, 211, 238, .45); }
.storyboard.kids .panel-figure { border-radius: 20px; }
.storyboard.kids .panel-body .prose { font-size: 1.12rem; line-height: 1.7; }
.storyboard.kids .panel-body h2 { font-size: 1.3rem; }
.storyboard.kids .panel-num { background: linear-gradient(135deg, #fbbf24, #f472b6); color: #1e1b4b; border: 0; }

@media (max-width: 820px) {
  .panel { grid-template-columns: 1fr; padding: 14px; }
  .panel:nth-child(even) .panel-figure { order: 0; }
}
.ai-badge .library-chip { margin-left: 8px; padding: 2px 10px; font-size: .78rem; cursor: help; }
