/* ==========================================================================
   Tahfidz — main frame stylesheet
   Minimal, modern, mobile-friendly. Light + dark themes via [data-theme].
   ========================================================================== */

/* ==========================================================================
   Palet MONOKROM — satu keluarga hue (abu-abu netral dingin).
   Terang & gelap dibuat dari tint/shade warna yang sama (color theory
   monokrom). Tidak memakai #000 murni maupun #fff murni.
   ========================================================================== */

:root {
  color-scheme: light;

  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --font-arabic: "Amiri", "Scheherazade New", "Traditional Arabic", serif;

  /* Netral utama */
  --bg: #f4f5f6;
  --surface: #fbfcfc;
  --surface-2: #eceef0;
  --text: #191c1f;
  --text-soft: #454b52;
  --muted: #69717a;
  --border: #dee1e5;
  --border-strong: #c4c9cf;

  /* Aksen (satu hue, hanya beda nilai/lightness) */
  --accent: #23272c;
  --accent-strong: #121519;
  --accent-soft: #e3e6e9;
  --accent-contrast: #f4f5f6;

  /* Status: desaturasi ringan agar tetap terbaca, tidak merusak kesan monokrom */
  --success: #577565;
  --success-soft: #e9efeb;
  --danger: #a3574d;
  --danger-soft: #f6ecea;
  --warning: #96722e;
  --warning-soft: #f4efe2;

  /* Kartu quote (panel terbalik, monokrom) */
  --quote-bg: #23272c;
  --quote-border: transparent;
  --quote-text: #f2f4f5;
  --quote-text-soft: #c7cdd3;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(16, 18, 22, 0.06);
  --shadow-md: 0 6px 24px rgba(16, 18, 22, 0.08);
  --shadow-lg: 0 16px 48px rgba(16, 18, 22, 0.14);

  --header-h: 64px;
  --max-w: 1080px;
  --max-w-narrow: 480px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #111316;
  --surface: #191c20;
  --surface-2: #22262b;
  --text: #e7eaed;
  --text-soft: #a6adb5;
  --muted: #8b939c;
  --border: #292e34;
  --border-strong: #394046;

  --accent: #e7eaed;
  --accent-strong: #f5f7f9;
  --accent-soft: #2a2f35;
  --accent-contrast: #121417;

  --success: #8fb39c;
  --success-soft: #243129;
  --danger: #d39289;
  --danger-soft: #362623;
  --warning: #ccae6b;
  --warning-soft: #332b1b;

  --quote-bg: #23282d;
  --quote-border: #394046;
  --quote-text: #eef1f4;
  --quote-text-soft: #aeb6be;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  /* Cegah scrollbar horizontal: drawer tertutup (translateX 100%) tidak
     boleh menambah area scroll dokumen. */
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 0 0 0.4em;
}

p {
  margin: 0 0 1em;
}

/* ---------- Layout ---------- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 20px 72px;
}

.site-main--narrow {
  max-width: var(--max-w-narrow);
}

/* ---------- Boot screen ---------- */
.boot-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
}

.boot-logo {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  color: var(--accent-contrast);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-radius: 22px;
  box-shadow: var(--shadow-md);
}

.boot-logo svg {
  width: 34px;
  height: 34px;
}

.boot-text {
  margin: 0;
  font-size: 14px;
}

