/* =========================================================================
   Nutanix - MCI Simulator - design system mobile-first
   Otimizado para telas 360-440px (Galaxy S24 Ultra: 412 x 915 @3.5x)
   ========================================================================= */

:root {
  --bg: #080b14;
  --bg-soft: #0d1220;
  --surface: #121a2b;
  --surface-2: #172034;
  --surface-3: #1d2842;
  --border: #243050;
  --border-soft: #1b2540;
  --text: #e7ecf7;
  --text-dim: #93a1c0;
  --text-mute: #6a7899;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --accent-2: #8b5cf6;
  --success: #23c98a;
  --success-soft: rgba(35, 201, 138, 0.14);
  --danger: #f2555a;
  --danger-soft: rgba(242, 85, 90, 0.14);
  --warning: #f5a524;
  --warning-soft: rgba(245, 165, 36, 0.14);

  /* Marca do app (gradiente roxo, alinhado a identidade Nutanix) */
  --brand-1: #5b6cff;
  --brand-2: #9d4ef5;

  --radius: 18px;
  --radius-sm: 13px;
  --radius-xs: 10px;
  --shadow: 0 16px 40px rgba(2, 6, 20, 0.5);
  --shadow-lg: 0 -14px 44px rgba(2, 6, 20, 0.65);

  --font: 'Segoe UI', system-ui, -apple-system, 'Inter', Roboto, Arial, sans-serif;
  --mono: 'Cascadia Code', 'Consolas', 'SFMono-Regular', monospace;

  --tap: 48px;                       /* alvo minimo de toque */  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --gutter: 16px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(700px 380px at 8% -6%, rgba(79, 140, 255, 0.18), transparent 62%),
    radial-gradient(620px 360px at 96% 2%, rgba(139, 92, 246, 0.14), transparent 64%);
  z-index: 0;
}

