:root{
  --bg: #f5f8ff;
  --card: #ffffff;
  --text: #0d1526;
  --muted: #5b6b86;
  --line: rgba(13,21,38,.10);
  --shadow: 0 18px 50px rgba(13,21,38,.08);
  --shadow2: 0 8px 24px rgba(13,21,38,.08);
  --blue: #2f6bff;
  --blue2: #2458d6;
  --good: #19b36b;
  --bad: #ff3b3b;
  --pill: rgba(47,107,255,.10);
  --radius: 18px;

  --fs: 16px;
  --h1: 44px;
  --h2: 22px;
  --w600: 600;
  --w500: 500;
  --w400: 400;
}

html[data-font="lg"]{
  --fs: 18px;
  --h1: 46px;
  --h2: 24px;
}

html[data-theme="dark"]{
  --bg: #0b1220;
  --card: #0f1a2e;
  --text: #eaf0ff;
  --muted: rgba(234,240,255,.70);
  --line: rgba(234,240,255,.10);
  --shadow: 0 18px 50px rgba(0,0,0,.35);
  --shadow2: 0 8px 24px rgba(0,0,0,.35);
  --pill: rgba(47,107,255,.18);
}

*{ box-sizing: border-box; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  font-size: var(--fs);
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 25% 0%, rgba(47,107,255,.15), transparent 60%),
    radial-gradient(900px 500px at 80% 20%, rgba(47,107,255,.08), transparent 60%),
    var(--bg);
}

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

.topbar{
  position: sticky;
  top:0;
  z-index: 10;
  background: rgba(245,248,255,.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
html[data-theme="dark"] .topbar{
  background: rgba(11,18,32,.75);
}
.topbar__inner{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 18px 18px;
  max-width: 1140px;
  margin: 0 auto;
}
.brand__title{
  font-weight: var(--w600);
  letter-spacing: -0.02em;
  font-size: 22px;
}
.brand__title--logo{
  /* o logo já contém o nome; evita altura extra de linha */
  line-height: 0;
}
.brand__logo{
  display:block;
  height: 34px;
  width: auto;
}
@media (max-width: 520px){
  .brand__logo{ height: 30px; }
}
.brand__subtitle{
  margin-top: 4px;
  color: var(--muted);
  font-weight: var(--w400);
  font-size: 14px;
}
.brand__subtitle--mobile{
  display:none;
  padding: 0 18px 14px;
  max-width: 1140px;
  margin: 0 auto;
}

.actions{
  display:flex;
  gap: 10px;
  align-items:center;
}

.iconbtn{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  display:grid;
  place-items:center;
  cursor:pointer;
  box-shadow: var(--shadow2);
  font-size: 18px;
  color: var(--text);
}
html[data-theme="dark"] .iconbtn{
  background: rgba(255,255,255,.04);
}
.iconbtn--ghost{
  box-shadow: none;
  background: transparent;
}

.pillbtn{
  height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  cursor:pointer;
  box-shadow: var(--shadow2);
  font-weight: var(--w500);
  color: var(--text);
}
html[data-theme="dark"] .pillbtn{
  background: rgba(255,255,255,.04);
}

.page{ padding: 26px 18px 40px; }
.shell{
  max-width: 1140px;
  margin: 0 auto;
}

.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.hero{
  padding: 32px 30px;
}

.h1{
  margin:0;
  font-size: var(--h1);
  letter-spacing: -0.03em;
  font-weight: var(--w600);
}
.lead{
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: var(--w400);
}

.grid{
  margin-top: 22px;
  display:grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 18px;
}

.subgrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.box{
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.55);
}
html[data-theme="dark"] .box{
  background: rgba(255,255,255,.03);
}
.box h3{
  margin:0;
  font-size: var(--h2);
  font-weight: var(--w600);
  letter-spacing: -0.02em;
}
.box .muted{ color: var(--muted); margin-top: 6px; }

.sectionTitle{
  margin: 18px 0 10px;
  font-weight: var(--w600);
  color: var(--text);
}

.subjectCard{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.70);
}
html[data-theme="dark"] .subjectCard{
  background: rgba(255,255,255,.03);
}
.subjectCard__name{
  font-weight: var(--w600);
  letter-spacing: -0.01em;
}
.subjectCard__meta{
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.btnRow{
  display:flex;
  gap: 10px;
  align-items:center;
}

.btn{
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: transparent;
  cursor:pointer;
  font-weight: var(--w500);
  color: var(--text);
}

.btn--sm{
  height: 36px;
  padding: 0 12px;
  font-size: 14px;
  border-radius: 12px;
}
.btn--primary{
  background: var(--blue);
  color: #fff;
  border-color: transparent;
}
.btn--primary:hover{ background: var(--blue2); }
.btn--soft{
  background: rgba(47,107,255,.08);
}
.btn--danger{
  background: rgba(255,59,59,.12);
  border-color: rgba(255,59,59,.20);
  color: var(--text);
}

.kpiGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.kpi{
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.65);
}
html[data-theme="dark"] .kpi{ background: rgba(255,255,255,.03); }
.kpi__title{ font-weight: var(--w600); margin-bottom: 10px; }
.kpiRow{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.55);
}
html[data-theme="dark"] .kpiRow{ background: rgba(255,255,255,.02); }
.kpiRow b{ font-weight: var(--w600); }
.kpiHint{ margin-top: 10px; color: var(--muted); font-size: 13px; }

