:root {
  --bg: #f2f2f7;
  --bg-glass: rgba(242, 242, 247, 0.78);
  --surface: #ffffff;
  --surface-2: rgba(0, 0, 0, 0.04);
  --surface-3: rgba(0, 0, 0, 0.08);
  --text: #1c1c1e;
  --text-muted: #6e6e73;
  --primary: #007aff;
  --primary-text: #ffffff;
  --primary-container: rgba(0, 122, 255, 0.12);
  --on-primary-container: #0067d6;
  --correct: #248a3d;
  --correct-container: rgba(52, 199, 89, 0.14);
  --wrong: #d70015;
  --wrong-container: rgba(255, 59, 48, 0.12);
  --border: rgba(0, 0, 0, 0.08);
  --card-border: rgba(0, 0, 0, 0.06);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 22, 40, 0.04), 0 1px 8px rgba(20, 22, 40, 0.04);
  --shadow-raised: 0 12px 26px -10px rgba(20, 22, 40, 0.18);
  --blur: blur(20px);
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-glass: rgba(0, 0, 0, 0.6);
  --surface: rgba(28, 28, 30, 0.65);
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-3: rgba(255, 255, 255, 0.1);
  --text: #f5f5f7;
  --text-muted: #8e8e93;
  --primary: #0a84ff;
  --primary-text: #ffffff;
  --primary-container: rgba(10, 132, 255, 0.16);
  --on-primary-container: #5eb0ff;
  --correct: #30d158;
  --correct-container: rgba(48, 209, 88, 0.14);
  --wrong: #ff453a;
  --wrong-container: rgba(255, 69, 58, 0.14);
  --border: rgba(255, 255, 255, 0.12);
  --card-border: rgba(255, 255, 255, 0.1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 8px rgba(0, 0, 0, 0.25);
  --shadow-raised: 0 16px 34px -12px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

a { color: var(--primary); }

/* Ambient glass glow, dark mode only */
#app::before,
#app::after {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
  filter: blur(90px);
}
[data-theme="dark"] #app::before,
[data-theme="dark"] #app::after {
  opacity: 1;
}
#app::before {
  top: -12%;
  left: -10%;
  width: 65vw;
  height: 65vw;
  max-width: 480px;
  max-height: 480px;
  background: radial-gradient(circle, rgba(10, 132, 255, 0.18) 0%, rgba(0, 0, 0, 0) 70%);
}
#app::after {
  top: 30%;
  right: -20%;
  width: 70vw;
  height: 70vw;
  max-width: 560px;
  max-height: 560px;
  background: radial-gradient(circle, rgba(191, 90, 242, 0.13) 0%, rgba(0, 0, 0, 0) 70%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 14px;
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.topbar h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  flex: 1;
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
  display: block;
  margin-top: 2px;
  white-space: normal;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.05rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.icon-btn:hover { background: var(--surface-3); }
.icon-btn:active { transform: scale(0.94); }

main {
  flex: 1;
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 28px);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s ease, background 0.25s ease;
}

.card-link { cursor: pointer; }
.card-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-raised); border-color: var(--primary); }
.card-link:active { transform: translateY(0); box-shadow: var(--shadow); }

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.card-row .title { font-weight: 600; font-size: 0.98rem; letter-spacing: -0.01em; }
.card-row .meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.answered-meta { font-size: 0.8rem; color: var(--correct); font-weight: 500; margin-top: 2px; }

