@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --navy:   #0F2040;
  --navy2:  #1A3560;
  --coral:  #E8553E;
  --coral2: #FF7A5E;
  --bg:     #F7F8FC;
  --white:  #FFFFFF;
  --gray1:  #F0F2F7;
  --gray2:  #D8DCE8;
  --gray3:  #9AA3B8;
  --gray4:  #5A6480;
  --text:   #1C2540;
  --easy:   #22C55E;
  --medium: #F59E0B;
  --hard:   #EF4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(15,32,64,0.08);
  --shadow-md: 0 4px 24px rgba(15,32,64,0.12);
  --transition: 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: 'Inter', system-ui, sans-serif; font-size: 16px; line-height: 1.6; color: var(--text); background: var(--bg); min-height: 100vh; }

h1, h2, h3 { font-family: 'DM Serif Display', serif; font-weight: 400; line-height: 1.2; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
h3 { font-size: 1.3rem; }
h4 { font-size: 1rem; font-weight: 600; }
p  { color: var(--gray4); }
a  { color: var(--coral); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ── */
.nav { background: var(--navy); padding: 0 24px; display: flex; align-items: center; justify-content: space-between; height: 60px; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 16px rgba(0,0,0,0.2); }
.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-logo-mark { width: 32px; height: 32px; background: var(--coral); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-family: 'DM Serif Display', serif; font-size: 18px; color: white; }
.nav-logo-text { font-family: 'DM Serif Display', serif; font-size: 1.3rem; color: white; }
.nav-logo-text span { color: var(--coral); }
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-links a { color: rgba(255,255,255,0.75); font-size: 0.9rem; font-weight: 500; padding: 6px 12px; border-radius: var(--radius-sm); transition: var(--transition); text-decoration: none; }
.nav-links a:hover { color: white; background: rgba(255,255,255,0.1); }
.nav-links a.active { color: white; }
.btn-nav { background: var(--coral) !important; color: white !important; padding: 6px 16px !important; border-radius: var(--radius-sm) !important; }
.btn-nav:hover { background: var(--coral2) !important; text-decoration: none !important; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 24px; border-radius: var(--radius); font-weight: 600; font-size: 0.95rem; cursor: pointer; border: none; transition: var(--transition); text-decoration: none; font-family: 'Inter', sans-serif; }
.btn-primary { background: var(--coral); color: white; }
.btn-primary:hover { background: var(--coral2); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(232,85,62,0.35); text-decoration: none; color: white; }
.btn-secondary { background: var(--navy); color: white; }
.btn-secondary:hover { background: var(--navy2); text-decoration: none; color: white; }
.btn-outline { background: transparent; color: var(--navy); border: 2px solid var(--gray2); }
.btn-outline:hover { border-color: var(--navy); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--gray4); }
.btn-ghost:hover { background: var(--gray1); color: var(--text); text-decoration: none; }
.btn-lg { padding: 16px 32px; font-size: 1.05rem; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; border-radius: var(--radius-sm); }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-easy   { background: #DCFCE7; color: #166534; }
.badge-medium { background: #FEF3C7; color: #92400E; }
.badge-hard   { background: #FEE2E2; color: #991B1B; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-weight: 600; font-size: 0.875rem; color: var(--text); }
.form-input { padding: 12px 16px; border: 1.5px solid var(--gray2); border-radius: var(--radius-sm); font-size: 0.95rem; font-family: 'Inter', sans-serif; transition: var(--transition); background: var(--white); color: var(--text); width: 100%; }
.form-input:focus { outline: none; border-color: var(--coral); box-shadow: 0 0 0 3px rgba(232,85,62,0.12); }
.form-error { font-size: 0.8rem; color: var(--hard); }
.form-hint  { font-size: 0.8rem; color: var(--gray3); }

/* ── Progress ── */
.progress-bar { height: 6px; background: var(--gray2); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--coral); border-radius: 3px; transition: width 0.3s ease; }

/* ── Layout ── */
.container    { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 680px;  margin: 0 auto; padding: 0 24px; }
.container-xs { max-width: 460px;  margin: 0 auto; padding: 0 24px; }
.section    { padding: 64px 0; }
.section-sm { padding: 40px 0; }
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

/* ── Alert ── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.mb-16 { margin-bottom: 16px; }

/* ── Spinner ── */
.spinner { width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ── */
.footer { background: var(--navy); color: rgba(255,255,255,0.6); padding: 32px 0; margin-top: 80px; font-size: 0.875rem; }
.footer a { color: rgba(255,255,255,0.7); }
.footer a:hover { color: white; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ── Breadcrumb ── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--gray3); padding: 16px 0 0; }
.breadcrumb a { color: var(--gray3); text-decoration: none; }
.breadcrumb a:hover { color: var(--navy); }
.breadcrumb-sep { color: var(--gray2); }

/* ── Domain pages ── */
.domain-header { padding: 40px 0 32px; border-bottom: 1px solid var(--gray2); margin-bottom: 40px; }
.domain-tag { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 12px; background: var(--d-bg, var(--gray1)); color: var(--d-color, var(--navy)); }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.topic-card { background: var(--white); border-radius: var(--radius); padding: 24px; border: 1.5px solid var(--gray2); cursor: pointer; transition: var(--transition); text-decoration: none; display: block; position: relative; overflow: hidden; }
.topic-card::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--d-color, var(--coral)); }
.topic-card:hover { border-color: var(--d-color, var(--coral)); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.topic-card h4 { color: var(--text); margin-bottom: 6px; }
.topic-card p  { font-size: 0.85rem; margin: 0; }
.topic-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.topic-count { font-size: 0.78rem; color: var(--gray3); font-weight: 600; }
.topic-q-count { font-size: 0.78rem; color: var(--d-color, var(--coral)); font-weight: 700; background: var(--d-bg, var(--gray1)); padding: 2px 8px; border-radius: 10px; }

/* ── Utility ── */
.text-center { text-align: center; }
.mt-8  { margin-top: 8px;  } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; } .mt-48 { margin-top: 48px; }
.mb-8  { margin-bottom: 8px;  } .mb-24 { margin-bottom: 24px; } .mb-32 { margin-bottom: 32px; }
.flex { display: flex; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 20px; }

/* ── Practice engine ── */
.practice-top { background: white; border-bottom: 1px solid var(--gray2); padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; position: sticky; top: 60px; z-index: 50; flex-wrap: wrap; }
.practice-topic-name { font-weight: 600; font-size: 0.9rem; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.practice-progress-wrap { flex: 1; min-width: 180px; max-width: 300px; }
.difficulty-select { padding: 6px 12px; border: 1.5px solid var(--gray2); border-radius: var(--radius-sm); font-family: 'Inter', sans-serif; font-size: 0.85rem; color: var(--text); background: white; cursor: pointer; }

.question-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 40px; max-width: 720px; width: 100%; }
.question-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray3); }
.question-stem { font-size: 1.05rem; line-height: 1.7; color: var(--text); margin-bottom: 28px; }

