/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,300&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0f0f13;
  --surface: #1a1a22;
  --surface2: #23232e;
  --border: #2e2e3d;
  --accent: #7c6aff;
  --accent2: #ff6a9b;
  --accent3: #6affb8;
  --text: #e8e8f0;
  --text-muted: #7a7a9a;
  --correct: #6affb8;
  --wrong: #ff6a9b;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px rgba(124, 106, 255, 0.15);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 0;
  font-size: 16px;
  line-height: 1.6;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(124, 106, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 106, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* === LAYOUT === */
.page-wrapper { position: relative; z-index: 1; min-height: 100vh; }
.container { max-width: 680px; margin: 0 auto; padding: 24px 20px 80px; }
.container--wide { max-width: 960px; margin: 0 auto; padding: 24px 20px 80px; }

/* === NAVBAR === */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15,15,19,0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}

.navbar-brand {
  font-family: 'Syne', sans-serif;
  font-weight: 800; font-size: 1.1rem;
  color: var(--text); text-decoration: none;
  letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 8px;
}
.navbar-brand .dot { width:8px; height:8px; border-radius:50%; background:var(--accent); display:inline-block; }

.navbar-links { display: flex; align-items: center; gap: 6px; }

.navbar-links a {
  color: var(--text-muted); text-decoration: none;
  font-size: 0.875rem; padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s; font-weight: 500;
}
.navbar-links a:hover { color: var(--text); background: var(--surface); }

.navbar-icon-link { display: inline-flex; align-items: center; }

.navbar-srs-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--accent3) !important;
  border: 1px solid rgba(106,255,184,0.25) !important;
  border-radius: var(--radius-sm);
  padding: 5px 10px !important;
  font-weight: 600 !important;
}
.navbar-srs-link:hover { background: rgba(106,255,184,0.08) !important; }

.due-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent3); color: #0f0f13;
  border-radius: 100px; font-size: 0.7rem; font-weight: 800;
  min-width: 18px; height: 18px; padding: 0 4px;
}

.admin-link {
  color: var(--accent) !important;
  border: 1px solid rgba(124, 106, 255, 0.3) !important;
}
.admin-link:hover { background: rgba(124, 106, 255, 0.1) !important; }

/* === TYPOGRAPHY === */
h1, h2, h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.2;
}
h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); }
h3 { font-size: 1.1rem; font-weight: 600; }

.page-title {
  margin: 32px 0 8px;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-muted) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.page-subtitle { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 28px; }

/* === CARDS === */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: all 0.25s ease;
  text-decoration: none; color: inherit; display: block;
  position: relative; overflow: hidden;
}
.card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(124,106,255,0.04) 100%);
  opacity: 0; transition: opacity 0.25s;
  pointer-events: none;
}
.card:hover { border-color: rgba(124,106,255,0.4); transform: translateY(-2px); box-shadow: var(--shadow), var(--shadow-glow); }
.card:hover::before { opacity: 1; }
.card:active { transform: translateY(0); }
.card-title { font-family: 'Syne', sans-serif; font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.card-desc { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 12px; }
.card-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-meta .badge, .badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(124,106,255,0.12); color: var(--accent);
  padding: 2px 8px; border-radius: 100px; font-size: 0.75rem; font-weight: 600;
}
.card-accent-left { border-left: 3px solid var(--accent); }
.grid-cards { display: grid; gap: 12px; }

/* === SRS BANNER === */
.srs-banner {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, rgba(106,255,184,0.08), rgba(106,255,184,0.04));
  border: 1px solid rgba(106,255,184,0.25);
  border-radius: var(--radius); padding: 16px 20px;
  text-decoration: none; color: inherit;
  margin-bottom: 20px;
  transition: all 0.2s;
  cursor: pointer;
}
.srs-banner:hover { border-color: rgba(106,255,184,0.5); transform: translateY(-1px); }
.srs-banner-icon { font-size: 1.8rem; flex-shrink: 0; }
.srs-banner-title { font-family: 'Syne', sans-serif; font-weight: 700; color: var(--accent3); }
.srs-banner-sub { font-size: 0.85rem; color: var(--text-muted); }

/* === BACK LINK === */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); text-decoration: none;
  font-size: 0.875rem; padding: 8px 0; margin-bottom: 8px; transition: color 0.2s;
}
.back-link:hover { color: var(--text); }
.back-link svg { transition: transform 0.2s; }
.back-link:hover svg { transform: translateX(-3px); }

