/* =====================================================
   Simulado ABIN (não oficial) — Design System Premium
   Canvas #F4F7FC · Cards #FFF · Ink #132B58 · Accent #154086
   ===================================================== */

:root {
  /* marca */
  --accent: #154086;
  --accent-deep: #132B58;
  --accent-soft: #EEF7FF;
  --accent-mist: #D9EEFF;

  /* canvas e superfícies */
  --canvas: #F4F7FC;
  --surface: #FFFFFF;
  --surface-sub: #F8FAFC;
  --border: #E2E8F0;

  /* tipografia */
  --ink: #132B58;
  --ink-soft: #475569;
  --ink-mute: #64748B;

  /* estados (pastéis) */
  --ok-text: #067647;
  --ok-bg: #ECFDF5;
  --ok-border: #A7F3D0;
  --err-text: #B42318;
  --err-bg: #FEF2F2;
  --err-border: #FECDCA;
  --warn-bg: #FFF8E6;
  --warn-text: #92700A;

  /* geometria e efeitos */
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-card: 0 10px 30px rgba(21, 64, 134, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
  --shadow-float: 0 18px 44px rgba(21, 64, 134, 0.10), 0 2px 6px rgba(19, 43, 88, 0.04);
  --shadow-btn: 0 8px 20px rgba(21, 64, 134, 0.22);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: var(--font);
  background:
    radial-gradient(900px 480px at 15% -8%, rgba(217, 238, 255, 0.55), transparent 65%),
    radial-gradient(760px 420px at 100% 0%, rgba(238, 247, 255, 0.8), transparent 60%),
    var(--canvas);
  color: var(--ink);
  line-height: 1.65;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header (claro, com blur) ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  padding-top: calc(12px + env(safe-area-inset-top));
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(21, 64, 134, 0.16);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 0.98rem; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.brand-text small { font-size: 0.72rem; font-weight: 500; color: var(--ink-mute); }

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 9999px;
  padding: 7px 16px;
  letter-spacing: 0.03em;
}

/* ---------- Aviso não oficial ---------- */
.disclaimer {
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 0.76rem;
  font-weight: 500;
  text-align: center;
  padding: 9px 16px;
}
.disclaimer strong { font-weight: 700; letter-spacing: 0.04em; }

/* ---------- Layout ---------- */
#app {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 18px 56px;
}

.screen { display: flex; flex-direction: column; gap: 18px; }
.screen:not(.hidden) { animation: screenIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both; }
.hidden { display: none !important; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .screen:not(.hidden) { animation: none; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 26px 24px;
}

.section-title {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin-top: 10px;
  padding-left: 6px;
}

/* ---------- Tela inicial ---------- */
.hero { text-align: center; padding-top: 34px; padding-bottom: 30px; }

.hero-logo {
  width: 92px;
  height: 92px;
  margin-bottom: 16px;
  filter: drop-shadow(0 10px 22px rgba(21, 64, 134, 0.18));
}

.hero h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 10px;
}

.hero-sub {
  font-size: 0.93rem;
  font-weight: 400;
  color: var(--ink-mute);
  max-width: 42ch;
  margin: 0 auto 24px;
}
.hero-sub strong { color: var(--ink-soft); font-weight: 600; }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat {
  background: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value { font-size: 1.3rem; font-weight: 700; color: var(--accent); letter-spacing: -0.02em; }
.stat-label { font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-mute); }

.btn-install {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: none;
  border-radius: 9999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s;
}
.btn-install:hover { background: var(--accent-mist); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(21, 64, 134, 0.12); }
.btn-install:active { transform: translateY(0); }

.load-error { margin-top: 16px; color: var(--err-text); font-size: 0.85rem; font-weight: 500; }

/* ---------- Cards de modo ---------- */
.mode-card { display: flex; flex-direction: column; gap: 18px; }

.mode-head { display: flex; align-items: flex-start; gap: 14px; }