/* MCQ choices */
.choices-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; }
.choice-btn { display: flex; align-items: flex-start; gap: 14px; padding: 16px; border: 2px solid var(--gray2); border-radius: var(--radius-sm); cursor: pointer; background: white; text-align: left; font-family: 'Inter', sans-serif; font-size: 0.95rem; color: var(--text); transition: var(--transition); width: 100%; }
.choice-btn:hover:not(:disabled) { border-color: var(--navy); background: var(--gray1); }
.choice-btn.selected  { border-color: var(--navy); background: #EEF2FF; }
.choice-btn.correct   { border-color: var(--easy); background: #DCFCE7; }
.choice-btn.incorrect { border-color: var(--hard); background: #FEE2E2; }
.choice-btn.show-correct { border-color: var(--easy); background: #DCFCE7; }
.choice-letter { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--gray3); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; flex-shrink: 0; color: var(--gray3); transition: var(--transition); }
.choice-btn.selected  .choice-letter { color: var(--navy);  border-color: var(--navy); }
.choice-btn.correct   .choice-letter { color: #166534; border-color: #166534; }
.choice-btn.incorrect .choice-letter { color: #991B1B; border-color: #991B1B; }
.choice-btn.show-correct .choice-letter { color: #166534; border-color: #166534; }

/* Grid-in */
.gridin-wrap { margin-bottom: 28px; }
.gridin-label { font-size: 0.85rem; font-weight: 600; color: var(--gray4); margin-bottom: 6px; }
.gridin-hint { font-size: 0.78rem; color: var(--gray3); margin-bottom: 10px; }
.gridin-input { padding: 14px 16px; border: 2px solid var(--gray2); border-radius: var(--radius-sm); font-size: 1.1rem; font-family: 'Inter', sans-serif; width: 100%; max-width: 240px; transition: var(--transition); color: var(--text); display: block; }
.gridin-input:focus { outline: none; border-color: var(--navy); }
.gridin-input.correct   { border-color: var(--easy); background: #DCFCE7; }
.gridin-input.incorrect { border-color: var(--hard); background: #FEE2E2; }

/* Question nav dots */
.q-dots { display: flex; flex-wrap: wrap; gap: 5px; max-width: 300px; }
.q-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gray2); transition: var(--transition); }
.q-dot.answered-correct { background: var(--easy); }
.q-dot.answered-wrong   { background: var(--hard); }
.q-dot.current          { background: var(--navy); ring: 2px solid var(--navy); outline: 2px solid var(--navy); outline-offset: 1px; }
.q-dot.skipped          { background: var(--medium); }

/* Actions */
.question-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.skip-btn { color: var(--gray3) !important; font-size: 0.85rem !important; padding: 8px 14px !important; }

/* State screens */
.state-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 50vh; gap: 16px; text-align: center; padding: 24px; }
.state-spinner { width: 36px; height: 36px; border: 3px solid var(--gray2); border-top-color: var(--navy); border-radius: 50%; animation: spin 0.7s linear infinite; }

/* Auth pages */
.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.auth-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 40px; width: 100%; max-width: 420px; }
.pw-wrap { position: relative; }
.pw-wrap .form-input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--gray3); font-size: 1rem; padding: 4px; }

/* Dashboard */
.stat-card { background: white; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.topic-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--gray1); gap: 12px; }
.topic-row:last-child { border-bottom: none; }
.topic-row-bar { height: 6px; background: var(--gray1); border-radius: 3px; flex: 1; max-width: 100px; overflow: hidden; }
.topic-row-fill { height: 100%; border-radius: 3px; }

/* Responsive */
@media (max-width: 768px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .nav-links a:not(.btn-nav) { display: none; }
  .question-card { padding: 24px 16px; }
  .practice-topic-name { max-width: 120px; }
}
@media (max-width: 480px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .container, .container-sm, .container-xs { padding: 0 16px; }
  .footer-inner { flex-direction: column; text-align: center; }
}
