:root {
  --navy-deep: #0B192C;
  --navy: #142B47;
  --navy-soft: #1E3D63;
  --bg: #F6F3EC;
  --bg-dot: #E2DACB;
  --surface: #FFFFFF;
  --surface-warm: #FFFDF9;
  --border: #E5DFD3;
  --border-strong: #D4CBBA;
  --text: #162231;
  --muted: #5B6778;
  --gold: #C89B3C;
  --gold-bright: #E5BA5C;
  --gold-soft: #FEF8E8;
  --burgundy: #9B1C31;
  --blue: #1D4ED8;
  --blue-hover: #1E40AF;
  --blue-soft: #EFF6FF;
  --emerald: #047857;
  --emerald-soft: #ECFDF5;
  --crimson: #B91C1C;
  --crimson-soft: #FEF2F2;
  --shadow-sm: 0 2px 8px rgba(11, 25, 44, 0.04);
  --shadow-md: 0 12px 34px rgba(11, 25, 44, 0.08), 0 2px 8px rgba(11, 25, 44, 0.04);
  --shadow-lg: 0 22px 48px rgba(11, 25, 44, 0.14);
  --radius: 18px;
  --font-display: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-sans: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* Fireworks Overlay & Celebration Toast */
.fireworks-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 90;
}

.celebration-toast {
  position: fixed;
  bottom: 24px;
  top: auto;
  left: 50%;
  transform: translateX(-50%) translateY(18px) scale(0.92);
  z-index: 95;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 620px);
  padding: 13px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0B192C 0%, #173459 100%);
  border: 2px solid var(--gold-bright);
  color: #FEF3C7;
  box-shadow: 0 18px 42px rgba(11, 25, 44, 0.36), 0 0 0 4px rgba(229, 186, 92, 0.24);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.01em;
  text-align: center;
  opacity: 0;
}

.celebration-toast.is-visible {
  animation: toastPopIn 0.42s cubic-bezier(0.22, 1.35, 0.36, 1) forwards;
}

.celebration-toast.is-leaving {
  animation: toastFadeOut 0.3s ease forwards;
}

.toast-sparkle {
  color: var(--gold-bright);
  font-size: 16px;
  flex-shrink: 0;
}

.toast-text {
  line-height: 1.25;
}

@keyframes toastPopIn {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(20px) scale(0.86);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes toastFadeOut {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(12px) scale(0.96);
  }
}

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

/* Header */
.topbar {
  background: linear-gradient(135deg, var(--navy-deep) 0%, #142C4A 60%, #1B3B63 100%);
  color: #FFFFFF;
  border-bottom: 2px solid rgba(200, 155, 60, 0.42);
  position: relative;
  overflow: hidden;
}

.topbar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.topbar-inner {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 15px 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-crest {
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
  flex-shrink: 0;
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: #FFFFFF;
}

.brand-text p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.78);
}

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

.goal-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label {
  font-size: 13px;
  font-weight: 600;
}

.topbar .control-label {
  color: rgba(255, 255, 255, 0.82);
}

.segmented {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 3px;
  border-radius: 11px;
  gap: 3px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.seg-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.seg-btn.active {
  background: #FFFFFF;
  color: var(--navy-deep);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.lang-pill {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  padding: 6px 13px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, border-color 0.15s;
}

.lang-pill:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
}

.lang-pill .lang-opt.active {
  color: #FFFFFF;
  text-decoration: underline;
  text-decoration-color: var(--gold-bright);
  text-underline-offset: 3px;
}

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, rgba(200, 155, 60, 0.28), rgba(229, 186, 92, 0.18));
  border: 1px solid rgba(229, 186, 92, 0.55);
  color: #FEF3C7;
  padding: 5px 12px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  border-radius: 999px;
  padding: 5px 12px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.topbar-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.42);
}

.topbar-btn-account.is-authed {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(229, 186, 92, 0.55);
  padding-left: 5px;
}

.account-avatar {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: var(--navy-deep);
  font-size: 11.5px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* Main Layout */
.main-container {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 22px 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Bento Dashboard Card */
.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px 22px;
}

.dashboard-top {
  display: grid;
  grid-template-columns: 1.3fr 1.15fr 1fr;
  gap: 18px;
  align-items: stretch;
}

.progress-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.calendar-block {
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.progress-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.sync-pill.guest {
  background: #F4EFE4;
  border: 1px solid var(--border-strong);
  color: var(--muted);
}

.sync-pill.synced {
  background: var(--emerald-soft);
  border: 1px solid #A7F3D0;
  color: #065F46;
}

.mode-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy-deep);
  background: var(--blue-soft);
  border: 1px solid #DBEAFE;
  padding: 3px 11px;
  border-radius: 999px;
}

