:root {
  --bg: #f4f7fe;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --secondary: #f97316;
  --secondary-hover: #ea580c;
  --secondary-soft: #fff7ed;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --border: #e2e8f0;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12% 12%, rgba(99, 102, 241, 0.08), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(249, 115, 22, 0.08), transparent 25%);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--warning-soft);
  color: #92400e;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.95rem;
  border: 1px solid #fde68a;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--surface-soft);
  transform: translateY(-1px);
}

/* Main Content */
.main-content {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  flex: 1;
}

.view {
  display: none;
  animation: fadeIn 0.25s ease;
}

.view.active {
  display: block;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.96rem;
  padding: 11px 20px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-lg {
  padding: 13px 24px;
  font-size: 1.02rem;
}

.btn-sm {
  padding: 7px 13px;
  font-size: 0.86rem;
  border-radius: 10px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.28);
}

.btn-secondary:hover {
  background: var(--secondary-hover);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #15803d;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-soft);
}

.btn-hint {
  background: var(--warning-soft);
  color: #92400e;
  border: 1px solid #fcd34d;
}

.btn-hint:hover {
  background: #fde68a;
}

/* Home Hero */
.hero-card {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 55%, #3b82f6 100%);
  color: #fff;
  border-radius: 26px;
  padding: 32px;
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 28px;
  box-shadow: 0 14px 36px rgba(79, 70, 229, 0.25);
  margin-bottom: 32px;
}

.hero-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.hero-text h2 {
  font-size: 1.95rem;
  font-weight: 900;
  line-height: 1.25;
  margin-bottom: 12px;
}

.hero-text p {
  font-size: 1.02rem;
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 22px;
}

.hero-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-cta .btn-primary {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

.hero-cta .btn-primary:hover {
  background: #eef2ff;
}

.hero-stats-box {
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.mascot-bubble {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.18);
  padding: 12px 14px;
  border-radius: 14px;
}

.mascot-avatar {
  font-size: 2rem;
  flex-shrink: 0;
}

.mascot-bubble p {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.4;
}

.mini-progress-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mini-stat {
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}

.mini-stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 700;
}

.mini-stat-val {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--primary);
}

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 18px;
}

.section-header h3 {
  font-size: 1.45rem;
  font-weight: 900;
}

.section-header p {
  color: var(--text-muted);
  font-size: 0.96rem;
}

/* Topics Grid */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 20px;
}

.topic-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.topic-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.topic-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.topic-icon-box {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  flex-shrink: 0;
}

.topic-status {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
}

.topic-status.done {
  background: var(--success-soft);
  color: var(--success);
}

.topic-status.todo {
  background: var(--surface-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.topic-card h4 {
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.3;
}

.topic-card p {
  font-size: 0.92rem;
  color: var(--text-muted);
  flex: 1;
}

.topic-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.topic-tag {
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--surface-soft);
  color: var(--text-muted);
  padding: 3px 9px;
  border-radius: 8px;
}

.topic-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

/* Theory View */
.theory-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 24px;
  align-items: start;
}

.theory-sidebar {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 86px;
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 900;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.topic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-topic-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.18s;
  color: var(--text);
}

.sidebar-topic-btn:hover {
  background: var(--surface-soft);
}

.sidebar-topic-btn.active {
  background: var(--primary-soft);
  border-color: #c7d2fe;
  color: var(--primary);
}

.sidebar-topic-btn .s-icon {
  font-size: 1.25rem;
}

.sidebar-topic-btn .s-text {
  font-size: 0.9rem;
  font-weight: 800;
  flex: 1;
  line-height: 1.3;
}

.sidebar-topic-btn .s-check {
  font-size: 0.9rem;
}

.theory-content-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 30px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.theory-banner {
  border-radius: 18px;
  padding: 22px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.theory-banner-icon {
  font-size: 2.6rem;
}

.theory-banner h2 {
  font-size: 1.55rem;
  font-weight: 900;
  margin-bottom: 4px;
}

.theory-banner p {
  font-size: 0.96rem;
  opacity: 0.9;
}

.lesson-block {
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px dashed var(--border);
}

.lesson-block:last-of-type {
  border-bottom: none;
}

.lesson-block h3 {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lesson-block p {
  margin-bottom: 10px;
  font-size: 1rem;
}

.lesson-list {
  margin: 8px 0 12px 22px;
}

.lesson-list li {
  margin-bottom: 6px;
}

.formula-box {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 2px solid #fbbf24;
  border-radius: 16px;
  padding: 16px 20px;
  margin: 14px 0;
}

.formula-box-title {
  font-weight: 900;
  color: #b45309;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.formula-box p,
.formula-box li {
  color: #78350f;
  font-weight: 700;
}

.example-box {
  background: #f0fdf4;
  border-left: 5px solid #22c55e;
  border-radius: 12px;
  padding: 14px 18px;
  margin: 12px 0;
}

.example-box-title {
  font-weight: 900;
  color: #15803d;
  margin-bottom: 6px;
}

.visual-diagram {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin: 14px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.theory-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.95rem;
}

.theory-table th,
.theory-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: center;
}

.theory-table th {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

.theory-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Quiz Setup */
.quiz-mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-bottom: 28px;
}

.mode-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 26px;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mode-practice {
  border-top: 6px solid var(--primary);
}

.mode-exam {
  border-top: 6px solid var(--secondary);
}

.mode-icon {
  font-size: 2.3rem;
}

.mode-card h4 {
  font-size: 1.3rem;
  font-weight: 900;
}

.mode-card > p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.select-input,
.text-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-soft);
}

