/* ==========================================================================
   TEAP — Aplicativo do aluno
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.55;
    color: var(--text);
    background: var(--page-bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -.02em;
    margin: 0;
    color: var(--brand-900);
}
:root[data-theme="dark"] h1, :root[data-theme="dark"] h2,
:root[data-theme="dark"] h3, :root[data-theme="dark"] h4 { color: var(--text) }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) h1, :root:not([data-theme="light"]) h2,
    :root:not([data-theme="light"]) h3, :root:not([data-theme="light"]) h4 { color: var(--text) }
}

p { margin: 0 0 var(--sp-4) }
p:last-child { margin-bottom: 0 }

a { color: var(--accent); text-decoration: none }
a:hover { text-decoration: underline }

img, svg { max-width: 100%; display: block }

button, input, select, textarea { font: inherit; color: inherit }

:focus-visible {
    outline: 3px solid var(--brand-400);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

::selection { background: var(--brand-200); color: var(--brand-900) }

/* --- Layout --------------------------------------------------------------- */

.page-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: var(--app-max);
    margin-inline: auto;
    padding-inline: var(--sp-4);
}
.container--narrow { max-width: 680px }
.container--phone  { max-width: var(--phone-max) }

.app-main {
    flex: 1;
    padding-block: var(--sp-5) calc(var(--tabbar-h) + var(--sp-8));
}
@media (min-width: 900px) {
    /* A barra flutua sobre o conteúdo: o respiro embaixo é o que impede
       que o último cartão da página fique escondido atrás dela. */
    .app-main { padding-bottom: calc(var(--tabbar-h) + var(--sp-9)) }
}

.stack   { display: flex; flex-direction: column; gap: var(--sp-4) }
.stack-2 { display: flex; flex-direction: column; gap: var(--sp-2) }
.stack-6 { display: flex; flex-direction: column; gap: var(--sp-6) }
.row     { display: flex; align-items: center; gap: var(--sp-3) }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3) }
.wrap    { flex-wrap: wrap }
.grow    { flex: 1 }
.center  { text-align: center }

.grid { display: grid; gap: var(--sp-4) }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) }

.hide-mobile { display: none }
@media (min-width: 900px) { .hide-mobile { display: revert } .hide-desktop { display: none } }

/* --- Tipografia auxiliar --------------------------------------------------- */

.display  { font-family: var(--font-display); font-size: clamp(2rem, 6vw, var(--text-4xl)); font-weight: 900; letter-spacing: -.03em }
.title    { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 800 }
.subtitle { font-size: var(--text-lg); color: var(--text-soft) }
.lead     { font-size: var(--text-lg); color: var(--text-soft); line-height: 1.6 }
.muted    { color: var(--text-muted) }
.small    { font-size: var(--text-sm) }
.tiny     { font-size: var(--text-xs) }
.strong   { font-weight: 700 }
.eyebrow  {
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.handwriting {
    font-family: var(--font-hand);
    font-size: 1.35rem;
    color: var(--brand-700);
    line-height: 1.15;
    transform: rotate(-3deg);
}
.gradient-text {
    background: linear-gradient(120deg, var(--brand-600), var(--brand-400));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* --- Botões ---------------------------------------------------------------- */

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: var(--tap);
    padding: 0 var(--sp-6);
    border: 0;
    border-radius: var(--r-pill);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--text-base);
    letter-spacing: -.01em;
    cursor: pointer;
    overflow: hidden;
    text-decoration: none;
    background: var(--surface-sunken);
    color: var(--text);
    transition: transform var(--dur-instant) var(--ease-snap),
                box-shadow var(--dur-fast) var(--ease-out),
                background-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out);
}
.btn:hover { text-decoration: none }
.btn:active { transform: translateY(2px) scale(.985) }
.btn[disabled], .btn.is-disabled {
    opacity: .5;
    pointer-events: none;
}

.btn--primary {
    background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
    color: #fff;
    box-shadow: var(--shadow-brand), var(--shadow-inset);
}
.btn--primary:hover { box-shadow: 0 14px 30px rgba(22, 104, 227, .34), var(--shadow-inset) }

