:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e6ef;
  --text: #1c2033;
  --muted: #667085;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef0ff;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --warn: #d97706;
  --warn-soft: #fff5e5;
  --gold: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --A1: #10b981; --A2: #06b6d4; --B1: #6366f1; --B2: #a855f7; --C1: #f43f5e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1220;
    --surface: #171b2e;
    --surface-2: #1f2440;
    --border: #2a3052;
    --text: #e8eaf6;
    --muted: #9aa3c0;
    --primary: #818cf8;
    --primary-2: #a5b4fc;
    --primary-soft: #23284a;
    --ok-soft: #12301f;
    --bad-soft: #3a1717;
    --warn-soft: #3a2a10;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.08rem; font-weight: 700; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* Layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; padding: 4px 10px 18px; color: var(--text); }
.brand img { width: 32px; height: 32px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: .95rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav .ico { width: 22px; text-align: center; }
.sidebar .spacer { flex: 1; }
.side-user { padding: 12px; border-top: 1px solid var(--border); font-size: .875rem; }
main.content { padding: 28px clamp(16px, 4vw, 44px) 100px; max-width: 1100px; width: 100%; }
.topstats { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 18px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 700; font-size: .875rem;
}
.mobile-nav { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; font-size: .7rem; color: var(--muted); font-weight: 600; padding: 4px; }
  .mobile-nav a .ico { font-size: 1.25rem; }
  .mobile-nav a.active { color: var(--primary); }
  main.content { padding-top: 16px; }
  .topstats { justify-content: flex-start; }
}

/* Cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.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)); }
@media (max-width: 960px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-title h2 { margin: 0; }

/* Buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 700;
  background: var(--primary); color: #fff; transition: transform .05s, filter .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.ok { background: var(--ok); }
.btn.bad { background: var(--bad); }
.btn.warn { background: var(--warn); }
.btn.sm { padding: 6px 12px; font-size: .85rem; }
.btn.lg { padding: 14px 24px; font-size: 1.05rem; }
.btn.block { width: 100%; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--border); border-radius: 50%; width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem; display: inline-flex; align-items: center; justify-content: center; color: var(--text); }
.icon-btn:hover { background: var(--primary-soft); }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 14px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { min-height: 160px; resize: vertical; }
.field { margin-bottom: 14px; }
.error-msg { color: var(--bad); font-size: .9rem; min-height: 1.2em; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background: linear-gradient(135deg, #4f46e5, #7c3aed 60%, #db2777); color: #fff; padding: 56px clamp(24px, 5vw, 72px);
  display: flex; flex-direction: column; justify-content: center;
}
.auth-hero h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
.auth-hero ul { list-style: none; padding: 0; margin: 24px 0 0; }
.auth-hero li { padding: 8px 0; font-size: 1.05rem; opacity: .95; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-form .card { width: 100%; max-width: 420px; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { padding: 32px 20px; } .auth-hero ul { display: none; } }

/* Progress & stats */
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 999px; transition: width .4s; }
.bar.ok span { background: var(--ok); }
.bar.gold span { background: var(--gold); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .num { font-size: 1.6rem; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: .85rem; font-weight: 600; }
.hero-card { background: linear-gradient(135deg, var(--primary), #7c3aed); color: #fff; border: none; }
.hero-card .muted { color: rgba(255,255,255,.8); }
.hero-card .bar { background: rgba(255,255,255,.25); }
.hero-card .bar span { background: #fff; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; color: #fff; background: var(--primary); letter-spacing: .02em; }
.badge.A1 { background: var(--A1); } .badge.A2 { background: var(--A2); } .badge.B1 { background: var(--B1); } .badge.B2 { background: var(--B2); } .badge.C1 { background: var(--C1); }
.badge.soft { background: var(--surface-2); color: var(--muted); }

/* Tasks */
.task { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
.task + .task { margin-top: 10px; }
.task:hover { border-color: var(--primary); }
.task .t-ico { font-size: 1.5rem; width: 44px; height: 44px; display: grid; place-items: center; background: var(--surface-2); border-radius: 12px; flex: none; }
.task .t-body { flex: 1; min-width: 0; }
.task .t-title { font-weight: 700; }
.task .check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; flex: none; }
.task.done { background: var(--ok-soft); border-color: transparent; }
.task.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.task.done .t-title { text-decoration: line-through; opacity: .7; }

/* Heatmap */
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heatmap i { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-2); display: block; }
.heatmap i.l1 { background: #c7d2fe; } .heatmap i.l2 { background: #818cf8; } .heatmap i.l3 { background: #4f46e5; } .heatmap i.l4 { background: #312e81; }

/* Path (trilha) */
.level-block { margin-bottom: 26px; }
.level-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.week { padding: 16px; }
.week-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day {
  aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; font-size: 1.15rem; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted); position: relative; cursor: default;
}
.day.done { background: var(--ok-soft); border-color: var(--ok); }
.day.current { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); cursor: pointer; }
.day.open { cursor: pointer; }
.day.locked { opacity: .45; }
.day .sc { position: absolute; bottom: 1px; right: 4px; font-size: .6rem; font-weight: 700; color: var(--ok); }

/* Lesson / exercises */
.lesson-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.steps { display: flex; gap: 6px; margin-bottom: 20px; }
.steps span { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-2); }
.steps span.on { background: var(--primary); }
.options { display: grid; gap: 10px; margin-top: 14px; }
.option {
  text-align: left; padding: 14px 16px; border: 2px solid var(--border); border-radius: 12px; background: var(--surface);
  font: inherit; font-weight: 600; cursor: pointer; color: var(--text);
}
.option:hover:not(:disabled) { border-color: var(--primary); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option:disabled { cursor: default; }
.feedback { margin-top: 14px; padding: 12px 14px; border-radius: 10px; font-weight: 500; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.question { font-size: 1.2rem; font-weight: 700; }
.big-word { font-size: 2rem; font-weight: 800; text-align: center; margin: 10px 0; }
.explain { background: var(--surface-2); border-radius: 12px; padding: 16px 18px; }
.explain ul { margin: 0 0 .8em; padding-left: 1.2em; }
.explain .bullet { display: block; padding-left: .2em; }
.example { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.example:last-child { border-bottom: 0; }
.example .en { font-weight: 600; }
.reading-text { font-size: 1.08rem; line-height: 1.8; }
.reading-text p { margin-bottom: 1em; }
.vocab-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.vocab-item:last-child { border-bottom: 0; }
.vocab-item .v-main { flex: 1; min-width: 0; }
.vocab-item .v-en { font-weight: 700; }
.dialogue .line { display: flex; gap: 10px; margin-bottom: 10px; align-items: flex-start; }
.dialogue .who { font-weight: 800; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; font-size: .8rem; }
.dialogue .line.B .who { background: var(--warn-soft); color: var(--warn); }
.dialogue .txt { background: var(--surface-2); padding: 8px 12px; border-radius: 12px; flex: 1; }
.dialogue .line.me .txt { outline: 2px solid var(--primary); }
.result-big { font-size: 3.2rem; font-weight: 800; }

/* Flashcards */
.flashcard {
  min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 28px; cursor: pointer; user-select: none;
}
.flashcard .front { font-size: 2rem; font-weight: 800; }
.flashcard .back { margin-top: 14px; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.grades .btn { flex-direction: column; gap: 0; padding: 10px 6px; }
.grades .btn small { font-weight: 500; opacity: .85; font-size: .72rem; }

/* Speech */
.mic { width: 84px; height: 84px; border-radius: 50%; border: none; background: var(--primary); color: #fff; font-size: 2rem; cursor: pointer; box-shadow: var(--shadow); }
.mic.rec { background: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.5); } 100% { box-shadow: 0 0 0 18px rgba(220,38,38,0); } }
.w-ok { color: var(--ok); font-weight: 700; }
.w-miss { color: var(--bad); font-weight: 700; text-decoration: underline wavy; }
.sentence-big { font-size: 1.35rem; font-weight: 700; text-align: center; margin: 12px 0; }

/* Chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; padding: 8px 4px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.feedback { align-self: flex-start; background: var(--warn-soft); border: 1px solid var(--warn); font-size: .9rem; max-width: 90%; white-space: normal; }
.msg .actions { margin-top: 4px; }
.chat-input { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.chat-input textarea { min-height: 48px; height: 48px; }
.scenario { cursor: pointer; display: flex; gap: 12px; align-items: center; }
.scenario:hover { border-color: var(--primary); }
.scenario .s-ico { font-size: 1.8rem; }

/* Misc */
.loading { display: grid; place-items: center; padding: 60px; }
.spinner { width: 36px; height: 36px; border: 4px solid var(--surface-2); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-weight: 600; box-shadow: var(--shadow); transition: opacity .4s, transform .4s; }
.toast-error { background: var(--bad); color: #fff; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-xp { background: var(--gold); color: #1c2033; font-size: 1.1rem; }
.toast.hide { opacity: 0; transform: translateY(-10px); }
.tip { background: var(--warn-soft); border-left: 4px solid var(--warn); padding: 12px 16px; border-radius: 10px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: var(--surface-2); border: 1px solid var(--border); padding: 8px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.confetti { font-size: 4rem; text-align: center; animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.3); } 80% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* Assinatura / planos */
.plan { display: flex; flex-direction: column; gap: 4px; }
.plan + .plan { margin-top: 0; }
.plan-hl { border: 2px solid var(--primary); }
.plan-price { font-size: 2rem; font-weight: 800; margin-top: 4px; }
.plan-feat { list-style: none; padding: 0; margin: 10px 0 16px; font-size: .92rem; }
.plan-feat li { padding: 3px 0; }
.pix-box { margin-top: 16px; border: 2px solid var(--ok); }
.pix-grid { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; margin-top: 12px; }
.pix-qr { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 12px; }
.st { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.st-approved { background: var(--ok-soft); color: var(--ok); }
.st-pending { background: var(--warn-soft); color: var(--warn); }
.st-rejected, .st-cancelled, .st-refunded, .st-charged_back, .st-amount_mismatch { background: var(--bad-soft); color: var(--bad); }
.st-expired { background: var(--surface-2); color: var(--muted); }
a.card.stat { color: var(--text); }
a.card.stat:hover { border-color: var(--primary); }

/* Controle de velocidade do áudio (estilo YouTube) */
#speed-ctl { position: fixed; right: 18px; bottom: 18px; z-index: 40; }
@media (max-width: 860px) { #speed-ctl { right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); } }
.speed-fab {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow);
  font: inherit; font-weight: 800; font-size: .9rem;
}
.speed-fab:hover { border-color: var(--primary); }
.speed-fab.changed { background: var(--primary); color: #fff; border-color: var(--primary); }
.speed-panel {
  position: absolute; right: 0; bottom: calc(100% + 10px); width: 300px; max-width: calc(100vw - 24px);
  background: rgba(28, 30, 48, .97); color: #fff; border-radius: 16px; padding: 14px 16px 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.35); backdrop-filter: blur(6px);
}
.speed-panel[hidden] { display: none; }
.speed-head { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; opacity: .85; }
.speed-x { background: none; border: 0; color: #fff; cursor: pointer; font-size: 1rem; opacity: .8; }
.speed-big { text-align: center; font-size: 1.6rem; font-weight: 800; margin: 6px 0 10px; }
.speed-row { display: flex; align-items: center; gap: 12px; }
.speed-step {
  width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; cursor: pointer; font-size: 1.4rem; line-height: 1;
  background: rgba(255,255,255,.15); color: #fff;
}
.speed-step:hover { background: rgba(255,255,255,.25); }
.speed-row input[type=range] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 4px; padding: 0; border: 0; border-radius: 99px; outline: none; box-shadow: none;
  background: linear-gradient(90deg, #fff var(--fill, 50%), rgba(255,255,255,.3) var(--fill, 50%));
}
.speed-row input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; cursor: pointer; }
.speed-row input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; cursor: pointer; }
.speed-presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 14px; }
.speed-presets button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; border-radius: 999px; cursor: pointer;
  background: rgba(255,255,255,.12); border: 0; color: #fff; font: inherit; font-size: .82rem;
}
.speed-presets button small { font-size: .62rem; opacity: .8; }
.speed-presets button.on { background: #fff; color: #1c1e30; }
.speed-test { margin-top: 12px; width: 100%; padding: 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: none; color: #fff; cursor: pointer; font: inherit; font-size: .85rem; }
.speed-test:hover { background: rgba(255,255,255,.1); }