.mode-badge.extra {
  background: var(--gold-soft);
  border-color: #FDE68A;
  color: #92400E;
}

.progress-counter {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.progress-track {
  height: 8px;
  background: #ECE7DC;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 11px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), #3B82F6);
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.step-dots {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.step-dots.is-ten {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 5px;
}

.step-dots.is-ten .step-dot {
  width: 100%;
  height: 27px;
  font-size: 11.5px;
  border-radius: 8px;
}

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-warm);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s;
}

.step-dot:hover {
  border-color: var(--blue);
  color: var(--blue);
  transform: translateY(-1px);
}

.step-dot.current {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.step-dot.correct {
  background: var(--emerald-soft);
  border-color: var(--emerald);
  color: var(--emerald);
}

.step-dot.wrong {
  background: var(--crimson-soft);
  border-color: var(--crimson);
  color: var(--crimson);
}

.mini-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}

.calendar-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.cal-weekday {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.cal-circle {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface-warm);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  transition: transform 0.15s;
}

.cal-circle.today {
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.cal-circle.done {
  background: linear-gradient(135deg, var(--emerald), #10B981);
  border-color: var(--emerald);
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(4, 120, 87, 0.25);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.stat-item {
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  color: var(--navy-deep);
  line-height: 1.15;
}

.stat-label {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

/* Exercise Card */
.exercise-card,
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 30px;
}

.exercise-card.is-shaking {
  animation: gentleShake 0.36s ease;
}

@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-4px); }
  85% { transform: translateX(3px); }
}

.exercise-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.exercise-index {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-deep);
  margin-right: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-topic {
  background: var(--blue-soft);
  color: var(--blue);
  border: 1px solid #DBEAFE;
}

.badge-source.past {
  background: var(--gold-soft);
  color: #8A5A00;
  border: 1px solid #F3D999;
}

.badge-source.generated {
  background: #F1F5F9;
  color: #334155;
  border: 1px solid #CBD5E1;
}

.difficulty-box {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
}

.diff-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #D6CFC2;
}

.diff-dot.filled {
  background: var(--gold);
}

.source-note {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
}

.exercise-prompt {
  font-size: 19px;
  font-weight: 600;
  color: var(--navy-deep);
  line-height: 1.62;
  white-space: pre-line;
  margin: 8px 0 18px;
}

.formula-box {
  position: relative;
  overflow: hidden;
  margin: 0 0 20px;
  padding: 16px 22px;
  border-radius: 14px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  color: var(--navy-deep);
  text-align: center;
  letter-spacing: 0.01em;
  overflow-x: auto;
}

.formula-box::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  background: var(--gold);
}

.diagram-wrap {
  margin: 0 auto 22px;
  max-width: 440px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  background: var(--surface-warm);
  box-shadow: var(--shadow-sm);
}

.diagram-svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Hint box */
.hint-box {
  position: relative;
  overflow: hidden;
  background: var(--gold-soft);
  border: 1px solid #F3D999;
  border-radius: 12px;
  padding: 13px 16px 13px 18px;
  margin-bottom: 18px;
}

.hint-box::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  background: var(--gold);
}

.hint-title {
  font-size: 12px;
  font-weight: 800;
  color: #8A5A00;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.hint-box p {
  margin: 0;
  font-size: 14.5px;
  color: #6E4700;
}

/* Answer area */
.number-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.answer-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy-deep);
}

.input-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  max-width: 440px;
}

.answer-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  padding: 12px 15px;
  border-radius: 12px;
  border: 2px solid var(--border-strong);
  color: var(--navy-deep);
  background: #FFFFFF;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.answer-input::placeholder {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 14.5px;
  color: #94A3B8;
}

.answer-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.14);
}

.answer-input:disabled {
  background: #F8FAFC;
  color: var(--muted);
}

.unit-badge {
  display: inline-flex;
  align-items: center;
  padding: 0 15px;
  border-radius: 12px;
  background: #F1EFE9;
  border: 1.5px solid var(--border);
  color: var(--navy-deep);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14.5px;
  white-space: nowrap;
}

