:root {
  --blue: #1a73e8;
  --blue-dark: #1765cc;
  --blue-050: #e8f0fe;
  --green: #1e8e3e;
  --green-050: #e6f4ea;
  --red: #d93025;
  --red-050: #fce8e6;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #202124;
  --muted: #5f6368;
  --border: #dadce0;
  --shadow-1: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-2: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
  --font: "Roboto", "Google Sans", system-ui, -apple-system, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.appbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 0.6rem; }
.logo {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}
.brand-title { font-size: 1.05rem; font-weight: 500; }

.chip {
  background: var(--blue-050);
  color: var(--blue-dark);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.progress { height: 4px; background: var(--blue-050); }
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--blue);
  transition: width .25s ease;
}

/* ---------- Layout ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-1);
  padding: 1.5rem;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

.card-title { margin: 0 0 0.4rem; font-weight: 500; }

.brand { cursor: pointer; }

.appbar-right { display: flex; align-items: center; gap: 0.5rem; }
.chip-timer { background: #fef7e0; color: #b06000; }
.chip-timer.low { background: var(--red-050); color: var(--red); }

/* ---------- Modo (segmented control) ---------- */
.mode-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.mode-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mode-help { font-size: 0.85rem; }
.seg {
  display: inline-flex;
  background: #e8eaed;
  border-radius: 999px;
  padding: 3px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}
.seg-btn.active { background: var(--surface); color: var(--blue); box-shadow: var(--shadow-1); }

/* ---------- Home / menú ---------- */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.section-title {
  margin: 1.6rem 0 0.7rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.7rem;
}
.grid-tests {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text);
  transition: box-shadow .15s, border-color .15s, transform .05s;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.tile:hover { box-shadow: var(--shadow-1); border-color: #c6d4f0; }
.tile:active { transform: translateY(1px); }
.tile .tile-name { font-weight: 500; }
.tile .tile-sub { font-size: 0.78rem; color: var(--muted); }
.tile .tile-terms {
  font-size: 0.72rem;
  color: #80868b;
  margin-top: 0.15rem;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-test {
  align-items: center;
  text-align: center;
  justify-content: center;
}
.tile-test .tile-name { font-size: 1.05rem; }

.actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ---------- Quiz ---------- */
.quiz-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}
.qcounter { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.tag {
  background: #f1f3f4;
  color: var(--muted);
  border-radius: 6px;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  letter-spacing: .02em;
}

.enunciado { font-size: 1.2rem; font-weight: 500; margin: 0 0 1rem; }

.qimage-wrap {
  margin: 0 0 1rem;
  background: #f1f3f4;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem;
  display: flex;
  justify-content: center;
}
.qimage { max-width: 100%; max-height: 300px; border-radius: 8px; }

.options { list-style: none; padding: 0; margin: 0; }
.options li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.options li:hover { background: #f8faff; border-color: #c6d4f0; }
.options li .letter {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}
.options li.selected { border-color: var(--blue); background: var(--blue-050); }
.options li.selected .letter { border-color: var(--blue); color: var(--blue); }
.options li.correct { border-color: var(--green); background: var(--green-050); }
.options li.correct .letter { border-color: var(--green); background: var(--green); color: #fff; }
.options li.wrong { border-color: var(--red); background: var(--red-050); }
.options li.wrong .letter { border-color: var(--red); background: var(--red); color: #fff; }
.options li.disabled { cursor: default; }
.options li.disabled:hover { background: inherit; }

.explain {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: var(--blue-050);
  border-radius: 12px;
  white-space: pre-wrap;
  font-size: 0.96rem;
}
.explain .src {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 0.6rem;
}

.quiz-nav { display: flex; align-items: center; gap: 0.4rem; margin-top: 1.4rem; }
.quiz-nav .spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 500;
  border-radius: 999px;
  padding: 0.55rem 1.4rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background .15s, box-shadow .15s, color .15s;
}
.btn .ic { font-size: 1rem; }
.btn-filled { background: var(--blue); color: #fff; }
.btn-filled:hover { background: var(--blue-dark); box-shadow: var(--shadow-1); }
.btn-text { background: transparent; color: var(--blue); }
.btn-text:hover { background: var(--blue-050); }
.btn:disabled { opacity: .4; cursor: default; box-shadow: none; }
.btn:disabled:hover { background: transparent; }
.btn-filled:disabled:hover { background: var(--blue); }

/* ---------- Result ---------- */
#result { text-align: center; }
.result-badge {
  width: 72px; height: 72px;
  margin: 0.5rem auto 0.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2.2rem;
}
.result-badge.apto { background: var(--green-050); }
.result-badge.no-apto { background: var(--red-050); }
.result-title { margin: 0 0 0.25rem; font-weight: 700; }
.result-title.apto { color: var(--green); }
.result-title.no-apto { color: var(--red); }
#result .actions { justify-content: center; }

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  font-size: 0.8rem;
  padding: 1.25rem 1rem 1.75rem;
}

@media (max-width: 520px) {
  .brand-title { font-size: 0.95rem; }
  .enunciado { font-size: 1.1rem; }
  .btn { padding: 0.55rem 1.1rem; }
}
