/* ============================================================================
   study-app — DESIGN SYSTEM · componentes
   Classes reutilizáveis que reproduzem o vocabulário visual do mockup.
   Depende dos tokens de theme.css. Telas devem COMPOR estas classes.
   ============================================================================ */

/* ============================ ÍCONES ============================ */
/* Tamanho padrão dos ícones (.ic). Regras de contexto (.btn svg, .tab svg,
   .kpi__icon svg, .badge svg…) sobrepõem. inline-block + vertical-align deixam o
   ícone alinhado ao texto quando aparece solto numa linha. */
.ic { display: inline-block; width: 1em; height: 1em; vertical-align: -0.15em; flex: none; }

/* ============================ APP SHELL ============================ */
.app { min-height: 100%; }

/* --- desktop: sidebar + topbar; mobile: topbar + bottom nav --- */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; min-height: 100dvh; }
@media (min-width: 1024px) {
  .shell { grid-template-columns: var(--sidebar-w) 1fr; }
}

/* ---- Sidebar (desktop) ---- */
.sidebar { display: none; }
@media (min-width: 1024px) {
  .sidebar {
    display: flex; flex-direction: column;
    background: var(--bg-elev); border-right: 1px solid var(--line-soft);
    position: sticky; top: 0; height: 100vh; height: 100dvh;
  }
}
.sidebar__brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); border-bottom: 1px solid var(--line-soft); }
.sidebar__logo {
  width: 34px; height: 34px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--indigo-500), var(--indigo-600));
  display: flex; align-items: center; justify-content: center; color: #fff; flex: none;
  box-shadow: var(--shadow-sm);
}
.sidebar__title { font-weight: 800; font-size: var(--text-sm); letter-spacing: .2px; }
.sidebar__sub { font-size: var(--text-2xs); color: var(--faint); font-weight: 600; }
.sidebar__nav { flex: 1; padding: var(--sp-3); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar__group { font-size: var(--text-2xs); font-weight: 800; color: var(--faint);
  text-transform: uppercase; letter-spacing: .12em; padding: var(--sp-3) var(--sp-2) var(--sp-1); }
.sidebar__foot { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line-soft); }

.navlink {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px var(--sp-3); border-radius: var(--r-lg);
  color: var(--muted); font-weight: 600; font-size: var(--text-sm);
  transition: background var(--transition), color var(--transition);
}
.navlink:hover { background: var(--surface-2); color: var(--fg-soft); }
.navlink.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.navlink svg { width: 18px; height: 18px; flex: none; }
.navlink__badge { margin-left: auto; }

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-4); background: color-mix(in srgb, var(--bg-elev) 86%, transparent);
  backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--line-soft);
}
.topbar__title { font-size: var(--text-2xs); font-weight: 800; color: var(--faint);
  text-transform: uppercase; letter-spacing: .14em; }
@media (max-width: 600px) { .topbar__title { display: none; } }   /* espaço p/ os ícones no celular */
.topbar__brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 800; }
@media (min-width: 1024px) { .topbar__brand { display: none; } }
.topbar__logo { width: 28px; height: 28px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--indigo-500), var(--indigo-600));
  display: flex; align-items: center; justify-content: center; color: #fff; }
.topbar [data-nav].is-active { color: var(--primary); background: var(--primary-soft); }
.avatar { width: 32px; height: 32px; border-radius: var(--r-full); background: var(--primary);
  color: var(--on-primary); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: var(--text-xs); flex: none; }