/* ---------- Ikon SVG monokrom ---------- */
.ic {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.navbar__logo .ic {
  width: 20px;
  height: 20px;
}

.drawer__icon .ic {
  width: 18px;
  height: 18px;
}

.placeholder-card__icon .ic {
  width: 20px;
  height: 20px;
}

.quiz-intro__icon .ic,
.coming-page__icon .ic {
  width: 30px;
  height: 30px;
}

.empty-state__icon .ic {
  width: 40px;
  height: 40px;
}

/* ---------- Spinner ---------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner--lg {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

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

/* ---------- Header / Navbar ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.navbar {
  max-width: var(--max-w);
  margin: 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.navbar__brand:hover {
  text-decoration: none;
}

.navbar__brand .navbar__logo {
  transition: transform 0.2s ease;
}

.navbar__brand:hover .navbar__logo {
  transform: scale(1.06);
}

.navbar__logo {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--accent-contrast);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
}

.navbar__links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.navbar__links::-webkit-scrollbar {
  display: none;
}

.nav-link {
  position: relative;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

/* Underline animasi saat hover/aktif */
.nav-link::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.nav-link:hover::after,
.nav-link:focus-visible::after,
.nav-link--active::after {
  opacity: 1;
  transform: scaleX(1);
}

.nav-link--active {
  color: var(--accent);
  background: var(--accent-soft);
}

.navbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.navbar__user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.navbar__user:hover {
  text-decoration: none;
  border-color: var(--border-strong);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--accent-contrast);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.navbar__username {
  font-size: 13.5px;
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar__toggle {
  display: none;
}

/* Drawer (mobile) */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(2, 6, 23, 0.5);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.drawer-overlay.drawer-overlay--open {
  opacity: 1;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 86vw);
  z-index: 95;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 20px;
  transform: translateX(100%);
  transition: transform 0.24s ease;
  overflow-y: auto;
}

.drawer--open {
  transform: translateX(0);
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.drawer__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.drawer__close {
  background: var(--surface-2);
  border: none;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--text-soft);
}

.drawer__group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 18px;
}

.drawer__label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 10px 0 4px 8px;
}

.drawer__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--text-soft);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.drawer__item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.drawer__item--active {
  color: var(--accent);
  background: var(--accent-soft);
}

.drawer__icon {
  width: 22px;
  text-align: center;
  font-size: 16px;
}

.drawer__item--danger {
  color: var(--danger);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
  user-select: none;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
  background: var(--accent-strong);
}

.btn--ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border-strong);
}

.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--soft {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.btn--soft:hover {
  filter: brightness(0.98);
}

.btn--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn--danger:hover {
  background: color-mix(in srgb, var(--danger-soft) 85%, var(--danger));
}

.btn--block {
  width: 100%;
}

.btn--lg {
  padding: 13px 24px;
  font-size: 16px;
  border-radius: 14px;
}

.btn--sm {
  padding: 7px 12px;
  font-size: 13.5px;
  border-radius: 10px;
}

.btn .spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.card--interactive {
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
  cursor: pointer;
}

.card--interactive:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

/* ---------- Homepage ---------- */
.hero {
  text-align: center;
  padding: 48px 8px 32px;
}

.hero__title {
  font-size: clamp(34px, 7vw, 56px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 14px;
}

.hero__title em {
  font-style: normal;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__subtitle {
  font-size: clamp(16px, 2.4vw, 19px);
  color: var(--text-soft);
  max-width: 520px;
  margin: 0 auto 30px;
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 8px;
}

.hero__note {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 16px;
}

/* ---------- Auth pages ---------- */
.auth-card {
  margin-top: 24px;
}

.auth-card__head {
  text-align: center;
  margin-bottom: 24px;
}

.auth-card__title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-card__sub {
  color: var(--text-soft);
  margin: 0;
}

.auth-card__foot {
  text-align: center;
  margin-top: 20px;
  color: var(--text-soft);
  font-size: 14px;
}

.auth-card__foot a {
  font-weight: 600;
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 5px;
}

.form-error {
  font-size: 12.5px;
  color: var(--danger);
  margin-top: 5px;
  display: none;
}

.form-group--invalid .form-error {
  display: block;
}

.input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input::placeholder {
  color: var(--muted);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.form-group--invalid .input {
  border-color: var(--danger);
}

.form-group--invalid .input:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}

/* ---------- Dashboard ---------- */
.dash-head {
  margin-bottom: 22px;
}

.dash-greet {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.placeholder-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 150px;
}

.placeholder-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.placeholder-card__icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: var(--surface-2);
  color: var(--text-soft);
}

.coming-soon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--warning);
  background: var(--warning-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.placeholder-card h3 {
  font-size: 16px;
  margin: 0;
}

.placeholder-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 13.5px;
  flex: 1;
}

.placeholder-card__cta {
  margin-top: auto;
}

.quote-card {
  background: var(--quote-bg);
  border: 1px solid var(--quote-border);
  color: var(--quote-text);
}

.quote-card__icon {
  color: var(--quote-text);
  background: color-mix(in srgb, var(--quote-text) 16%, transparent);
}

.quote-card h3,
.quote-card p {
  color: var(--quote-text);
}

.quote-text {
  font-family: var(--font-arabic);
  font-size: 18px;
  line-height: 2;
  text-align: right;
}

.quote-trans {
  color: var(--quote-text-soft);
  font-size: 13.5px;
}

.quote-source {
  margin: 12px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--quote-text-soft);
  text-align: right;
}