.btn--success {
    background: linear-gradient(180deg, #27C46B, var(--green-600));
    color: #fff;
    box-shadow: 0 10px 24px rgba(14, 159, 110, .3), var(--shadow-inset);
}

.btn--danger {
    background: linear-gradient(180deg, #F05252, var(--red-600));
    color: #fff;
    box-shadow: 0 10px 24px rgba(220, 38, 38, .28), var(--shadow-inset);
}

.btn--ghost {
    background: transparent;
    color: var(--accent-text);
    border: 2px solid var(--brand-200);
}
.btn--ghost:hover { background: var(--accent-soft) }

.btn--quiet {
    background: transparent;
    color: var(--text-soft);
    min-height: 40px;
    padding-inline: var(--sp-4);
}
.btn--quiet:hover { background: var(--surface-sunken) }

/* Botão sobre fundo colorido (cartão de continuidade, celebrações). */
.btn--on-brand {
    background: #fff;
    color: var(--brand-700);
    box-shadow: 0 8px 20px rgba(3, 20, 50, .22), inset 0 -3px 0 rgba(11, 27, 51, .08);
}
.btn--on-brand:hover { background: #fff; box-shadow: 0 12px 26px rgba(3, 20, 50, .28) }

.btn--block { width: 100%; display: flex }
.btn--lg { min-height: 56px; font-size: var(--text-lg); padding-inline: var(--sp-7) }
.btn--sm { min-height: 38px; font-size: var(--text-sm); padding-inline: var(--sp-4) }

/*
   Auto-suficiente de propósito: é um modificador que já foi usado sem a
   classe base, e o ícone acabava encostado no canto do círculo.
*/
.btn--icon {
    display: inline-grid;
    place-items: center;
    width: var(--tap);
    height: var(--tap);
    min-height: var(--tap);
    flex-shrink: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    color: var(--text-soft);
    cursor: pointer;
}
.btn--icon:hover {
    color: var(--accent);
    border-color: var(--brand-300);
    box-shadow: var(--shadow-sm);
}
.btn--icon svg { width: 22px; height: 22px }

.btn__arrow { transition: transform var(--dur-base) var(--ease-spring) }
.btn:hover .btn__arrow { transform: translateX(5px) }

/* --- Cards ----------------------------------------------------------------- */

.card {
    background: var(--surface);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: var(--sp-5);
    transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.card--flat { box-shadow: none }
.card--lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-md) }
.card--pad-lg { padding: var(--sp-6) }
.card--tint { background: linear-gradient(160deg, var(--brand-050), var(--surface)) }

.card__title { font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg) }

/* --- Badges / pílulas ------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 5px 12px;
    border-radius: var(--r-pill);
    font-size: var(--text-xs);
    font-weight: 700;
    background: var(--surface-sunken);
    color: var(--text-soft);
    white-space: nowrap;
}
.badge--brand   { background: var(--brand-100); color: var(--brand-700) }
.badge--success { background: var(--green-100); color: var(--green-600) }
.badge--warning { background: var(--amber-100); color: #A46608 }
.badge--danger  { background: var(--red-100);   color: var(--red-600) }
.badge--violet  { background: var(--violet-100);color: var(--violet-600) }
:root[data-theme="dark"] .badge--brand   { background: rgba(79,163,247,.16); color: var(--brand-300) }
:root[data-theme="dark"] .badge--success { background: rgba(34,197,94,.16);  color: #5EE49B }
:root[data-theme="dark"] .badge--warning { background: rgba(245,165,36,.16); color: #F7C56B }
:root[data-theme="dark"] .badge--danger  { background: rgba(239,68,68,.16);  color: #FB8C8C }

/* --- Barra de progresso ----------------------------------------------------- */

.progress {
    position: relative;
    height: 12px;
    border-radius: var(--r-pill);
    background: var(--surface-sunken);
    overflow: hidden;
}
.progress__bar {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-400));
    /* A largura real vem do HTML; a animação parte do zero até ela. */
    animation: barFill var(--dur-slower) var(--ease-out) both;
    transition: width var(--dur-slower) var(--ease-out);
    position: relative;
}
.progress__bar::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.45) 50%, transparent 80%);
    background-size: 220% 100%;
    animation: shimmer 2.4s linear infinite;
}
.progress--slim { height: 8px }
.progress--success .progress__bar { background: linear-gradient(90deg, var(--green-500), var(--green-600)) }
.progress--amber  .progress__bar { background: linear-gradient(90deg, #FFC55A, var(--amber-500)) }

/* --- Cabeçalho do app -------------------------------------------------------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    border-bottom: 1px solid var(--border);
    transition: box-shadow var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}
.app-header.is-scrolled { box-shadow: var(--shadow-sm) }

.app-header__inner {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    min-height: var(--header-h);
}

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none }
.brand:hover { text-decoration: none }
.brand__mark { height: 34px; width: auto }
.brand__text { display: flex; flex-direction: column; line-height: 1 }
.brand__name {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1.35rem;
    letter-spacing: -.04em;
    color: var(--brand-800);
}
:root[data-theme="dark"] .brand__name { color: var(--brand-300) }
.brand__sub { font-size: .58rem; letter-spacing: .04em; color: var(--text-muted); margin-top: 2px }

/* Estatísticas do topo (sequência / XP) */
.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: var(--r-pill);
    background: var(--surface-sunken);
    font-weight: 800;
    font-size: var(--text-sm);
    transition: transform var(--dur-base) var(--ease-spring);
}
.stat-pill:hover { transform: translateY(-2px) }
.stat-pill__value { font-family: var(--font-display); color: var(--text) }
.stat-pill__unit  { font-size: var(--text-xs); font-weight: 600; color: var(--text-muted) }
.stat-pill--fire  { background: linear-gradient(180deg, #FFF1E2, #FFE6CF); color: #B4520B }
.stat-pill--xp    { background: linear-gradient(180deg, #FFF6DC, #FFEDBF); color: #8A5A05 }
:root[data-theme="dark"] .stat-pill--fire { background: rgba(245,124,36,.15); color: #FFB870 }
:root[data-theme="dark"] .stat-pill--xp   { background: rgba(245,196,36,.15); color: #FFD97A }

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 2px var(--brand-200);
    display: grid;
    place-items: center;
    background: linear-gradient(140deg, var(--brand-400), var(--brand-600));
    color: #fff;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--text-sm);
    text-decoration: none;
    transition: transform var(--dur-base) var(--ease-spring), box-shadow var(--dur-base) var(--ease-out);
}
.avatar:hover { transform: scale(1.06); box-shadow: 0 0 0 3px var(--brand-300) }
.avatar--lg { width: 96px; height: 96px; font-size: var(--text-2xl) }

/* --- Barra inferior de navegação ----------------------------------------------- */

.tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 50;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--border);
}
@media (min-width: 900px) {
    .tabbar {
        /*
           Continua fixa, como no celular: "sticky" com bottom rolava junto
           com a página e só encostava no rodapé no fim da rolagem. Aqui ela
           vira uma pílula flutuante centrada, sempre à vista.

           A largura é explícita porque, num container flex em coluna,
           margin-inline:auto encolhe o item até o conteúdo — a barra ficava
           com metade do tamanho e os rótulos se encostavam.
        */
        left: 50%;
        right: auto;
        bottom: var(--sp-5);
        transform: translateX(-50%);
        width: min(640px, calc(100% - var(--sp-7)));
        margin: 0;
        height: var(--tabbar-h);
        padding-inline: var(--sp-2);
        border-radius: var(--r-pill);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        padding-bottom: 0;
    }
}

.tabbar__item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding-inline: 4px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: -.01em;
    line-height: 1.1;
    text-align: center;
    position: relative;
    transition: color var(--dur-fast) var(--ease-out);
    -webkit-tap-highlight-color: transparent;
}
/* O rótulo nunca quebra nem encosta no vizinho. */
.tabbar__item > span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tabbar__item.is-active { font-weight: 800 }
.tabbar__item:hover { text-decoration: none; color: var(--accent) }
.tabbar__item svg { width: 24px; height: 24px; transition: transform var(--dur-base) var(--ease-spring) }
.tabbar__item:active svg { transform: scale(.86) }
.tabbar__item.is-active { color: var(--accent) }
.tabbar__item.is-active svg { transform: translateY(-2px) scale(1.06) }
.tabbar__item.is-active::after {
    content: "";
    position: absolute;
    bottom: 5px;
    left: 50%;
    width: 20px;
    height: 3px;
    margin-left: -10px;
    border-radius: var(--r-pill);
    background: var(--accent);
    animation: tabIndicator var(--dur-base) var(--ease-spring) both;
}
.tabbar__badge {
    position: absolute;
    top: 6px;
    right: 50%;
    transform: translateX(18px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--r-pill);
    background: var(--red-500);
    color: #fff;
    font-size: .6rem;
    font-weight: 800;
    display: grid;
    place-items: center;
    box-shadow: 0 0 0 2px var(--surface);
    animation: popIn var(--dur-base) var(--ease-spring) both;
}

/* --- Formulários -------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px }
.field__label { font-size: var(--text-sm); font-weight: 700; color: var(--text-soft) }
.field__error { font-size: var(--text-sm); color: var(--red-600); animation: riseInSmall var(--dur-fast) var(--ease-out) both }
.field__help  { font-size: var(--text-xs); color: var(--text-muted) }

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--r-md);
    transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input-wrap:focus-within {
    border-color: var(--brand-400);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.input-wrap__icon {
    display: grid;
    place-items: center;
    width: 46px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.input-wrap__action {
    background: none;
    border: 0;
    padding: 0 var(--sp-4);
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease-out);
}
.input-wrap__action:hover { color: var(--accent) }

.input, .select, .textarea {
    flex: 1;
    width: 100%;
    min-height: var(--tap);
    padding: 10px var(--sp-4);
    border: 0;
    border-radius: inherit;
    background: transparent;
    outline: none;
    font-size: var(--text-base);
}
.input-wrap .input { padding-left: 0 }
.input-wrap__icon + .input { padding-left: 0 }

.input--solo, .select--solo, .textarea--solo {
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: var(--r-md);
    transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input--solo:focus, .select--solo:focus, .textarea--solo:focus {
    border-color: var(--brand-400);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.textarea, .textarea--solo { min-height: 110px; padding: var(--sp-3) var(--sp-4); resize: vertical; line-height: 1.55 }

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: var(--text-sm);
    user-select: none;
}
.checkbox input { width: 20px; height: 20px; accent-color: var(--brand-600) }

.switch {
    position: relative;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
    border-radius: var(--r-pill);
    background: var(--border-strong);
    border: 0;
    cursor: pointer;
    transition: background-color var(--dur-base) var(--ease-out);
}
.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur-base) var(--ease-spring);
}
.switch[aria-checked="true"] { background: var(--brand-600) }
.switch[aria-checked="true"]::after { transform: translateX(22px) }

/* --- Escolha de opção (onboarding, metas) ----------------------------------- */

.choice {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    width: 100%;
    padding: var(--sp-4);
    border-radius: var(--r-lg);
    border: 2px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--dur-fast) var(--ease-out),
                background-color var(--dur-fast) var(--ease-out),
                transform var(--dur-instant) var(--ease-snap);
}
.choice:hover { border-color: var(--brand-300) }
.choice:active { transform: scale(.99) }
.choice.is-selected {
    border-color: var(--brand-500);
    background: var(--accent-soft);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.choice__icon {
    width: 46px; height: 46px;
    border-radius: var(--r-md);
    display: grid; place-items: center;
    background: var(--brand-100);
    color: var(--brand-700);
    flex-shrink: 0;
}
.choice__title { font-family: var(--font-display); font-weight: 800 }
.choice__sub { font-size: var(--text-sm); color: var(--text-muted) }

/* --- Mensagens flash ---------------------------------------------------------- */

.flash-stack {
    position: fixed;
    top: calc(var(--header-h) + var(--sp-3));
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    width: min(92vw, 460px);
    pointer-events: none;
}
.flash {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--accent);
    font-size: var(--text-sm);
    pointer-events: auto;
    animation: riseIn var(--dur-base) var(--ease-spring) both;
}
.flash--success { border-left-color: var(--green-500) }
.flash--error   { border-left-color: var(--red-500) }
.flash--warning { border-left-color: var(--amber-500) }
.flash.is-hiding { animation: popOut var(--dur-fast) var(--ease-in-out) forwards }

/* --- Bottom sheet ------------------------------------------------------------- */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(8, 20, 38, .48);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeIn var(--dur-base) var(--ease-out) both;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.sheet-backdrop.is-hiding { animation: fadeOut var(--dur-fast) var(--ease-in-out) forwards }

.sheet {
    width: min(100%, 560px);
    max-height: 88dvh;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--brand-050), var(--surface) 42%);
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    padding: var(--sp-4) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-xl);
    animation: sheetUp var(--dur-slow) var(--ease-out) both;
    overscroll-behavior: contain;
}
.sheet-backdrop.is-hiding .sheet { animation: sheetDown var(--dur-base) var(--ease-in-out) forwards }
@media (min-width: 720px) {
    .sheet-backdrop { align-items: center }
    .sheet { border-radius: var(--r-2xl); max-height: 82dvh; animation: popIn var(--dur-base) var(--ease-spring) both }
}

