/* App-specific styles for Cognifiy */

/* ========================================
   GLOBAL FONT ENFORCEMENT - Inter
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

html, body, button, input, select, textarea {
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ========================================
   GLOBAL MODAL SYSTEM
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  width: min(640px, calc(100vw - 32px));
  background: #ffffff;
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 24px 60px rgba(14, 36, 77, 0.18), 0 0 0 1px rgba(45, 108, 223, 0.08);
  transform: scale(0.96);
  opacity: 0;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.18s ease;
}

.modal-overlay.is-open .modal-box {
  transform: scale(1);
  opacity: 1;
}

.modal-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px;
  border-bottom: 1px solid #e3e8f2;
}

.modal-box-header h2 {
  font-size: 20px;
  font-weight: 900;
  color: #1a202c;
  margin: 0;
}

.modal-box-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: transparent;
  border: none;
  font-size: 22px;
  color: #6b7a90;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.modal-box-close:hover {
  background: #f1f5f9;
  color: #1a202c;
}

.modal-box-body {
  padding: 22px 24px;
}

.modal-box-body .form-group {
  margin-bottom: 16px;
}

.modal-box-body .form-group:last-child {
  margin-bottom: 0;
}

.modal-box-body label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #6b7a90;
  margin-bottom: 8px;
}

.modal-box-body input[type="text"],
.modal-box-body input[type="email"],
.modal-box-body input[type="password"],
.modal-box-body textarea,
.modal-box-body select {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid #e3e8f2;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 400;
  color: #1a202c;
  background: #ffffff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-box-body textarea {
  height: auto;
  min-height: 100px;
  padding: 12px 16px;
  resize: vertical;
}

.modal-box-body input:focus,
.modal-box-body textarea:focus,
.modal-box-body select:focus {
  outline: none;
  border-color: #2d6cdf;
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.15);
}

.modal-box-body input::placeholder,
.modal-box-body textarea::placeholder {
  color: #94a3b8;
}

.modal-box-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid #e3e8f2;
}

/* ========================================
   GLOBAL ANIMATIONS
   ======================================== */