/* ---------- Page header ---------- */
.page-head {
  margin-bottom: 22px;
}

.page-head__title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}

.page-head__sub {
  color: var(--text-soft);
  margin: 4px 0 0;
  font-size: 14.5px;
}

/* ---------- Empty / placeholder states ---------- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-soft);
}

.empty-state__icon {
  font-size: 44px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.empty-state__title {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state__desc {
  font-size: 14px;
  max-width: 380px;
  margin: 0 auto 18px;
}

/* Coming soon page */
.coming-page {
  text-align: center;
  padding: 56px 20px;
}

.coming-page__icon {
  width: 84px;
  height: 84px;
  margin: 0 auto 20px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  font-size: 36px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.coming-page h1 {
  font-size: 26px;
  font-weight: 800;
}

.coming-page p {
  color: var(--text-soft);
  max-width: 420px;
  margin: 0 auto 24px;
}

/* ---------- Profile ---------- */
.profile-section {
  margin-bottom: 20px;
}

.profile-section__title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-divider {
  height: 1px;
  background: var(--border);
  margin: 26px 0;
  border: 0;
}

/* ---------- Quiz ---------- */
.quiz-shell {
  max-width: 640px;
  margin: 0 auto;
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 36px 32px;
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.quiz-progress__bar {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.quiz-progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.quiz-progress__label {
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 600;
  white-space: nowrap;
}

.quiz-question {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 8px;
}

.quiz-category {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 22px;
}

.quiz-options {
  display: grid;
  gap: 12px;
}

.quiz-options--pair {
  grid-template-columns: repeat(2, 1fr);
}

.quiz-option {
  text-align: left;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quiz-option:disabled {
  cursor: default;
  opacity: 0.85;
}

.quiz-option--correct {
  border-color: var(--success);
  background: var(--success-soft);
  font-weight: 600;
}

.quiz-option--wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.quiz-option__check {
  float: right;
}

.quiz-next {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

/* Quiz intro */
.quiz-intro {
  text-align: center;
}

.quiz-intro__icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 24px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 32px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.quiz-intro h1 {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 8px;
}

.quiz-intro .meta {
  color: var(--text-soft);
  margin: 0 auto 28px;
  max-width: 380px;
  font-size: 14.5px;
}

/* Quiz setup (topik, juz, jumlah soal) */
.quiz-setup {
  display: flex;
  flex-direction: column;
  gap: 24px;
  text-align: left;
}

.quiz-setup__block {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.quiz-setup__row {
  display: flex;
  gap: 24px;
  align-items: stretch;
  flex-wrap: wrap;
}

.quiz-setup__block--grow {
  flex: 1 1 220px;
  min-width: 0;
}

.quiz-setup__label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.quiz-topics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.quiz-topic {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

.quiz-topic:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.quiz-topic--active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quiz-topic__icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text-soft);
}

.quiz-topic--active .quiz-topic__icon {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.quiz-topic__label {
  font-weight: 600;
  font-size: 14.5px;
}

/* Select juz */
.quiz-select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

.quiz-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.quiz-juz-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}

/* Jumlah soal: input angka + slider */
.quiz-count-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.quiz-count-input {
  flex: 1;
  min-width: 0;
  padding: 12px 10px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  -moz-appearance: textfield;
  appearance: textfield;
}

.quiz-count-input::-webkit-outer-spin-button,
.quiz-count-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.quiz-count-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.quiz-step {
  width: 44px;
  height: 46px;
  padding: 0;
  font-size: 18px;
  flex-shrink: 0;
}

.quiz-range {
  width: 100%;
  margin-top: 16px;
  accent-color: var(--accent);
  height: 6px;
  cursor: pointer;
}

.quiz-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
}

/* Quiz result */
.quiz-result {
  text-align: center;
}

.result-score {
  font-size: clamp(44px, 10vw, 64px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 6px 0 2px;
}

.result-label {
  color: var(--text-soft);
  margin-bottom: 18px;
}

.result-ring {
  width: 140px;
  height: 140px;
  margin: 0 auto 6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(closest-side, var(--surface) 78%, transparent 79% 100%),
    conic-gradient(var(--accent) calc(var(--p, 0) * 1%), var(--surface-2) 0);
}

.result-message {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.result-sub {
  color: var(--text-soft);
  font-size: 14px;
  margin-bottom: 4px;
}

.result-note {
  color: var(--muted);
  font-size: 12.5px;
  margin-bottom: 22px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface);
}

/* ---------- Toast ---------- */
#toast-root {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  width: 100%;
}

.toast--show {
  opacity: 1;
  transform: translateY(0);
}

.toast__icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  flex-shrink: 0;
}

.toast--success .toast__icon {
  background: var(--success-soft);
  color: var(--success);
}

.toast--error .toast__icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.toast--info .toast__icon {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(2, 6, 23, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.18s ease;
}

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

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 520px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.22s ease;
}

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

.modal__title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
}

.modal__body {
  color: var(--text-soft);
  font-size: 14.5px;
  margin-bottom: 22px;
}

.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 20px;
  }

  .modal {
    border-radius: var(--radius-lg);
  }
}