.input-helper {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 11px;
  margin-bottom: 4px;
}

.choice-btn {
  text-align: left;
  padding: 13px 15px;
  border-radius: 13px;
  border: 2px solid var(--border);
  background: #FFFFFF;
  color: var(--navy-deep);
  font-family: var(--font-sans);
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 11px;
  transition: all 0.15s;
}

.choice-key {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #F1EFE9;
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--blue-soft);
  transform: translateY(-1px);
}

.choice-btn.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.choice-btn.selected .choice-key {
  background: var(--blue);
  border-color: var(--blue);
  color: #FFFFFF;
}

.choice-btn.correct {
  border-color: var(--emerald);
  background: var(--emerald-soft);
  color: #065F46;
}

.choice-btn.correct .choice-key {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #FFFFFF;
}

.choice-btn.wrong {
  border-color: var(--crimson);
  background: var(--crimson-soft);
  color: #991B1B;
}

.choice-btn.wrong .choice-key {
  background: var(--crimson);
  border-color: var(--crimson);
  color: #FFFFFF;
}

.validation-error {
  margin: 10px 0 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--crimson);
}

/* Action bar */
.action-bar {
  margin-top: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.action-right {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 19px;
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform 0.1s, background 0.15s, box-shadow 0.15s;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--blue), #2563EB);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.24);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--blue-hover), var(--blue));
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.3);
}

.btn-secondary {
  background: #F1EFE9;
  color: var(--navy-deep);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #E6E2D8;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-warm);
  color: var(--navy-deep);
  border-color: var(--border-strong);
}

/* Review Panel */
.review-panel {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.verdict-banner {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 15px 18px;
  border-radius: 14px;
}

.verdict-banner.correct {
  background: var(--emerald-soft);
  border: 1.5px solid #A7F3D0;
  color: #064E3B;
}

.verdict-banner.wrong {
  background: var(--crimson-soft);
  border: 1.5px solid #FECACA;
  color: #7F1D1D;
}

.verdict-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}

.verdict-banner.correct .verdict-icon {
  background: var(--emerald);
  color: #FFFFFF;
}

.verdict-banner.wrong .verdict-icon {
  background: var(--crimson);
  color: #FFFFFF;
}

.verdict-title {
  font-size: 16px;
  font-weight: 800;
}

.verdict-shoutout {
  display: inline-block;
  margin-top: 5px;
  margin-bottom: 3px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--navy-deep);
  color: #FDE68A;
  border: 1px solid var(--gold);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
}

.verdict-banner.wrong .verdict-shoutout {
  background: var(--burgundy);
  color: #FEF3C7;
  border-color: #F59E0B;
}

.verdict-expected {
  font-size: 14px;
  font-weight: 600;
  margin-top: 3px;
}

.solution-box {
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
}

.solution-box h3 {
  margin: 0 0 11px;
  font-size: 12.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--navy-deep);
}

.solution-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 14.5px;
  color: var(--text);
}

/* Summary Card */
.summary-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.score-ring-wrap {
  position: relative;
  width: 92px;
  height: 92px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.score-ring-svg {
  width: 92px;
  height: 92px;
  transform: rotate(-90deg);
}

.score-ring-track {
  fill: none;
  stroke: #E8E2D6;
  stroke-width: 8;
}

.score-ring-arc {
  fill: none;
  stroke: var(--emerald);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 263.89;
  stroke-dashoffset: 263.89;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.summary-score-text {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 18.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--navy-deep);
}

.summary-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--navy-deep);
}

.summary-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14.5px;
}

.streak-banner {
  background: linear-gradient(135deg, #FEF8E8 0%, #FDE68A 100%);
  border: 1.5px solid var(--gold);
  color: #6E4700;
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 22px;
}

.summary-columns {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 22px;
  margin-bottom: 24px;
}

.summary-section h3 {
  margin: 0 0 11px;
  font-size: 12.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 310px;
  overflow-y: auto;
  padding-right: 4px;
}

.review-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  cursor: pointer;
  background: #FFFFFF;
  text-align: left;
  transition: border-color 0.15s, transform 0.1s;
}

.review-item:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.review-item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.review-item-title {
  font-weight: 700;
  color: var(--navy-deep);
}

.review-item-meta {
  font-size: 12px;
  color: var(--muted);
}

.review-pill {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.review-pill.ok {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.review-pill.no {
  background: var(--crimson-soft);
  color: var(--crimson);
}

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

.mastery-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mastery-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-deep);
}