.badge {
  background: var(--surface-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  flex-shrink: 0;
}

.badge.score {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-color: transparent;
}

.section-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 22px 2px 10px;
  padding-left: 10px;
  border-left: 3px solid var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.btn-primary { background: var(--primary); color: var(--primary-text); box-shadow: 0 8px 20px -8px rgba(10, 132, 255, 0.55); }
.btn-primary:hover { box-shadow: 0 8px 24px -6px rgba(10, 132, 255, 0.65); filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.4; box-shadow: none; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-text { background: transparent; color: var(--primary); font-weight: 600; }

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar > div { height: 100%; background: linear-gradient(90deg, #0a84ff, #5e5ce6); border-radius: 999px; transition: width 0.25s ease; }
.progress-bar.answered > div { background: linear-gradient(90deg, #30d158, #29c46f); }

input[type="password"], input[type="number"], input[type="text"], textarea {
  font-size: 1rem;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s ease;
}
input[type="password"]:focus, input[type="number"]:focus, input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
textarea { font-family: inherit; resize: vertical; margin-top: 10px; }

.error-text { color: var(--wrong); font-size: 0.85rem; min-height: 1.2em; }

.account-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 15px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  margin-bottom: 12px;
}
.account-form .field-label { font-size: 0.8rem; color: var(--text-muted); }
.account-status { color: var(--text-muted); }
.account-status.is-error { color: var(--wrong); }
.account-status.is-success { color: var(--correct); }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 13px 15px;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 10px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.option:not(:disabled):hover { border-color: var(--primary); transform: translateY(-1px); }
.option:not(:disabled):active { transform: translateY(0); }

.option-letter {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.82rem;
  background: var(--surface-3);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.option-text { flex: 1; line-height: 1.4; }
.option-icon { font-size: 1.1rem; flex-shrink: 0; }

.option.correct { background: var(--correct-container); border-color: var(--correct); border-width: 2px; color: var(--text); }
.option.wrong   { background: var(--wrong-container);   border-color: var(--wrong);   border-width: 2px; color: var(--text); }
.option.correct .option-letter { background: var(--correct); color: white; }
.option.wrong   .option-letter { background: var(--wrong);   color: white; }
.option:disabled { cursor: default; }

.feedback-banner {
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.feedback-banner.correct { background: var(--correct-container); color: var(--correct); }
.feedback-banner.wrong { background: var(--wrong-container); color: var(--wrong); }

.explanation {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px;
  margin-top: 4px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.explanation .label { color: var(--primary); font-weight: 700; font-size: 0.85rem; margin-bottom: 4px; }

.quiz-image {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

.chip {
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.chip:hover { border-color: var(--primary); }
.chip.selected { background: var(--primary-container); border-color: var(--primary); color: var(--on-primary-container); font-weight: 600; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--card-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: 20px;
  padding: 22px;
  max-width: 360px;
  width: 100%;
  max-height: 86dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-raised);
}

.modal h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.score-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 8px;
}

.timer-pill {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.timer-pill.urgent { background: var(--wrong-container); color: var(--wrong); border-color: transparent; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 0.95rem;
}

.theme-options, .radio-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px;
  cursor: pointer;
}
.radio-row.selected { background: var(--primary-container); border-color: var(--primary); color: var(--on-primary-container); }

.loading-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--surface-3);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Dashboard (bento) ---------- */

main.dashboard-main {
  max-width: 1180px;
}

.dash-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 14px;
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  flex-wrap: wrap;
}

.nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}

.nav-pill-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}
.nav-pill-item:hover { color: var(--text); }
.nav-pill-item.active { background: var(--text); color: var(--bg); }

.hero {
  margin: 26px 0 24px;
}

.hero-left { max-width: 560px; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: 999px;
  padding: 5px 13px 5px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  border: none;
}
.hero-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.hero-title {
  font-size: clamp(1.6rem, 5vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 10px 0 6px;
  line-height: 1.1;
}

.hero-subtitle { color: var(--text-muted); font-size: 0.92rem; line-height: 1.55; margin: 0; }

.module-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 680px) {
  .module-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1020px) {
  .module-grid { grid-template-columns: repeat(4, 1fr); }
  .module-card.featured { grid-column: span 2; }
}

.module-card {
  position: relative;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  min-height: 200px;
}
.module-card.featured {
  background: linear-gradient(165deg, var(--primary-container) 0%, var(--surface) 55%);
  min-height: 260px;
}
[data-theme="dark"] .module-card.featured {
  background: linear-gradient(165deg, rgba(10, 132, 255, 0.16) 0%, rgba(28, 28, 30, 0.65) 60%);
}

.module-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding-right: 28px;
}

.favorite-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
}
.favorite-btn.active { color: #f5a623; }
.module-card.featured .favorite-btn { top: 16px; right: 62px; }

.module-title {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  margin-top: 3px;
  line-height: 1.25;
  padding-right: 8px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-height: calc(1.25em * 2);
}
.module-card.featured .module-title { font-size: 1.35rem; padding-right: 46px; min-height: calc(1.25em * 2); }

.play-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  box-shadow: var(--shadow-raised);
  flex-shrink: 0;
}

.pill-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.74rem;
  color: var(--text-muted);
}
.pill-badge strong { color: var(--text); font-weight: 600; }

.meta-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; font-size: 0.82rem; }
.meta-row { display: flex; justify-content: space-between; gap: 10px; }
.meta-row .k { color: var(--text-muted); }
.meta-row .v { font-weight: 600; text-align: right; }

