:root {
  --bg: #07111f;
  --bg2: #0f172a;
  --card: rgba(255, 255, 255, 0.92);
  --card-solid: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --soft: #e2e8f0;
  --primary: #6366f1;
  --primary2: #8b5cf6;
  --accent: #06b6d4;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --shadow: 0 24px 80px rgba(2, 8, 23, 0.28);
  --radius: 26px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #e5e7eb;
  background: radial-gradient(circle at top left, #1e1b4b 0, transparent 32rem),
              radial-gradient(circle at top right, #164e63 0, transparent 28rem),
              linear-gradient(135deg, #020617 0%, #0f172a 44%, #111827 100%);
  overflow-x: hidden;
}

button, select { font: inherit; }
button { cursor: pointer; }

.bg-orbs { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.orb { position: absolute; border-radius: 999px; filter: blur(18px); opacity: 0.36; animation: float 13s ease-in-out infinite; }
.orb-a { width: 380px; height: 380px; background: #6366f1; top: -90px; left: -90px; }
.orb-b { width: 320px; height: 320px; background: #06b6d4; top: 70px; right: -110px; animation-delay: -4s; }
.orb-c { width: 280px; height: 280px; background: #8b5cf6; bottom: -120px; left: 24%; animation-delay: -7s; }
@keyframes float { 0%,100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(22px,-18px,0) scale(1.06); } }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: center;
  padding: 1.1rem clamp(1rem, 3vw, 3rem);
  backdrop-filter: blur(24px);
  background: rgba(2, 6, 23, 0.62);
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.brand { display: flex; align-items: center; gap: 1rem; }
.brand-mark {
  width: 54px; height: 54px;
  border-radius: 18px;
  display: grid; place-items: center;
  font-weight: 950;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 12px 36px rgba(99,102,241,0.35);
}
.brand h1 { margin: 0; font-size: 1.25rem; letter-spacing: -0.03em; }
.brand p { margin: 0.15rem 0 0; color: #94a3b8; font-size: 0.85rem; }
.top-nav { display: flex; gap: 0.55rem; flex-wrap: wrap; justify-content: flex-end; }
.nav-pill {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 0.62rem 0.95rem;
  transition: 0.22s ease;
}
.nav-pill:hover, .nav-pill.active { color: white; background: rgba(99,102,241,0.35); border-color: rgba(129,140,248,0.6); transform: translateY(-1px); }

.shell { position: relative; z-index: 1; width: min(1280px, calc(100% - 2rem)); margin: 0 auto; padding: 2rem 0 5rem; }
.screen { display: none; animation: fadeUp .42s ease both; }
.screen.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.hero-card,
.config-card,
.preview-card,
.question-card,
.results-card,
.analytics-card,
.bank-table,
.bank-summary {
  border: 1px solid rgba(255,255,255,0.18);
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: 1.55fr 0.85fr;
  gap: 1.5rem;
  padding: clamp(1.5rem, 4vw, 3rem);
  overflow: hidden;
  position: relative;
}
.hero-card:before {
  content: "";
  position: absolute;
  inset: -40% auto auto 52%;
  width: 540px;
  height: 540px;
  background: radial-gradient(circle, rgba(99,102,241,0.20), transparent 62%);
  pointer-events: none;
}
.eyebrow { display: inline-flex; color: #4338ca; background: #e0e7ff; font-weight: 850; font-size: 0.76rem; padding: 0.35rem 0.7rem; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.06em; }
.hero-copy h2, .screen-head h2 { margin: 1rem 0; font-size: clamp(2rem, 5vw, 4.35rem); line-height: 0.98; letter-spacing: -0.065em; color: #0f172a; }
.hero-copy p, .screen-head p { color: #475569; font-size: 1.05rem; line-height: 1.75; max-width: 70ch; }
.hero-stats { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1.8rem; }
.hero-stats div { min-width: 120px; padding: 1rem; border-radius: 20px; background: #f8fafc; border: 1px solid #e2e8f0; }
.hero-stats strong { display: block; font-size: 1.7rem; color: #111827; }
.hero-stats span { color: #64748b; font-weight: 700; font-size: 0.82rem; }
.hero-panel {
  position: relative;
  align-self: stretch;
  padding: 1.5rem;
  border-radius: 24px;
  color: white;
  background: linear-gradient(135deg, #312e81, #155e75);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}
.hero-panel:after { content: ""; position: absolute; width: 220px; height: 220px; border-radius: 999px; background: rgba(255,255,255,0.12); bottom: -90px; right: -80px; }
.hero-panel h3 { margin-top: 2.2rem; font-size: 1.7rem; }
.hero-panel p { color: #dbeafe; line-height: 1.65; }
.pulse-dot { width: 16px; height: 16px; background: #22c55e; border-radius: 999px; box-shadow: 0 0 0 0 rgba(34,197,94,0.65); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 16px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
.mini-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 0.7rem; margin-top: 2rem; position: relative; z-index: 1; }
.mini-grid span { padding: 0.8rem; border-radius: 16px; background: rgba(255,255,255,0.12); font-weight: 800; text-align: center; }

.layout-grid { display: grid; grid-template-columns: 380px 1fr; gap: 1.5rem; margin-top: 1.5rem; align-items: start; }
.config-card, .preview-card, .analytics-card, .bank-summary, .bank-table { padding: 1.35rem; }
.config-card { position: sticky; top: 96px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.card-head h3 { margin: 0; font-size: 1.25rem; }
.screen-head { margin-bottom: 1.2rem; color: var(--ink); background: var(--card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,0.18); }
.screen-head h2 { font-size: clamp(2rem, 4vw, 3.4rem); }

.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-size: 0.85rem; font-weight: 850; color: #334155; margin-bottom: 0.5rem; }
select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 0.85rem 0.95rem;
  background: #fff;
  color: #0f172a;
  outline: none;
  transition: 0.2s ease;
}
select:focus { border-color: #818cf8; box-shadow: 0 0 0 4px rgba(99,102,241,0.14); }
.topic-actions { display: flex; gap: 0.5rem; margin-bottom: 0.65rem; }
.topic-picker { display: grid; gap: 0.55rem; max-height: 330px; overflow: auto; padding-right: 0.15rem; }
.topic-check {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.75rem;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  transition: 0.2s ease;
}
.topic-check:hover { transform: translateY(-1px); border-color: #a5b4fc; }
.topic-check input { margin-top: 0.28rem; accent-color: #6366f1; }
.topic-check strong { display: block; font-size: 0.88rem; }
.topic-check span { color: #64748b; font-size: 0.78rem; line-height: 1.35; }

.primary-btn, .secondary-btn, .ghost-btn, .tiny-btn {
  border: 0;
  border-radius: 16px;
  font-weight: 900;
  transition: 0.22s ease;
}
.primary-btn {
  width: 100%;
  padding: 1rem 1.15rem;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  box-shadow: 0 14px 28px rgba(99,102,241,0.28);
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(99,102,241,0.36); }
.secondary-btn { padding: 0.9rem 1rem; color: #3730a3; background: #eef2ff; border: 1px solid #c7d2fe; }
.secondary-btn:hover { background: #e0e7ff; transform: translateY(-1px); }
.ghost-btn { padding: 0.7rem 0.9rem; color: #475569; background: #f8fafc; border: 1px solid #e2e8f0; }
.ghost-btn:hover { background: #e2e8f0; }
.tiny-btn { padding: 0.48rem 0.7rem; font-size: 0.78rem; background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }
.danger-text { color: #b91c1c; }
.hint { color: #64748b; font-size: 0.88rem; line-height: 1.55; margin: 1rem 0 0; }

.theme-map { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0.9rem; }
.theme-tile {
  padding: 1rem;
  border-radius: 20px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  position: relative;
  overflow: hidden;
}
.theme-tile:before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: linear-gradient(var(--primary), var(--accent)); }
.theme-tile h4 { margin: 0 0 0.55rem; color: #0f172a; }
.theme-tile p { margin: 0; color: #64748b; font-size: 0.88rem; line-height: 1.5; }
.theme-tile .coverage { display: flex; justify-content: space-between; margin-top: 0.75rem; font-weight: 850; color: #4338ca; font-size: 0.82rem; }
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  color: #3730a3;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 900;
}
.badge.muted { color: #475569; background: #f1f5f9; border-color: #e2e8f0; }
.badge.danger { color: #991b1b; background: #fee2e2; border-color: #fecaca; }
.badge.success { color: #065f46; background: #d1fae5; border-color: #a7f3d0; }

.quiz-shell { max-width: 980px; margin: 0 auto; }
.quiz-topbar { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.progress-wrap { padding: 0.9rem 1rem; background: rgba(255,255,255,0.9); color: var(--ink); border-radius: 20px; box-shadow: 0 12px 28px rgba(0,0,0,0.16); }
.progress-text { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 0.55rem; font-weight: 850; color: #334155; font-size: 0.88rem; }
.progress-track { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: inherit; transition: width 0.35s ease; }
.question-card { padding: clamp(1.3rem, 3vw, 2.4rem); }
.question-meta { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 1.2rem; }
.question-card h2 { color: #0f172a; font-size: clamp(1.35rem, 2.5vw, 2.05rem); line-height: 1.25; letter-spacing: -0.035em; margin: 0 0 1.5rem; }
.answer-list { display: grid; gap: 0.8rem; }
.answer-btn {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 0.9rem;
  align-items: start;
  width: 100%;
  border: 1px solid #dbe3ef;
  background: #f8fafc;
  padding: 1rem;
  text-align: left;
  border-radius: 18px;
  color: #1e293b;
  transition: 0.18s ease;
}
.answer-btn:hover { border-color: #a5b4fc; background: #eef2ff; transform: translateY(-1px); }
.answer-btn .letter { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; color: #4338ca; background: #e0e7ff; font-weight: 950; }
.answer-btn.selected { border-color: #6366f1; background: #eef2ff; }
.answer-btn.correct { border-color: #10b981; background: #ecfdf5; }
.answer-btn.correct .letter { background: #d1fae5; color: #065f46; }
.answer-btn.wrong { border-color: #ef4444; background: #fef2f2; }
.answer-btn.wrong .letter { background: #fee2e2; color: #991b1b; }
.feedback { margin-top: 1.2rem; padding: 1rem; border-radius: 18px; background: #f8fafc; border: 1px solid #e2e8f0; color: #334155; line-height: 1.65; }
.feedback.good { background: #ecfdf5; border-color: #a7f3d0; }
.feedback.bad { background: #fef2f2; border-color: #fecaca; }
.hidden { display: none !important; }
.quiz-actions { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.4rem; }
.quiz-actions .primary-btn { width: auto; min-width: 160px; }

.results-card { padding: clamp(1.4rem, 4vw, 2.7rem); max-width: 1100px; margin: 0 auto; }
.results-hero { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.results-hero h2 { margin: 0.8rem 0 0.4rem; font-size: clamp(2rem, 4vw, 3.4rem); letter-spacing: -0.055em; }
.results-hero p { color: #64748b; line-height: 1.65; }
.score-ring {
  flex: 0 0 150px;
  width: 150px; height: 150px;
  border-radius: 999px;
  display: grid; place-items: center;
  background: conic-gradient(var(--primary) 0deg, #e2e8f0 0deg);
  position: relative;
}
.score-ring:after { content: ""; position: absolute; inset: 13px; border-radius: inherit; background: white; }
.score-ring span { position: relative; z-index: 1; font-size: 2.1rem; font-weight: 950; color: #0f172a; }
.results-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 0.85rem; margin-top: 1.5rem; }
.result-tile { padding: 1rem; border-radius: 18px; background: #f8fafc; border: 1px solid #e2e8f0; }
.result-tile strong { display: block; font-size: 1.3rem; color: #0f172a; }
.result-tile span { color: #64748b; font-size: 0.82rem; font-weight: 750; }
.recommendation { margin-top: 1.3rem; padding: 1.1rem; border-radius: 18px; background: #fffbeb; border: 1px solid #fde68a; color: #78350f; line-height: 1.65; }
.results-actions { display: flex; gap: 0.85rem; margin-top: 1.3rem; justify-content: flex-end; }
.results-actions .primary-btn { width: auto; }

.analytics-layout { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 1rem; }
.analytics-card.wide { grid-column: span 1; }
.global-stats { display: grid; gap: 0.8rem; }
.big-number { font-size: 3rem; font-weight: 950; letter-spacing: -0.06em; color: #0f172a; }
.topic-analytics, .subtopic-analytics { display: grid; gap: 0.75rem; }
.bar-row { display: grid; grid-template-columns: minmax(130px, 220px) 1fr auto; gap: 0.7rem; align-items: center; }
.bar-name { font-weight: 800; color: #334155; font-size: 0.88rem; }
.bar-track { height: 12px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); min-width: 2%; }
.bar-pct { font-weight: 900; color: #0f172a; font-size: 0.88rem; }

.bank-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin-bottom: 1rem; }
.bank-summary .result-tile { background: white; }
.bank-table { overflow: auto; }
.bank-table table { width: 100%; border-collapse: collapse; min-width: 760px; }
.bank-table th, .bank-table td { padding: 0.8rem; border-bottom: 1px solid #e2e8f0; text-align: left; color: #334155; font-size: 0.88rem; }
.bank-table th { color: #0f172a; background: #f8fafc; font-weight: 950; position: sticky; top: 0; }
.toast { position: fixed; z-index: 50; bottom: 1rem; left: 50%; transform: translateX(-50%) translateY(30px); opacity: 0; transition: 0.25s ease; background: #0f172a; color: white; padding: 0.85rem 1rem; border-radius: 999px; box-shadow: 0 16px 32px rgba(0,0,0,0.28); max-width: min(92vw, 680px); text-align: center; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (max-width: 1060px) {
  .hero-card, .layout-grid { grid-template-columns: 1fr; }
  .config-card { position: static; }
  .theme-map { grid-template-columns: 1fr; }
  .analytics-layout { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .top-nav { width: 100%; justify-content: stretch; }
  .nav-pill { flex: 1; }
  .brand p { display: none; }
  .shell { width: min(100% - 1rem, 1280px); padding-top: 1rem; }
  .hero-card, .config-card, .preview-card, .question-card, .results-card, .analytics-card, .bank-table, .bank-summary { border-radius: 20px; }
  .quiz-topbar { grid-template-columns: 1fr; }
  .quiz-actions, .results-actions, .results-hero { flex-direction: column; align-items: stretch; }
  .quiz-actions .primary-btn, .results-actions .primary-btn { width: 100%; }
  .score-ring { align-self: center; }
  .results-grid, .bank-summary { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; gap: 0.35rem; }
}