/* ---------- Error page ---------- */
.error-page {
  text-align: center;
  padding: 72px 20px;
}

.error-page h1 {
  font-size: 72px;
  margin: 0;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Utilities ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spacer {
  flex: 1;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.text-muted { color: var(--muted); }
.text-soft { color: var(--text-soft); }
.text-center { text-align: center; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Responsive ---------- */

/* Tablet & mobile: menu masuk drawer */
@media (max-width: 900px) {
  .navbar__links {
    display: none;
  }

  .navbar__toggle {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 18px;
    color: var(--text);
    margin-left: auto;
    flex-shrink: 0;
  }

  .navbar__user .navbar__username {
    display: none;
  }

  .navbar__actions {
    margin-left: auto;
  }
}

/* Layar kecil: navbar ringkas, tombol auth dipindah ke drawer */
@media (max-width: 560px) {
  .navbar {
    padding: 0 14px;
    gap: 8px;
  }

  .navbar__brand {
    font-size: 17px;
  }

  /* Tombol "Masuk/Daftar/Keluar" ada di drawer, disembunyikan di navbar
     agar tidak meluap pada layar sempit. */
  .navbar__actions a.btn--ghost,
  .navbar__actions a.btn--primary,
  .navbar__actions .nav-logout {
    display: none;
  }

  .navbar__actions {
    gap: 6px;
  }
}

/* Quiz: grid topik menjadi dua kolom saat cukup lebar */
@media (min-width: 560px) {
  .quiz-topics {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile */
@media (max-width: 480px) {
  .site-main {
    padding: 20px 16px 64px;
  }

  .card {
    padding: 18px;
  }

  .hero {
    padding: 36px 4px 24px;
  }

  .dash-grid {
    grid-template-columns: 1fr;
  }

  .quiz-card {
    padding: 28px 20px;
  }

  .quiz-setup__row {
    flex-direction: column;
    gap: 20px;
  }

  .quiz-topic {
    padding: 13px 14px;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions .btn {
    width: 100%;
  }
}

/* Layar sangat kecil (320–380px) */
@media (max-width: 380px) {
  .site-main {
    padding: 18px 12px 60px;
  }

  .navbar__brand span:last-child {
    display: none;
  }

  .navbar__toggle,
  .nav-theme {
    width: 36px;
    height: 36px;
  }

  .hero__cta .btn {
    width: 100%;
  }

  .quiz-card {
    padding: 24px 18px;
  }

  .quiz-options--pair {
    grid-template-columns: 1fr;
  }

  .quiz-count-row {
    gap: 8px;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