.progress{
  height: 10px;
  border-radius: 999px;
  background: rgba(47,107,255,.12);
  overflow:hidden;
  border: 1px solid var(--line);
}
.progress > div{
  height:100%;
  width: 0%;
  background: var(--blue);
  border-radius: 999px;
}

.miniCards{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.miniCard{
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.65);
  display:flex;
  gap: 10px;
  align-items:center;
  cursor:pointer;
}
html[data-theme="dark"] .miniCard{ background: rgba(255,255,255,.03); }
.miniIcon{
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: rgba(13,21,38,.92);
  color: #fff;
  display:grid;
  place-items:center;
  font-size: 18px;
}
.miniText b{ font-weight: var(--w600); }
.miniText div{ color: var(--muted); font-size: 13px; }

.hr{ height:1px; background: var(--line); margin: 16px 0; border:0; }

.quizTop{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.quizMeta{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items:center;
}
.pill{
  display:inline-flex;
  gap: 8px;
  align-items:center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--pill);
  font-size: 13px;
  color: var(--text);
}
.pill b{ font-weight: var(--w600); }

.qCard{
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.70);
}
html[data-theme="dark"] .qCard{ background: rgba(255,255,255,.03); }

.qHead{
  display:flex;
  justify-content: space-between;
  gap: 12px;
  align-items:flex-start;
}
.qTitle{
  font-weight: var(--w600);
  letter-spacing: -0.01em;
  margin: 0;
  font-size: 18px;
}
.qStar{
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: transparent;
  cursor:pointer;
  display:grid;
  place-items:center;
  font-size: 18px;
  color: var(--text);
}
.qStar.is-on{
  background: rgba(255,193,7,.18);
  border-color: rgba(255,193,7,.35);
}

.options{
  margin-top: 14px;
  display:grid;
  gap: 10px;
}
.opt{
  text-align:left;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.60);
  cursor:pointer;
  font-weight: var(--w500);
  color: var(--text);
}
html[data-theme="dark"] .opt{ background: rgba(255,255,255,.02); }
.opt small{
  display:block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: var(--w400);
}
.opt.is-correct{
  border-color: rgba(25,179,107,.35);
  background: rgba(25,179,107,.12);
}
.opt.is-wrong{
  border-color: rgba(255,59,59,.30);
  background: rgba(255,59,59,.10);
}
.opt.is-picked{
  border-color: rgba(47,107,255,.35);
  background: rgba(47,107,255,.08);
}


