/* Interactive Enhancements (Stages 1-4)
   Styles for Glitch Hunter, Strategy Selector, Confidence Gauge, and Speech Reasoning Sparkles */

/* Universal Explorable Model Input Bars */
.expl-inputs-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: #334155;
}

.expl-num-in {
  width: 44px;
  height: 32px;
  font-size: 0.9375rem;
  font-weight: 800;
  color: #0f172a;
  text-align: center;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
}

.expl-update-btn {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  margin-left: 0.25rem;
  transition: background 0.15s ease;
}

.expl-update-btn:hover {
  background: #1d4ed8;
}

.expl-slicer-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

/* 1. Glitch Hunter (Bug Hunt) */
.glitch-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 6px solid #f59e0b;
  border-radius: 10px;
  padding: 1rem 1.15rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  font-family: var(--pub-sans, system-ui, sans-serif);
}

.glitch-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.glitch-tag {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #b45309;
}

.glitch-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
}

.glitch-sub {
  margin: 0;
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.4;
}

.glitch-steps-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.glitch-step-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.glitch-step-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.glitch-step-item.is-flagged {
  border-color: #f59e0b;
  background: #fffbeb;
}

.glitch-step-item.glitch-correct {
  border-color: #10b981;
  background: #ecfdf5;
}

.glitch-step-badge {
  font-size: 0.75rem;
  font-weight: 800;
  background: #e2e8f0;
  color: #334155;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.glitch-step-text {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
}

.glitch-flag-btn {
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  background: #ffffff;
  padding: 0.2rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}

.glitch-step-item.is-flagged .glitch-flag-btn {
  background: #f59e0b;
  color: #ffffff;
  border-color: #d97706;
}

.glitch-diagnosis-box,
.glitch-repair-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
}

.glitch-box-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #0f172a;
}

.glitch-chips-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.glitch-chip {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.glitch-chip:hover {
  background: #f1f5f9;
}

.glitch-chip.is-selected {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
}

.glitch-chip.chip-correct {
  border-color: #10b981;
  background: #ecfdf5;
  color: #065f46;
}

.glitch-repair-input-row {
  display: flex;
  gap: 0.5rem;
}

.glitch-repair-input {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
}

.glitch-repair-submit {
  padding: 0.45rem 0.95rem;
  background: #10b981;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.glitch-feedback-banner {
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.4;
}

.glitch-feedback-banner.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.glitch-feedback-banner.warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.glitch-feedback-banner.resolved {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* 2. Strategy Selector */
.strategy-selector-panel {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.strategy-selector-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 800;
  color: #0f172a;
}

.strategy-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
}

.strat-choice-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.75rem;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.strat-choice-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.strat-choice-card.is-active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.strat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.strat-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: #475569;
}

.strat-recommended-tag {
  font-size: 0.72rem;
  font-weight: 800;
  background: #fef3c7;
  color: #92400e;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.strat-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #0f172a;
}

.strat-choice-card.is-active .strat-title {
  color: #1e40af;
}

.strat-desc {
  margin: 0;
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.35;
}

/* 3. Metacognitive Confidence Gauge */
.confidence-gauge-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-top: 0.5rem;
}

.conf-gauge-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #334155;
}

.conf-gauge-row {
  display: flex;
  gap: 0.5rem;
}

.conf-gauge-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.conf-gauge-btn:hover {
  background: #f1f5f9;
}

.conf-gauge-btn.is-active {
  border-color: #10b981;
  background: #ecfdf5;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.conf-emoji {
  font-size: 1.25rem;
}

.conf-label {
  display: flex;
  flex-direction: column;
}

.conf-label strong {
  font-size: 0.82rem;
  color: #0f172a;
}

.conf-label small {
  font-size: 0.72rem;
  color: #64748b;
}

/* 4. Reasoning Sparkles */
.math-sparkle-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #166534;
  animation: sparklePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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


/* 5. Coordinate Explorer */
.coord-explorer-wrap,
.triangle-shear-wrap,
.base10-mat-wrap,
.ratio-scaler-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-family: var(--pub-sans, system-ui, sans-serif);
}

.coord-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.coord-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #0f172a;
}