/* === QUIZ PROGRESS === */
.quiz-header { margin-bottom: 24px; }
.quiz-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px;
}
.quiz-score-pill {
  background: rgba(106,255,184,0.1); color: var(--accent3);
  padding: 4px 10px; border-radius: 100px; font-weight: 600; font-size: 0.8rem;
}
.progress-bar { width: 100%; height: 6px; background: var(--surface2); border-radius: 100px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 100px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === QUESTION BOX === */
.question-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
}
.question-text { font-size: 1.1rem; font-weight: 500; line-height: 1.5; color: var(--text); }
.question-image { margin-top: 16px; }
.question-image img { width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* === MARKDOWN CONTENT === */
.md-content { line-height: 1.7; }
.md-content p { margin-bottom: 0.8em; }
.md-content p:last-child { margin-bottom: 0; }
.md-content strong { color: var(--text); font-weight: 600; }
.md-content em { font-style: italic; }
.md-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  background: rgba(124,106,255,0.12);
  color: var(--accent);
  padding: 1px 6px; border-radius: 4px;
}
.md-content pre {
  background: #12121a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0;
}
.md-content pre code {
  background: none; color: var(--accent3); padding: 0; font-size: 0.875rem;
}
.md-content table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.9rem; }
.md-content th { background: var(--surface2); padding: 8px 12px; border: 1px solid var(--border); text-align: left; font-weight: 600; }
.md-content td { padding: 8px 12px; border: 1px solid var(--border); }
.md-content ul, .md-content ol { padding-left: 1.4em; margin: 0.5em 0; }
.md-content li { margin-bottom: 0.25em; }
.md-content blockquote {
  border-left: 3px solid var(--accent); padding-left: 14px;
  color: var(--text-muted); margin: 8px 0; font-style: italic;
}

/* === OPTIONS === */
.options-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.btn-option {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px 20px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: var(--text);
  font-size: 0.95rem; font-family: 'DM Sans', sans-serif;
  transition: all 0.2s ease; cursor: pointer; position: relative; overflow: hidden;
}
.btn-option::before {
  content: ''; position: absolute; left:0; top:0; bottom:0; width:4px;
  background: var(--accent); transform: scaleY(0); transition: transform 0.2s;
  border-radius: 0 2px 2px 0;
}
.btn-option:hover { border-color: var(--accent); background: rgba(124,106,255,0.08); transform: translateX(4px); }
.btn-option:hover::before { transform: scaleY(1); }
.btn-option:active { transform: scale(0.99); }
.option-letter {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  font-size: 0.75rem; font-weight: 700; color: var(--text-muted); flex-shrink: 0;
}

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: 100px;
  font-family: 'DM Sans', sans-serif; font-weight: 600; font-size: 0.95rem;
  text-decoration: none; cursor: pointer; transition: all 0.2s ease; border: none;
}
.btn-primary { background: var(--accent); color: white; box-shadow: 0 4px 16px rgba(124,106,255,0.35); }
.btn-primary:hover { background: #9882ff; transform: translateY(-1px); box-shadow: 0 6px 24px rgba(124,106,255,0.45); }
.btn-secondary { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { color: var(--text); border-color: rgba(124,106,255,0.4); }
.btn-success { background: rgba(106,255,184,0.15); color: var(--accent3); border: 1px solid rgba(106,255,184,0.25); }
.btn-success:hover { background: rgba(106,255,184,0.25); }
.btn-danger { background: rgba(255,106,155,0.1); color: var(--wrong); border: 1px solid rgba(255,106,155,0.25); }
.btn-danger:hover { background: rgba(255,106,155,0.2); }
.btn-warning { background: rgba(255,185,80,0.1); color: #ffb950; border: 1px solid rgba(255,185,80,0.25); }
.btn-warning:hover { background: rgba(255,185,80,0.2); }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }

/* === RESULT PAGE === */
.result-banner { text-align: center; padding: 28px 24px; border-radius: var(--radius); margin-bottom: 20px; }
.result-banner.correct { background: rgba(106,255,184,0.08); border: 1px solid rgba(106,255,184,0.2); }
.result-banner.wrong { background: rgba(255,106,155,0.08); border: 1px solid rgba(255,106,155,0.2); }
.result-emoji { font-size: 3rem; margin-bottom: 8px; }
.result-label { font-family: 'Syne', sans-serif; font-size: 1.5rem; font-weight: 800; }
.result-banner.correct .result-label { color: var(--correct); }
.result-banner.wrong .result-label { color: var(--wrong); }

.explanation-box {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.explanation-box h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); margin-bottom: 8px; }

/* Score card */
.score-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px; text-align: center;
  margin-bottom: 20px; position: relative; overflow: hidden;
}
.score-card::before {
  content: ''; position: absolute; top: -40px; left: 50%; transform: translateX(-50%);
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(124,106,255,0.15) 0%, transparent 70%);
}
.score-number { font-family: 'Syne', sans-serif; font-size: 4rem; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.score-fraction { color: var(--text-muted); font-size: 2rem; }
.score-percent { font-size: 1rem; color: var(--text-muted); margin-bottom: 20px; }
.score-bar { height: 10px; background: var(--surface2); border-radius: 100px; overflow: hidden; margin: 0 auto; max-width: 320px; }
.score-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent3)); border-radius: 100px; transition: width 1s cubic-bezier(0.4, 0, 0.2, 1); }