/* ---- Main / content ---- */
.main { min-width: 0; display: flex; flex-direction: column; }
.content {
  flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) calc(var(--bottomnav-h) + var(--sp-6));
  display: flex; flex-direction: column; gap: var(--sp-4);
}
@media (min-width: 1024px) { .content { padding: var(--sp-6); padding-bottom: var(--sp-10); } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.page-title { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -.02em; }
.page-sub { font-size: var(--text-xs); font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }

/* ---- Bottom nav (mobile) ---- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px); border-top: 1px solid var(--line-soft);
}
@media (min-width: 1024px) { .bottomnav { display: none; } }
.bottomnav__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--faint); font-size: var(--text-2xs); font-weight: 700;
  transition: color var(--transition); position: relative;
}
.bottomnav__item svg { width: 22px; height: 22px; }
.bottomnav__item.is-active { color: var(--primary); }
.bottomnav__item.is-active::before {
  content: ""; position: absolute; top: 0; width: 26px; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--primary);
}

/* ============================ CARDS ============================ */
.card {
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-radius: var(--r-2xl); box-shadow: var(--shadow-sm);
}
.card--pad { padding: var(--sp-4); }
.card--pad-lg { padding: var(--sp-6); }
.card--hover { transition: box-shadow var(--transition), transform var(--transition); }
.card--hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.card--accent { border-color: var(--primary-soft); }
.card-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.card-title { font-size: var(--text-sm); font-weight: 700; color: var(--fg-soft); }

/* "section header" colapsável estilo mockup */
.section { background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-radius: var(--r-2xl); box-shadow: var(--shadow-sm); }
.section__head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4); gap: var(--sp-3); }
.section__title { font-size: var(--text-sm); font-weight: 700; }
.section__desc { font-size: var(--text-xs); color: var(--muted); margin-top: 1px; }

/* ============================ BOTÕES ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 var(--sp-4);
  border-radius: var(--r-lg); font-weight: 700; font-size: var(--text-sm);
  border: 1px solid transparent; transition: background var(--transition),
    border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap; user-select: none;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn--primary:hover:not(:disabled) { background: var(--primary-strong); box-shadow: 0 4px 16px var(--primary-ring); }
.btn--ghost { background: var(--bg-elev); color: var(--fg-soft); border-color: var(--line); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn--subtle { background: var(--surface-2); color: var(--fg-soft); }
.btn--subtle:hover:not(:disabled) { background: var(--line); }
.btn--danger { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.btn--danger:hover:not(:disabled) { background: color-mix(in srgb, var(--bad) 16%, var(--bg-elev)); }
.btn--block { display: flex; width: 100%; }
.btn--lg { min-height: 52px; font-size: var(--text-base); border-radius: var(--r-xl); padding: 0 var(--sp-6); }
.btn--sm { min-height: 40px; font-size: var(--text-xs); padding: 0 var(--sp-3); border-radius: var(--r-md); }
.btn--icon { padding: 0; width: var(--tap); flex: none; }
.btn--icon.btn--sm { width: 40px; }
.btn--lg.btn--icon { width: 52px; }   /* mantém quadrado no tamanho grande */

/* barra de ações fixada acima da bottom-nav (mobile); cola no fundo no desktop */
.sticky-actions { position: sticky; bottom: calc(var(--bottomnav-h) + var(--sp-2)); z-index: 10; }
@media (min-width: 1024px) { .sticky-actions { bottom: var(--sp-4); } }

/* FAB (mobile) */
.fab {
  position: fixed; right: var(--sp-4); bottom: calc(var(--bottomnav-h) + var(--sp-4) + env(safe-area-inset-bottom));
  z-index: 25; min-height: 56px; padding: 0 var(--sp-5); border-radius: var(--r-full);
  background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-lg);
  display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 800;
}
@media (min-width: 1024px) { .fab { display: none; } }

/* ============================ CHIPS / PILLS ============================ */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
  padding: 0 var(--sp-3); border-radius: var(--r-full); border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--fg-soft); font-size: var(--text-xs); font-weight: 700;
  transition: all var(--transition); cursor: pointer;
}
.chip:hover { border-color: var(--indigo-300); }
.chip.chip--on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chip .chip__n { opacity: .7; font-size: var(--text-2xs); }
.chip.chip--on .chip__n { opacity: .85; }
.chip--sm { min-height: 32px; padding: 0 var(--sp-2); font-size: var(--text-2xs); }