button, input, select, textarea { font-family: inherit; color: inherit; }
button { touch-action: manipulation; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.012em; }
p { margin: 0; }
a { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ------------------------------- Estrutura -------------------------------- */

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.sidebar { display: none; }

.main-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--gutter) 12px;
  padding-top: calc(10px + var(--safe-t));
  padding-left: calc(var(--gutter) + var(--safe-l));
  padding-right: calc(var(--gutter) + var(--safe-r));
  background: rgba(8, 11, 20, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-soft);
  z-index: 20;
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 {
  font-size: 1.22rem;
  line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title p {
  font-size: 0.78rem; color: var(--text-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.back-btn[hidden] { display: none; }

.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
  outline: none;
  padding: var(--gutter);
  padding-left: calc(var(--gutter) + var(--safe-l));
  padding-right: calc(var(--gutter) + var(--safe-r));
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 28px);
}
body.exam-mode .content { padding-bottom: calc(76px + var(--safe-b) + 20px); }

/* ------------------------------ Barra de abas ----------------------------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(11, 15, 26, 0.9);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-top: 1px solid var(--border-soft);
  transition: transform .26s var(--ease);
}
body.exam-mode .tabbar { transform: translateY(110%); pointer-events: none; }

.tab-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  border: 0; background: none;
  color: var(--text-mute);
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.01em;
  cursor: pointer;
  position: relative;
  transition: color .18s var(--ease);
}
.tab-item .ico { width: 23px; height: 23px; fill: currentColor; transition: transform .24s var(--ease); }
.tab-item::before {
  content: '';
  position: absolute; top: 6px;
  width: 46px; height: 30px; border-radius: 999px;
  background: var(--accent-soft);
  opacity: 0; transform: scale(.6);
  transition: opacity .2s var(--ease), transform .24s var(--ease);
}
.tab-item.active { color: #a9c7ff; }
.tab-item.active::before { opacity: 1; transform: scale(1); }
.tab-item.active .ico { transform: translateY(-1px); }
.tab-item:active .ico { transform: scale(.88); }

/* ------------------------------- Componentes ------------------------------ */

.ico { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: transform .1s var(--ease), background .18s var(--ease), border-color .18s var(--ease), opacity .18s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .ico { width: 18px; height: 18px; fill: currentColor; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #3d6ff0);
  border-color: transparent; color: #fff;
  box-shadow: 0 10px 26px rgba(79, 140, 255, 0.3);
}
.btn-danger { background: var(--danger-soft); border-color: rgba(242, 85, 90, .35); color: #ffb4b6; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 0.84rem; border-radius: var(--radius-xs); }

.icon-btn {
  width: 42px; height: 42px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  transition: transform .1s var(--ease), background .18s var(--ease);
}
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn:active { transform: scale(.92); }

.fab {
  position: fixed;
  right: calc(var(--gutter) + var(--safe-r));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  width: 56px; height: 56px;
  border-radius: 18px;
  border: 0;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 14px 30px rgba(79, 140, 255, .42);
  cursor: pointer;
  z-index: 35;
  transition: transform .14s var(--ease);
}
.fab svg { width: 26px; height: 26px; fill: currentColor; }
.fab:active { transform: scale(.9); }

.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 0.98rem; margin-bottom: 3px; }
.card-sub { font-size: 0.8rem; color: var(--text-mute); line-height: 1.5; }

.grid { display: grid; gap: 12px; }
.grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

.section-head {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 2px 12px;
}
.section-head h2 { font-size: 1rem; }
.section-head .spacer { flex: 1; }

/* Cartoes de estatistica com rolagem horizontal (padrao mobile) */
.stat-scroller {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 63%;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px calc(var(--gutter) + var(--safe-r)) 4px var(--gutter);
  margin: 0 calc(-1 * var(--gutter));
}
.stat-scroller::-webkit-scrollbar { display: none; }
.stat-scroller > .card { scroll-snap-align: start; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-mute); }
.stat-value { font-size: 1.85rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; }
.stat-foot { font-size: 0.74rem; color: var(--text-dim); }
.stat-accent { color: var(--accent); }
.stat-success { color: var(--success); }
.stat-warning { color: var(--warning); }

.stat-tap { text-align: left; cursor: pointer; font: inherit; transition: transform .16s var(--ease), border-color .16s var(--ease); }
.stat-tap:active { transform: scale(.97); border-color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 0.82rem; color: var(--text-dim); font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;           /* evita zoom automatico no foco (Android/iOS) */
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2393a1c0'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 22px;
  padding-right: 38px;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 96px; line-height: 1.55; }
.hint { font-size: 0.76rem; color: var(--text-mute); line-height: 1.5; }

/* Controle segmentado (estilo iOS/Material) */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.seg-item {
  min-height: 42px;
  border: 0; border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.seg-item small { font-size: 0.66rem; font-weight: 500; opacity: .7; }
.seg-item.active { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(79,140,255,.32); }

/* Stepper numerico */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  transition: transform .1s var(--ease);
}
.stepper button:active { transform: scale(.9); }
.stepper .input { text-align: center; font-weight: 700; font-size: 1.05rem; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.84rem; font-weight: 550;
  transition: transform .1s var(--ease), background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.chip:active { transform: scale(.95); }
.chip.active { background: var(--accent-soft); border-color: rgba(79,140,255,.5); color: #cfe0ff; }
.chip strong { color: var(--accent); }
.chip.active strong { color: #cfe0ff; }

.chip-scroller {
  display: flex; gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px var(--gutter) 4px;
  margin: 0 calc(-1 * var(--gutter));
}
.chip-scroller::-webkit-scrollbar { display: none; }
.chip-scroller .chip { flex-shrink: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem; font-weight: 650; letter-spacing: 0.015em;
  border: 1px solid transparent;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge-easy { background: var(--success-soft); color: #7ee6bd; border-color: rgba(35,201,138,.3); }
.badge-medium { background: var(--warning-soft); color: #ffd08a; border-color: rgba(245,165,36,.3); }
.badge-hard { background: var(--danger-soft); color: #ffa0a3; border-color: rgba(242,85,90,.3); }
.badge-domain { background: var(--surface-3); color: var(--text-dim); border-color: var(--border); }
.badge-source { background: rgba(79, 140, 255, .12); color: var(--accent); border-color: rgba(79, 140, 255, .3); }
.badge-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.badge-ok { background: var(--success-soft); color: #7ee6bd; border-color: rgba(35,201,138,.3); }
.badge-err { background: var(--danger-soft); color: #ffa0a3; border-color: rgba(242,85,90,.3); }

.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .5s var(--ease);
}
.bar.ok > span { background: linear-gradient(90deg, #1fae79, var(--success)); }
.bar.warn > span { background: linear-gradient(90deg, #d98c12, var(--warning)); }
.bar.bad > span { background: linear-gradient(90deg, #d13c41, var(--danger)); }
.bar.slim { height: 5px; }

/* Listas (substituem tabelas no mobile) */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--border-soft);
  width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0;
  color: inherit; text-align: left;
  min-height: var(--tap);
}
.list-row:last-child { border-bottom: none; }
button.list-row { cursor: pointer; transition: background .18s var(--ease); border-radius: var(--radius-xs); padding-left: 8px; padding-right: 8px; }
button.list-row:active { background: var(--surface-2); }
.list-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.list-title {
  font-size: 0.92rem; font-weight: 550; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.list-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 0.76rem; color: var(--text-mute); }
.list-meta .ico { width: 14px; height: 14px; }
.list-answer { color: var(--success); flex-wrap: nowrap; align-items: flex-start; }
.list-answer .ico { margin-top: 2px; }
.list-trail { flex-shrink: 0; display: flex; align-items: center; gap: 8px; text-align: right; }
.list-avatar {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 13px; display: grid; place-items: center;
  font-size: 0.82rem; font-weight: 700;
  background: var(--surface-3); color: var(--text-dim);
}
.list-avatar.ok { background: var(--success-soft); color: #7ee6bd; }
.list-avatar.err { background: var(--danger-soft); color: #ffa0a3; }
.list-avatar.accent { background: var(--accent-soft); color: #a9c7ff; }

.perf-row { display: flex; flex-direction: column; gap: 7px; padding: 12px 2px; border-bottom: 1px solid var(--border-soft); }
.perf-row:last-child { border-bottom: none; }
.perf-head { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.perf-head .spacer { flex: 1; }
.perf-pct { font-variant-numeric: tabular-nums; font-weight: 700; }
.perf-frac { font-size: 0.75rem; color: var(--text-mute); }

.empty { text-align: center; padding: 40px 18px; color: var(--text-mute); }
.empty svg { width: 46px; height: 46px; fill: var(--surface-3); margin-bottom: 12px; }
.empty strong { display: block; color: var(--text-dim); margin-bottom: 5px; font-size: 0.98rem; }

.loader { display: grid; place-items: center; padding: 56px; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--surface-3); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.page-enter { animation: pageIn .28s var(--ease); }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } }

/* -------------------------------- Simulado -------------------------------- */

.exam-bar {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  margin: -4px 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: rgba(18, 26, 43, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.exam-bar .progress-wrap { flex: 1; min-width: 0; }
.exam-bar .progress-line {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 0.72rem; color: var(--text-mute); margin-bottom: 5px;
  white-space: nowrap;
}
.timer {
  font-family: var(--mono); font-size: 1.02rem; font-weight: 700;
  letter-spacing: 0.03em; font-variant-numeric: tabular-nums;
  padding: 6px 10px; border-radius: 10px;
  background: var(--surface-3); flex-shrink: 0;
}
.timer.danger { color: #ffb4b6; background: var(--danger-soft); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.exam-layout { display: block; }
.map-panel { display: none; }

.question-card { padding: 18px 16px 20px; }
.question-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.question-index {
  font-size: 0.72rem; color: var(--text-mute); font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
}
.question-meta .spacer { flex: 1; }
.flag-btn {
  width: 38px; height: 38px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2);
  display: grid; place-items: center; cursor: pointer; color: var(--text-mute);
  transition: transform .12s var(--ease);
}
.flag-btn svg { width: 18px; height: 18px; fill: currentColor; }
.flag-btn:active { transform: scale(.9); }
.flag-btn.on { background: var(--warning-soft); border-color: rgba(245,165,36,.4); color: #ffd08a; }

/* --------------------------- Dica da resposta --------------------------- */

.hint-wrap { position: relative; display: inline-flex; }
.hint-btn {
  width: 38px; height: 38px; border-radius: 12px;
  border: 1px solid rgba(245,165,36,.28); background: var(--warning-soft);
  display: grid; place-items: center; cursor: pointer; color: #ffd08a;
  transition: transform .12s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}
.hint-btn svg { width: 18px; height: 18px; fill: currentColor; }
.hint-btn:hover, .hint-btn[aria-expanded="true"] {
  background: rgba(245,165,36,.24); border-color: rgba(245,165,36,.55);
}
.hint-btn:active { transform: scale(.9); }

.hint-pop {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 40;
  width: min(300px, calc(100vw - 48px));
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 13px;
  background: var(--surface-2);
  border: 1px solid rgba(35,201,138,.34);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  animation: hint-in .16s var(--ease);
  text-align: left;
}
.hint-pop[hidden] { display: none; }
.hint-pop::before {
  content: ''; position: absolute; top: -6px; right: 14px;
  width: 10px; height: 10px; background: var(--surface-2);
  border-left: 1px solid rgba(35,201,138,.34);
  border-top: 1px solid rgba(35,201,138,.34);
  transform: rotate(45deg);
}
.hint-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--success);
}
.hint-title .ico { width: 13px; height: 13px; }
.hint-answer { font-size: 0.88rem; line-height: 1.5; color: var(--text); }
.hint-answer b { color: var(--success); margin-right: 4px; }
.hint-explain {
  font-size: 0.78rem; line-height: 1.55; color: var(--text-dim);
  border-top: 1px solid var(--border-soft); padding-top: 7px; margin-top: 1px;
}
@keyframes hint-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.question-statement {
  font-size: 1.02rem; line-height: 1.68;
  white-space: pre-wrap; word-break: break-word;
  margin-bottom: 18px;
}

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  cursor: pointer;
  text-align: left; width: 100%;
  transition: border-color .18s var(--ease), background .18s var(--ease), transform .1s var(--ease);
}
.option:active:not(:disabled) { transform: scale(.985); }
.option:disabled { cursor: default; }
.option-letter {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-size: 0.82rem; font-weight: 700;
  color: var(--text-dim);
  transition: background .18s var(--ease), color .18s var(--ease);
}
.option-body { flex: 1; min-width: 0; }
.option-text { line-height: 1.55; word-break: break-word; display: block; }
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option.selected .option-letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.option.correct { border-color: rgba(35,201,138,.6); background: var(--success-soft); animation: popIn .3s var(--ease); }
.option.correct .option-letter { background: var(--success); border-color: var(--success); color: #04231a; }
.option.wrong { border-color: rgba(242,85,90,.6); background: var(--danger-soft); animation: shake .34s var(--ease); }
.option.wrong .option-letter { background: var(--danger); border-color: var(--danger); color: #2b0709; }
@keyframes popIn { from { transform: scale(.97); } }
@keyframes shake { 25% { transform: translateX(-5px); } 60% { transform: translateX(4px); } }

.option-explain {
  margin-top: 9px; padding-top: 9px;
  border-top: 1px dashed var(--border);
  font-size: 0.84rem; color: var(--text-dim); line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  display: block;
}

.explain-box {
  margin-top: 16px; padding: 14px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(79,140,255,.22);
  background: rgba(79,140,255,.07);
  animation: pageIn .3s var(--ease);
}
.explain-box h4 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); margin-bottom: 7px;
}
.explain-box p { font-size: 0.87rem; color: var(--text-dim); line-height: 1.65; white-space: pre-wrap; word-break: break-word; }

/* Barra de acoes fixa do simulado */
.exam-actions {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 10px calc(var(--gutter) + var(--safe-r)) 10px calc(var(--gutter) + var(--safe-l));
  padding-bottom: calc(10px + var(--safe-b));
  background: rgba(11, 15, 26, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-soft);
  animation: barIn .3s var(--ease);
}
@keyframes barIn { from { transform: translateY(100%); } }
.exam-actions .btn { flex: 1; }
.exam-actions .icon-btn { width: 48px; height: 48px; }
.swipe-hint {
  text-align: center; font-size: 0.73rem; color: var(--text-mute);
  margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
.swipe-hint .ico { width: 13px; height: 13px; opacity: .8; }

/* Mapa de questoes */
.map-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.map-cell {
  position: relative;
  aspect-ratio: 1;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-mute);
  font-size: 0.85rem; font-weight: 650;
  cursor: pointer; display: grid; place-items: center;
  transition: transform .12s var(--ease), background .18s var(--ease);
}
.map-cell:active { transform: scale(.9); }
.map-cell.answered { background: var(--accent-soft); border-color: rgba(79,140,255,.45); color: #cfe0ff; }
.map-cell.correct { background: var(--success-soft); border-color: rgba(35,201,138,.45); color: #7ee6bd; }
.map-cell.wrong { background: var(--danger-soft); border-color: rgba(242,85,90,.45); color: #ffa0a3; }
.map-cell.current { outline: 2px solid var(--accent); outline-offset: 2px; }
.map-cell.flagged::after {
  content: ''; position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--warning);
}
.map-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin-top: 16px; font-size: 0.75rem; color: var(--text-mute);
}
.map-legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 4px; display: inline-block; }

/* -------------------------------- Resultado ------------------------------- */

.result-hero {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding: 24px 18px; margin-bottom: 16px; text-align: center;
}
.score-ring {
  --pct: 0;
  width: 152px; height: 152px; flex-shrink: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--ring-color, var(--accent)) calc(var(--pct) * 1%), var(--surface-3) 0);
  position: relative;
  animation: ringIn .7s var(--ease);
}
@keyframes ringIn { from { transform: scale(.85) rotate(-25deg); opacity: 0; } }
.score-ring::before { content: ''; position: absolute; inset: 12px; border-radius: 50%; background: var(--bg-soft); }
.score-ring > div { position: relative; }
.score-num { font-size: 2.3rem; font-weight: 780; letter-spacing: -0.04em; line-height: 1; }
.score-cap { font-size: 0.68rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.09em; margin-top: 4px; }

.result-summary { width: 100%; }
.result-summary h2 { font-size: 1.3rem; margin-bottom: 6px; }
.result-metrics {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-top: 18px; width: 100%;
}
.result-metric {
  padding: 12px 8px; border-radius: var(--radius-sm);
  background: var(--bg-soft); border: 1px solid var(--border-soft);
  align-items: center; text-align: center;
}
.result-metric .stat-value { font-size: 1.1rem; }
.result-metric .stat-label { font-size: 0.63rem; }

.review-item {
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  overflow: hidden;
}
.review-head {
  display: flex; align-items: center; gap: 11px; cursor: pointer;
  padding: 13px 14px; min-height: var(--tap);
  transition: background .18s var(--ease);
}
.review-head:active { background: var(--surface-2); }
.review-num {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 10px; display: grid; place-items: center;
  font-size: 0.78rem; font-weight: 700;
}
.review-num.ok { background: var(--success-soft); color: #7ee6bd; }
.review-num.err { background: var(--danger-soft); color: #ffa0a3; }
.review-num.skip { background: var(--surface-3); color: var(--text-mute); }
.review-title {
  flex: 1; min-width: 0; font-size: 0.85rem; color: var(--text-dim); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.review-caret { flex-shrink: 0; width: 20px; height: 20px; fill: var(--text-mute); transition: transform .24s var(--ease); }
.review-item.open .review-caret { transform: rotate(180deg); }
.review-body { padding: 4px 14px 18px; display: none; }
.review-item.open .review-body { display: block; animation: pageIn .26s var(--ease); }

/* ---------------------------- Folha inferior ------------------------------ */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(4, 7, 15, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s var(--ease);
}
.sheet-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }

.sheet {
  width: 100%;
  max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheetUp .3s var(--ease);
  padding-bottom: var(--safe-b);
  transition: transform .18s var(--ease);
}
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet.closing { animation: sheetDown .22s var(--ease) forwards; }
@keyframes sheetDown { to { transform: translateY(100%); } }

.sheet-grabber { padding: 10px 0 2px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.sheet-grabber i { width: 40px; height: 4px; border-radius: 999px; background: var(--surface-3); display: block; }

.sheet-head { display: flex; align-items: center; gap: 12px; padding: 8px 18px 14px; }
.sheet-head h2 { flex: 1; font-size: 1.05rem; }
.sheet-body {
  padding: 4px 18px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sheet-foot {
  padding: 12px 18px calc(14px + var(--safe-b));
  border-top: 1px solid var(--border-soft);
  display: flex; gap: 10px;
}
.sheet-foot:empty { display: none; }
.sheet-foot .btn { flex: 1; }

/* --------------------------------- Toast ---------------------------------- */

.toast-stack {
  position: fixed; z-index: 90;
  left: calc(var(--gutter) + var(--safe-l));
  right: calc(var(--gutter) + var(--safe-r));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
body.exam-mode .toast-stack { bottom: calc(78px + var(--safe-b)); }
.toast {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(23, 32, 52, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  font-size: 0.87rem; line-height: 1.45;
  animation: toastIn .26s var(--ease);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.toast.success { border-color: rgba(35,201,138,.45); }
.toast.error { border-color: rgba(242,85,90,.45); }

/* --------------------------------- Editor --------------------------------- */

.opt-editor {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px; margin-bottom: 10px; background: var(--bg-soft);
}
.opt-editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.opt-editor-head label {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.82rem; color: var(--text-dim); cursor: pointer;
  min-height: 36px;
}
.opt-editor-head input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); }
.opt-editor-head .spacer { flex: 1; }

.filters { display: grid; gap: 10px; grid-template-columns: 1fr; }
.search-wrap { position: relative; }
.search-wrap .ico {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; fill: var(--text-mute); pointer-events: none;
}
.search-wrap .input { padding-left: 42px; }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.pager .btn { flex: 1; }
.pager .hint { flex-shrink: 0; text-align: center; }

/* Tabela (apenas telas grandes) */
.table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.table th {
  text-align: left; padding: 10px 12px;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-mute); border-bottom: 1px solid var(--border-soft); font-weight: 650;
}
.table td { padding: 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

.pill {
  display: inline-block; padding: 5px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 0.75rem; color: var(--text-dim);
}

/* ========================================================================= */
/* Tablet: 2 colunas                                                          */
/* ========================================================================= */

@media (min-width: 680px) {
  :root { --gutter: 22px; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-scroller { grid-auto-columns: 34%; }
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .map-grid { grid-template-columns: repeat(8, 1fr); }
  .sheet { max-width: 620px; border-radius: 26px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
  .sheet-backdrop { align-items: center; padding: 20px; }
  .result-hero { flex-direction: row; text-align: left; gap: 28px; }
  .result-summary { width: auto; flex: 1; }
  .result-metrics { max-width: 420px; }
}

/* ========================================================================= */
/* Desktop: barra lateral                                                     */
/* ========================================================================= */

@media (min-width: 1024px) {
  :root { --gutter: 28px; }

  body { font-size: 15px; }

  .app-shell { display: grid; grid-template-columns: 258px 1fr; }

  .sidebar {
    display: flex; flex-direction: column; gap: 26px;
    padding: 24px 16px;
    background: linear-gradient(180deg, rgba(18, 26, 43, 0.95), rgba(10, 14, 26, 0.95));
    border-right: 1px solid var(--border-soft);
    overflow-y: auto;
  }
  .brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
  .brand-mark {
    width: 44px; height: 44px; border-radius: 14px;
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
    display: grid; place-items: center;
    box-shadow: 0 8px 22px rgba(124, 88, 250, 0.35);
  }
  .brand-mark svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 13; stroke-linecap: round; stroke-linejoin: round; }
  .brand-text { display: flex; flex-direction: column; line-height: 1.2; }
  .brand-text strong { font-size: 1.05rem; letter-spacing: 0.02em; }
  .brand-text span { font-size: 0.76rem; color: var(--text-mute); }

  .nav { display: flex; flex-direction: column; gap: 4px; }
  .nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; min-height: 46px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-dim);
    cursor: pointer; text-align: left; font-size: 0.92rem; font-weight: 550;
    transition: background .18s var(--ease), color .18s var(--ease);
  }
  .nav-item .ico { width: 20px; height: 20px; fill: currentColor; opacity: .9; }
  .nav-item:hover { background: var(--surface-2); color: var(--text); }
  .nav-item.active { background: var(--accent-soft); color: #cfe0ff; border-color: rgba(79, 140, 255, 0.35); }

  .sidebar-footer { margin-top: auto; padding: 0 6px; color: var(--text-mute); font-size: 0.78rem; }
  .sidebar-footer p { margin-top: 10px; line-height: 1.5; }

  .tabbar { display: none; }
  .fab { display: none; }
  .content { padding-bottom: 60px; }
  body.exam-mode .content { padding-bottom: 60px; }
  .toast-stack { left: auto; right: 24px; bottom: 24px; width: 360px; }
  body.exam-mode .toast-stack { bottom: 24px; }

  .topbar { padding: 18px 28px; }
  .topbar-title h1 { font-size: 1.32rem; }
  .back-btn { display: none !important; }

  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-scroller {
    display: grid; grid-auto-flow: row; grid-template-columns: repeat(4, 1fr);
    overflow: visible; margin: 0; padding: 0; gap: 16px;
  }

  .exam-layout { display: grid; grid-template-columns: 1fr 260px; gap: 20px; align-items: start; }
  .map-panel { display: block; position: sticky; top: 8px; }
  .exam-actions {
    position: static; padding: 0; margin-top: 20px;
    background: none; backdrop-filter: none; border: 0; animation: none;
  }
  .exam-actions .btn { flex: 0 0 auto; min-width: 140px; }
  .exam-actions .map-toggle { display: none; }
  .swipe-hint { display: none; }
  .map-grid { grid-template-columns: repeat(5, 1fr); }
  .map-cell { min-height: 0; font-size: 0.78rem; }

  .card { padding: 20px; }
  .question-card { padding: 26px; }
  .option:hover:not(:disabled) { border-color: #33456f; background: var(--surface-2); }
  .chip:hover { color: var(--text); }
  .btn:hover:not(:disabled) { filter: brightness(1.08); }
  button.list-row:hover { background: var(--surface-2); }
}

/* =========================================================================
   Tela de autenticacao
   ========================================================================= */

body.booting .app-shell,
body.booting .tabbar { visibility: hidden; }

body.locked { overflow: hidden; }
body.locked .app-shell,
body.locked .tabbar { display: none; }

.auth-screen {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  background:
    radial-gradient(80% 55% at 50% -10%, rgba(79,140,255,.16), transparent 70%),
    radial-gradient(60% 45% at 100% 100%, rgba(139,92,246,.12), transparent 70%),
    var(--bg);
  overflow-y: auto;
}
.auth-screen[hidden] { display: none; }

.auth-card {
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; align-items: center;
  padding: 34px 24px 26px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: auth-in .38s var(--ease);
  text-align: center;
}

.auth-mark {
  width: 62px; height: 62px; border-radius: 20px; margin-bottom: 18px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  box-shadow: 0 12px 30px rgba(124, 88, 250, .34);
}
.auth-mark svg {
  width: 34px; height: 34px; fill: none;
  stroke: #fff; stroke-width: 13; stroke-linecap: round; stroke-linejoin: round;
}

.auth-card h1 { font-size: 1.28rem; font-weight: 800; letter-spacing: -0.02em; }
.auth-sub {
  margin-top: 6px; font-size: 0.8rem; line-height: 1.5; color: var(--text-mute);
}

.auth-card form { width: 100%; margin-top: 26px; text-align: left; }
.auth-label {
  display: block; font-size: 0.7rem; font-weight: 800;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-dim);
  margin-bottom: 8px;
}

.auth-field { position: relative; }
.auth-field input {
  width: 100%; height: 56px;
  padding: 0 54px 0 18px;
  font-family: var(--mono); font-size: 1.22rem; letter-spacing: 0.34em;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.auth-field input::placeholder { color: var(--text-mute); letter-spacing: 0.34em; }
.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-eye {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  width: 40px; height: 40px; color: var(--text-mute);
}
.auth-eye svg { width: 20px; height: 20px; fill: currentColor; }

.auth-error {
  margin-top: 12px; padding: 9px 12px;
  font-size: 0.8rem; color: #ffb9bb;
  background: var(--danger-soft); border: 1px solid rgba(242,85,90,.3);
  border-radius: var(--radius-xs);
}
.auth-error[hidden] { display: none; }

.auth-card form .btn { margin-top: 18px; height: 52px; font-size: 0.95rem; }

.auth-foot {
  margin-top: 20px; font-size: 0.72rem; color: var(--text-mute);
}

@keyframes auth-in {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-card.shake { animation: auth-shake .34s var(--ease); }
@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card, .auth-card.shake, .hint-pop { animation: none; }
}