/* Wrong review */
.wrong-review { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.wrong-review-header { padding: 12px 16px; background: rgba(255,106,155,0.08); border-bottom: 1px solid var(--border); font-size: 0.85rem; font-weight: 600; color: var(--wrong); }
.wrong-review-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.wrong-review-item:last-child { border-bottom: none; }
.wrong-review-item .correct-answer { font-size: 0.8rem; color: var(--correct); margin-top: 4px; }

/* === FORMS === */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.form-label span.required { color: var(--accent2); margin-left: 2px; }
.form-label span.optional { color: var(--text-muted); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 0.8rem; }

.form-control {
  width: 100%; padding: 12px 16px;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 0.95rem;
  transition: border-color 0.2s; outline: none; resize: vertical;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,106,255,0.12); }
.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a7a9a' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px;
}

.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.form-section-title {
  font-family: 'Syne', sans-serif; font-size: 0.9rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.form-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.file-input-wrapper { position: relative; }
.file-input-label {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--surface2);
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.2s; color: var(--text-muted); font-size: 0.9rem;
}
.file-input-label:hover { border-color: var(--accent); color: var(--text); }
input[type="file"] { position: absolute; opacity: 0; inset: 0; cursor: pointer; width: 100%; }

/* === ADMIN DASHBOARD === */
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-number { font-family: 'Syne', sans-serif; font-size: 2rem; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.admin-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; margin-top: 28px; }
.admin-category-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.admin-category-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); background: rgba(124,106,255,0.04); }
.admin-category-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1rem; }
.admin-actions { display: flex; gap: 6px; }
.admin-subtopic-list { padding: 8px; }
.admin-subtopic-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: var(--radius-sm); transition: background 0.15s; }
.admin-subtopic-row:hover { background: var(--surface2); }
.admin-subtopic-name { font-size: 0.9rem; }
.admin-subtopic-meta { font-size: 0.8rem; color: var(--text-muted); }

/* === LOGIN === */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; width: 100%; max-width: 380px; text-align: center; }
.login-icon { width: 56px; height: 56px; background: rgba(124,106,255,0.12); border-radius: 16px; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; font-size: 1.5rem; }
.error-msg { background: rgba(255,106,155,0.1); border: 1px solid rgba(255,106,155,0.25); color: var(--wrong); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.875rem; margin-bottom: 16px; text-align: left; }

/* === SKIP BUTTON === */
.btn-skip {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--text-muted);
  padding: 8px 16px; border-radius: 100px; text-decoration: none;
  font-size: 0.85rem; border: 1px solid var(--border); transition: all 0.2s;
}
.btn-skip:hover { color: var(--text); border-color: var(--text-muted); }

/* === ADMIN ZONE === */
.admin-zone { margin-top: 32px; padding: 16px; background: rgba(255,106,155,0.05); border: 1px dashed rgba(255,106,155,0.2); border-radius: var(--radius); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.admin-zone-label { font-size: 0.8rem; color: rgba(255,106,155,0.6); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

/* === TAGS === */
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 100px; font-size: 0.75rem; font-weight: 600; }
.tag-purple { background: rgba(124,106,255,0.12); color: var(--accent); }
.tag-green  { background: rgba(106,255,184,0.12); color: var(--accent3); }
.tag-pink   { background: rgba(255,106,155,0.12); color: var(--accent2); }

/* === ALERTS === */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.9rem; margin-bottom: 16px; }
.alert-error { background: rgba(255,106,155,0.1); border: 1px solid rgba(255,106,155,0.25); color: var(--wrong); }

/* === RESPONSIVE === */
@media (max-width: 480px) {
  .admin-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-number { font-size: 1.5rem; }
  .admin-category-header { flex-wrap: wrap; gap: 8px; }
  .navbar-links a { padding: 5px 8px; font-size: 0.8rem; }
}

/* === ANIMATIONS === */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both; }
.animate-in:nth-child(1) { animation-delay: 0ms; }
.animate-in:nth-child(2) { animation-delay: 60ms; }
.animate-in:nth-child(3) { animation-delay: 120ms; }
.animate-in:nth-child(4) { animation-delay: 180ms; }
.animate-in:nth-child(5) { animation-delay: 240ms; }
.animate-in:nth-child(6) { animation-delay: 300ms; }