:root {
    --sidebar-width: 250px;
    --primary: #4f46e5;
    --radius: 12px;
}

body {
    background: #f4f6fb;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

[data-bs-theme="dark"] body { background: #0f1117; }

/* Remove o delay de ~300ms que navegadores mobile aplicam a toques em
   controles interativos (aguardando um possível duplo-toque de zoom). */
button, .btn, [role="button"] { touch-action: manipulation; }

/* ---------------- Layout ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid rgba(0,0,0,.06);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.25rem 1rem;
    z-index: 100;
}
[data-bs-theme="dark"] .app-sidebar { background: #161925; border-color: rgba(255,255,255,.06); }

.sidebar-brand { display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px; font-size: 1.2rem; font-weight: 700; margin-bottom: 1.5rem; color: var(--primary); }
.sidebar-brand i { font-size: 1.4rem; }
.sidebar-brand .sidebar-logo { display: block; height: 90px; max-height: 90px; width: auto; max-width: 100%; object-fit: contain; }
.sidebar-brand .sidebar-logo-dark { display: none; }
[data-bs-theme="dark"] .sidebar-brand .sidebar-logo-light { display: none; }
[data-bs-theme="dark"] .sidebar-brand .sidebar-logo-dark { display: block; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .75rem; border-radius: 8px;
    color: inherit; text-decoration: none; font-size: .92rem;
}
.sidebar-nav a:hover { background: rgba(79,70,229,.08); }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-nav a i { width: 18px; text-align: center; }
.sidebar-divider { font-size: .7rem; text-transform: uppercase; color: #94a3b8; margin: .75rem .5rem .25rem; letter-spacing: .05em; }

.sidebar-logout { margin-top: .5rem; }
.sidebar-logout button {
    width: 100%; background: transparent; border: 1px solid rgba(0,0,0,.1);
    padding: .55rem; border-radius: 8px; color: #ef4444; font-size: .9rem;
}

.app-main { flex: 1; min-width: 0; }

.app-topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: .75rem 1.5rem; background: #fff;
    border-bottom: 1px solid rgba(0,0,0,.06);
    position: sticky; top: 0; z-index: 90;
}
[data-bs-theme="dark"] .app-topbar { background: #161925; border-color: rgba(255,255,255,.06); }

.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.topbar-search input { width: 100%; padding: .5rem .75rem .5rem 2.2rem; border-radius: 999px; border: 1px solid rgba(0,0,0,.1); background: #f4f6fb; }
[data-bs-theme="dark"] .topbar-search input { background: #1e2230; border-color: rgba(255,255,255,.08); color: #e2e8f0; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.topbar-due, .topbar-theme { position: relative; border: none; background: transparent; font-size: 1.1rem; color: inherit; }
.badge-dot { position: absolute; top: -6px; right: -8px; background: #ef4444; color: #fff; font-size: .65rem; border-radius: 999px; padding: 1px 5px; }

.topbar-user { display: flex; align-items: center; gap: .5rem; border: none; background: transparent; }
.topbar-user img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar-fallback { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }

.sidebar-toggle { border: none; background: transparent; font-size: 1.2rem; }

/* ---------------- Componentes gerais ---------------- */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .1rem; }

.card-panel { background: #fff; border-radius: var(--radius); padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,.05); margin-bottom: 0; }
[data-bs-theme="dark"] .card-panel { background: #161925; }

.js-topic-item { cursor: grab; border-radius: .35rem; transition: background-color .1s ease; }
.js-topic-item:active { cursor: grabbing; }
.js-topic-dropzone.topic-drop-hover { background-color: rgba(79,70,229,.12); outline: 1px dashed #4f46e5; }
.js-topic-toggle { cursor: pointer; }

/* Altura fixa para os gráficos Chart.js: sem isso, um <canvas responsive> dentro
   de uma coluna flex (grid do Bootstrap) pode colapsar a quase zero de altura. */
.chart-wrap { position: relative; height: 240px; margin-top: .75rem; }

.stat-card { background: #fff; border-radius: var(--radius); padding: 1rem; display: flex; align-items: center; gap: .9rem; box-shadow: 0 1px 3px rgba(0,0,0,.05); position: relative; }
[data-bs-theme="dark"] .stat-card { background: #161925; }
.stat-card i { font-size: 1.7rem; }
.stat-card span { display: block; font-size: 1.3rem; font-weight: 700; line-height: 1.1; }
.stat-card small { color: #94a3b8; }

.stat-info-btn {
    position: absolute; top: .6rem; right: .6rem;
    background: none; border: none; padding: 0; line-height: 1;
    color: #cbd5e1;
}
.stat-info-btn i { font-size: .85rem; }
.stat-info-btn:hover { color: #64748b; }
[data-bs-theme="dark"] .stat-info-btn { color: #3f4a63; }
[data-bs-theme="dark"] .stat-info-btn:hover { color: #64748b; }

.empty-state { text-align: center; padding: 4rem 1rem; color: #94a3b8; }
.empty-state i { font-size: 3rem; margin-bottom: 1rem; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

/* ---------------- Auth ---------------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#4f46e5,#7c3aed); padding: 1rem; }
.auth-card { background: #fff; border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand i { font-size: 2.2rem; color: var(--primary); }
.auth-brand img { display: block; margin: 0 auto; }
.auth-back { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: #64748b; text-decoration: none; margin-bottom: 1rem; }
.auth-back:hover { color: var(--primary); text-decoration: underline; }
.auth-legal { font-size: .78rem; color: #64748b; text-align: center; margin: .75rem 0 0; }
.auth-brand h1 { font-size: 1.4rem; margin: .5rem 0 .2rem; }
.auth-brand p { color: #64748b; font-size: .85rem; }
.auth-links { display: flex; justify-content: space-between; margin-top: 1rem; font-size: .85rem; }
.auth-divider { display: flex; align-items: center; text-align: center; color: #94a3b8; font-size: .8rem; margin: 1rem 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; border-bottom: 1px solid rgba(0,0,0,.1); }
.auth-divider span { padding: 0 .75rem; }
.toggle-password { border-color: #ced4da; }

/* ---------------- Flashcards ---------------- */
.badge-subject { color: #fff; padding: .25rem .6rem; border-radius: 999px; font-size: .72rem; }
.status-pill { padding: .2rem .55rem; border-radius: 999px; font-size: .7rem; text-transform: capitalize; background: #e2e8f0; }
.status-novo { background: #e2e8f0; }
.status-aprendendo { background: #fef3c7; color: #92400e; }
.status-revisao { background: #dbeafe; color: #1e40af; }
.status-dominado { background: #dcfce7; color: #166534; }
.status-suspenso { background: #fee2e2; color: #991b1b; }

.flashcard-item { background: #fff; border-radius: var(--radius); padding: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,.05); height: 100%; }
[data-bs-theme="dark"] .flashcard-item { background: #161925; }
.flashcard-actions { display: flex; gap: .35rem; margin-top: .5rem; flex-wrap: wrap; }

.report-reason-box {
    display: flex; align-items: flex-start; gap: .4rem;
    background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
    border-radius: 8px; padding: .45rem .6rem; font-size: .78rem; line-height: 1.4;
}
.report-reason-box i { margin-top: .15rem; flex-shrink: 0; }
[data-bs-theme="dark"] .report-reason-box { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.3); }

/* ---------------- Multi-seleção de assuntos ---------------- */
.topic-select-btn { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.topic-select-btn::after { display: none; }
.topic-select-menu {
    max-height: 320px; overflow-y: auto; min-width: 280px; width: 100%;
    padding: .5rem; box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
.topic-select-menu .topic-select-clear {
    width: 100%; text-align: left; border: 0; background: none; color: var(--primary);
    font-size: .8rem; font-weight: 600; padding: .25rem .5rem; border-radius: .375rem;
}
.topic-select-menu .topic-select-clear:hover { background: rgba(79,70,229,.08); }
.topic-select-menu .topic-select-group-label {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
    color: #94a3b8; margin: .6rem .25rem .25rem;
}
.topic-select-menu .form-check { padding-left: 1.75rem; margin: 0 .25rem .15rem; border-radius: .375rem; }
.topic-select-menu .form-check:hover { background: rgba(79,70,229,.06); }
.topic-select-menu .form-check-label { cursor: pointer; width: 100%; padding: .15rem 0; }
.topic-select-menu .topic-select-empty { padding: .5rem; }

/* ---------------- Estudo ---------------- */
.mode-card {
    display: block; height: 100%; width: 100%; background: #fff; border: 1px solid rgba(0,0,0,.06); border-radius: var(--radius);
    padding: 1.5rem 1rem; text-align: center; transition: .15s; color: inherit; text-decoration: none;
}
[data-bs-theme="dark"] .mode-card { background: #161925; border-color: rgba(255,255,255,.08); }
.mode-card:hover, .mode-card:focus-visible { border-color: var(--primary); transform: translateY(-2px); color: inherit; }
.mode-card i { display: block; font-size: 1.8rem; color: var(--primary); margin-bottom: .5rem; }
.mode-card h6 { margin-bottom: .25rem; }
.mode-card small { color: #94a3b8; }

.modes-group-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: #94a3b8; font-weight: 700; margin-bottom: .75rem; }

/* Tela principal de estudo: Revisão Personalizada */
.review-hero {
    max-width: 560px; margin: 1rem auto 0; text-align: center;
    background: #fff; border: 1px solid rgba(0,0,0,.06); border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.05); padding: 2.25rem 1.5rem 2rem;
}
[data-bs-theme="dark"] .review-hero { background: #161925; border-color: rgba(255,255,255,.08); }
.review-hero-icon {
    width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 50%;
    background: rgba(79,70,229,.1); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-size: 1.6rem;
}
[data-bs-theme="dark"] .review-hero-icon { background: rgba(129,140,248,.16); color: #a5b4fc; }
.review-hero-title { font-size: 1.35rem; font-weight: 700; margin-bottom: .35rem; }
.review-hero-scope { color: #64748b; font-size: .92rem; margin-bottom: 1.25rem; overflow-wrap: anywhere; }
[data-bs-theme="dark"] .review-hero-scope { color: #94a3b8; }
.review-hero-more { display: inline-block; padding: 0 .4rem; border-radius: 999px; background: rgba(79,70,229,.1); color: var(--primary); font-size: .78rem; font-weight: 700; }

.review-hero-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1.5rem; }
.review-hero-count { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .7rem .25rem; border-radius: 10px; background: rgba(0,0,0,.025); }
[data-bs-theme="dark"] .review-hero-count { background: rgba(255,255,255,.04); }
.review-hero-count .study-count { font-size: 1.45rem; }
.review-hero-count small { font-size: .7rem; text-transform: uppercase; letter-spacing: .03em; color: #94a3b8; font-weight: 600; }

.review-hero-actions { display: flex; justify-content: center; align-items: stretch; gap: .6rem; }
.review-hero-start { flex: 0 1 280px; font-weight: 600; }
.review-hero-settings {
    flex: 0 0 auto; width: 52px; border-radius: var(--bs-border-radius-lg); font-size: 1.2rem;
    border: 1px solid rgba(79,70,229,.3); color: var(--primary); background: transparent;
}
.review-hero-settings:hover, .review-hero-settings:focus-visible { background: rgba(79,70,229,.08); color: var(--primary); border-color: var(--primary); }
.review-hero-settings:hover i { transform: rotate(60deg); }
.review-hero-settings i { transition: transform .3s; }
[data-bs-theme="dark"] .review-hero-settings { color: #a5b4fc; border-color: rgba(129,140,248,.4); }
.review-hero-hint { margin: 1rem 0 0; font-size: .85rem; color: #64748b; }
[data-bs-theme="dark"] .review-hero-hint { color: #94a3b8; }

.review-more-link { color: #64748b; font-size: .9rem; text-decoration: none; }
.review-more-link:hover { color: var(--primary); }
.review-more-link i { font-size: .7rem; }

.crt-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }

@media (max-width: 576px) {
    .review-hero { padding: 1.75rem 1rem 1.5rem; margin-top: 0; }
    .review-hero-start { flex: 1 1 auto; }
    .crt-tree { max-height: none; }
}

/* ---------------- Revisão Personalizada (árvore matéria → assunto) ---------------- */
.crt-head, .crt-row { display: flex; align-items: center; gap: .4rem; padding: .4rem .5rem; }
.crt-head { padding-top: 0; padding-bottom: 0; margin-bottom: .35rem; }
.crt-head-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8; font-weight: 600; }

.crt-tree { max-height: 46vh; overflow-y: auto; overflow-x: hidden; border: 1px solid rgba(0,0,0,.1); border-radius: 8px; padding: .3rem 0; background: #fff; }
[data-bs-theme="dark"] .crt-tree { background: #161925; border-color: rgba(255,255,255,.1); }

.crt-row { border-radius: 6px; cursor: pointer; }
.crt-row:hover { background: rgba(79,70,229,.06); }
[data-bs-theme="dark"] .crt-row:hover { background: rgba(129,140,248,.1); }
.crt-row-subject .crt-name { font-weight: 700; }
.crt-row-topic { padding-left: calc(.5rem + var(--depth, 0) * 1.5rem); }

.crt-toggle {
    width: 1.5rem; height: 1.5rem; flex-shrink: 0; border: none; background: transparent;
    display: flex; align-items: center; justify-content: center; color: #64748b;
    border-radius: 4px; padding: 0; font-size: .8rem;
}
.crt-toggle:hover:not(:disabled) { background: rgba(0,0,0,.07); }
[data-bs-theme="dark"] .crt-toggle { color: #94a3b8; }
[data-bs-theme="dark"] .crt-toggle:hover:not(:disabled) { background: rgba(255,255,255,.1); }
.crt-toggle-empty { visibility: hidden; }

.crt-checkbox { display: flex; align-items: center; flex-shrink: 0; margin: 0; }
.crt-checkbox input { width: 16px; height: 16px; margin: 0; cursor: pointer; }

.crt-dot { width: .6rem; height: .6rem; border-radius: 50%; flex-shrink: 0; }

.crt-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.crt-counts, .crt-head-counts {
    flex-shrink: 0; margin-left: auto; display: grid; grid-template-columns: repeat(3, minmax(3.6rem, auto));
    gap: .4rem; text-align: right; padding-left: .5rem;
}
.crt-count { font-weight: 700; font-size: .9rem; }
.crt-count-label {
    font-size: .62rem; text-transform: uppercase; letter-spacing: .02em; color: #94a3b8; font-weight: 600;
    white-space: normal; overflow-wrap: break-word; line-height: 1.15;
}

.crt-summary { margin-top: 1rem; padding: .85rem 1rem; border-radius: 8px; background: rgba(79,70,229,.06); border: 1px solid rgba(79,70,229,.15); }
[data-bs-theme="dark"] .crt-summary { background: rgba(129,140,248,.08); border-color: rgba(129,140,248,.22); }
.crt-summary-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8; font-weight: 700; margin-bottom: .4rem; }
.crt-summary-list { list-style: none; margin: 0 0 .5rem; padding: 0; font-size: .88rem; }
.crt-summary-list li { padding: .12rem 0; }
.crt-summary-subject { font-weight: 700; }
.crt-summary-subject-tag { color: #94a3b8; font-weight: 600; }
.crt-summary-subject-tag::after { content: ' \203a '; }
.crt-summary-total { font-size: .92rem; padding-top: .5rem; border-top: 1px dashed rgba(0,0,0,.12); }
[data-bs-theme="dark"] .crt-summary-total { border-color: rgba(255,255,255,.12); }
.crt-summary-total strong { font-size: 1.3rem; color: var(--primary); }
[data-bs-theme="dark"] .crt-summary-total strong { color: #a5b4fc; }
.crt-summary-breakdown { display: block; color: #94a3b8; font-size: .78rem; margin-top: .15rem; }

@media (max-width: 576px) {
    .crt-head-label { display: none; }
    .crt-counts, .crt-head-counts { grid-template-columns: repeat(3, minmax(2.9rem, auto)); gap: .25rem; }
    .crt-row { flex-wrap: wrap; }
    .crt-row .crt-counts { flex-basis: 100%; margin-left: 2.5rem; margin-top: .1rem; width: auto; }
    .crt-count { font-size: .8rem; }
    .crt-count-label { font-size: .56rem; }
}

.study-wrapper { max-width: 800px; margin: 0 auto; background: #f4f6fb; padding: 1rem; }
[data-bs-theme="dark"] .study-wrapper { background: #0f1117; }

/* Modo maximizado (Fullscreen API): o navegador só expande o wrapper para
   ocupar a tela, sem centralizar nada — por padrão o conteúdo colaria no
   topo. Vira uma coluna flex com padding relativo à viewport, e o
   .study-grid (que carrega todo o conteúdo real) cresce dentro dela pra
   ocupar o espaço restante, responsiva em qualquer resolução, sem
   posicionamento fixo. */
.study-wrapper:fullscreen,
.study-wrapper:-webkit-full-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: clamp(1.25rem, 4vh, 2.5rem) clamp(1rem, 4vw, 2rem);
    overflow-y: auto;
}
.study-wrapper:fullscreen .study-grid,
.study-wrapper:-webkit-full-screen .study-grid {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    /* minmax(0, 1fr) em vez de só "1fr": por padrão uma track de grid
       nunca fica menor que o conteúdo (min-content), então com um card
       de resposta longa essa linha crescia junto com ele — a rolagem
       acabava acontecendo na página inteira (levando o cabeçalho junto
       pra fora da tela) em vez de só dentro do #studyArea. Forçando o
       mínimo pra 0 aqui, a linha realmente fica limitada ao espaço
       disponível, e é o overflow-y:auto do #studyArea (abaixo) quem
       passa a rolar sozinho quando o card não cabe. */
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    /* Sem isso, mesmo com a linha "limitada" acima, o conteúdo que não
       coubesse continuava vazando visualmente para fora da grid (grid
       não recorta o próprio conteúdo por padrão) — daí a rolagem ainda
       acontecia na página inteira em vez de só dentro do #studyArea. */
    overflow: hidden;
}
.study-wrapper:fullscreen #studyArea,
.study-wrapper:-webkit-full-screen #studyArea {
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* "safe center": com uma resposta longa, centralizar o card sem essa
       palavra-chave faz o navegador tratar o item como se coubesse
       inteiro, e o card acaba renderizado menor que o próprio conteúdo
       (o fundo branco/sombra param antes do texto acabar). "safe" faz o
       navegador cair para alinhamento no topo quando centralizar causaria
       esse corte, então o card cresce certinho e rola por completo.
       Repetida (não combinada numa linha só) de propósito: navegadores
       sem suporte a "safe" ignoram essa segunda declaração e ficam com o
       "center" comum acima, em vez de descartar a regra inteira. */
    justify-content: safe center;
    overflow-y: auto;
}
/* Sem isso, o card é o item flexível dentro do #studyArea e, com uma
   resposta longa, o navegador o ENCOLHE pra caber no espaço visível — mas
   o texto dentro não encolhe junto, e vaza pra fora do fundo branco/sombra
   do card (bug visível em telas de tablet, que não caem na media query
   mobile abaixo). flex-shrink:0 obriga o card a manter a altura real do
   conteúdo, e aí quem rola é o #studyArea. */
.study-wrapper:fullscreen .study-card,
.study-wrapper:-webkit-full-screen .study-card {
    flex-shrink: 0;
}

/* Grid único que carrega todo o conteúdo da sessão de estudo (botões,
   caixinhas de estatística, progresso, o card e os atalhos). Usar um
   grid com 3 colunas (extremos iguais + meio automático) é o que permite
   as caixinhas ficarem SEMPRE centralizadas de verdade, mesmo com botões
   de larguras diferentes nas pontas — cada botão fica preso à borda da
   sua própria coluna (que tem a mesma largura da coluna do outro lado),
   então o conteúdo do meio nunca fica puxado pra um lado.
   No mobile (ver media query abaixo), as áreas são redistribuídas para
   empilhar: estatísticas → progresso → card → botões → atalhos. */
.study-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
        "endbtn stats fullbtn"
        "progress progress progress"
        "studyarea studyarea studyarea"
        "shortcuts shortcuts shortcuts";
    align-items: center;
    row-gap: 1.1rem;
    column-gap: .75rem;
}
#btnEndStudy { grid-area: endbtn; justify-self: start; }
#fullscreenBtn { grid-area: fullbtn; justify-self: end; }
.study-overall-progress { grid-area: progress; }
/* align-self: stretch (em vez de herdar o align-items:center do grid) é
   o que faz essa célula realmente assumir a altura da linha em vez de só
   encolher pro tamanho do próprio conteúdo — sem isso, o card de resposta
   longa "empurrava" a própria altura da célula pra caber tudo, e o
   overflow-y:auto abaixo nunca tinha o que rolar (a caixa já estava do
   tamanho exato do conteúdo). Só importa mesmo em tela cheia, mas não
   atrapalha em nenhum outro contexto. */
#studyArea { grid-area: studyarea; align-self: stretch; }
.study-shortcuts { grid-area: shortcuts; }

/* Botões de ação do topbar (Encerrar estudo / Tela cheia) — mesmo estilo
   de caixa arredondada com borda sutil usado nas caixinhas de estatística,
   pra tudo parecer parte de um único conjunto visual coeso. */
.btn-study-action {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    background: #fff; border: 1px solid rgba(15,23,42,.1); border-radius: 12px;
    padding: 10px; font-size: .85rem; font-weight: 600; color: #475569;
    transition: background .15s, border-color .15s; cursor: pointer;
}
.btn-study-action:hover { background: #f1f5f9; border-color: rgba(15,23,42,.16); }
.btn-study-action:disabled { opacity: .5; cursor: not-allowed; }
.btn-study-action:disabled:hover { background: #fff; border-color: rgba(15,23,42,.1); }
[data-bs-theme="dark"] .btn-study-action { background: #161925; border-color: rgba(255,255,255,.08); color: #cbd5e1; }
[data-bs-theme="dark"] .btn-study-action:hover { background: #1e2230; border-color: rgba(255,255,255,.16); }
[data-bs-theme="dark"] .btn-study-action:disabled:hover { background: #161925; border-color: rgba(255,255,255,.08); }
#fullscreenBtn.btn-study-action { padding: 10px; }

/* Caixinhas de estatística (Novos/Aprendendo/Revisão) */
.study-counts { grid-area: stats; justify-self: center; display: flex; align-items: stretch; justify-content: center; gap: .6rem; flex-wrap: wrap; }
.study-count-box {
    display: flex; align-items: center; gap: .6rem;
    background: #fff; border: 1px solid rgba(15,23,42,.08); border-radius: 12px;
    padding: .5rem .9rem; min-width: 108px;
}
[data-bs-theme="dark"] .study-count-box { background: #161925; border-color: rgba(255,255,255,.08); }

.study-count-box-icon {
    width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: .95rem;
}
.study-count-box-new .study-count-box-icon { background: rgba(59,130,246,.12); color: #3b82f6; }
.study-count-box-learning .study-count-box-icon { background: rgba(239,68,68,.12); color: #ef4444; }
.study-count-box-review .study-count-box-icon { background: rgba(34,197,94,.12); color: #22c55e; }
[data-bs-theme="dark"] .study-count-box-new .study-count-box-icon { background: rgba(96,165,250,.18); color: #60a5fa; }
[data-bs-theme="dark"] .study-count-box-learning .study-count-box-icon { background: rgba(248,113,113,.18); color: #f87171; }
[data-bs-theme="dark"] .study-count-box-review .study-count-box-icon { background: rgba(74,222,128,.18); color: #4ade80; }

.study-count-box-body { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.study-count-box-body small {
    font-size: .62rem; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.study-count { min-width: 1.1em; font-size: 1.1rem; font-weight: 700; line-height: 1; }
.study-count-new { color: #3b82f6; }
.study-count-learning { color: #ef4444; }
.study-count-review { color: #22c55e; }
[data-bs-theme="dark"] .study-count-new { color: #60a5fa; }
[data-bs-theme="dark"] .study-count-learning { color: #f87171; }
[data-bs-theme="dark"] .study-count-review { color: #4ade80; }

/* Progresso geral da fila, centralizado abaixo da linha de caixinhas */
.study-overall-progress { display: flex; flex-direction: column-reverse; align-items: center; gap: .35rem; }
.study-overall-progress .progress { width: min(320px, 100%); height: 6px; }
.study-progress-label { font-size: .72rem; color: #94a3b8; }

.study-card {
    background: #fff; border-radius: 16px; padding: 2rem;
    min-height: 460px; box-shadow: 0 4px 20px rgba(0,0,0,.08);
    display: flex; flex-direction: column;
}
[data-bs-theme="dark"] .study-card { background: #161925; }

.study-card-meta { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.25rem; }
.study-card-toprow { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; }
.study-card-badges { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

.btn-report {
    background: none; margin-left: 5px;border: none; color: #cbd5e1; font-size: .95rem;
    padding: .3rem .55rem; border-radius: 6px; line-height: 1; flex-shrink: 0;
    transition: color .15s, background-color .15s;
}
.btn-report:hover { color: #ef4444; background: rgba(239,68,68,.08); }
[data-bs-theme="dark"] .btn-report { color: #3f4a63; }
[data-bs-theme="dark"] .btn-report:hover { color: #f87171; background: rgba(248,113,113,.12); }

.study-card-meta .badge-subject { font-weight: 600; line-height: 1.4; }

.study-card-topic-wrap { text-align: center; }
.study-card-topic {
    display: inline-block; font-size: 1.35rem; font-weight: 700;
    color: #1e293b; line-height: 1.35; padding: 0 .1rem .3rem;
    border-bottom: 3px solid transparent;
}
[data-bs-theme="dark"] .study-card-topic { color: #e2e8f0; }

.study-card-topic.status-underline-novo { border-bottom-color: #3b82f6; }
.study-card-topic.status-underline-aprendendo { border-bottom-color: #ef4444; }
.study-card-topic.status-underline-revisao { border-bottom-color: #22c55e; }
.study-card-topic.status-underline-dominado { border-bottom-color: #eab308; }

/* Badge de dificuldade AUTOMÁTICA (visual, calculada a partir do
   histórico de revisões — ver Flashcard::updateComputedDifficulty()).
   Sem escopo a um container específico: usada tanto na grade de
   flashcards quanto na tela de estudo e no preview. */
.badge-cdiff {
    padding: .25rem .65rem; border-radius: 999px; font-size: .72rem;
    font-weight: 600; line-height: 1.4;
    background: #f1f5f9; color: #475569;
}
.badge-cdiff-novo { background: #f1f5f9; color: #64748b; }
.badge-cdiff-facil { background: #dcfce7; color: #166534; }
.badge-cdiff-media { background: #fef3c7; color: #92400e; }
.badge-cdiff-dificil { background: #fee2e2; color: #991b1b; }
[data-bs-theme="dark"] .badge-cdiff { background: #1e2230; color: #cbd5e1; }
[data-bs-theme="dark"] .badge-cdiff-novo { background: #1e2230; color: #94a3b8; }
[data-bs-theme="dark"] .badge-cdiff-facil { background: rgba(34,197,94,.18); color: #86efac; }
[data-bs-theme="dark"] .badge-cdiff-media { background: rgba(245,158,11,.18); color: #fcd34d; }
[data-bs-theme="dark"] .badge-cdiff-dificil { background: rgba(239,68,68,.18); color: #fca5a5; }

.study-card-title {
    font-size: 1.05rem; font-weight: 700; margin: 0 0 1rem;
    padding-bottom: .85rem; border-bottom: 1px solid rgba(0,0,0,.07);
}
[data-bs-theme="dark"] .study-card-title { border-color: rgba(255,255,255,.08); }

.study-card-body { flex: 1; display: flex; flex-direction: column; justify-content: center; }

.study-card-face { font-size: 1.2rem; line-height: 1.7; }
.study-card-face#cardFront { text-align: center; font-size: 1.65rem; font-weight: 600; }
.study-card-face#cardBack { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 2px dashed rgba(0,0,0,.1); text-align: left; }
[data-bs-theme="dark"] .study-card-face#cardBack { border-color: rgba(255,255,255,.1); }

.study-card-footer { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid rgba(0,0,0,.06); }
[data-bs-theme="dark"] .study-card-footer { border-color: rgba(255,255,255,.06); }

.study-actions { text-align: center; }

.study-rating { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.btn-rate { border: none; border-radius: 10px; padding: .8rem .4rem; display: flex; flex-direction: column; align-items: center; gap: .25rem; font-size: 1.4rem; color: #fff; }
.btn-rate span { font-size: .78rem; }
.btn-rate-time { font-size: .68rem; font-weight: 600; opacity: .85; margin-top: -.1rem; }
.btn-rate kbd { font-size: .65rem; opacity: .8; }
.btn-rate-forgot { background: #ef4444; }
.btn-rate-hard { background: #f59e0b; }
.btn-rate-good { background: #3b82f6; }
.btn-rate-easy { background: #22c55e; }

/* ---------------- Resumo de encerramento de sessão (inline em #studyArea) ---------------- */
.study-card-result {
    align-items: center; justify-content: center; text-align: center;
}
.session-summary-badge {
    position: relative;
    width: 72px; height: 72px; margin: 0 auto;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: rgba(79,70,229,.12);
    font-size: 1.9rem; color: var(--primary);
    animation: session-badge-pop .5s cubic-bezier(.34,1.56,.64,1) both;
}
[data-bs-theme="dark"] .session-summary-badge { background: rgba(129,140,248,.16); color: #a5b4fc; }

@keyframes session-badge-pop {
    0% { transform: scale(.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.session-confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti-dot {
    position: absolute; top: 50%; left: 50%; width: 6px; height: 6px;
    margin: -3px 0 0 -3px; border-radius: 2px; background: var(--bg, var(--primary));
    opacity: 0;
    animation: confetti-burst .8s ease-out forwards;
}
@keyframes confetti-burst {
    0% { transform: translate(0, 0) scale(.4) rotate(0deg); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(180deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .session-summary-badge, .confetti-dot { animation: none; opacity: 1; transform: none; }
}

.session-summary-stats { margin-top: .25rem; }
.session-summary-accuracy span { transition: color .3s; }
.session-summary-accuracy.is-high span { color: #16a34a; }
.session-summary-accuracy.is-low span { color: #dc2626; }
[data-bs-theme="dark"] .session-summary-accuracy.is-high span { color: #4ade80; }
[data-bs-theme="dark"] .session-summary-accuracy.is-low span { color: #f87171; }

@media (max-width: 576px) {
    .study-wrapper { padding: .5rem; }

    /* Reorganiza o grid no mobile: estatísticas → progresso → card de
       estudo → "Encerrar estudo" + "Tela cheia" (lado a lado) → atalhos.
       Os dois botões só aparecem DEPOIS do #studyArea, como no desktop
       eles ficam nas pontas da 1ª linha, aqui viram sua própria linha,
       logo abaixo do card. */
    .study-grid {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "stats stats"
            "progress progress"
            "studyarea studyarea"
            "endbtn fullbtn"
            "shortcuts shortcuts";
        row-gap: .85rem;
        column-gap: .5rem;
    }
    .study-counts { gap: .4rem; }
    #btnEndStudy { justify-self: stretch; }
    #fullscreenBtn { justify-self: stretch; }
    .btn-end-study-label { display: inline; }
    .btn-study-action { padding: .6rem .9rem; }

    .study-count-box { flex: 1 1 0; min-width: 0; padding: .45rem .5rem; gap: .4rem; }
    .study-count-box-icon { width: 26px; height: 26px; font-size: .8rem; }
    .study-count { font-size: .95rem; }
    .study-count-box-body small { font-size: .55rem; }
    .study-card { padding: 1.25rem 1rem; min-height: unset; border-radius: 14px; }

    /* Modo tela cheia no celular: sem isso o card fica pequeno "flutuando"
       no meio de um vão enorme (o card centralizado num #studyArea que
       cresce pra ocupar a tela toda), e o cabeçalho gruda perto da
       câmera/notch. Aumenta o card pra ocupar mais da altura disponível
       e afasta o topo um pouco mais da borda da tela. */
    .study-wrapper:fullscreen,
    .study-wrapper:-webkit-full-screen {
        padding-top: clamp(2.5rem, 11vh, 4rem);
    }
    .study-wrapper:fullscreen .study-card,
    .study-wrapper:-webkit-full-screen .study-card {
        min-height: 48vh;
    }
    .study-card-meta { gap: .8rem; margin-bottom: .85rem; }
    .study-card-meta .badge-subject, .badge-cdiff { font-size: .68rem; }
    .study-card-topic { font-size: 1.05rem; }
    .btn-report { font-size: .85rem; padding: .2rem .4rem; }
    .study-card-title { font-size: .95rem; padding-bottom: .65rem; margin-bottom: .85rem; }
    .study-card-face { font-size: 1.05rem; line-height: 1.6; }
    .study-card-face#cardFront { text-align: left; font-size: 1.05rem; font-weight: 400; }
    .study-card-footer { margin-top: 1rem; padding-top: 1rem; }
    .study-actions .btn-lg { width: 100%; padding: .75rem 1rem; font-size: 1rem; }
    .study-rating { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
    .btn-rate { font-size: 1.2rem; padding: .7rem .4rem; }
    .btn-rate-time { font-size: .62rem; }
}

/* ---------------- Editor rico simples ---------------- */
.rich-toolbar { display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; background: #f1f5f9; border: 1px solid rgba(0,0,0,.1); border-bottom: none; border-radius: 8px 8px 0 0; padding: .35rem; }
.rich-toolbar button { border: none; background: transparent; color: #334155; width: 30px; height: 30px; border-radius: 6px; }
.rich-toolbar button:hover { background: rgba(0,0,0,.08); }
.rich-toolbar button.active { background: rgba(99,102,241,.18); color: #4f46e5; }
.rich-toolbar button:disabled { opacity: .4; pointer-events: none; }
.rich-toolbar-select { border: 1px solid rgba(0,0,0,.12); background: #fff; color: #1e293b; border-radius: 6px; font-size: .8rem; height: 30px; padding: 0 .3rem; margin-left: .15rem; }
[data-bs-theme="dark"] .rich-toolbar { background: #1e2230; border-color: rgba(255,255,255,.1); }
[data-bs-theme="dark"] .rich-toolbar button { color: #e2e8f0; }
[data-bs-theme="dark"] .rich-toolbar button:hover { background: rgba(255,255,255,.1); }
[data-bs-theme="dark"] .rich-toolbar button.active { background: rgba(99,102,241,.3); color: #c7d2fe; }
[data-bs-theme="dark"] .rich-toolbar-select { background: #1e2230; border-color: rgba(255,255,255,.15); color: #e2e8f0; }

.rich-color-picker { position: relative; }
.rich-toolbar .rich-toolbar-color-btn { width: 30px; height: 34px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 3px 0; }
.rich-color-text-icon { font-weight: 700; font-size: .8rem; line-height: 1; }
.rich-toolbar .rich-toolbar-color-btn .rich-color-bar { width: 18px; height: 3px; border-radius: 2px; border: 1px solid rgba(0,0,0,.15); }
.rich-color-popover { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; width: 216px; background: #fff; border: 1px solid rgba(0,0,0,.12); border-radius: 10px; padding: .6rem; box-shadow: 0 10px 28px rgba(0,0,0,.2); }
.rich-toolbar .rich-color-clear { width: 100%; height: auto; display: flex; align-items: center; gap: .5rem; border-radius: 6px; padding: .35rem .4rem; font-size: .8rem; margin-bottom: .45rem; }
.rich-toolbar .rich-color-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.rich-toolbar .rich-color-swatch { width: 16px; height: 16px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); padding: 0; }
.rich-toolbar .rich-color-swatch:hover { outline: 2px solid #6366f1; outline-offset: 1px; }
.rich-color-recent-label { font-size: .7rem; color: #64748b; margin: .5rem 0 .3rem; }
[data-bs-theme="dark"] .rich-color-popover { background: #1e2230; border-color: rgba(255,255,255,.15); }
[data-bs-theme="dark"] .rich-color-recent-label { color: #94a3b8; }
[data-bs-theme="dark"] .rich-toolbar .rich-color-swatch { border-color: rgba(255,255,255,.2); }
[data-bs-theme="dark"] .rich-toolbar .rich-toolbar-color-btn .rich-color-bar { border-color: rgba(255,255,255,.25); }

.rich-editable { border: 1px solid rgba(0,0,0,.1); border-radius: 0 0 8px 8px; min-height: 140px; padding: .6rem; background: #fff; }
[data-bs-theme="dark"] .rich-editable { background: #1e2230; border-color: rgba(255,255,255,.1); }
.rich-editable.rich-editable-source {
    font-family: Consolas, 'Courier New', monospace;
    font-size: .85rem;
    white-space: pre-wrap;
    word-break: break-all;
    background: #f8fafc;
}
[data-bs-theme="dark"] .rich-editable.rich-editable-source { background: #11141c; }

.rich-editable blockquote,
.study-card-face blockquote {
    margin: .5rem 0;
    padding: .4rem .9rem;
    border-left: 3px solid var(--primary);
    background: rgba(79,70,229,.06);
    color: #475569;
    font-style: italic;
}
[data-bs-theme="dark"] .rich-editable blockquote,
[data-bs-theme="dark"] .study-card-face blockquote { background: rgba(99,102,241,.14); color: #cbd5e1; }

.rich-editable pre,
.study-card-face pre {
    margin: .5rem 0;
    padding: .6rem .8rem;
    background: #f1f5f9;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 6px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: .85rem;
    white-space: pre-wrap;
    overflow-x: auto;
}
[data-bs-theme="dark"] .rich-editable pre,
[data-bs-theme="dark"] .study-card-face pre { background: #11141c; border-color: rgba(255,255,255,.08); color: #e2e8f0; }

.rich-editable code,
.study-card-face code {
    font-family: Consolas, 'Courier New', monospace;
    background: rgba(0,0,0,.06);
    padding: .1rem .3rem;
    border-radius: 4px;
    font-size: .85em;
}
[data-bs-theme="dark"] .rich-editable code,
[data-bs-theme="dark"] .study-card-face code { background: rgba(255,255,255,.1); }
.rich-editable pre code,
.study-card-face pre code { background: none; padding: 0; }

.js-cloze-btn { color: #4f46e5; }
[data-bs-theme="dark"] .js-cloze-btn { color: #a5b4fc; }

/* ---------------- Omissão de Palavras (cloze) ---------------- */
.cloze-blank {
    background: rgba(79, 70, 229, .14);
    border-radius: 4px;
    padding: 0 .2rem;
    filter: blur(5px);
    transition: filter .15s ease;
}
[data-bs-theme="dark"] .cloze-blank { background: rgba(99, 102, 241, .28); }
.rich-editable .cloze-blank:hover { filter: none; cursor: help; }
.study-card-face.cloze-revealed .cloze-blank { filter: none; background: rgba(34, 197, 94, .22); }

/* ---------------- Informação Extra (anotações em trechos do texto) ---------------- */
.js-annotate-btn { color: #f97316; }
[data-bs-theme="dark"] .js-annotate-btn { color: #fb923c; }

.fc-annotation {
    background: rgba(249, 115, 22, .10);
    border-bottom: 1px dashed rgba(249, 115, 22, .55);
    border-radius: 3px;
    padding: 0 .1rem;
    cursor: pointer;
    transition: background-color .15s ease;
}
.fc-annotation:hover { background: rgba(249, 115, 22, .2); }
[data-bs-theme="dark"] .fc-annotation { background: rgba(251, 146, 60, .14); border-bottom-color: rgba(251, 146, 60, .55); }
[data-bs-theme="dark"] .fc-annotation:hover { background: rgba(251, 146, 60, .24); }

.fc-annotation-popover {
    position: absolute;
    z-index: 1080;
    width: max-content;
    max-width: 320px;
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.16);
    padding: .75rem 1.6rem .75rem .9rem;
    font-size: .85rem;
    line-height: 1.5;
    color: #334155;
}
[data-bs-theme="dark"] .fc-annotation-popover { background: #1e2230; border-color: rgba(255,255,255,.1); color: #e2e8f0; }
.fc-annotation-popover-title {
    display: flex; align-items: center; gap: .4rem;
    font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em;
    color: #f97316; margin-bottom: .35rem;
}
[data-bs-theme="dark"] .fc-annotation-popover-title { color: #fb923c; }
.fc-annotation-popover-body { white-space: pre-line; word-break: break-word; }
.fc-annotation-popover-close {
    position: absolute; top: 6px; right: 8px; border: none; background: transparent;
    color: inherit; opacity: .5; cursor: pointer; font-size: 1.05rem; line-height: 1; padding: 2px 4px;
}
.fc-annotation-popover-close:hover { opacity: 1; }

/* ---------------- Calendário ---------------- */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: .78rem; border-radius: 6px; background: #f1f5f9; }
[data-bs-theme="dark"] .cal-cell { background: #1e2230; }
.cal-empty { background: transparent; }
.cal-low { background: #bbf7d0; }
.cal-mid { background: #4ade80; color: #fff; }
.cal-high { background: #16a34a; color: #fff; }
.cal-today { box-shadow: inset 0 0 0 2px var(--primary); font-weight: 700; }
.cal-cell:not(.cal-empty) { cursor: default; }

.cal-tooltip {
    position: absolute; z-index: 2000; pointer-events: none;
    background: #1e2230; color: #fff; padding: .55rem .75rem; border-radius: 8px;
    font-size: .8rem; line-height: 1.5; white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
    transform: translate(-50%, calc(-100% - 10px));
}
.cal-tooltip strong { display: block; font-weight: 600; }
.cal-tooltip span { display: block; color: #94a3b8; }

/* ---------------- Dashboard: Hoje / Previsão ---------------- */
.today-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.today-stat { text-align: center; }
.today-stat span { display: block; font-size: 1.3rem; font-weight: 700; line-height: 1.2; }
.today-stat small { color: #94a3b8; font-size: .72rem; }

.today-breakdown {
    display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .78rem; font-weight: 600;
    padding-top: .85rem; border-top: 1px solid rgba(0,0,0,.06);
}
[data-bs-theme="dark"] .today-breakdown { border-color: rgba(255,255,255,.06); }

.forecast-range { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; font-size: .85rem; }
.forecast-range label { display: flex; align-items: center; gap: .35rem; cursor: pointer; margin: 0; }

.forecast-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem 1rem; text-align: center; font-size: .8rem; }
.forecast-summary strong { font-size: 1.1rem; }
@media (min-width: 992px) {
    .forecast-summary { grid-template-columns: repeat(4, 1fr); }
}

/* ---------------- Admin ---------------- */
.admin-quick-link { display: block; background: #fff; border-radius: var(--radius); padding: 1.5rem; text-decoration: none; color: inherit; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
[data-bs-theme="dark"] .admin-quick-link { background: #161925; }
.admin-quick-link i { font-size: 1.8rem; color: var(--primary); margin-bottom: .5rem; }
.admin-quick-link:hover { transform: translateY(-2px); }

/* ---------------- Identidade Visual ---------------- */
.branding-preview {
    display: flex; align-items: center; justify-content: center;
    width: 96px; height: 96px; border-radius: var(--radius);
    background: #f1f5f9; border: 1px dashed #cbd5e1; overflow: hidden;
}
[data-bs-theme="dark"] .branding-preview { background: #161925; border-color: #2c3346; }
.branding-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.branding-preview i { font-size: 1.6rem; color: #94a3b8; }
.branding-preview.is-dark { background: #161925; border-color: #2c3346; }

/* ---------------- Perfil ---------------- */
.profile-avatar, .profile-avatar-fallback { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; }
.profile-avatar-fallback { background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; font-weight: 700; margin: 0 auto; }

/* ---------------- Responsivo ---------------- */
@media (max-width: 991px) {
    .app-sidebar { position: fixed; left: -260px; transition: left .2s; }
    .app-sidebar.open { left: 0; }
}

.flash-container { position: sticky; top: 70px; z-index: 80; }

/* ---------------- Cronograma de Estudos ---------------- */
.notif-dropdown { width: 320px; max-height: 400px; overflow-y: auto; padding-top: .5rem; }
.notif-dropdown .dropdown-item { white-space: normal; }

/* ---- Barra de ferramentas (período + navegação de semana) ---- */
.sched-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem;
    background: #fff; border-radius: var(--radius); padding: .9rem 1.1rem; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
[data-bs-theme="dark"] .sched-toolbar { background: #161925; }
.sched-toolbar-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.sched-toolbar-nav strong { min-width: 84px; text-align: center; font-size: .92rem; }

.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 999px; border: 1px solid rgba(0,0,0,.08);
    background: #fff; color: #475569; text-decoration: none; transition: .15s;
}
.btn-icon:hover { background: #f1f5f9; color: var(--primary); }
[data-bs-theme="dark"] .btn-icon { background: #1e2230; border-color: rgba(255,255,255,.08); color: #cbd5e1; }
[data-bs-theme="dark"] .btn-icon:hover { background: #262b3d; }
.btn-icon-sm { width: 30px; height: 30px; font-size: .8rem; border: none; background: transparent; }
.btn-icon-xs { width: 24px; height: 24px; font-size: .7rem; border: none; background: transparent; }
.btn-icon-sm:hover, .btn-icon-xs:hover { background: rgba(79,70,229,.1); color: var(--primary); }

/* ---- Indicadores discretos ---- */
.sched-stats { display: flex; flex-wrap: wrap; gap: .5rem; }
.sched-stat {
    flex: 1 1 140px; display: flex; align-items: baseline; gap: .4rem;
    background: #fff; border-radius: 10px; padding: .55rem .85rem; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
[data-bs-theme="dark"] .sched-stat { background: #161925; }
.sched-stat-value { font-size: 1.05rem; font-weight: 700; }
.sched-stat-label { font-size: .74rem; color: #94a3b8; display: inline-flex; align-items: center; gap: .3rem; }
.sched-stat-label i { font-size: .7rem; opacity: .7; }

/* ---- Estado vazio da semana ---- */
.sched-week-empty {
    text-align: center; padding: 3rem 1.5rem; background: #fff; border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.05); margin-bottom: 1rem;
}
[data-bs-theme="dark"] .sched-week-empty { background: #161925; }
.sched-week-empty i { font-size: 2.4rem; color: #c7d2fe; margin-bottom: .75rem; display: block; }
[data-bs-theme="dark"] .sched-week-empty i { color: #3730a3; }
.sched-week-empty h5 { margin-bottom: .25rem; }
.sched-week-empty p { margin-bottom: 1rem; }

/* ---- Grade semanal ---- */
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(220px, 1fr)); gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.day-col { background: #fff; border-radius: var(--radius); padding: .7rem; box-shadow: 0 1px 3px rgba(0,0,0,.05); display: flex; flex-direction: column; gap: .6rem; }
[data-bs-theme="dark"] .day-col { background: #161925; }
.day-col.is-today { box-shadow: 0 0 0 2px var(--primary), 0 1px 3px rgba(0,0,0,.05); }

.day-col-header { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.day-col-heading { display: flex; align-items: baseline; gap: .4rem; }
.day-col-heading .day-name { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .02em; }
.day-col.is-today .day-col-heading .day-name { color: var(--primary); }
.day-col-heading .day-date { font-size: .78rem; color: #94a3b8; }
.day-col-actions { display: flex; align-items: center; gap: .1rem; opacity: .55; transition: opacity .15s; }
.day-col:hover .day-col-actions, .day-col-actions:focus-within { opacity: 1; }

.day-empty-hint { display: none; flex-direction: column; align-items: center; gap: .35rem; color: #cbd5e1; padding: .75rem 0 .25rem; font-size: .78rem; }
.day-col.is-empty .day-empty-hint { display: flex; }
.day-empty-hint i { font-size: 1.3rem; }
[data-bs-theme="dark"] .day-empty-hint { color: #3f4a63; }

.day-section { display: flex; flex-direction: column; gap: .4rem; }
.day-section-header { display: flex; align-items: center; justify-content: space-between; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #94a3b8; }
.day-section-header .day-section-emoji { margin-right: .35rem; font-size: .9rem; }
[data-bs-theme="dark"] .day-section-header { color: #64748b; }
.day-section-body { display: flex; flex-direction: column; gap: .5rem; min-height: 8px; border-radius: 8px; transition: background-color .15s; padding: 2px; }
.day-section-body.is-drag-over { background: rgba(79,70,229,.08); outline: 2px dashed rgba(79,70,229,.35); outline-offset: 2px; }

/* ---------------- Dashboard: chamada para preferências de estudo ---------------- */
.dashboard-cta {
    display: flex; align-items: center; gap: 1rem;
    background: linear-gradient(135deg, rgba(79,70,229,.08), rgba(79,70,229,.02));
    border: 1px solid rgba(79,70,229,.18);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    text-decoration: none; color: inherit;
    transition: transform .15s ease, box-shadow .15s ease;
}
.dashboard-cta:hover, .dashboard-cta:focus-visible { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(79,70,229,.15); color: inherit; }
[data-bs-theme="dark"] .dashboard-cta { background: linear-gradient(135deg, rgba(129,140,248,.14), rgba(129,140,248,.03)); border-color: rgba(129,140,248,.28); }
.dashboard-cta-icon {
    flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
}
.dashboard-cta-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.dashboard-cta-body strong { font-size: .98rem; }
.dashboard-cta-body span { font-size: .84rem; color: #64748b; }
[data-bs-theme="dark"] .dashboard-cta-body span { color: #94a3b8; }
.dashboard-cta-arrow { color: var(--primary); font-size: .85rem; flex: 0 0 auto; }
@media (max-width: 575px) {
    .dashboard-cta-arrow { display: none; }
}

/* ---------------- Preferências de estudo (por usuário) ---------------- */
.settings-grid { display: flex; flex-direction: column; gap: 1.25rem; }

.settings-section-head {
    display: flex; flex-wrap: wrap; align-items: flex-start; gap: .85rem;
    margin-bottom: 1.1rem; padding-bottom: .9rem;
    border-bottom: 1px solid rgba(0,0,0,.06);
}
[data-bs-theme="dark"] .settings-section-head { border-color: rgba(255,255,255,.08); }
.settings-section-head > i {
    flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px;
    background: rgba(79,70,229,.1); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
[data-bs-theme="dark"] .settings-section-head > i { background: rgba(129,140,248,.16); }
.settings-section-head > div { flex: 1 1 200px; min-width: 0; }
.settings-section-head h5 { margin-bottom: .15rem; }
.settings-section-head > .settings-badge { margin-left: auto; align-self: center; }

.settings-label { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-weight: 600; font-size: .88rem; margin-bottom: .35rem; }

.settings-badge {
    display: inline-flex; align-items: center;
    font-size: .66rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
    padding: .15rem .55rem; border-radius: 999px;
    background: #eef0f4; color: #64748b; white-space: nowrap;
}
[data-bs-theme="dark"] .settings-badge { background: #262b3d; color: #94a3b8; }
.settings-badge.is-custom { background: rgba(79,70,229,.14); color: var(--primary); }
[data-bs-theme="dark"] .settings-badge.is-custom { background: rgba(129,140,248,.2); color: #a5b4fc; }

.settings-today-section { border: 1px solid rgba(245,158,11,.35); background: rgba(245,158,11,.05); }
[data-bs-theme="dark"] .settings-today-section { background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.32); }
.settings-today-section .settings-section-head { border-bottom-color: rgba(245,158,11,.25); }
.settings-today-section .settings-section-head > i { background: rgba(245,158,11,.18); color: #b45309; }
[data-bs-theme="dark"] .settings-today-section .settings-section-head > i { background: rgba(245,158,11,.22); color: #fbbf24; }
.section-empty { margin: 0; font-size: .74rem; color: #cbd5e1; padding: .2rem 0; }
[data-bs-theme="dark"] .section-empty { color: #3f4a63; }

/* ---- Cartão de bloco de estudo ---- */
.study-block-card {
    background: #f8fafc; border-radius: 10px; padding: .55rem .65rem;
    border-left: 3px solid #94a3b8; cursor: grab; transition: box-shadow .15s, transform .15s, opacity .15s;
}
[data-bs-theme="dark"] .study-block-card { background: #1e2230; }
.study-block-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.study-block-card.is-dragging { opacity: .4; }
.study-block-card.priority-alta { border-left-color: #ef4444; }
.study-block-card.priority-media { border-left-color: #f59e0b; }
.study-block-card.priority-baixa { border-left-color: #22c55e; }

.study-block-top { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-bottom: .3rem; }
.study-block-time { font-size: .78rem; }
.study-block-subject { display: flex; align-items: center; font-size: .84rem; font-weight: 600; margin-top: .1rem; }
.study-block-notes { font-style: italic; }
.study-block-footer { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-top: .45rem; }
.study-block-actions { display: flex; align-items: center; gap: .05rem; opacity: 0; transition: opacity .15s; }
.study-block-card:hover .study-block-actions, .study-block-actions:focus-within { opacity: 1; }

.badge-priority { padding: .15rem .5rem; border-radius: 999px; font-size: .68rem; font-weight: 600; }
.priority-badge-alta { background: #fee2e2; color: #991b1b; }
.priority-badge-media { background: #fef3c7; color: #92400e; }
.priority-badge-baixa { background: #dcfce7; color: #166534; }
[data-bs-theme="dark"] .priority-badge-alta { background: rgba(239,68,68,.18); color: #fca5a5; }
[data-bs-theme="dark"] .priority-badge-media { background: rgba(245,158,11,.18); color: #fcd34d; }
[data-bs-theme="dark"] .priority-badge-baixa { background: rgba(34,197,94,.18); color: #86efac; }

.status-pill.block-status-nao_iniciado { background: #e2e8f0; }
.status-pill.block-status-em_andamento { background: #dbeafe; color: #1e40af; }
.status-pill.block-status-concluido { background: #dcfce7; color: #166534; }
.status-pill.block-status-adiado { background: #fef3c7; color: #92400e; }
.status-pill.block-status-cancelado { background: #fee2e2; color: #991b1b; }

.sched-cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: .78rem; color: #94a3b8; margin-bottom: 4px; }
.sched-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.sched-cal-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: .82rem; border-radius: 6px; background: #f1f5f9; cursor: pointer; }
[data-bs-theme="dark"] .sched-cal-cell { background: #1e2230; }
.sched-cal-cell.sched-cal-empty { background: transparent; cursor: default; }
.sched-cal-cell.sched-done { background: #22c55e; color: #fff; }
.sched-cal-cell.sched-partial { background: #f59e0b; color: #fff; }
.sched-cal-cell.sched-missed { background: #ef4444; color: #fff; }
.sched-cal-cell.sched-today { background: var(--primary); color: #fff; font-weight: 700; }
.sched-cal-cell.sched-future { background: #f1f5f9; color: #94a3b8; }
[data-bs-theme="dark"] .sched-cal-cell.sched-future { background: #1e2230; color: #64748b; }

.sched-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.sched-legend-dot.sched-done { background: #22c55e; }
.sched-legend-dot.sched-partial { background: #f59e0b; }
.sched-legend-dot.sched-missed { background: #ef4444; }
.sched-legend-dot.sched-today { background: var(--primary); }
.sched-legend-dot.sched-future { background: #cbd5e1; }

/* ---- Modal de bloco: duração automática + "mais opções" ---- */
.duration-display {
    height: calc(1.5em + .75rem + 2px); display: flex; align-items: center; justify-content: center;
    background: #f1f5f9; border-radius: .375rem; font-size: .8rem; font-weight: 600; color: #64748b;
}
[data-bs-theme="dark"] .duration-display { background: #1e2230; color: #cbd5e1; }

.btn-more-options {
    border: none; background: transparent; color: var(--primary); font-size: .84rem; font-weight: 600;
    padding: .2rem 0; display: inline-flex; align-items: center;
}
.btn-more-options i { transition: transform .15s; }
.more-options-panel { padding-top: .25rem; border-top: 1px dashed rgba(0,0,0,.08); margin-top: .25rem; }
[data-bs-theme="dark"] .more-options-panel { border-color: rgba(255,255,255,.1); }

/* ---- Responsivo ---- */
@media (max-width: 767px) {
    .week-grid { grid-template-columns: repeat(7, 82vw); }
    .day-col { scroll-snap-align: start; }
    .week-grid { scroll-snap-type: x mandatory; }
    .sched-toolbar { flex-direction: column; align-items: stretch; }
    .sched-toolbar-nav { justify-content: space-between; }
    .sched-stats { gap: .4rem; }
    .sched-stat { flex-basis: 45%; }
}