/* ============================ FILTER PANEL ============================ */
.filter-panel { display: flex; flex-direction: column; gap: var(--sp-4); }
.filter-section__head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2);
}
.filter-section__title { font-weight: 700; font-size: var(--text-sm); color: var(--fg-soft); }
.filter-section__chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.filter-section__chips--scroll { max-height: 180px; overflow-y: auto; scrollbar-width: thin; }
.chip-search {
  width: 100%; padding: var(--sp-1) var(--sp-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: var(--text-xs); background: var(--surface-2);
  color: var(--fg); margin-bottom: var(--sp-2);
}
.chip-search::placeholder { color: var(--muted); }
.filter-panel__clear { font-size: var(--text-xs); color: var(--muted); cursor: pointer; text-decoration: underline; }
.filter-panel__clear:hover { color: var(--fg-soft); }

/* ============================ QUIZ WIZARD ============================ */
.wizard { display: flex; flex-direction: column; gap: var(--sp-4); }
.wizard__label { font-weight: 700; font-size: var(--text-sm); color: var(--fg-soft); margin-bottom: var(--sp-2); }
.wizard__options { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.qty-picker { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.qty-picker .chip { min-width: 48px; text-align: center; justify-content: center; }
.quiz-summary { font-size: var(--text-sm); color: var(--muted); padding: var(--sp-2) 0; }

/* ============================ BADGES ============================ */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: var(--r-full); font-size: var(--text-2xs); font-weight: 800; line-height: 1.6; }
.badge--primary { background: var(--primary-soft); color: var(--primary); }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--bad { background: var(--bad-bg); color: var(--bad); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--info { background: var(--info-bg); color: var(--info); }
.badge--neutral { background: var(--surface-2); color: var(--muted); }
.badge--count { background: var(--red-600); color: #fff; min-width: 18px; height: 18px;
  justify-content: center; padding: 0 5px; }

.dot { width: 8px; height: 8px; border-radius: var(--r-full); flex: none; }
.dot--ok { background: var(--emerald-500); } .dot--bad { background: var(--red-500); }
.dot--warn { background: var(--amber-500); } .dot--muted { background: var(--slate-400); }
/* ping (pulso) — status ao vivo */
.ping { position: relative; display: inline-flex; }
.ping__core { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--emerald-500); }
.ping__wave { position: absolute; inset: 0; border-radius: var(--r-full); background: var(--emerald-500);
  opacity: .75; animation: ping 1.6s cubic-bezier(0,0,.2,1) infinite; }
@keyframes ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }

/* ============================ KPI ============================ */
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi__top { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: 4px; }
.kpi__icon { width: 30px; height: 30px; border-radius: var(--r-md); display: flex;
  align-items: center; justify-content: center; flex: none; }
.kpi__icon svg { width: 16px; height: 16px; }
.kpi__label { font-size: var(--text-2xs); font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; }
.kpi__value { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -.02em; }
.kpi__hint { font-size: var(--text-xs); font-weight: 700; color: var(--muted); }
/* fundos tonais p/ ícones de KPI */
.tone-indigo { background: var(--primary-soft); color: var(--primary); }
.tone-ok { background: var(--ok-bg); color: var(--ok); }
.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-info { background: var(--info-bg); color: var(--info); }

/* grids responsivos comuns */
.grid { display: grid; gap: var(--sp-3); }
.grid--kpi { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .grid--kpi { grid-template-columns: repeat(4, 1fr); } }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

/* ============================ PROGRESS ============================ */
.bar { width: 100%; height: 8px; background: var(--surface-2); border-radius: var(--r-full); overflow: hidden; }
.bar__fill { height: 100%; background: var(--primary); border-radius: var(--r-full);
  transition: width .4s cubic-bezier(.4,0,.2,1); }
.bar__fill--ok { background: var(--emerald-500); }
.bar__fill--warn { background: var(--amber-500); }
.bar__fill--bad { background: var(--red-500); }

/* anel de progresso (SVG) helper de cor */
.ring-track { stroke: var(--surface-2); } .ring-fill { stroke: var(--primary); }

/* ============================ FORM ============================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--text-xs); font-weight: 700; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 0 var(--sp-3);
  background: var(--bg-elev); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--r-lg); font-size: var(--text-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.textarea { padding: var(--sp-3); min-height: 80px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg { position: absolute; left: var(--sp-3); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.input-wrap > .input { padding-left: calc(var(--sp-3) + 20px); }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) 0; }
.field-row + .field-row { border-top: 1px solid var(--line-soft); }
.field-row__text { min-width: 0; }
.field-row__title { font-weight: 600; font-size: var(--text-sm); }
.field-row__desc { font-size: var(--text-xs); color: var(--muted); margin-top: 1px; }

/* switch */
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track { position: absolute; inset: 0; background: var(--line); border-radius: var(--r-full);
  transition: background var(--transition); }
.switch__thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: var(--r-full);
  background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--transition); }