.mode-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  flex-shrink: 0;
}

.mode-head h3 { font-size: 1.02rem; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; line-height: 1.3; }
.mode-head p { font-size: 0.84rem; font-weight: 400; color: var(--ink-mute); margin-top: 3px; }

.quick-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 6px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.quick-btn small { font-size: 0.63rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-mute); }
.quick-btn:not(:disabled):hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(21, 64, 134, 0.10);
}

/* ---------- Lista de categorias ---------- */
.category-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.category-loading { font-size: 0.85rem; color: var(--ink-mute); padding: 4px 2px; }

.category-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  background: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s ease, box-shadow 0.15s ease;
}
.category-item:hover {
  border-color: var(--accent);
  background: var(--surface);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(21, 64, 134, 0.08);
}
.category-item:active { transform: translateY(0); }

.category-item .cat-name { flex: 1; min-width: 0; }

.category-item .cat-count {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 9999px;
  padding: 4px 12px;
  white-space: nowrap;
}

.category-item .cat-arrow { color: var(--accent); font-weight: 700; opacity: 0.55; transition: opacity 0.15s, transform 0.15s; }
.category-item:hover .cat-arrow { opacity: 1; transform: translateX(2px); }

/* ---------- Botões ---------- */
.btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.93rem;
  border: none;
  border-radius: 14px;
  padding: 14px 28px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-btn);
}
.btn-primary:not(:disabled):hover {
  background: #1A4C9C;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(21, 64, 134, 0.30);
}
.btn-primary:not(:disabled):active { transform: translateY(0); }

.btn-lg { width: 100%; padding: 16px 28px; font-size: 1rem; }

.btn-ghost {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.btn-ghost:not(:disabled):hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(21, 64, 134, 0.08); }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-outline:hover { background: var(--accent-soft); transform: translateY(-1px); }

/* ---------- Quiz: topo ---------- */
.quiz-top { display: flex; flex-direction: column; gap: 12px; }

.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 9999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 9999px;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.quiz-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.quiz-counter { font-size: 0.84rem; font-weight: 600; color: var(--ink); }
.quiz-counter .mode-tag { font-weight: 500; color: var(--ink-mute); }

.chip {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 5px 14px;
  border-radius: 9999px;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Questão ---------- */
.question-card { display: flex; flex-direction: column; gap: 18px; }

.texto-apoio {
  background: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.texto-apoio summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--accent);
  padding: 13px 16px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.texto-apoio summary::-webkit-details-marker { display: none; }
.texto-apoio summary::before { content: '📄'; }
.texto-apoio[open] summary { border-bottom: 1px solid var(--border); }
.texto-apoio-body {
  padding: 16px 18px;
  font-size: 0.88rem;
  font-weight: 400;
  line-height: 1.75;
  color: var(--ink-soft);
}
.texto-apoio-body p + p { margin-top: 12px; }
.texto-apoio-body .fonte { font-size: 0.75rem; color: var(--ink-mute); font-style: italic; }

.comando {
  font-size: 0.83rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--accent);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.enunciado { font-size: 1.02rem; font-weight: 400; line-height: 1.8; color: var(--ink); }
.enunciado p + p { margin-top: 14px; }
.enunciado strong { color: var(--accent); font-weight: 600; }

/* ---------- Alternativas ---------- */
.options { display: flex; flex-direction: column; gap: 12px; }
.options.options-ce { flex-direction: row; }
.options.options-ce .option { flex: 1; justify-content: center; text-align: center; }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  font-family: var(--font);
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.option:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(21, 64, 134, 0.07); }

.option .option-key {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
}