.coord-badges {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.coord-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.coord-badge.point-a { background: #dbeafe; color: #1e40af; }
.coord-badge.point-b { background: #d1fae5; color: #065f46; }
.coord-badge.slope-badge { background: #e0f2fe; color: #075985; }
.coord-badge.dist-badge { background: #fef3c7; color: #92400e; }
.coord-badge.abs-badge { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.coord-badge.target { background: #ccfbf1; color: #0f766e; }

.coord-eyebrow { margin: 0 0 .15rem; color: #526478; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.coord-title { margin: 0; font-size: clamp(1.05rem, 2vw, 1.35rem); }
.coord-instruction { max-width: 68ch; margin: 0; color: #334155; line-height: 1.45; }

.coord-stage-box {
  width: 100%;
  height: clamp(320px, 58vw, 440px);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
}

.coord-svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
}

.coord-plane-bg { fill: #fff; }
.coord-quad-tint { fill: #38bdf8; fill-opacity: 0.08; pointer-events: none; }
.coord-gridline { stroke: #e8edf2; stroke-width: 1; vector-effect: non-scaling-stroke; }
.coord-gridline.is-major { stroke: #cbd5e1; stroke-width: 1.3; }
.coord-axis { stroke: #30445c; stroke-width: 2; vector-effect: non-scaling-stroke; }
.coord-arrowhead { fill: #30445c; }
.coord-tick { fill: #536477; font-size: 9.5px; font-variant-numeric: tabular-nums; pointer-events: none; }
.coord-tick-mark { stroke: #30445c; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.coord-axis-label { fill: #1f334b; font-size: 15px; font-style: italic; font-weight: 900; }
.coord-quadrant { fill: #64748b; font-size: 11px; font-weight: 800; opacity: .75; pointer-events: none; }
.coord-proj-line { fill: none; stroke-width: 2; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.coord-proj-line.proj-x { stroke: #0284c7; }
.coord-proj-line.proj-y { stroke: #0f766e; }
.coord-abs-tag-bg { fill: #ffffff; stroke: #94a3b8; stroke-width: 1; opacity: 0.95; }
.coord-abs-tag { fill: #0f172a; font-size: 10px; font-weight: 800; pointer-events: none; font-variant-numeric: tabular-nums; }
.coord-shared-axis-line { stroke: #16a34a; stroke-width: 4; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.coord-dist-badge-bg { fill: #f0fdf4; stroke: #22c55e; stroke-width: 1.5; opacity: 0.95; }
.coord-dist-badge-text { fill: #166534; font-size: 10px; font-weight: 900; pointer-events: none; }
.coord-mirror-line { stroke: #f59e0b; stroke-width: 3.5; stroke-dasharray: 6 3; vector-effect: non-scaling-stroke; opacity: 0.85; }
.coord-reflect-dash { stroke: #d97706; stroke-width: 1.5; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.coord-reflect-img { fill: #fff; stroke: #d97706; stroke-width: 2.5; }
.coord-reflect-label { fill: #b45309; font-size: 11px; font-weight: 800; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.coord-connector { stroke: #334155; stroke-width: 2.5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.coord-slope-triangle { fill: none; stroke: #0e7490; stroke-width: 2; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.coord-delta { fill: #0e7490; font-size: 11px; font-weight: 800; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.coord-handle { cursor: grab; outline: none; touch-action: none; }
.coord-handle:active { cursor: grabbing; }
.coord-hit { fill: transparent; }
.coord-halo { fill: var(--point-color); fill-opacity: .16; stroke: var(--point-color); stroke-opacity: .35; stroke-width: 1; }
.coord-dot { fill: var(--point-color); stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.coord-target-point { fill: #fff; stroke: #b45309; stroke-width: 3; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }
.coord-point-label { fill: #142b45; font-size: 12px; font-weight: 800; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.coord-handle.is-active .coord-halo, .coord-handle:focus-visible .coord-halo { fill-opacity: .3; stroke-width: 3; }
.coord-handle:focus-visible .coord-dot { stroke: #111827; stroke-width: 3; }
.coord-point-controls, .coord-coordinate-inputs { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; }
.coord-btn.point-a { color: #144e9a; }
.coord-btn.point-b { color: #08634f; }
.coord-btn.is-selected { outline: 3px solid #94a3b8; outline-offset: 1px; }
.coord-coordinate-inputs { justify-content: space-evenly; }
.coord-input-pair { display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; padding: .35rem .6rem; border: 1px solid #d5dee8; border-radius: 9px; background: #fff; font-weight: 750; }
.coord-input-pair input { width: 3.4rem; min-height: 40px; border: 1px solid #9aa9bb; border-radius: 6px; color: #142b45; font: inherit; text-align: center; }
.coord-input-pair input:focus-visible, .coord-btn:focus-visible { outline: 3px solid #2463a8; outline-offset: 2px; }
.coord-readout { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.coord-readout p { display: grid; gap: .2rem; margin: 0; padding: .65rem; border: 1px solid #dbe3eb; border-radius: 8px; background: #fff; }
.coord-readout p span { color: #526478; font-size: .76rem; }
.coord-readout strong { color: #142b45; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .coord-stage-box { height: min(105vw, 390px); }
  .coord-readout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .coord-coordinate-inputs { align-items: stretch; }
  .coord-input-pair { flex-wrap: wrap; justify-content: center; width: 100%; }
}

.coord-controls-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.coord-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.coord-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.coord-btn.is-highlighted {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  animation: pulseHighlight 1s infinite alternate;
}

@keyframes pulseHighlight {
  0% { transform: scale(1); }
  100% { transform: scale(1.02); }
}

/* 6. Triangle Shear Slider */
.tri-shear-slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tri-shear-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  accent-color: #f59e0b;
  cursor: pointer;
}

/* 7. Base-10 Regrouping Mat */
.pv-columns-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

.pv-col {
  display: flex;
  flex-direction: column;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.pv-col.pv-needs-group {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.pv-col-header {
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
  color: #ffffff;
}

.pv-col-header.hundreds { background: #3b82f6; }
.pv-col-header.tens { background: #10b981; }
.pv-col-header.ones { background: #f59e0b; }

.pv-disks-box {
  min-height: 110px;
  padding: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-content: flex-start;
  background: #fafafa;
}

.pv-disk {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  animation: diskDrop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes diskDrop {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.pv-col-actions {
  display: flex;
  border-top: 1px solid #e2e8f0;
}

.pv-mini-btn {
  flex: 1;
  padding: 0.3rem 0;
  border: none;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
}

.pv-mini-btn:hover { background: #f1f5f9; color: #0f172a; }
.pv-mini-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* 8. Ratio Scaler */
.ratio-display-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 0.85rem;
}

@media (max-width: 640px) {
  .ratio-display-grid { grid-template-columns: 1fr; }
}

.ratio-tapes-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ratio-tape-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.ratio-tape-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
}

.ratio-tape-track {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 0.25rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-height: 32px;
}

.ratio-tape-block {
  width: 22px;
  height: 24px;
  border: 1.5px solid;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: #334155;
}

.ratio-table-column {
  display: flex;
  flex-direction: column;
}

.ratio-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  text-align: center;
}

.ratio-table th {
  background: #f1f5f9;
  padding: 0.3rem 0.4rem;
  border: 1px solid #cbd5e1;
  font-weight: 800;
  color: #334155;
}

.ratio-table td {
  padding: 0.3rem 0.4rem;
  border: 1px solid #cbd5e1;
  font-variant-numeric: tabular-nums;
}

.ratio-row-current {
  background: #f0fdf4;
  font-weight: 800;
  color: #15803d;
}


/* 9. Angle Protractor Studio */
.angle-protractor-wrap,
.prime-lab-wrap,
.prob-sandbox-wrap,
.net-folder-wrap,
.function-machine-wrap,
.unit-rate-wrap,
.circle-lab-wrap,
.pythagoras-lab-wrap,
.box-plot-wrap,
.integer-vector-wrap,
.algebra-tiles-wrap,
.dilation-lab-wrap,
.proof-words-wrap,
.trig-wave-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-family: var(--pub-sans, system-ui, sans-serif);
}

.coord-point-handle {
  cursor: grab;
  transition: transform 0.1s ease;
}

.coord-point-handle:hover {
  transform: scale(1.2);
}

/* 10. Probability Spinner & Stats */
.prob-stage-grid {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
}

@media (max-width: 640px) {
  .prob-stage-grid { grid-template-columns: 1fr; }
}

.prob-spinner-box {
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

.prob-stats-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.prob-stat-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.4rem 0.6rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.prob-stat-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.prob-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.prob-stat-bar-track {
  height: 8px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}

.prob-stat-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.prob-stat-values {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* 11. Function Machine Box */
.func-machine-box {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.5rem;
}

.func-machine-box svg {
  width: 100%;
  max-width: 240px;
}

/* 12. Algebra Tiles Mat & Interactive Balancer */
.algebra-mat-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 1rem;
}

@media (max-width: 640px) {
  .algebra-mat-grid { grid-template-columns: 1fr; }
}

.algebra-mat-side {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 0.75rem;
  min-height: 120px;
}

.algebra-mat-label {
  font-size: 0.85rem;
  color: #334155;
}

.algebra-mat-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.algebra-equals-sign {
  font-size: 1.75rem;
  font-weight: 900;
  color: #1e293b;
}

.algebra-scale-fulcrum {
  font-size: 0.9rem;
  color: #64748b;
}

.tiles-container {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tiles-row-x, .tiles-row-c {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tile-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 54px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: default;
  user-select: none;
}

.tile-x-pos {
  background: #10b981;
  color: #ffffff;
  border: 1px solid #047857;
}

.tile-x-neg {
  background: #ef4444;
  color: #ffffff;
  border: 1px solid #b91c1c;
}

.tile-unit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: default;
  user-select: none;
}

.tile-1-pos {
  background: #fbbf24;
  color: #78350f;
  border: 1px solid #d97706;
}

.tile-1-neg {
  background: #f87171;
  color: #7f1d1d;
  border: 1px solid #dc2626;
}

.algebra-action-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem;
  background: #f1f5f9;
  border-radius: 6px;
}

/* ==========================================================================
   Vertical Fractions (.v-frac) — Textbook math notation across all views
   ========================================================================== */
.v-frac-wrap {
  display: inline;
}

.v-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: -0.42em;
  text-align: center;
  font-size: 0.88em;
  line-height: 1;
  margin: 0 0.16em;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.v-frac .v-num {
  display: block;
  padding: 0 0.15em 0.08em;
  border-bottom: 0.06em solid currentColor;
  font-weight: inherit;
  line-height: 1;
}

.v-frac .v-den {
  display: block;
  padding: 0.1em 0.15em 0;
  font-weight: inherit;
  line-height: 1;
}

/* In large headers / .question display */
.question .v-frac {
  vertical-align: -0.38em;
  font-size: 0.85em;
  margin: 0 0.2em;
}

.question .v-frac .v-num {
  border-bottom-width: 0.07em;
  padding-bottom: 0.06em;
}

/* ==========================================================================
   Keep-Change-Flip (KCF) Interactive Fraction Division Studio
   ========================================================================== */
.kcf-studio-container {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 18px;
  padding: 1.75rem;
  margin: 1.5rem 0;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
  font-family: var(--pub-sans, system-ui, -apple-system, sans-serif);
}

.kcf-header {
  margin-bottom: 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 1rem;
}

.kcf-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.kcf-badge {
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.8125rem;
  font-weight: 800;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid #bfdbfe;
  letter-spacing: 0.02em;
}

.kcf-header h4 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 900;
  color: #0f172a;
}

.kcf-subtitle {
  margin: 0;
  font-size: 1.05rem;
  color: #334155;
  line-height: 1.6;
}

/* Problem Hero Banner */
.kcf-problem-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f8fafc, #f0fdf4);
  border: 2px solid #93c5fd;
  border-radius: 16px;
  margin-bottom: 1.5rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.kcf-hero-equation {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 2.25rem;
  font-weight: 900;
  color: #0f172a;
}

.kcf-hero-frac {
  display: inline-flex;
  align-items: center;
}

.kcf-hero-op {
  color: #2563eb;
  font-size: 2rem;
}

.kcf-hero-op-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 2px solid #93c5fd;
  background: #ffffff;
  color: #2563eb;
  font-size: 2.25rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.kcf-hero-op-btn:hover {
  background: #eff6ff;
  border-color: #2563eb;
  transform: scale(1.08);
}

.kcf-hero-op-btn.is-mult {
  background: #f0fdf4;
  border-color: #16a34a;
  color: #16a34a;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.2);
}

.kcf-op-switch-container {
  display: flex;
  justify-content: center;
  margin-top: 0.65rem;
  width: 100%;
}

.kcf-op-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  border-radius: 20px;
  border: 1.5px solid #2563eb;
  background: #ffffff;
  color: #1d4ed8;
  font-size: 0.875rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.1);
}

.kcf-op-switch-btn:hover {
  background: #2563eb;
  color: #ffffff;
}

.kcf-op-switch-btn.is-mult {
  border-color: #16a34a;
  color: #15803d;
  background: #f0fdf4;
}

.kcf-op-switch-btn.is-mult:hover {
  background: #16a34a;
  color: #ffffff;
}

.kcf-reciprocal-tag {
  display: block;
  font-size: 0.625rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #15803d;
  background: #dcfce7;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-bottom: 0.25rem;
  letter-spacing: 0.03em;
}

/* Reducible indicator pill on unreduced fractions */
.kcf-reducible-pill {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #c2410c;
  background: #ffedd5;
  border: 1px solid #fdba74;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

/* Guided Fraction Reduction Studio (No Auto-Reducing) */
.kcf-reduction-section {
  margin-top: 1.25rem;
  width: 100%;
}

.kcf-reduction-card {
  background: #ffffff;
  border: 2px solid #fed7aa;
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.08);
}

.kcf-reduction-card .kcf-card-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.kcf-stage-pill.orange {
  background: #ea580c;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.kcf-reduction-hint {
  font-size: 0.9375rem;
  color: #475569;
  margin: 0.5rem 0 1rem;
  line-height: 1.5;
}

.kcf-reduction-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.kcf-reduce-term {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.kcf-term-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
}

.kcf-conv-arrow {
  font-size: 1.5rem;
  color: #ea580c;
  font-weight: 900;
}

.kcf-conv-num-in.gcf-in {
  width: 64px;
  border-color: #f97316;
}

.kcf-already-simplified-banner {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  color: #166534;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Practice Mode Step 5 Reduction */
.kcf-solve-step-reduce {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed #cbd5e1;
}

.kcf-reduce-inputs-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

/* Guided Mixed Number Conversion Studio (No Auto-Conversion) */
.kcf-mixed-converter-section {
  margin-top: 1.25rem;
  width: 100%;
}

.kcf-converter-card {
  background: #ffffff;
  border: 2px solid #fed7aa;
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.08);
}

.kcf-converter-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.kcf-converter-tag {
  background: #ea580c;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.kcf-improper-badge {
  background: #ffedd5;
  color: #c2410c;
  font-size: 0.8125rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  margin-left: auto;
}

.kcf-converter-hint {
  font-size: 0.9375rem;
  color: #475569;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.kcf-converter-interactive-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.kcf-converter-model-stage {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
}

.kcf-converter-model-label {
  font-size: 0.8125rem;
  font-weight: 800;
  color: #334155;
  margin-bottom: 0.5rem;
}

.kcf-mixed-bars-svg {
  width: 100%;
  max-width: 640px;
  height: auto;
  display: block;
}

.kcf-conv-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.kcf-conv-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.kcf-conv-box label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
}

.kcf-conv-num-in {
  width: 54px;
  height: 44px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 900;
  color: #0f172a;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.kcf-conv-num-in:focus {
  border-color: #ea580c;
  outline: none;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.2);
}

.kcf-conv-vertical-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.kcf-conv-frac-line {
  display: block;
  width: 100%;
  height: 2.5px;
  background: #0f172a;
  margin: 0.2rem 0;
}

.kcf-conv-plus, .kcf-conv-eq, .kcf-solve-plus {
  font-size: 1.5rem;
  font-weight: 900;
  color: #64748b;
}

.kcf-conv-result-preview {
  display: inline-flex;
  align-items: center;
  min-width: 60px;
  font-size: 1.5rem;
}

.kcf-preview-placeholder {
  color: #94a3b8;
  font-weight: 700;
}

.kcf-conv-btn-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.kcf-conv-check-btn {
  background: #ea580c;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.kcf-conv-check-btn:hover {
  background: #c2410c;
}

.kcf-conv-feedback {
  margin-top: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 800;
  border-radius: 8px;
}

.kcf-conv-feedback.is-correct {
  color: #15803d;
  background: #dcfce7;
  padding: 0.6rem 0.85rem;
  border: 1px solid #86efac;
}

.kcf-conv-feedback.is-error {
  color: #b91c1c;
  background: #fee2e2;
  padding: 0.6rem 0.85rem;
  border: 1px solid #fca5a5;
}

/* Practice Mode Step 5 Mixed Conversion */
.kcf-solve-step5-row {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed #cbd5e1;
}

.kcf-step5-inputs-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.kcf-solve-subhint {
  font-size: 0.8125rem;
  color: #64748b;
  margin-bottom: 0.5rem;
}

.kcf-hero-result {
  color: #15803d;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.kcf-res-val {
  font-size: 2.5rem;
  color: #15803d;
}

.kcf-hero-caption {
  font-size: 1.05rem;
  font-weight: 700;
  color: #475569;
}

/* Tab Navigation */
.kcf-model-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.5rem;
}

.kcf-tab-btn {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  color: #475569;
  font-size: 0.9375rem;
  font-weight: 800;
  padding: 0.65rem 1.15rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.kcf-tab-btn:hover {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.kcf-tab-btn.is-active {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

/* Tab Panels */
.kcf-tab-panel {
  display: none;
}

.kcf-tab-panel.is-active {
  display: block;
  animation: kcfFadeIn 0.25s ease-out;
}

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

.kcf-panel-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.kcf-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.kcf-card-header h5 {
  margin: 0 0 0.35rem 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
}

.kcf-card-sub {
  margin: 0;
  font-size: 0.95rem;
  color: #475569;
  line-height: 1.5;
  max-width: 650px;
}

.kcf-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.kcf-tool-btn {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  color: #1e293b;
  font-size: 0.875rem;
  font-weight: 800;
  padding: 0.55rem 0.95rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.kcf-tool-btn:hover {
  background: #e2e8f0;
}

.kcf-tool-btn.primary {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
}

.kcf-tool-btn.primary:hover {
  background: #1d4ed8;
}

.kcf-tool-btn.warning {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}

.kcf-tool-btn.warning:hover {
  background: #fde68a;
}

/* Measurement Tape Model SVG */
.kcf-svg-tape-stage {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.kcf-svg-tape {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  height: auto;
}

.kcf-measure-walkthrough {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.kcf-step-pill-row {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.kcf-step-pill-row.highlight {
  background: #f0fdf4;
  border-color: #86efac;
}

.kcf-step-pill-row p {
  margin: 0.4rem 0 0;
  font-size: 0.9375rem;
  color: #1e293b;
  line-height: 1.5;
}

.kcf-math-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #2563eb;
  background: #eff6ff;
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
}

.kcf-step-pill-row.highlight .kcf-math-tag {
  color: #15803d;
  background: #dcfce7;
}

/* Complex Fraction Proof Visualizer */
.kcf-proof-stage {
  padding: 0.5rem 0;
}

.kcf-complex-frac-box {
  background: #f8fafc;
  border: 2px solid #bfdbfe;
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.kcf-complex-title {
  font-size: 0.9375rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #1e40af;
  margin-bottom: 1rem;
}

.kcf-complex-equation {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.kcf-stacked-fraction-unit {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  font-size: 1.75rem;
  font-weight: 800;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.kcf-stacked-fraction-unit.is-highlighted {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.15);
}

.kcf-stacked-fraction-unit.is-popping {
  transform: scale(1.08);
}

.kcf-c-num, .kcf-c-den {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.kcf-c-bar {
  display: block;
  width: 100%;
  height: 3px;
  background: #0f172a;
  margin: 0.45rem 0;
  border-radius: 2px;
}

.kcf-op-symbol {
  color: #2563eb;
  font-size: 1.35rem;
}

.kcf-recip-badge {
  background: #fef3c7;
  border: 1.5px solid #f59e0b;
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  color: #b45309;
}

.kcf-one-badge {
  color: #15803d;
  font-size: 2rem;
}

.kcf-proof-arrow {
  font-size: 1.75rem;
  font-weight: 900;
  color: #64748b;
}

.kcf-proof-final {
  background: #dcfce7;
  border: 2px solid #22c55e;
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  font-size: 1.75rem;
  font-weight: 900;
  color: #15803d;
}

.kcf-proof-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.kcf-proof-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.15rem;
}

.kcf-proof-card.highlight {
  background: #f0fdf4;
  border-color: #86efac;
}

.kcf-proof-step-num {
  font-size: 0.75rem;
  font-weight: 800;
  color: #2563eb;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.25rem;
}

.kcf-proof-card strong {
  display: block;
  font-size: 1.05rem;
  color: #0f172a;
  margin-bottom: 0.4rem;
}

.kcf-proof-card p {
  margin: 0;
  font-size: 0.875rem;
  color: #475569;
  line-height: 1.5;
}

/* 3-Stage Stepper Cards */
.kcf-stages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.kcf-stage-card {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.kcf-stage-card.card-keep {
  border-color: #93c5fd;
}

.kcf-stage-card.card-change {
  border-color: #fde047;
}

.kcf-stage-card.card-flip {
  border-color: #a7f3d0;
}

.kcf-stage-card.is-active {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25), 0 8px 16px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
  background: #fafcff;
}

.kcf-card-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-weight: 800;
  font-size: 1rem;
}

.kcf-stage-pill {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
}

.kcf-fraction-display {
  font-size: 2.25rem;
  font-weight: 800;
  margin: 0.5rem 0;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kcf-operator-display {
  font-size: 2.75rem;
  font-weight: 900;
  color: #d97706;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.kcf-stage-card.is-active .kcf-operator-display {
  color: #16a34a;
}

.kcf-flip-wrapper {
  perspective: 600px;
}

.kcf-flip-inner {
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-style: preserve-3d;
}

.kcf-stage-card.is-active .kcf-flip-inner {
  color: #059669;
}

.kcf-card-desc {
  font-size: 0.8125rem;
  color: #64748b;
  margin: 0.25rem 0 1rem;
  line-height: 1.35;
  min-height: 34px;
}

.kcf-action-btn {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
  font-size: 0.875rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}

.kcf-action-btn:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.kcf-stage-card.is-active .kcf-action-btn {
  background: #16a34a;
  color: #ffffff;
  border-color: #16a34a;
}

/* Cross-Cancel Box */
.kcf-cross-cancel-box {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: 10px;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.kcf-cross-cancel-box.is-hidden {
  display: none;
}

.kcf-cancel-badge {
  background: #f59e0b;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}

.kcf-cancel-content {
  font-size: 0.9375rem;
  color: #78350f;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.kcf-cancel-factor {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
}

/* Solution Banner */
.kcf-solution-banner {
  background: #f0fdf4;
  border: 2px solid #86efac;
  border-radius: 14px;
  padding: 1.5rem;
  text-align: center;
}

.kcf-sol-title {
  font-size: 0.9375rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #15803d;
  margin-bottom: 0.75rem;
}

.kcf-sol-equation {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 1.75rem;
  font-weight: 800;
  color: #065f46;
  gap: 0.4rem;
}

.kcf-calc-op {
  color: #15803d;
  font-size: 1.6rem;
  margin: 0 0.15rem;
}

.kcf-stacked-calc {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-size: 1.35rem;
  font-weight: 800;
  color: #065f46;
}

.kcf-calc-line {
  display: block;
  width: 100%;
  height: 2px;
  background: #065f46;
  margin: 0.15rem 0;
}

.kcf-reduced-tag {
  font-size: 0.75rem;
  font-weight: 800;
  background: #dcfce7;
  color: #15803d;
  border-radius: 4px;
  padding: 0.2rem 0.45rem;
}

.kcf-final-badge {
  background: #ffffff;
  border: 2px solid #16a34a;
  border-radius: 10px;
  padding: 0.25rem 0.75rem;
  display: inline-flex;
  align-items: center;
}

/* 2D Area Model */
.kcf-grid-area-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 0;
}

.kcf-svg-grid {
  max-width: 420px;
  width: 100%;
  height: auto;
}

.kcf-area-caption {
  font-size: 1rem;
  color: #334155;
  line-height: 1.5;
  text-align: center;
  max-width: 600px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 0.85rem 1.25rem;
  border-radius: 10px;
}

/* Presets & Custom Sandbox Footer */
.kcf-sandbox-footer {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.kcf-presets-row, .kcf-custom-row, .kcf-hero-presets-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.kcf-hero-presets-row {
  margin-top: 0.75rem;
  width: 100%;
}

.kcf-presets-label,
.kcf-sb-label {
  font-size: 0.875rem;
  font-weight: 800;
  color: #334155;
}

.kcf-preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.kcf-preset-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.kcf-preset-btn:hover {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.kcf-preset-btn.is-selected {
  background: #1d4ed8;
  color: #ffffff;
  border-color: #1d4ed8;
}

.kcf-sb-inputs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.kcf-input-frac {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.25rem 0.5rem;
}

.kcf-num-in {
  width: 46px;
  height: 34px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 800;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  color: #0f172a;
}

.kcf-frac-slash {
  font-size: 1.25rem;
  font-weight: 700;
  color: #64748b;
}

.kcf-sb-op {
  font-size: 1.5rem;
  font-weight: 900;
  color: #2563eb;
}

.kcf-recalc-btn {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease;
}

.kcf-recalc-btn:hover {
  background: #1d4ed8;
}

/* Mode Toggle (Concept Explorer vs Put In Numbers) */
.kcf-mode-toggle {
  display: inline-flex;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: 10px;
  margin-left: auto;
  gap: 0.25rem;
}

.kcf-mode-btn {
  background: transparent;
  border: none;
  font-size: 0.8125rem;
  font-weight: 800;
  color: #475569;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.kcf-mode-btn.is-active {
  background: #ffffff;
  color: #1e293b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Interactive Direct-Input Fraction Box in Hero Equation */
.kcf-interactive-fraction-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: #ffffff;
  border: 2px solid #93c5fd;
  border-radius: 12px;
  padding: 0.4rem 0.6rem;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.12);
  transition: border-color 0.2s ease;
}

.kcf-interactive-fraction-box:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.kcf-input-stepper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.kcf-step-arrow {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 0.65rem;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
}

.kcf-step-arrow:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.kcf-hero-in {
  width: 52px;
  height: 36px;
  font-size: 1.5rem;
  font-weight: 900;
  color: #0f172a;
  text-align: center;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  transition: all 0.15s ease;
}

.kcf-hero-in:focus {
  background: #ffffff;
  border-color: #2563eb;
  outline: none;
}

.kcf-hero-bar {
  display: block;
  width: 100%;
  height: 3px;
  background: #0f172a;
  margin: 0.25rem 0;
  border-radius: 2px;
}

/* Slider Controller Row */
.kcf-slider-controller-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 0.65rem 1rem;
  border-radius: 8px;
}

.kcf-tape-slider {
  flex: 1;
  min-width: 180px;
  cursor: pointer;
}

.kcf-serving-scrub-val {
  font-size: 0.875rem;
  font-weight: 800;
  color: #2563eb;
  min-width: 160px;
}

/* Practice View ("Put in Numbers & Solve") */
.kcf-view-container.is-hidden {
  display: none;
}

.kcf-view-container.is-visible {
  display: block;
  animation: kcfFadeIn 0.25s ease-out;
}

.kcf-practice-card {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.kcf-practice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.kcf-practice-stages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.kcf-solve-prompt {
  font-size: 0.875rem;
  font-weight: 700;
  color: #475569;
  margin: 0 0 0.5rem 0;
}

.kcf-solve-frac-inputs {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 0.5rem 0;
}

.kcf-solve-input {
  width: 58px;
  height: 42px;
  font-size: 1.45rem;
  font-weight: 900;
  text-align: center;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  transition: all 0.2s ease;
}

.kcf-solve-input:focus {
  border-color: #2563eb;
  background: #ffffff;
  outline: none;
}

.kcf-solve-input.is-correct {
  border-color: #16a34a;
  background: #f0fdf4;
  color: #15803d;
}

.kcf-solve-line {
  display: block;
  width: 100%;
  height: 3px;
  background: #0f172a;
  margin: 0.35rem 0;
  border-radius: 2px;
}

.kcf-op-choices {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 0.5rem 0;
}

.kcf-op-btn {
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  font-weight: 900;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  cursor: pointer;
  transition: all 0.15s ease;
}

.kcf-op-btn:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
}

.kcf-op-btn.is-selected {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.kcf-feedback-msg {
  font-size: 0.8125rem;
  font-weight: 700;
  min-height: 24px;
  display: block;
  margin-top: 0.4rem;
}

.kcf-feedback-msg.is-correct {
  color: #15803d;
}

.kcf-feedback-msg.is-error {
  color: #dc2626;
}

/* Multiply Across Workout */
.kcf-solve-workout-banner {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
}

.kcf-solve-workout-banner h6 {
  margin: 0 0 0.85rem 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
}

.kcf-solve-mult-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.kcf-solve-term {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.kcf-solve-term label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #475569;
}

.kcf-solve-input-small {
  width: 65px;
  height: 38px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
}

.kcf-solve-input-final {
  width: 95px;
  height: 38px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  border: 2px solid #2563eb;
  border-radius: 6px;
  background: #eff6ff;
  color: #1e40af;
}

.kcf-solve-slash, .kcf-solve-arrow {
  font-size: 1.75rem;
  font-weight: 900;
  color: #64748b;
  margin-top: 1rem;
}

.kcf-check-solve-btn {
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 800;
  cursor: pointer;
  margin-top: 1rem;
  transition: background 0.15s ease;
}

.kcf-check-solve-btn:hover {
  background: #15803d;
}

.kcf-solve-celebration {
  margin-top: 1rem;
  padding: 0.75rem 1.25rem;
  background: #dcfce7;
  border: 1.5px solid #86efac;
  border-radius: 8px;
  color: #15803d;
  font-size: 1.05rem;
}

.kcf-solve-celebration.is-hidden {
  display: none;
}