.switch input:checked ~ .switch__track { background: var(--primary); }
.switch input:checked ~ .switch__thumb { transform: translateX(18px); }

/* slider */
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: var(--r-full);
  background: var(--surface-2); outline: none; }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); box-shadow: var(--shadow-sm); cursor: pointer; }
.slider::-moz-range-thumb { width: 20px; height: 20px; border: none; border-radius: 50%; background: var(--primary); cursor: pointer; }

/* segmented control (tabs) */
.tabs { display: inline-flex; background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-radius: var(--r-xl); padding: 4px; gap: 2px; box-shadow: var(--shadow-sm); }
.tab { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px var(--sp-3); border-radius: var(--r-md); font-size: var(--text-sm); font-weight: 700;
  color: var(--muted); transition: all var(--transition); min-width: 0; }
.tab svg { width: 16px; height: 16px; flex: none; }
.tab:hover { color: var(--fg-soft); }
.tab.is-active { background: var(--primary-soft); color: var(--primary); }
/* logos e ícones de badge com tamanho próprio (não herdam 1em) */
.sidebar__logo svg, .topbar__logo svg { width: 18px; height: 18px; }
.badge svg { width: 13px; height: 13px; flex: none; }

/* ============================ BANNER / ALERT ============================ */
.alert { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-xl);
  font-size: var(--text-sm); line-height: 1.45; border: 1px solid transparent; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert--warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert--info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert--bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert b { color: var(--fg); }

/* ============================ EMPTY STATE ============================ */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-4); color: var(--faint); }
.empty svg { width: 44px; height: 44px; opacity: .5; }
.empty__title { font-weight: 700; color: var(--muted); font-size: var(--text-sm); }
.empty__desc { font-size: var(--text-xs); color: var(--muted); }

/* ============================ TOAST ============================ */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--bottomnav-h) + var(--sp-4));
  z-index: 60; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  pointer-events: none; padding: 0 var(--sp-4); }
@media (min-width: 1024px) { .toast-wrap { bottom: var(--sp-6); right: var(--sp-6); left: auto; align-items: flex-end; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-xl); background: var(--slate-900); color: #fff;
  font-size: var(--text-sm); font-weight: 600; box-shadow: var(--shadow-xl);
  animation: toast-in .25s cubic-bezier(.2,.8,.2,1); max-width: 420px; }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast--ok { background: var(--emerald-600); } .toast--bad { background: var(--red-600); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ============================ MODAL / SHEET ============================ */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(2, 6, 23, .5);
  display: flex; align-items: center; justify-content: center; padding: var(--sp-4);
  animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--bg-elev); border-radius: var(--r-3xl); box-shadow: var(--shadow-xl);
  width: 100%; max-width: 440px; padding: var(--sp-6); animation: modal-in .25s cubic-bezier(.2,.8,.2,1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
/* em telas pequenas, vira bottom-sheet */
@media (max-width: 640px) {
  .overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; border-radius: var(--r-3xl) var(--r-3xl) 0 0; padding-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom)); }
}