.fade-in-up {
  opacity: 0;
  transform: translateY(10px);
  animation: globalFadeUp 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes globalFadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-out {
  animation: globalFadeOut 0.16s ease forwards;
}

@keyframes globalFadeOut {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* Layout */
.page-wrap{
  min-height: calc(100vh - 74px);
  padding: 34px 0 60px;
}

.auth-grid{
  display:grid;
  place-items:center;
}

/* Topbar additions (base.css provides core tokens) */
.topbar-inner{
  height: 74px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  min-width: 180px;
}

.brand-logo{
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: contain;
}

.brand-text{
  font-weight: 900;
  letter-spacing: -0.02em;
  font-size: 18px;
}

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

/* App Navigation Links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 16px;
}

.nav-link {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 8px;
  transition: all 0.15s ease;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(29,111,255,.06);
}

.nav-link.active {
  color: var(--blue);
  background: rgba(29,111,255,.1);
}

/* User Dropdown */
.nav-user {
  position: relative;
}

.nav-user-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-user-btn:hover {
  background: #fff;
  border-color: var(--blue);
}

.nav-user-email {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(13,60,135,.12);
  padding: 6px;
  display: none;
  z-index: 100;
}

.nav-user-dropdown.is-open {
  display: block;
  animation: dropdownIn 0.15s ease;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: block;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.12s ease;
}

.dropdown-item:hover {
  background: var(--bg-subtle);
}

.dropdown-item-danger {
  color: #dc2626;
}

.dropdown-item-danger:hover {
  background: rgba(220,38,38,.08);
}

.nav-desktop-menu{
  display:flex;
  gap:10px;
  align-items:center;
}

.nav-mobile-toggle{ display:none; }
.nav-mobile-menu{ display:none; }

@media (max-width: 900px){
  .nav-links { display: none; }
}

@media (max-width: 760px){
  .nav-mobile-toggle{ display:inline-flex; }
  .nav-desktop-menu{ display:none; }

  .nav-mobile-menu{
    position:absolute;
    right: 14px;
    top: 66px;
    display:none;
    flex-direction:column;
    gap:10px;
    background:#fff;
    border:1px solid var(--border);
    border-radius: 16px;
    padding: 10px;
    box-shadow: 0 18px 40px rgba(13,60,135,.10);
  }
  .nav-mobile-menu.is-open{ display:flex; }
}

/* Surfaces */
.card{
  background:#fff;
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  box-shadow: 0 10px 22px rgba(13,60,135,.06);
}

/* Auth */
.auth-card{
  width: min(460px, 100%);
  padding: 22px;
}

.kicker{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(29,111,255,.08);
  border: 1px solid rgba(29,111,255,.16);
  color: rgba(15,91,214,.95);
  font-weight: 800;
  font-size: 13px;
}

.kicker .dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(29,111,255,.45);
}

.h1{
  margin: 18px 0 10px;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.p{
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.form{ margin-top: 16px; display:grid; gap: 12px; }
.field{ display:grid; gap: 7px; }

.label{
  font-size: 13px;
  color: rgba(11,18,32,.62);
  font-weight: 700;
}

.input{
  width:100%;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  outline:none;
}

textarea.input{
  min-height: 92px;
  padding: 12px 14px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.55;
}

.input::placeholder{ color: rgba(11,18,32,.35); }

.input:focus{
  border-color: rgba(29,111,255,.38);
  box-shadow: 0 0 0 4px rgba(29,111,255,.10);
}

.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  flex-wrap:wrap;
}

.small{ font-size: 13px; color: rgba(11,18,32,.62); font-weight: 700; }
.link{ color: rgba(15,91,214,.95); font-weight: 800; }
.link:hover{ text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

.alert{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background:#fff;
  box-shadow: 0 10px 22px rgba(13,60,135,.06);
  font-size: 13px;
  display:none;
}

.alert.show{ display:block; }
.alert.ok{ border-color: rgba(34,197,94,.25); }
.alert.err{ border-color: rgba(239,68,68,.25); }

.footer-note{
  margin-top: 12px;
  text-align:center;
  color: rgba(11,18,32,.58);
  font-weight: 700;
  font-size: 13px;
}

.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(29,111,255,.06);
  border: 1px solid rgba(29,111,255,.16);
  color: rgba(15,91,214,.95);
  font-weight: 800;
  font-size: 13px;
}

/* Dashboard / shared panels */
.dash-shell{ display:grid; grid-template-columns: 1fr; gap: 14px; margin-top: 18px; }
.dash-card{ padding: 18px; border-radius: var(--radius2); }
.dash-title{ font-size: 18px; font-weight: 900; margin: 0 0 6px 0; letter-spacing: -0.02em; }
.dash-sub{ margin:0; color: var(--muted); line-height: 1.65; font-weight: 600; }

/* Cognifiy MVP UI primitives (used by new pages) */
.grid-2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 980px){
  .grid-2{ grid-template-columns: 1fr; }
}

.section-title{
  margin: 0 0 10px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.muted{ color: var(--muted); }

.pill{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  font-weight: 900;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(29,111,255,.08);
  border: 1px solid rgba(29,111,255,.16);
  color: rgba(15,91,214,.95);
}

.confidence{
  margin-top: 10px;
}

.confidence-top{
  display:flex;
  justify-content:space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.confidence-label{ font-weight: 900; font-size: 12px; color: rgba(11,18,32,.58); }
.confidence-value{ font-weight: 950; color: rgba(15,91,214,.95); }

.confidence-bar{
  height: 10px;
  border-radius: 999px;
  background: rgba(29,111,255,.10);
  border: 1px solid rgba(29,111,255,.12);
  overflow:hidden;
}

.confidence-fill{
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(29,111,255,.92), rgba(15,91,214,.92));
}

.dropzone{
  border-radius: var(--radius2);
  border: 1px dashed rgba(29,111,255,.35);
  background: rgba(29,111,255,.06);
  padding: 18px;
  display:grid;
  gap: 12px;
}

.dropzone.is-dragover{
  background: rgba(29,111,255,.10);
  border-color: rgba(29,111,255,.55);
}

.preview-img{
  border-radius: 16px;
  border: 1px solid rgba(230,236,245,.95);
  background:#fff;
}

.table{
  width:100%;
  border-collapse: collapse;
}

.table th,
.table td{
  padding: 12px 10px;
  border-bottom: 1px solid rgba(230,236,245,.95);
  text-align:left;
  font-size: 14px;
}

.table th{
  font-weight: 900;
  color: rgba(11,18,32,.58);
  font-size: 12px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

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

/* ============================================================================
   ATTEMPT VIEW + PRACTICE STYLES
   ============================================================================ */

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-content {
  text-align: center;
}

.loading-spinner-lg {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 16px;
  color: var(--muted);
  margin-top: 12px;
}

/* Attempt Header */
.attempt-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.attempt-header .badge {
  margin-left: auto;
}

/* Reveal Flow */
.reveal-container {
  display: grid;
  gap: 16px;
}

.reveal-stage {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.reveal-stage.hidden {
  display: none;
}

.reveal-stage.collapsed {
  opacity: 0.7;
}

.reveal-stage.collapsed .understood-btn {
  display: none;
}

.fade-in {
  animation: fadeIn 0.4s ease forwards;
}

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

/* Math Display */
.math-display {
  font-size: 18px;
  line-height: 1.6;
  padding: 16px 0;
  font-weight: 500;
}

.math-display sup {
  font-size: 0.7em;
  vertical-align: super;
  line-height: 0;
}

/* Step List */
.step-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.step-item {
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(29,111,255,.04);
  border: 1px solid rgba(29,111,255,.12);
  position: relative;
}

.step-item.wrong {
  background: rgba(239,68,68,.06);
  border-color: rgba(239,68,68,.25);
}

/* Step Header with Badge - Aligned Layout */
.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.step-badge {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 900;
  font-size: 13px;
  line-height: 1;
  background: rgba(29,111,255,.12);
  color: var(--blue);
}

.step-item.wrong .step-badge {
  background: rgba(239,68,68,.12);
  color: #dc2626;
}

.step-label {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.step-item.wrong .step-label {
  color: #991b1b;
}

.step-error-tag {
  font-size: 11px;
  font-weight: 700;
  color: #dc2626;
  background: rgba(239,68,68,.1);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: auto;
}

/* Legacy step-num for backwards compatibility */
.step-num {
  font-weight: 900;
  font-size: 12px;
  color: var(--blue-dark);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.step-item.wrong .step-num {
  color: #991b1b;
}

.step-text {
  font-size: 15px;
  line-height: 1.5;
}

.step-next-btn {
  margin-top: 10px;
}

/* Compare Grid */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

@media (max-width: 600px) {
  .compare-grid {
    grid-template-columns: 1fr;
  }
}

.compare-card {
  padding: 16px;
  border-radius: 14px;
}

.compare-card.error {
  background: rgba(239,68,68,.06);
  border: 1px solid rgba(239,68,68,.2);
}

.compare-card.correct {
  background: rgba(34,197,94,.06);
  border: 1px solid rgba(34,197,94,.2);
}

.compare-label {
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.compare-card.error .compare-label { color: #991b1b; }
.compare-card.correct .compare-label { color: #166534; }

/* Explanation Box */
.explanation-box {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(251,191,36,.08);
  border: 1px solid rgba(251,191,36,.25);
  border-radius: 12px;
}

/* Analysis Boxes */
.analysis-box {
  padding: 16px;
  border-radius: 14px;
  margin-top: 14px;
}

.analysis-box.error {
  background: rgba(239,68,68,.06);
  border: 1px solid rgba(239,68,68,.2);
}

.analysis-box.correct {
  background: rgba(34,197,94,.06);
  border: 1px solid rgba(34,197,94,.2);
}

.analysis-box.low-conf {
  background: rgba(251,191,36,.08);
  border: 1px solid rgba(251,191,36,.3);
}

.analysis-title {
  font-weight: 900;
  font-size: 14px;
  margin-bottom: 8px;
}

.analysis-box.error .analysis-title { color: #991b1b; }
.analysis-box.correct .analysis-title { color: #166534; }
.analysis-box.low-conf .analysis-title { color: #92400e; }

/* Pills */
.error-pill {
  background: rgba(239,68,68,.1);
  border-color: rgba(239,68,68,.25);
  color: #991b1b;
  text-transform: capitalize;
}

.mastered-pill {
  background: rgba(34,197,94,.1);
  border-color: rgba(34,197,94,.25);
  color: #166534;
  font-weight: 700;
}

/* Photo Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.photo-modal {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
}

.photo-modal-img {
  max-width: 100%;
  max-height: 85vh;
  display: block;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: none;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.modal-close:hover {
  background: rgba(0,0,0,.8);
}

/* Practice Styles */
.practice-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.practice-panel {
  padding: 24px;
}

.confidence-target {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  text-align: right;
}

.start-practice-box {
  text-align: center;
  padding: 40px 20px;
}

.start-practice-box .p {
  margin-bottom: 20px;
}

.loading-question-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.question-box {
  padding: 20px;
  border-radius: 16px;
  background: rgba(29,111,255,.04);
  border: 1px solid rgba(29,111,255,.12);
  margin-top: 20px;
}

.question-text {
  font-size: 18px;
  line-height: 1.6;
  font-weight: 600;
}

.answer-input {
  margin-top: 20px;
}

.answer-input .input {
  font-size: 18px;
  height: 56px;
}

.practice-actions {
  margin-top: 16px;
  justify-content: flex-start;
}

.feedback-box {
  padding: 16px;
  border-radius: 14px;
  margin-top: 20px;
}

.feedback-box.correct {
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.25);
}

.feedback-box.wrong {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.25);
}

.feedback-title {
  font-weight: 900;
  font-size: 16px;
  margin-bottom: 8px;
}

.feedback-box.correct .feedback-title { color: #166534; }
.feedback-box.wrong .feedback-title { color: #991b1b; }

.feedback-box .expected {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,.08);
}

/* Mastered Box */
.mastered-box {
  text-align: center;
  padding: 40px 20px;
}

.mastered-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(34,197,94,.1);
  border: 2px solid rgba(34,197,94,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: #166534;
  font-size: 36px;
  font-weight: 700;
}

.stats-row {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--blue-dark);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Error Banner */
.error-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #991b1b;
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
}

/* Understood Button */
.understood-btn {
  margin-top: 20px;
}

/* ============================================================================
   PRACTICE MODE UPGRADES
   ============================================================================ */

/* Question Instruction */
.question-instruction {
  font-size: 14px;
  font-weight: 700;
  color: var(--blue-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(29,111,255,.12);
}

/* Upload Work Section */
.upload-work-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.work-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(29,111,255,.04);
  border-radius: 12px;
  margin-top: 8px;
}

.work-preview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* Upload Modal */
.upload-modal {
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

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

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--blue);
  background: rgba(29,111,255,.04);
}

.dropzone-content {
  pointer-events: none;
}

.dropzone-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.dropzone-content p {
  margin: 4px 0;
}

.dropzone-content .small {
  font-size: 12px;
}

.upload-preview-img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 12px;
  display: block;
  margin: 0 auto;
}

/* Previous Attempts History */
.previous-attempts-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.toggle-history {
  font-size: 13px;
  color: var(--muted);
}

.history-list {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.history-item.correct {
  background: rgba(34,197,94,.06);
  border: 1px solid rgba(34,197,94,.15);
}

.history-item.wrong {
  background: rgba(239,68,68,.06);
  border: 1px solid rgba(239,68,68,.15);
}

.history-answer {
  font-family: monospace;
}

.history-result {
  font-weight: 700;
}

.history-item.correct .history-result { color: #166534; }
.history-item.wrong .history-result { color: #991b1b; }

/* Session Resume Banner */
.resume-banner {
  background: rgba(251,191,36,.1);
  border: 1px solid rgba(251,191,36,.3);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.resume-banner-icon {
  font-size: 20px;
}

.resume-banner-text {
  flex: 1;
  font-size: 14px;
}

.resume-banner-text strong {
  display: block;
  margin-bottom: 2px;
}

/* Improved Practice Panel Spacing */
.practice-panel {
  padding: 28px;
}

.practice-panel .question-box {
  margin-top: 24px;
}

.practice-panel .answer-input {
  margin-top: 24px;
}

.practice-panel .practice-actions {
  margin-top: 20px;
  gap: 12px;
}

/* Better Progress Bar Label */
.confidence-target {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  text-align: right;
}

.confidence-bar {
  position: relative;
}

/* Grading Method Badge (for debugging) */
.grading-method {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 8px;
}

/* ============================================================================
   STRUCTURED FEEDBACK UI - Cognitive Clarity Principles
   1) VERDICT (large text)
   2) PROOF (counterexample)
   3) DIFFERENCE (your vs expected)
   4) TEACHING (brief explanation)
   ============================================================================ */

/* Feedback Verdict - Large prominent text */
.feedback-verdict {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
}

.feedback-box.correct .feedback-verdict {
  color: #166534;
}

.feedback-box.wrong .feedback-verdict {
  color: #991b1b;
}

/* Feedback Proof - Counterexample display */
.feedback-proof {
  background: rgba(239,68,68,.06);
  border: 1px solid rgba(239,68,68,.15);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.proof-label {
  font-size: 14px;
  font-weight: 600;
  color: #991b1b;
  margin-bottom: 12px;
}

.proof-values {
  display: grid;
  gap: 8px;
}

.proof-value {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
}

.proof-value.user {
  background: rgba(239,68,68,.08);
  color: #991b1b;
}

.proof-value.correct {
  background: rgba(34,197,94,.08);
  color: #166534;
}

/* Feedback Difference - Your answer vs Expected */
.feedback-difference {
  background: var(--bg-subtle);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.diff-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.diff-row:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.diff-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.diff-value {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 14px;
  font-weight: 600;
}

.diff-note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 12px;
  font-style: italic;
}

/* Feedback Teaching - Brief explanation */
.feedback-teaching {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  padding: 12px 16px;
  background: rgba(29,111,255,.04);
  border-left: 3px solid var(--blue);
  border-radius: 0 8px 8px 0;
  margin-top: 16px;
}

/* Work Analysis - Step-by-step display */
.work-analysis {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.work-analysis-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.work-steps {
  display: grid;
  gap: 8px;
}

.work-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.work-step.error {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
}

.step-num {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
}

.work-step.error .step-num {
  background: #ef4444;
  color: #fff;
}

.step-text {
  flex: 1;
  font-family: 'SF Mono', Monaco, monospace;
}

.step-error-badge {
  font-size: 11px;
  font-weight: 600;
  color: #991b1b;
  background: rgba(239,68,68,.12);
  padding: 4px 8px;
  border-radius: 6px;
}

/* Work Error Detail - Comparison */
.work-error-detail {
  margin-top: 16px;
  padding: 16px;
  background: rgba(239,68,68,.04);
  border-radius: 12px;
  border: 1px solid rgba(239,68,68,.12);
}

.error-comparison {
  display: grid;
  gap: 8px;
}

.error-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.error-label {
  font-size: 12px;
  color: var(--muted);
  width: 80px;
  flex-shrink: 0;
}

.error-value {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 6px;
  flex: 1;
}

.error-value.wrong {
  background: rgba(239,68,68,.1);
  color: #991b1b;
  text-decoration: line-through;
}

.error-value.correct {
  background: rgba(34,197,94,.1);
  color: #166534;
}

.error-explanation {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

/* Equivalent Form Badge */
.equivalent-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #166534;
  background: rgba(34,197,94,.1);
  padding: 4px 10px;
  border-radius: 20px;
  margin-left: 8px;
}

/* Improved Feedback Box States */
.feedback-box {
  padding: 24px;
  border-radius: 16px;
  margin-bottom: 16px;
}

.feedback-box.correct {
  background: rgba(34,197,94,.06);
  border: 1px solid rgba(34,197,94,.15);
}

.feedback-box.wrong {
  background: rgba(239,68,68,.04);
  border: 1px solid rgba(239,68,68,.12);
}

/* ============================================================================
   MATH INPUT TOOLBAR
   Lightweight toolbar for structured math input (powers, fractions, symbols)
   ============================================================================ */

.math-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.math-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: 'SF Mono', Monaco, 'Consolas', monospace;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.math-btn:hover {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  transform: translateY(-1px);
}

.math-btn:active {
  transform: translateY(0);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
}

.math-btn-clear {
  color: #991b1b;
  border-color: rgba(239,68,68,.3);
  background: rgba(239,68,68,.05);
}

.math-btn-clear:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.math-toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 4px 4px;
  align-self: center;
}

/* Mobile: smaller buttons */
@media (max-width: 480px) {
  .math-toolbar {
    gap: 4px;
    padding: 8px;
  }
  
  .math-btn {
    min-width: 32px;
    height: 28px;
    padding: 0 8px;
    font-size: 13px;
  }
  
  .math-toolbar-divider {
    display: none;
  }
}

/* ============================================================================
   FRACTION DISPLAY (Stacked Style)
   ============================================================================ */

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 4px;
  font-size: 0.85em;
}

.frac-num {
  padding: 0 4px 2px;
}

.frac-bar {
  width: 100%;
  height: 1px;
  background: currentColor;
  margin: 1px 0;
}

.frac-den {
  padding: 2px 4px 0;
}

/* Inline fraction alternative (simpler) */
.frac-inline {
  display: inline;
}

.frac-inline .frac-num::after {
  content: '/';
  margin: 0 2px;
}

/* ============================================================================
   MATH DISPLAY ENHANCEMENTS
   ============================================================================ */

/* Superscript styling */
.question-text sup,
.feedback-box sup,
.diff-value sup,
.history-answer sup {
  font-size: 0.7em;
  vertical-align: super;
  line-height: 0;
}

/* Square root symbol */
.sqrt-symbol {
  font-size: 1.1em;
}

/* Math expression container */
.math-expr {
  font-family: 'SF Mono', Monaco, 'Consolas', monospace;
  letter-spacing: 0.5px;
}

/* ============================================================================
   VISUAL FRACTION INPUT
   Clickable numerator/denominator boxes for easy fraction entry
   ============================================================================ */

.fraction-input-container {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg);
  border: 2px solid var(--blue);
  border-radius: 12px;
  margin-top: 10px;
  box-shadow: 0 4px 12px rgba(29,111,255,.12);
}

.fraction-prefix,
.fraction-suffix {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 16px;
  color: var(--text);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fraction-input-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  padding: 4px;
  background: var(--bg-subtle);
  border-radius: 8px;
}

.frac-input {
  width: 100px;
  padding: 8px 12px;
  font-size: 15px;
  font-family: 'SF Mono', Monaco, monospace;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  transition: all 0.15s ease;
}

.frac-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29,111,255,.15);
  background: #fff;
}

.frac-input::placeholder {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

.frac-input-bar {
  width: 100%;
  height: 2px;
  background: var(--text);
  margin: 6px 0;
  border-radius: 1px;
}

.fraction-done-btn {
  padding: 8px 14px;
  font-size: 16px;
  min-width: 40px;
}

.fraction-cancel-btn {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--muted);
}

.fraction-cancel-btn:hover {
  color: #991b1b;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .fraction-input-container {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }
  
  .fraction-prefix,
  .fraction-suffix {
    max-width: 80px;
    font-size: 14px;
  }
  
  .frac-input {
    width: 80px;
    padding: 6px 10px;
    font-size: 14px;
  }
}

/* ============================================================================
   STREAK INDICATOR
   ============================================================================ */

.streak-indicator {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #f59e0b;
  margin-top: 12px;
  padding: 8px 16px;
  background: rgba(245,158,11,.1);
  border-radius: 999px;
  display: inline-block;
}

/* ============================================================================
   MASTERY PROMPT MODAL
   ============================================================================ */

.mastery-modal {
  text-align: center;
  padding: 32px;
  max-width: 400px;
}

.mastery-modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.mastery-modal h2 {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
}

.modal {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,.15);
  transform: scale(0.96);
  transition: transform 0.18s ease;
}

.modal-backdrop.is-open .modal {
  transform: scale(1);
}

/* ============================================================================
   LOADING STATES & ANIMATIONS
   ============================================================================ */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.loading-content {
  text-align: center;
}

.loading-spinner-lg {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

/* Fade in animation */
.fade-in {
  animation: fadeIn 0.3s ease;
}

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

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle) 25%, #e8ecf2 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Button loading state */
.btn.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  left: 50%;
  top: 50%;
  margin-left: -8px;
  margin-top: -8px;
}

/* Card hover animations */
.card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(13,60,135,.1);
}

/* Button click effect */
.btn:active {
  transform: scale(0.98);
}

/* Error banner */
.error-banner {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1001;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Success toast */
.success-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  z-index: 1001;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  animation: slideUp 0.3s ease;
}

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

/* Pulse animation for attention */
.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Progress bar animation */
.mastery-fill,
.confidence-fill {
  transition: width 0.5s ease;
}

/* ============================================================================
   MASTERY CELEBRATION SCREEN
   ============================================================================ */

.mastery-celebration {
  position: relative;
  text-align: center;
  padding: 40px 24px;
  overflow: hidden;
}

.confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.mastery-check-circle {
  width: 80px;
  height: 80px;
  background: rgba(22,163,74,0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: #16A34A;
  position: relative;
  z-index: 2;
}

.mastery-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 8px;
  position: relative;
  z-index: 2;
}

.mastery-subtitle {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 28px;
  position: relative;
  z-index: 2;
}

.mastery-subtitle strong {
  color: var(--text);
}

.mastery-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 24px;
  position: relative;
  z-index: 2;
}

.mastery-stat {
  text-align: center;
}

.mastery-stat-value {
  font-size: 32px;
  font-weight: 900;
  color: #1D6FFF;
  line-height: 1;
}

.mastery-stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 6px;
}

.mastery-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #fcd34d;
  padding: 8px 16px;
  border-radius: 999px;
  margin-bottom: 24px;
  position: relative;
  z-index: 2;
}

.badge-icon {
  font-size: 16px;
}

.badge-text {
  font-size: 13px;
  font-weight: 700;
  color: #92400e;
}

.mastery-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 280px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

/* ============================================================================
   HUMAN-FRIENDLY MATH DISPLAY
   ============================================================================ */

/* Inline fraction display */
.frac {
  display: inline-grid;
  grid-template-rows: auto 1px auto;
  align-items: center;
  justify-items: center;
  vertical-align: middle;
  padding: 0 3px;
  margin: 0 2px;
  font-size: 0.9em;
}

.frac .frac-num,
.frac .frac-top {
  font-size: 0.95em;
  padding: 0 2px;
  line-height: 1.2;
}

.frac .frac-bar {
  width: 100%;
  height: 1px;
  background: rgba(11,18,32,.5);
  margin: 1px 0;
}

.frac .frac-den,
.frac .frac-bottom {
  font-size: 0.95em;
  padding: 0 2px;
  line-height: 1.2;
}

/* Fraction input widget for answer input */
.frac-input-widget {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 4px;
  padding: 2px 6px;
  background: rgba(29,111,255,.06);
  border: 1px solid rgba(29,111,255,.2);
  border-radius: 6px;
}

.frac-input-widget input {
  width: 48px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}

.frac-input-widget input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(29,111,255,.15);
}

.frac-input-widget .frac-bar-input {
  width: 100%;
  height: 2px;
  background: var(--text);
  margin: 3px 0;
}

/* Math toolbar */
.math-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  padding: 8px;
  background: rgba(29,111,255,.04);
  border-radius: 8px;
  border: 1px solid rgba(29,111,255,.1);
}

.math-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  font-family: inherit;
}