.sheet__grabber {
    width: 44px; height: 5px;
    border-radius: var(--r-pill);
    background: var(--border-strong);
    margin: 0 auto var(--sp-4);
}
.sheet__head { display: flex; gap: var(--sp-4); align-items: flex-start; margin-bottom: var(--sp-4) }
.sheet__icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    display: grid; place-items: center;
    flex-shrink: 0;
    color: #fff;
    background: linear-gradient(150deg, var(--brand-400), var(--brand-600));
    box-shadow: var(--shadow-brand);
    animation: popIn var(--dur-slow) var(--ease-spring) both;
}
.sheet__icon--green { background: linear-gradient(150deg, #34D399, var(--green-600)); box-shadow: 0 10px 22px rgba(14,159,110,.3) }
.sheet__icon--amber { background: linear-gradient(150deg, #FFD166, var(--amber-500)); box-shadow: 0 10px 22px rgba(245,165,36,.3) }
.sheet__close {
    margin-left: auto;
    background: none;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--sp-2);
    border-radius: 50%;
    transition: background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
}
.sheet__close:hover { background: var(--surface-sunken); transform: rotate(90deg) }
.sheet__step { font-size: var(--text-sm); font-weight: 700; color: var(--text-muted) }
.sheet__title { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 800 }
.sheet__sub { color: var(--text-soft); font-size: var(--text-sm); margin-top: 4px }

/* --- Mascote ------------------------------------------------------------------ */

.lex { width: 100%; height: auto; overflow: visible }
.lex--sm { width: 84px }
.lex--md { width: 132px }
.lex--lg { width: 190px }
.lex--xl { width: 260px }

.lex__body { transform-origin: 50% 100%; animation: breathe 4.6s var(--ease-in-out) infinite }
.lex__arm-wave { transform-origin: 78% 46%; animation: wave 2.6s var(--ease-in-out) infinite }
.lex__eyelid { transform-origin: center; animation: blink 6.5s steps(1, end) infinite }

@keyframes wave {
    0%, 60%, 100% { transform: rotate(0deg) }
    70%           { transform: rotate(-18deg) }
    80%           { transform: rotate(6deg) }
    90%           { transform: rotate(-12deg) }
}
@keyframes blink {
    0%, 92%, 100% { transform: scaleY(0) }
    94%, 97%      { transform: scaleY(1) }
}

.lex-bubble {
    position: relative;
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: var(--sp-3) var(--sp-4);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    font-size: var(--text-sm);
    animation: popIn var(--dur-slow) var(--ease-spring) both;
}
.lex-bubble::after {
    content: "";
    position: absolute;
    left: var(--sp-6);
    bottom: -9px;
    width: 18px; height: 18px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    transform: rotate(45deg);
}
.lex-bubble--right::after { left: auto; right: var(--sp-6) }

/* --- Utilidades --------------------------------------------------------------- */

.divider { height: 1px; background: var(--border); border: 0; margin: var(--sp-5) 0 }
.divider--text {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin: var(--sp-5) 0;
}
.divider--text::before, .divider--text::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skeleton {
    border-radius: var(--r-md);
    background: linear-gradient(100deg, var(--surface-sunken) 30%, var(--ink-100) 50%, var(--surface-sunken) 70%);
    background-size: 220% 100%;
    animation: shimmer 1.4s linear infinite;
}

.empty-state {
    text-align: center;
    padding: var(--sp-8) var(--sp-4);
    color: var(--text-muted);
}
.empty-state__icon {
    width: 84px; height: 84px;
    margin: 0 auto var(--sp-4);
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--surface-sunken);
    color: var(--text-muted);
    animation: popIn var(--dur-slow) var(--ease-spring) both;
}

.icon { width: 22px; height: 22px; flex-shrink: 0 }
.icon--sm { width: 18px; height: 18px }
.icon--lg { width: 28px; height: 28px }
.icon--xl { width: 40px; height: 40px }


/* ---------------------------------------------------------------------
   Tema escuro quando vem da preferência do sistema.

   As regras acima respondem ao atributo data-theme, que só é escrito no
   HTML quando o aluno escolhe um tema explicitamente. No padrão "sistema"
   o atributo não existe: as cores base viram escuras pelos tokens e, sem
   este espelho, nenhum ajuste de componente aplicava — daí texto claro
   sobre fundo claro na alternativa selecionada e nas pílulas do topo.
   --------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) h1, :root:not([data-theme="light"]) h2,
    :root:not([data-theme="light"]) h3, :root:not([data-theme="light"]) h4 { color: var(--text) }
    :root:not([data-theme="light"]) .badge--brand   { background: rgba(79,163,247,.16); color: var(--brand-300) }
    :root:not([data-theme="light"]) .badge--success { background: rgba(34,197,94,.16);  color: #5EE49B }
    :root:not([data-theme="light"]) .badge--warning { background: rgba(245,165,36,.16); color: #F7C56B }
    :root:not([data-theme="light"]) .badge--danger  { background: rgba(239,68,68,.16);  color: #FB8C8C }
    :root:not([data-theme="light"]) .brand__name { color: var(--brand-300) }
    :root:not([data-theme="light"]) .stat-pill--fire { background: rgba(245,124,36,.15); color: #FFB870 }
    :root:not([data-theme="light"]) .stat-pill--xp   { background: rgba(245,196,36,.15); color: #FFD97A }
}