.card-divider { height: 1px; background: var(--border); margin: 16px 0 10px; border: none; }

.card-footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: var(--text-muted); margin-top: auto; }
.card-footer .pct { font-weight: 700; color: var(--primary); }

.study-progress {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.study-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.study-progress-label .k { font-weight: 600; font-size: 0.88rem; }
.study-progress-label .pct { font-weight: 800; font-size: 1.15rem; color: var(--primary); }
.study-progress-sub { font-size: 0.78rem; color: var(--text-muted); margin: 3px 0 10px; }

/* ---------- Bento redesign (indigo accent) — Settings + Module pages ---------- */

:root { --accent-indigo: #818cf8; }

.bg-grid-fade {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-size: 40px 40px;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  mask-image: linear-gradient(to bottom, black 20%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 20%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
[data-theme="dark"] .bg-grid-fade { opacity: 1; }

.settings-section-label,
.bento-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 2px 14px;
}
.settings-section-label .bar,
.bento-section-label .bar {
  width: 4px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent-indigo);
  box-shadow: 0 0 8px rgba(129, 140, 248, 0.5);
  flex-shrink: 0;
}
.settings-section-label span,
.bento-section-label span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.bento-list { display: flex; flex-direction: column; gap: 10px; }

.bento-item {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 15px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: background 0.25s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.25s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.bento-item:hover:not(.bento-item-active) {
  background: var(--surface-3);
  transform: translateX(4px);
}
.bento-item .label {
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s ease;
}
.bento-item:hover .label { color: var(--text); }

.bento-item-active { background: rgba(129, 140, 248, 0.08); }
.bento-item-active .label { color: var(--text); font-weight: 600; }
.bento-item-active::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(45deg, rgba(129, 140, 248, 0.6), transparent 80%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.bento-item-check {
  color: var(--accent-indigo);
  font-weight: 700;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(129, 140, 248, 0.6));
}

/* Module detail page */

.module-overview-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 22px;
  overflow: hidden;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  margin-bottom: 16px;
}
.module-overview-card::before {
  content: "";
  position: absolute;
  top: -48px;
  right: -48px;
  width: 190px;
  height: 190px;
  background: rgba(129, 140, 248, 0.12);
  filter: blur(60px);
  border-radius: 50%;
  pointer-events: none;
}
.module-overview-bar {
  position: relative;
  width: 100%;
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}
.module-overview-bar > div {
  height: 100%;
  background: var(--accent-indigo);
  border-radius: 999px;
  transition: width 0.25s ease;
}
.module-overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: relative;
}
.module-overview-head h3 { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.module-overview-pct {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-indigo);
  background: rgba(129, 140, 248, 0.12);
  padding: 3px 9px;
  border-radius: 999px;
  flex-shrink: 0;
}
.module-overview-sub { font-size: 0.82rem; color: var(--text-muted); margin: 4px 0 0; position: relative; }

.action-row { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
@media (min-width: 560px) { .action-row { flex-direction: row; } }

.btn-glow {
  flex: 1;
  background: rgba(129, 140, 248, 0.1);
  border: 1px solid rgba(129, 140, 248, 0.3);
  color: var(--accent-indigo);
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  text-align: center;
}
.btn-glow:hover {
  background: rgba(129, 140, 248, 0.18);
  border-color: rgba(129, 140, 248, 0.5);
  box-shadow: 0 0 20px rgba(129, 140, 248, 0.15);
}

.btn-bento-secondary {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
@media (min-width: 560px) { .btn-bento-secondary { width: auto; } }
.btn-bento-secondary:hover { background: var(--surface-3); color: var(--text); }
.btn-bento-secondary.selected { color: var(--text); border-color: var(--accent-indigo); }

.bento-item-review {
  border-color: rgba(129, 140, 248, 0.3);
  background: rgba(129, 140, 248, 0.06);
}
.bento-item-review .label { color: var(--text); font-weight: 600; }
.bento-item-review .count-badge {
  background: var(--accent-indigo);
  color: #0a0a0a;
  font-weight: 700;
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 3px 10px;
}

.bento-item-sub {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.bento-item-sub-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}
.bento-item-sub .sub-title { font-weight: 500; color: var(--text); }
.bento-item-sub .sub-meta { display: flex; align-items: center; gap: 12px; font-size: 0.76rem; }
.bento-item-sub .sub-meta .best { color: var(--text-muted); }
.bento-item-sub .sub-meta .answered { color: var(--correct); font-weight: 500; }
.count-pill {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 4px 10px;
  flex-shrink: 0;
}
.bento-item-sub .mini-bar {
  width: 100%;
  max-width: 200px;
  height: 4px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.bento-item-sub .mini-bar > div { height: 100%; background: var(--correct); border-radius: 999px; }

/* "Modern bento" override so na pagina de detalhe do modulo, modo escuro
   (mockup part66_module_details_empty_modern.html, pedido 2026-09-01):
   accent azul-500 em vez do indigo partilhado, cartoes quase-pretos com
   borda subtil em vez do surface translucido. Escopado a esta pagina, nao
   ao design system global -- mesmo padrao ja usado em .download-view. */
[data-theme="dark"] .module-detail-view { --md-accent: #3b82f6; }

[data-theme="dark"] .module-detail-view .bento-item,
[data-theme="dark"] .module-detail-view .module-overview-card,
[data-theme="dark"] .module-detail-view .btn-bento-secondary {
  background: #0a0a0a;
  border-color: #222222;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
[data-theme="dark"] .module-detail-view .bento-item:hover:not(.bento-item-active) {
  background: #121212;
  border-color: #333333;
}
[data-theme="dark"] .module-detail-view .bento-section-label .bar {
  background: var(--md-accent);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}
[data-theme="dark"] .module-detail-view .btn-glow {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--md-accent);
}
[data-theme="dark"] .module-detail-view .btn-glow:hover {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
}
[data-theme="dark"] .module-detail-view .btn-bento-secondary.selected { border-color: var(--md-accent); }
[data-theme="dark"] .module-detail-view .module-overview-card::before { background: rgba(59, 130, 246, 0.12); }
[data-theme="dark"] .module-detail-view .module-overview-bar { background: #1c1c1e; }
[data-theme="dark"] .module-detail-view .module-overview-bar > div { background: var(--md-accent); }
[data-theme="dark"] .module-detail-view .module-overview-pct {
  color: var(--md-accent);
  background: rgba(59, 130, 246, 0.12);
}
[data-theme="dark"] .module-detail-view .bento-item-review {
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.06);
}
[data-theme="dark"] .module-detail-view .bento-item-review .count-badge { background: var(--md-accent); color: #050505; }
[data-theme="dark"] .module-detail-view .count-pill { background: #121212; border-color: #222222; }

/* ---------- Download page (blue accent, bento redesign) ---------- */

.download-view { --dl-accent: #2563eb; --dl-accent-light: #3b82f6; }

.dl-info-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.dl-info-banner .icon-badge {
  background: rgba(59, 130, 246, 0.2);
  color: var(--dl-accent-light);
  border-radius: 12px;
  padding: 8px;
  flex-shrink: 0;
  display: flex;
}
.dl-info-banner p { margin: 2px 0 0; font-size: 0.88rem; line-height: 1.5; color: var(--text); }

.dl-card {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 16px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: background 0.25s ease, border-color 0.25s ease;
}

.dl-card-head { display: flex; align-items: center; gap: 12px; }
.dl-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dl-card-icon.android { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.2); color: #10b981; }
.dl-card-icon.ios { background: var(--surface-3); border: 1px solid var(--border); color: var(--text); }
.dl-card-title { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.dl-card-meta { font-size: 0.76rem; color: var(--text-muted); margin: 2px 0 0; }

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

.dl-btn {
  width: 100%;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.dl-btn-primary {
  background: var(--dl-accent);
  border: 1px solid var(--dl-accent-light);
  color: #ffffff;
}
.dl-btn-primary:hover { background: #1d4ed8; box-shadow: 0 0 20px rgba(37, 99, 235, 0.3); }
.dl-btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.dl-btn-secondary:hover { background: var(--surface-3); border-color: var(--text-muted); }

.dl-note {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}
.dl-note svg { flex-shrink: 0; margin-top: 1px; }
.dl-note a { color: var(--dl-accent-light); }

.changelog-intro { color: var(--text-muted); font-size: 0.88rem; margin: 0 0 18px; }
.changelog-list { display: flex; flex-direction: column; gap: 14px; }
.changelog-loading { color: var(--text-muted); font-size: 0.88rem; }

.changelog-entry {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 20px 22px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.changelog-entry-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.changelog-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
}
.changelog-badge-web { background: rgba(79, 109, 245, 0.12); color: var(--primary); }
.changelog-badge-android { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.changelog-badge-ios { background: var(--surface-3); color: var(--text); border: 1px solid var(--border); }
.changelog-version { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); }
.changelog-date { font-size: 0.78rem; color: var(--text-muted); margin-left: auto; }

.changelog-title { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 10px; }
.changelog-changes { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 0.86rem; line-height: 1.5; color: var(--text); }

.dl-footer {
  display: flex;
  justify-content: center;
  margin: 32px 0 16px;
  opacity: 0.5;
}

/* Footer persistente (app-shell, ver router.js) + pagina de Contacto.
   #app e flex-column (min-height:100dvh); sem flex:1 aqui, o footer ficava
   logo a seguir ao conteudo em paginas curtas e sobrava um vazio enorme
   por baixo dele ate perfazer o min-height de #app -- flex:1 faz o
   conteudo esticar e empurra o footer para o fundo do ecra. */
.app-page { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.app-page > * { flex-shrink: 0; }

.app-footer {
  padding: 22px 16px calc(env(safe-area-inset-bottom, 0px) + 22px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.app-footer-inner {
  width: 100%;
  max-width: 720px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.app-footer-link {
  color: var(--accent-indigo);
  text-decoration: none;
  font-weight: 600;
}
.app-footer-link:hover { text-decoration: underline; }

.contact-view main { display: flex; justify-content: center; padding-top: 24px; }

.contact-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 36px 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.contact-icon { font-size: 2.4rem; margin-bottom: 10px; }

.contact-card h2 { margin: 0 0 8px; font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }

.contact-sub { margin: 0 0 22px; font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }

.contact-whatsapp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 20px;
  border-radius: 16px;
  background: #25d366;
  color: #06210f;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  transition: filter 0.2s ease;
}
.contact-whatsapp-btn:hover { filter: brightness(1.08); }