.math-btn:hover {
  background: rgba(29,111,255,.08);
  border-color: var(--blue);
  color: var(--blue);
}

.math-btn:active {
  transform: scale(0.95);
}

.math-btn sup {
  font-size: 0.7em;
  vertical-align: super;
}

.math-btn-clear {
  color: #dc2626;
  border-color: rgba(239,68,68,.3);
}

.math-btn-clear:hover {
  background: rgba(239,68,68,.08);
  border-color: #dc2626;
  color: #dc2626;
}

.math-toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

/* Fraction input container */
.fraction-input-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--blue);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(29,111,255,.12);
}

.fraction-prefix,
.fraction-suffix {
  font-size: 16px;
  color: var(--text);
}

.fraction-input-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 8px;
  background: rgba(29,111,255,.06);
  border: 1px solid rgba(29,111,255,.2);
  border-radius: 6px;
}

.frac-input {
  width: 60px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
}

.frac-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(29,111,255,.15);
}

.frac-input-bar {
  width: 100%;
  height: 2px;
  background: var(--text);
  margin: 4px 0;
}

.fraction-done-btn,
.fraction-cancel-btn {
  padding: 6px 12px !important;
}

/* Display-only math symbols */
.math-multiply::before { content: '×'; }
.math-divide::before { content: '÷'; }