.mastery-bar {
  height: 9px;
  background: #ECE7DC;
  border-radius: 999px;
  overflow: hidden;
}

.mastery-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.45s ease;
}

.summary-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
}

.summary-extra-prompt {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy-deep);
}

.extra-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topic-select {
  padding: 10px 13px;
  border-radius: 11px;
  border: 1.5px solid var(--border-strong);
  background: #FFFFFF;
  color: var(--navy-deep);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
}

[hidden] {
  display: none !important;
}

@media (max-width: 840px) {
  .dashboard-top {
    grid-template-columns: 1fr;
    gap: 16px;
  }

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

  .exercise-card,
  .summary-card {
    padding: 20px;
  }

  .exercise-prompt {
    font-size: 17px;
  }

  .formula-box {
    font-size: 16.5px;
    padding: 13px 14px;
  }

  .celebration-toast {
    bottom: 16px;
    top: auto;
    font-size: 14.5px;
    padding: 10px 16px;
  }
}

@media (max-width: 540px) {
  .step-dots.is-ten {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }
}

@media (max-width: 520px) {
  .topbar-inner {
    padding: 13px 16px;
  }

  .main-container {
    padding: 16px 14px 44px;
  }

  .brand-text h1 {
    font-size: 17.5px;
  }

  .topbar-controls {
    width: 100%;
    justify-content: space-between;
  }

.badge {
  padding: 3px 9px;
  font-size: 11.5px;
}
}

/* Modals (Auth & Leaderboard) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(11, 25, 44, 0.56);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 24px 26px;
  animation: modalIn 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-card-wide {
  max-width: 660px;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--navy-deep);
}

.modal-close {
  border: 1px solid var(--border);
  background: var(--surface-warm);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.modal-close:hover {
  background: #ECE7DC;
  color: var(--navy-deep);
}

.modal-subtitle {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #F4EFE4;
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.auth-tab {
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 9px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

.auth-tab.active {
  background: #FFFFFF;
  color: var(--navy-deep);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-deep);
}

.modal-input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1.5px solid var(--border-strong);
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--navy-deep);
  background: #FFFFFF;
  outline: none;
}

.modal-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.modal-submit-btn {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.profile-avatar-lg {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: var(--navy-deep);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.profile-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--navy-deep);
}

.profile-handle {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}

.profile-card .sync-pill {
  margin-left: auto;
}

.lb-state,
.lb-empty {
  text-align: center;
  padding: 26px 14px;
  color: var(--muted);
  font-size: 14.5px;
}

.lb-empty p {
  margin: 0 0 14px;
}

.lb-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.lb-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-warm);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}

.lb-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #F1ECE2;
  color: var(--navy-deep);
  white-space: nowrap;
}

.lb-table tr:last-child td {
  border-bottom: none;
}

.lb-row-me {
  background: #EFF6FF;
}

.lb-student-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}

.lb-you-pill {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--blue);
  color: #FFFFFF;
}

.lb-mono {
  font-family: var(--font-mono);
  font-weight: 700;
}

@media (max-width: 520px) {
  .modal-card {
    padding: 18px 16px;
  }

  .lb-table th,
  .lb-table td {
    padding: 9px 8px;
    font-size: 12.5px;
  }
}

/* Sign-In Gate */
.auth-gate {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 32px 18px 56px;
}

.auth-gate-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 32px 30px 28px;
  animation: modalIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-gate-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--navy-deep), var(--gold), var(--navy-deep));
}

.gate-crest {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  filter: drop-shadow(0 6px 14px rgba(11, 25, 44, 0.16));
}

.gate-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.22;
  text-align: center;
  color: var(--navy-deep);
}

.gate-subtitle {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 520px) {
  .auth-gate-card {
    padding: 26px 20px 24px;
  }

  .gate-title {
    font-size: 21px;
  }
}

/* Wrong Answer Popup */
.wrong-popup-card {
  position: relative;
  overflow: hidden;
  max-width: 440px;
  text-align: center;
  padding: 30px 28px 26px;
}

.wrong-popup-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--crimson), var(--gold), var(--crimson));
}

.wrong-popup-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: var(--crimson-soft);
  border: 2px solid #FECACA;
  display: grid;
  place-items: center;
  font-size: 26px;
}

.wrong-popup-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.28;
  color: var(--navy-deep);
}

.wrong-popup-sub {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