/* ============================ SKELETON ============================ */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-soft) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-md); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ============================ QUIZ OPTIONS ============================ */
.opt {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line);
  border-radius: var(--r-xl); background: var(--bg-elev);
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.opt__ltr {
  width: 26px; height: 26px; border-radius: var(--r-full); flex: none;
  background: var(--surface-2); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: var(--text-xs);
}
.opt:disabled { opacity: 1; cursor: default; color: var(--fg); }
.opt--tap { cursor: pointer; }
.opt--tap:hover { border-color: var(--indigo-300); }
.opt--tap:focus-visible { border-color: var(--primary); }
.opt--tap:active { transform: scale(.99); }
.opt--ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.opt--ok .opt__ltr { background: var(--ok); color: #fff; }
.opt--bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.opt--bad .opt__ltr { background: var(--bad); color: #fff; }
.opt--sel { border-color: var(--primary); background: var(--primary-soft); }  /* escolha sem correção */
.opt--sel .opt__ltr { background: var(--primary); color: var(--on-primary); }

/* ============================ IMAGENS DE QUESTÃO ============================ */
.q-imgs { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.q-img { max-width: 100%; max-height: 340px; border-radius: var(--r-lg); border: 1px solid var(--line);
  background: var(--bg-sunk); object-fit: contain; cursor: zoom-in; }
.q-cap { font-size: var(--text-xs); color: var(--muted); line-height: 1.35; margin-top: 4px; }
.q-cred { font-size: var(--text-xs); color: var(--faint); margin-top: var(--sp-2); }

/* ============================ CHAT (tutor) ============================ */
.chat { display: flex; flex-direction: column; gap: var(--sp-3); }
.msg { display: flex; gap: var(--sp-2); max-width: 88%; }
.msg__bubble { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-2xl); font-size: var(--text-sm); line-height: 1.5; white-space: pre-wrap; }
.msg--user { align-self: flex-end; flex-direction: row-reverse; }
.msg--user .msg__bubble { background: var(--primary); color: var(--on-primary); border-bottom-right-radius: var(--r-sm); }
.msg--bot .msg__bubble { background: var(--bg-elev); border: 1px solid var(--line-soft); border-bottom-left-radius: var(--r-sm); box-shadow: var(--shadow-sm); }
.msg__avatar { width: 30px; height: 30px; border-radius: var(--r-full); flex: none; display: flex; align-items: center; justify-content: center; }
.msg--bot .msg__avatar { background: var(--primary-soft); color: var(--primary); }
.msg__src { margin-top: var(--sp-2); font-size: var(--text-2xs); color: var(--muted); }
.msg__src a, .msg__src span { display: inline-block; background: var(--surface-2); border-radius: var(--r-full); padding: 1px 8px; margin: 2px 4px 0 0; }
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* mic em escuta — pulsa */
.mic-live { position: relative; }
.mic-live::after { content: ""; position: absolute; inset: -4px; border-radius: var(--r-full);
  border: 2px solid var(--primary); opacity: .6; animation: ping 1.4s cubic-bezier(0,0,.2,1) infinite; }

/* ============================ HEATMAP (progresso) ============================ */
.heat { display: grid; gap: 4px; align-items: center; }
.heat__cell { min-height: 34px; border-radius: var(--r-sm); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-size: var(--text-2xs); font-weight: 700; }
.heat__h { font-size: var(--text-2xs); font-weight: 800; color: var(--muted); text-align: center; }
.heat__row { font-size: var(--text-xs); font-weight: 600; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; padding-right: 6px; }

/* ============================ SKIP LINK ============================ */
.skip-link { position: fixed; left: 8px; top: -60px; z-index: 100; background: var(--primary);
  color: var(--on-primary); padding: 10px 16px; border-radius: var(--r-md); font-weight: 700;
  font-size: var(--text-sm); box-shadow: var(--shadow-lg); transition: top .15s; }
.skip-link:focus { top: 8px; }

/* ============================ SR-ONLY ============================ */
.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; }