.option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(21, 64, 134, 0.10);
}
.option.selected .option-key { background: var(--accent); color: #fff; }

.option.correct { border-color: var(--ok-border); background: var(--ok-bg); color: var(--ok-text); }
.option.correct .option-key { background: var(--ok-text); color: #fff; }
.option.wrong { border-color: var(--err-border); background: var(--err-bg); color: var(--err-text); }
.option.wrong .option-key { background: var(--err-text); color: #fff; }
.option:disabled { cursor: default; opacity: 1; transform: none; box-shadow: none; }
.option.dimmed { opacity: 0.5; }

/* ---------- Feedback ---------- */
.feedback {
  border-radius: var(--radius-md);
  padding: 13px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: screenIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.feedback.ok { background: var(--ok-bg); color: var(--ok-text); }
.feedback.err { background: var(--err-bg); color: var(--err-text); }

/* ---------- Navegação ---------- */
.quiz-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.finish-row { display: flex; justify-content: center; }
.finish-row .btn { font-size: 0.84rem; padding: 11px 26px; }

/* ---------- Resultados ---------- */
.results-card { text-align: center; padding-top: 32px; }
.results-card h2 { color: var(--ink); font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }

.results-mode { font-size: 0.8rem; font-weight: 500; color: var(--ink-mute); margin-bottom: 22px; }

.score-ring {
  width: 164px;
  height: 164px;
  border-radius: 50%;
  margin: 0 auto 24px;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) 0%, var(--border) 0%);
}
.score-ring-inner {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
}
.score-pct { font-size: 2.1rem; font-weight: 700; color: var(--accent); letter-spacing: -0.03em; line-height: 1.1; }
.score-caption { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-mute); }

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
  text-align: left;
}
.result-item {
  background: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.result-item .ri-label { font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-mute); display: block; }
.result-item .ri-value { font-size: 1.2rem; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.result-item.ri-ok .ri-value { color: var(--ok-text); }
.result-item.ri-err .ri-value { color: var(--err-text); }

.results-actions { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Resumo ---------- */
.summary-title { color: var(--ink); font-size: 1.02rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 16px; }

.summary-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.summary-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.85rem;
}
.summary-item .si-num {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
}
.summary-item.ok .si-num { background: var(--ok-bg); color: var(--ok-text); }
.summary-item.err .si-num { background: var(--err-bg); color: var(--err-text); }

.summary-item .si-body { flex: 1; min-width: 0; }
.summary-item .si-area { font-weight: 600; color: var(--ink); font-size: 0.78rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-item .si-detail { font-size: 0.74rem; color: var(--ink-mute); }

.summary-item .si-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 9999px;
  flex-shrink: 0;
}
.si-badge.ok { background: var(--ok-bg); color: var(--ok-text); }
.si-badge.err { background: var(--err-bg); color: var(--err-text); }
.si-badge.blank { background: var(--accent-soft); color: var(--accent); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(19, 43, 88, 0.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  padding: 16px;
  animation: fadeIn 0.2s ease both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  padding: 28px 24px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  animation: modalIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(36px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-card h3 { color: var(--ink); font-size: 1.12rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 8px; }

.modal-body { font-size: 0.9rem; font-weight: 400; line-height: 1.6; color: var(--ink-soft); margin-bottom: 20px; }
.modal-body strong { color: var(--ink); font-weight: 600; }
.modal-body .modal-highlight {
  display: block;
  margin-top: 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

.modal-actions { display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 560px) {
  .modal-overlay { align-items: center; }
  .modal-actions { flex-direction: row-reverse; }
  .modal-actions .btn { flex: 1; }
}

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--ink-mute);
  font-size: 0.72rem;
  font-weight: 400;
  text-align: center;
  padding: 20px 18px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.app-footer strong { color: var(--ink-soft); font-weight: 600; }

/* ---------- Telas maiores ---------- */
@media (min-width: 560px) {
  #app { padding: 36px 24px 64px; }
  .hero h1 { font-size: 1.8rem; }
  .card { padding: 32px 32px; }
  .mode-card { padding: 28px 32px; }
  .results-grid { grid-template-columns: repeat(3, 1fr); }
  .results-actions { flex-direction: row; }
  .results-actions .btn { flex: 1; }
}