/* Superscript styling in display */
.math-display sup,
.step-text sup,
.question-text sup,
.feedback-text sup {
  font-size: 0.75em;
  vertical-align: super;
  line-height: 0;
}

/* Answer input with display mode */
.answer-input-wrap {
  position: relative;
}

.answer-display {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  cursor: text;
  line-height: 1.6;
}

.answer-display:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29,111,255,.12);
}

.answer-display:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

/* Hidden machine input */
.answer-machine {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.mastery-actions .btn {
  width: 100%;
}

/* Scale pop animation */
.scale-pop {
  animation: scalePop 0.35s ease;
}

@keyframes scalePop {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* Staggered fade-in for children */
.mastery-celebration .fade-in {
  animation: fadeInUp 0.4s ease forwards;
  opacity: 0;
}

.mastery-celebration .mastery-title { animation-delay: 0.2s; }
.mastery-celebration .mastery-subtitle { animation-delay: 0.3s; }
.mastery-celebration .mastery-stats { animation-delay: 0.4s; }
.mastery-celebration .mastery-badge { animation-delay: 0.5s; }
.mastery-celebration .mastery-actions { animation-delay: 0.6s; }

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

/* Error State UI */
.error-state {
  text-align: center;
  padding: 48px 24px;
}

.error-state .error-icon {
  color: var(--red-6, #dc2626);
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
}

.error-state .error-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.error-state .error-description {
  font-size: 14px;
  margin-bottom: 24px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.error-state .error-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Button loading state */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
}

@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

/* Skill Detected Modal */
.skill-detected-modal {
  text-align: center;
  padding: 32px 24px;
  max-width: 380px;
}

.skill-modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.skill-detected-modal h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
}

.skill-detected-modal p {
  font-size: 14px;
  line-height: 1.5;
}

.skill-modal-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-subtle);
  border-radius: 10px;
}