.select-input:focus,
.text-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.exam-highlights {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--secondary-soft);
  padding: 14px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.92rem;
  color: #9a3412;
  flex: 1;
}

.quick-topic-quizzes {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  border: 1px solid var(--border);
}

.quick-topic-quizzes h4 {
  font-size: 1.05rem;
  font-weight: 900;
  margin-bottom: 12px;
}

.quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-pill-btn {
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s;
}

.quick-pill-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

/* Active Quiz */
.quiz-active-container {
  max-width: 820px;
  margin: 0 auto;
}

.quiz-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.quiz-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 800;
}

.timer-pill {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #c7d2fe;
}

.streak-pill {
  color: #c2410c;
  background: var(--secondary-soft);
  border-color: #fed7aa;
}

.progress-wrapper {
  margin-bottom: 18px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 0.92rem;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.progress-track {
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #06b6d4);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.question-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 28px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.q-topic-tag {
  font-size: 0.82rem;
  font-weight: 800;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 999px;
}

.q-level-tag {
  font-size: 0.82rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-muted);
}

.q-level-tag.advanced {
  background: #fae8ff;
  color: #a21caf;
}

.question-text {
  font-size: 1.32rem;
  font-weight: 800;
  line-height: 1.45;
  margin-bottom: 14px;
}

.question-visual {
  display: flex;
  justify-content: center;
  padding: 14px;
  background: var(--surface-soft);
  border-radius: 14px;
  margin-bottom: 16px;
}

.hint-row {
  margin-bottom: 18px;
}

.hint-box {
  margin-top: 10px;
  background: var(--warning-soft);
  border: 1px solid #fcd34d;
  color: #92400e;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.94rem;
  font-weight: 700;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 16px 18px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  transition: all 0.16s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-2px);
}

.option-btn:disabled {
  cursor: default;
}

.option-letter {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: var(--primary);
  flex-shrink: 0;
}

.option-btn.correct {
  border-color: var(--success);
  background: var(--success-soft);
  color: #14532d;
}

.option-btn.correct .option-letter {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.option-btn.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: #7f1d1d;
}