.explain{
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.explain b{ color: var(--text); font-weight: var(--w600); }

.resultTop{
  display:flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.bigScore{
  font-size: 56px;
  letter-spacing: -0.03em;
  font-weight: var(--w600);
  margin: 6px 0 0;
}
.subScore{
  color: var(--muted);
  font-weight: var(--w500);
}

.list{
  margin-top: 16px;
  display:grid;
  gap: 12px;
}

.tabs{
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.tab{
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
.tab:hover{ background: rgba(47,107,255,.06); }
html[data-theme="dark"] .tab:hover{ background: rgba(47,107,255,.10); }
.tab.is-active{
  background: var(--pill);
  border-color: rgba(47,107,255,.40);
}
.tabContent{ margin-top: 6px; }
.item{
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.65);
}
html[data-theme="dark"] .item{ background: rgba(255,255,255,.03); }
.item h4{ margin:0; font-weight: var(--w600); }
.tags{
  margin-top: 10px;
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tag{
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.55);
  font-size: 13px;
}
html[data-theme="dark"] .tag{ background: rgba(255,255,255,.02); }
.tag--bad{ background: rgba(255,59,59,.10); border-color: rgba(255,59,59,.20); }
.tag--good{ background: rgba(25,179,107,.12); border-color: rgba(25,179,107,.22); }

.drawerOverlay, .modalOverlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 50;
}
.drawer{
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(420px, 92vw);
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 60;
  transform: translateX(110%);
  transition: transform .22s ease;
  display:flex;
  flex-direction: column;
}
.drawer.is-open{ transform: translateX(0); }

.drawer__head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.drawer__title{
  font-weight: var(--w600);
  font-size: 18px;
}
.drawer__body{
  padding: 18px;
  overflow:auto;
}

.setRow{
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}
.setRow__label{ font-weight: var(--w600); }
.setRow__hint{ color: var(--muted); font-size: 13px; margin-top: 4px; }

.select{
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 0 12px;
  font-weight: var(--w500);
}

.switch{
  position: relative;
  width: 52px;
  height: 30px;
  display:inline-block;
}
.switch input{ display:none; }
.switch__ui{
  position:absolute; inset:0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.45);
  cursor:pointer;
  transition: .18s ease;
}
html[data-theme="dark"] .switch__ui{ background: rgba(255,255,255,.05); }
.switch__ui::after{
  content:"";
  position:absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  transition: .18s ease;
}
.switch input:checked + .switch__ui{
  background: rgba(47,107,255,.25);
  border-color: rgba(47,107,255,.35);
}
.switch input:checked + .switch__ui::after{
  transform: translateX(22px);
}

.supportGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.fineprint{
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.modal{
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  width: min(560px, 94vw);
  max-height: calc(100vh - 28px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  z-index: 80;

  display:none;

  overflow: hidden;
  flex-direction: column;
}
@supports (height: 100dvh){
  .modal{ max-height: calc(100dvh - 28px); }
}

.modal.is-open{ display:flex; }
.modal__head{
  display:flex;
  justify-content: space-between;
  align-items:center;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.modal__title{ font-weight: var(--w600); }
.modal__body{ padding: 16px; color: var(--text); overflow:auto; flex:1; min-height:0; }
.modal__foot{
  padding: 12px 16px 16px;
  display:flex;
  justify-content:flex-end;
  gap: 10px;
}

.toast{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(13,21,38,.92);
  color:#fff;
  padding: 10px 14px;
  border-radius: 999px;
  z-index: 90;
  box-shadow: var(--shadow2);
  font-size: 14px;
}

/* Responsivo */
@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
  .kpiGrid{ grid-template-columns: 1fr; }
}

@media (max-width: 720px){
  .brand__subtitle--desktop{ display:none; }
  .brand__subtitle--mobile{ display:block; }
  .topbar__inner{ padding: 14px 14px; }
  .page{ padding: 18px 14px 34px; }
  .hero{ padding: 22px 18px; }
  .h1{ font-size: 36px; }
  .subgrid{ grid-template-columns: 1fr; }
  .miniCards{ grid-template-columns: 1fr; }
  .actions{ gap: 8px; }
  .pillbtn{ padding: 0 14px; }
}

/* ===== PATCH: Dark mode - títulos legíveis ===== */
/* cobre os 2 jeitos comuns de tema: body.dark e html[data-theme="dark"] */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
body.dark h1,
body.dark h2,
body.dark h3,
body.dark h4,
body.dark h5,
body.dark h6{
  color: rgba(240,246,255,.96) !important;
}

/* classes comuns de títulos (caso teu HTML use alguma delas) */
html[data-theme="dark"] .title,
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .panel-title,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .modal-title,
html[data-theme="dark"] .drawer-title,
body.dark .title,
body.dark .section-title,
body.dark .panel-title,
body.dark .card-title,
body.dark .modal-title,
body.dark .drawer-title{
  color: rgba(240,246,255,.96) !important;
}

/* textos secundários no dark (mais confortáveis) */
html[data-theme="dark"] .muted,
html[data-theme="dark"] .subtitle,
body.dark .muted,
body.dark .subtitle{
  color: rgba(226,232,240,.72) !important;
}



/* --------- Histórico (Home) --------- */
.historyList{ display:grid; gap:10px; }
.historyItem{
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
  cursor: pointer;
  background: rgba(0,0,0,.02);
  transition: transform .08s ease, border-color .12s ease;
}
.historyItem:hover{ transform: translateY(-1px); border-color: rgba(99,102,241,.45); }
html[data-theme="dark"] .historyItem{ background: rgba(255,255,255,.03); }

.historyItem__top{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.historyItem__name{ font-weight:700; }
.historyItem__pct{ font-weight:800; }
.historyItem__meta{ margin-top:4px; font-size: 12.5px; color: var(--muted); }

/* --------- Nível (ícone) --------- */
.levelRow{ display:flex; align-items:center; gap:12px; margin-top: 6px; }
.levelIcon{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.02);
  object-fit: cover;
}
html[data-theme="dark"] .levelIcon{ background: rgba(255,255,255,.03); }
.levelMain{ font-size: 18px; font-weight: 900; line-height: 1.05; }

/* --------- Lista clicável --------- */
.item--click{ cursor:pointer; }
.itemTop{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.itemTitle{ font-weight:800; }
.itemRight{ font-weight:900; }