/* Mastery Modal */
.mastery-modal {
  text-align: center;
  padding: 32px 24px;
  max-width: 380px;
}

.mastery-modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* Multi-Part Question Styles */
.multipart-answers {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.part-block {
  background: rgba(29, 111, 255, 0.05);
  border: 1px solid #E6ECF5;
  border-radius: 14px;
  padding: 14px 16px;
}

.part-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.part-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 10px;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  flex-shrink: 0;
}

.part-prompt {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

.part-input {
  margin-top: 8px;
}

.part-answer-input {
  width: 100%;
  font-size: 15px;
}

/* Part Results (Feedback) */
.part-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 16px;
}

.part-result {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid;
}

.part-result.correct {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.3);
}

.part-result.wrong {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.25);
}

.part-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.part-result-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--blue);
}

.part-result-verdict {
  font-size: 13px;
  font-weight: 600;
}

.part-result.correct .part-result-verdict {
  color: #16a34a;
}

.part-result.wrong .part-result-verdict {
  color: #dc2626;
}

.part-result-diff {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

.part-result-details {
  margin-top: 10px;
  padding: 10px;
  background: rgba(0,0,0,0.02);
  border-radius: 8px;
  font-size: 13px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.detail-row:not(:last-child) {
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.detail-label {
  color: var(--text-muted);
  font-weight: 500;
}

.detail-value {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-weight: 600;
}

.detail-value.wrong {
  color: #dc2626;
}

/* Solution Steps Toggle */
.solution-steps-section {
  margin-top: 20px;
}

.solution-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--blue);
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}

.solution-toggle:hover {
  background: rgba(29, 111, 255, 0.08);
}

.toggle-icon {
  font-size: 10px;
  transition: transform 0.2s;
}

.solution-steps-content {
  margin-top: 16px;
  background: #FAFBFC;
  border: 1px solid #E6ECF5;
  border-radius: 12px;
  padding: 20px;
}

.solution-step {
  padding: 14px 0;
  border-bottom: 1px solid #E6ECF5;
}

.solution-step:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.solution-step:first-child {
  padding-top: 0;
}

.solution-step.highlight {
  background: rgba(22, 163, 74, 0.08);
  margin: 14px -20px 0;
  padding: 16px 20px;
  border-radius: 8px;
  border-bottom: none;
}

.step-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--blue);
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.solution-step.highlight .step-title {
  color: #16a34a;
  font-size: 15px;
}

.step-math {
  background: white;
  border: 1px solid #E6ECF5;
  border-radius: 8px;
  padding: 12px 16px;
  margin-left: 32px;
}

.solution-step.highlight .step-math {
  background: rgba(22, 163, 74, 0.05);
  border-color: rgba(22, 163, 74, 0.2);
  margin-left: 0;
}

.math-line {
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
}

.math-line + .math-line {
  margin-top: 4px;
}

/* Currency formatting in feedback */
.expected-formatted {
  font-weight: 700;
  color: #16a34a;
}