.option-btn.wrong .option-letter {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.feedback-box {
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 18px;
}

.feedback-box.correct {
  background: var(--success-soft);
  border: 1.5px solid #86efac;
  color: #14532d;
}

.feedback-box.wrong {
  background: var(--danger-soft);
  border: 1.5px solid #fca5a5;
  color: #7f1d1d;
}

.feedback-title {
  font-size: 1.08rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.feedback-explanation {
  font-size: 0.96rem;
  font-weight: 700;
}

.question-footer {
  display: flex;
  justify-content: flex-end;
}

/* Result Screen */
.quiz-result-container {
  max-width: 820px;
  margin: 0 auto;
}

.result-card {
  background: var(--surface);
  border-radius: 26px;
  padding: 32px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.result-trophy {
  font-size: 4rem;
  margin-bottom: 8px;
}

.result-card h2 {
  font-size: 1.8rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.result-sub {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.result-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.res-stat {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 10px;
}

.res-stat span {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 700;
}

.res-stat strong {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--primary);
}

.result-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

.review-section {
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 22px;
}

.review-section h4 {
  font-size: 1.15rem;
  font-weight: 900;
  margin-bottom: 14px;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.review-item {
  border-radius: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.review-item.is-correct {
  border-left: 5px solid var(--success);
}

.review-item.is-wrong {
  border-left: 5px solid var(--danger);
  background: #fff5f5;
}

.review-q {
  font-weight: 800;
  margin-bottom: 6px;
}

.review-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.review-exp {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 700;
}

/* Tools: Multiplication Table */
.tools-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 22px;
  align-items: start;
}

.tool-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.table-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.num-tab {
  min-width: 76px;
  padding: 0 12px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
  color: var(--text);
  transition: all 0.16s;
}

.num-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.table-mode-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.toggle-btn {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  padding: 8px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text-muted);
}

.toggle-btn.active {
  background: var(--secondary-soft);
  border-color: #fdba74;
  color: #c2410c;
}

.mul-rows {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mul-row {
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 1.12rem;
  font-weight: 900;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s;
}

.mul-row:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.mul-result {
  color: var(--primary);
  background: #fff;
  padding: 2px 10px;
  border-radius: 8px;
  border: 1px solid #c7d2fe;
}

.mul-result.hidden-val {
  background: var(--warning-soft);
  color: #b45309;
  border-color: #fcd34d;
}

.speed-drill-card h4 {
  font-size: 1.25rem;
  font-weight: 900;
  margin-bottom: 4px;
}

.muted {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.drill-box {
  margin-top: 18px;
  background: linear-gradient(135deg, #eef2ff, #f8fafc);
  border: 2px solid #c7d2fe;
  border-radius: 18px;
  padding: 22px;
  text-align: center;
}

.drill-score {
  font-size: 0.95rem;
  font-weight: 800;
  color: #c2410c;
  margin-bottom: 10px;
}

.drill-question {
  font-size: 2.3rem;
  font-weight: 900;
  color: var(--primary);
  margin: 12px 0 18px;
}

.drill-input-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.drill-input {
  width: 110px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 900;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid var(--primary);
  font-family: inherit;
}

.drill-feedback {
  margin-top: 14px;
  min-height: 28px;
  font-weight: 800;
  font-size: 1rem;
}

/* Profile */
.profile-grid {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 24px;
  align-items: start;
}

.profile-card,
.badges-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 26px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.profile-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--primary-soft);
  font-size: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.profile-name-row label {
  display: block;
  font-size: 0.86rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.name-edit-group {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.profile-summary-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.p-stat {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}

.p-stat span {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 700;
}

.p-stat strong {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--primary);
}

.danger-zone {
  text-align: center;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.badge-item {
  border-radius: 16px;
  padding: 16px;
  border: 1.5px solid var(--border);
  text-align: center;
  background: var(--surface-soft);
  opacity: 0.55;
  filter: grayscale(0.7);
}

.badge-item.unlocked {
  opacity: 1;
  filter: none;
  background: linear-gradient(135deg, #fffbeb, #fff);
  border-color: #fbbf24;
  box-shadow: var(--shadow-sm);
}

.badge-emoji {
  font-size: 2.2rem;
  margin-bottom: 6px;
}

.badge-item h5 {
  font-size: 0.96rem;
  font-weight: 900;
  margin-bottom: 4px;
}

.badge-item p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  gap: 12px;
}

.history-score {
  font-weight: 900;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 10px;
  border-radius: 8px;
}

/* Footer & Toast */
.app-footer {
  text-align: center;
  padding: 18px;
  color: var(--text-muted);
  font-size: 0.86rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: 14px;
  font-weight: 800;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.22);
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

/* Responsive */
@media (max-width: 960px) {
  .hero-card,
  .theory-layout,
  .quiz-mode-cards,
  .tools-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .theory-sidebar {
    position: static;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 10px 14px;
  }

  .hero-card {
    padding: 22px;
  }

  .hero-text h2 {
    font-size: 1.45rem;
  }

  .options-grid,
  .result-stats-row,
  .mul-rows {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}


/* Blazor inline reset confirmation */
.reset-confirm-box {
  background: var(--danger-soft);
  border: 1.5px solid #fca5a5;
  border-radius: 14px;
  padding: 12px 14px;
  color: #7f1d1d;
  font-size: 0.86rem;
  font-weight: 700;
}

.reset-confirm-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

/* Blazor WebAssembly Loading Splash & Error Bar */
.wasm-loader {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef2ff, #f8fafc);
}

.wasm-loader-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  padding: 36px 40px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 32px rgba(79, 70, 229, 0.1);
}

.wasm-loader-owl {
  font-size: 3.6rem;
  margin-bottom: 10px;
}

.wasm-loader-card h2 {
  font-size: 1.5rem;
  font-weight: 900;
  color: #1e293b;
  margin-bottom: 8px;
}

.wasm-loader-card p {
  color: #64748b;
  font-weight: 700;
  font-size: 0.96rem;
  margin-bottom: 20px;
}

.wasm-loader-bar {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.wasm-loader-bar-fill {
  height: 100%;
  width: 45%;
  background: linear-gradient(90deg, #4f46e5, #06b6d4);
  border-radius: 999px;
  animation: wasmLoadingSlide 1.2s ease-in-out infinite;
}

@keyframes wasmLoadingSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(260%); }
}

#blazor-error-ui {
  background: #fef2f2;
  color: #991b1b;
  border-top: 2px solid #fca5a5;
  bottom: 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.12);
  display: none;
  left: 0;
  padding: 0.7rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
  font-weight: 700;
}

#blazor-error-ui .reload {
  color: #4f46e5;
  margin-left: 8px;
  text-decoration: underline;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 1rem;
  top: 0.65rem;
}
