/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ───────────────────────────────────────── */
:root {
  --bg:           #eef2fb;
  --bg-2:         #dce6f5;
  --ink:          #0f1e3d;
  --ink-soft:     #4a5780;
  --panel:        #ffffff;
  --blue:         #2255d8;
  --blue-dark:    #1a3fbf;
  --blue-dim:     #1a3580;
  --blue-soft:    #dbeafe;
  --teal:         #0b8a76;
  --teal-soft:    #d4f0ea;
  --teal-dim:     #097a68;
  --amber:        #c47a00;
  --amber-bright: #f59e0b;
  --amber-soft:   #fef3c7;
  --red:          #b83030;
  --red-soft:     #fee2e2;
  --line:         #bfd0ee;
  --shadow-sm:    0 2px 6px rgba(20,40,100,0.10);
  --shadow:       0 4px 14px rgba(20,40,100,0.12), 0 1px 3px rgba(20,40,100,0.08);
  --shadow-lg:    0 8px 28px rgba(20,40,100,0.16), 0 2px 8px rgba(20,40,100,0.10);
  --radius:       8px;
  --radius-md:    12px;
  --font-ui:      'Quicksand', system-ui, sans-serif;
  --font-body:    'Quicksand', system-ui, sans-serif;
  --font-worksheet: 'Space Grotesk', system-ui, sans-serif;
}

html, body {
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
}

body {
  /* Deep navy band for the header zone, then light blue-tinted content bg */
  background: linear-gradient(to bottom, var(--blue-dim) 0px, var(--blue-dim) 168px, var(--bg) 168px);
}

button, input { font: inherit; }

/* ── Shell ───────────────────────────────────────────────── */
.app-shell {
  width: min(1100px, calc(100% - 24px));
  margin: 0 auto;
  padding: 22px 0 56px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.is-hidden {
  display: none !important;
}

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.brand {
  display: grid;
  gap: 2px;
}

.brand-name {
  font-family: var(--font-ui);
  font-size: clamp(30px, 6vw, 54px);
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.4px;
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow: 0 3px 0 rgba(5, 18, 61, 0.35);
}

.brand-caption {
  color: rgba(255,255,255,0.78);
  font-size: clamp(13px, 2.4vw, 18px);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.problem-badge {
  background: var(--amber-bright);
  color: #1a1200;
  border: none;
  font-family: var(--font-worksheet);
  font-size: clamp(22px, 4vw, 36px);
  font-weight: 700;
  padding: 10px 32px;
  border-radius: var(--radius-md);
  letter-spacing: 0;
  min-width: 168px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(245,158,11,0.5), 0 1px 4px rgba(0,0,0,0.18);
}

.problem-badge.home-badge {
  display: none;
}

/* ── Home menu ─────────────────────────────────────────────── */
.home-screen {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(280px, 500px);
  gap: 18px;
  align-items: start;
}

.home-hero {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px;
  border: 2px solid rgba(255,255,255,0.24);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 18% 18%, rgba(245,158,11,0.34), transparent 24%),
    radial-gradient(circle at 78% 76%, rgba(11,138,118,0.32), transparent 30%),
    linear-gradient(145deg, #2147c7 0%, #102764 54%, #081736 100%);
  color: #ffffff;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.home-hero::after {
  content: "";
  position: absolute;
  inset: auto 26px 26px auto;
  width: 140px;
  height: 140px;
  border: 22px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  transform: rotate(-10deg);
}

.home-kicker {
  margin-bottom: 12px;
  color: #fed766;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.home-hero h1 {
  max-width: 620px;
  font-size: clamp(42px, 7vw, 76px);
  line-height: 0.98;
  font-weight: 700;
  letter-spacing: 0;
  position: relative;
  z-index: 1;
}

.home-copy {
  max-width: 520px;
  margin-top: 16px;
  color: rgba(255,255,255,0.82);
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.45;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

.activity-list {
  display: grid;
  gap: 14px;
}

.activity-card {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 112px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.activity-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--amber-bright);
  box-shadow: var(--shadow-lg);
}

.activity-card:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.activity-card-active {
  border-color: var(--amber-bright);
  background: linear-gradient(135deg, #fff9ed, #ffffff);
}

.activity-meta {
  width: max-content;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.activity-card-active .activity-meta {
  background: var(--amber-bright);
  color: #1a1200;
}

.activity-copy {
  display: grid;
  gap: 2px;
}

.activity-title {
  font-size: clamp(25px, 3.4vw, 34px);
  font-weight: 700;
  line-height: 1.1;
}

.activity-desc {
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.activity-art {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue-dark);
  position: relative;
  overflow: hidden;
}

.activity-card-active .activity-art {
  background: var(--blue-dim);
  color: #ffffff;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,0.18);
}

.division-mark,
.activity-art-multiply span {
  font-family: var(--font-worksheet);
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
}

.activity-art-fraction {
  background: #e9f8f3;
}

.pie-slice {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background:
    conic-gradient(var(--teal) 0 35%, #ffffff 35% 100%);
  border: 4px solid var(--teal);
}

.activity-art-story {
  align-content: center;
  gap: 7px;
  background: #fff1e1;
}

.activity-art-story span {
  display: block;
  width: 42px;
  height: 7px;
  border-radius: 999px;
  background: var(--amber);
}

.activity-art-story span:nth-child(2) { width: 32px; }
.activity-art-story span:nth-child(3) { width: 22px; }

.activity-art-multiply {
  background: #eef2ff;
  color: var(--blue);
}

/* ── Controls ────────────────────────────────────────────── */
.control-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow);
}

.menu-btn {
  align-self: end;
  min-height: 48px;
  border: 2px solid var(--blue);
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--blue-dark);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  padding: 0 16px;
}

.menu-btn:hover {
  background: var(--blue);
  color: #ffffff;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 110px;
}

.input-label {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.num-input {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 22px;
  font-weight: 700;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.num-input:focus  { border-color: var(--blue); background: var(--panel); box-shadow: 0 0 0 3px var(--blue-soft); }
.num-input.invalid { border-color: var(--red); background: var(--red-soft); }

.divide-symbol {
  font-family: var(--font-ui);
  font-size: 24px;
  font-weight: 700;
  color: var(--line);
  padding: 0 2px;
  margin-top: 18px;
  flex-shrink: 0;
}

.reset-btn {
  margin-top: 18px;
  width: 48px;
  height: 48px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink-soft);
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.reset-btn:hover  { background: var(--bg-2); border-color: var(--blue); color: var(--blue); }
.reset-btn:active { background: var(--bg-2); }

/* ── Warning ─────────────────────────────────────────────── */
.warning-bar {
  display: none;
  background: var(--red-soft);
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  color: var(--red);
  font-weight: 700;
  padding: 11px 16px;
  font-size: 14px;
}
.warning-bar.show { display: block; }

/* ── Workspace ───────────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: 1fr minmax(290px, 400px);
  gap: 14px;
  align-items: start;
}

/* ── Panel base ──────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ── Lab panel (left) ────────────────────────────────────── */
.lab-panel {
  display: flex;
  flex-direction: column;
  min-height: 540px;
}

.panel-header {
  padding: 18px 22px 16px;
  border-bottom: 2px solid var(--line);
  background: var(--blue-soft);
}

.panel-tag {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--blue);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.panel-title {
  font-family: var(--font-ui);
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

/* ── Place Blocks ────────────────────────────────────────── */
.place-blocks {
  display: flex;
  gap: 10px;
  padding: 20px 22px 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.place-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 72px;
  flex: 1;
  max-width: 110px;
  cursor: pointer;
}
.place-block:hover .place-digit:not(.active):not(.done) { border-color: var(--blue); }

.place-digit {
  font-family: var(--font-worksheet);
  font-size: clamp(32px, 5.5vw, 50px);
  font-weight: 700;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--ink-soft);
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.place-digit.active {
  background: var(--amber-bright);
  color: #1a1200;
  border-color: #c07000;
  border-width: 3px;
  box-shadow: 0 4px 16px rgba(245,158,11,0.45);
}

.place-digit.done {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal-dim);
}

.place-digit.muted { opacity: 0.25; }

.place-name {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1px;
  color: var(--ink-soft);
  text-transform: uppercase;
}

/* ── Current number ──────────────────────────────────────── */
.current-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 22px 16px;
}

.current-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.current-bubble {
  font-family: var(--font-worksheet);
  font-size: clamp(38px, 6.5vw, 60px);
  font-weight: 700;
  color: var(--blue);
  padding: 8px 36px;
  min-width: 130px;
  text-align: center;
  border-left: 5px solid var(--blue);
  background: var(--blue-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: color 0.2s, background 0.2s;
}

.current-bubble.pop {
  animation: num-flash 0.3s ease;
}
@keyframes num-flash {
  0%   { opacity: 0.4; }
  100% { opacity: 1; }
}

/* ── Visual stage ────────────────────────────────────────── */
.visual-stage {
  flex: 1;
  padding: 6px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Sifir ladder */
.sifir-ladder {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 260px;
  overflow-y: auto;
}

.sifir-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--bg);
}

.sifir-row.chosen {
  background: var(--teal-soft);
  color: var(--teal-dim);
  border-left-color: var(--teal);
  font-weight: 700;
}

.sifir-row.too-big {
  color: var(--line);
  font-style: italic;
}

.sifir-row.dimmed { color: var(--line); }

.sifir-label { flex: 1; }

.sifir-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0;
}

.sifir-row.chosen .sifir-badge { color: var(--teal); }
.sifir-row.too-big .sifir-badge { color: var(--line); font-style: normal; }

/* Group tokens */
.groups-compact {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.groups-header {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.group-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.group-token {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--teal);
  display: grid;
  place-items: center;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.more-badge {
  background: var(--teal-soft);
  color: var(--teal-dim);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--teal-soft);
}

/* Remainder strip */
.remainder-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--amber-soft);
  border-left: 4px solid var(--amber-bright);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.remainder-strip-label {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--amber);
  white-space: nowrap;
}

.remainder-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.rem-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--amber-bright);
  opacity: 0.8;
}

/* Not-enough box */
.not-enough-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  background: var(--amber-soft);
  border-left: 4px solid var(--amber-bright);
  border-radius: var(--radius);
}

.not-enough-icon { display: none; }

.not-enough-text {
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 700;
  color: var(--amber);
  line-height: 1.4;
}

/* Number line */
.number-line-wrap {
  overflow-x: auto;
  padding: 8px 0 28px;
}

.number-line {
  position: relative;
  height: 60px;
  min-width: 100%;
  border-bottom: 2.5px solid var(--ink-soft);
}

.nl-tick {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.nl-tick::before {
  content: '';
  width: 2px;
  height: 10px;
  background: var(--ink-soft);
}

.nl-tick-label {
  position: absolute;
  bottom: -22px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

.nl-tick.highlight::before { background: var(--teal); height: 16px; }
.nl-tick.highlight .nl-tick-label { color: var(--teal); font-size: 13px; }

.nl-arc {
  position: absolute;
  bottom: 3px;
  border: 2px solid var(--teal);
  border-bottom: none;
  border-radius: 999px 999px 0 0;
  opacity: 0.5;
}

.nl-arc-label {
  position: absolute;
  background: var(--teal);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}

/* Answer summary */
.answer-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 18px;
  background: var(--teal-soft);
  border-left: 5px solid var(--teal);
  border-radius: var(--radius);
}

.answer-big {
  font-family: var(--font-ui);
  font-size: clamp(20px, 3.5vw, 28px);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.answer-big .ans-q { color: var(--teal); }
.answer-big .ans-r { color: var(--amber); }

.answer-detail {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--teal-dim);
}

.answer-detail-r {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--amber);
}

/* ── Right panel ─────────────────────────────────────────── */
.right-panel {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 16px;
}

/* ── Division board ──────────────────────────────────────── */
.division-wrap {
  padding: 22px 20px 16px;
  background: #fffdf5;
  border-bottom: 2px solid var(--line);
  overflow-x: auto;
}

/* Subtle squared-paper grid on each calculation cell */
.div-cell:not(.blank):not(.divisor-cell):not(.place-name-cell),
.div-op-cell {
  box-shadow: inset -1px 0 0 rgba(0,0,0,0.07), inset 0 -1px 0 rgba(0,0,0,0.05);
}

.division-board {
  font-family: var(--font-worksheet);
  font-weight: 700;
  display: block;
  width: max-content;
  margin: 0 auto;
}

.div-grid {
  display: grid;
  grid-template-columns: var(--divisor-w, 44px) repeat(var(--cols), var(--cell-w, 50px));
  grid-auto-rows: auto;
  align-items: center;
  width: max-content;
  min-width: 0;
}

.div-cell {
  display: grid;
  place-items: center;
  font-size: clamp(30px, 5vw, 44px);
  min-height: 50px;
  min-width: var(--cell-w, 50px);
  line-height: 1;
}

.div-cell.divisor-cell {
  font-size: clamp(26px, 4.2vw, 38px);
  color: var(--ink-soft);
  padding-right: 8px;
  place-items: center end;
  min-width: var(--divisor-w, 44px);
  padding-left: 4px;
}

.div-cell.quotient-cell { color: var(--teal); }

.div-cell.quotient-cell.reveal {
  animation: digit-drop 0.3s ease;
}
@keyframes digit-drop {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.div-cell.dividend-cell {
  border-top: 3px solid var(--ink);
  color: var(--ink);
}
.div-cell.dividend-cell.first-col { border-left: 3px solid var(--ink); }

.div-cell.highlight-digit {
  background: var(--amber-soft);
  border-radius: var(--radius);
  outline: 2px solid var(--amber-bright);
  outline-offset: -2px;
}

.div-cell.active-quotient {
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: var(--radius);
}

.div-cell.place-name-cell {
  font-size: 9px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0;
  min-height: 20px;
  opacity: 0.55;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: var(--cell-w, 50px);
}

.div-cell.blank { /* empty */ }

.div-op-cell {
  font-size: clamp(26px, 4.2vw, 38px);
  font-family: var(--font-worksheet);
  font-weight: 700;
  min-height: 42px;
  display: grid;
  place-items: center;
}

.div-op-cell.op-product {
  color: var(--red);
  border-bottom: 2px solid var(--ink-soft);
}

.div-op-cell.op-remainder { color: var(--teal); }

.div-op-cell.op-minus {
  color: var(--red);
  font-size: 28px;
  place-items: end center;
  padding-bottom: 2px;
  border-bottom: 2px solid var(--ink-soft);
}

/* Brought-down digit in remainder row */
.div-op-cell.op-brought {
  color: var(--ink);
}

.div-op-cell.op-brought-active {
  color: var(--teal-dim);
  background: var(--teal-soft);
  border-radius: var(--radius);
  animation: digit-drop 0.3s ease;
}

/* ── Explain card — coach panel ──────────────────────────── */
.explain-card {
  padding: 20px 22px;
  border-bottom: 2px solid var(--blue-dark);
  min-height: 110px;
  display: flex;
  align-items: flex-start;
  background: var(--blue-dim);
}

.explain-icon { display: none; }

.explain-text {
  font-size: 20px;
  line-height: 1.6;
  color: rgba(255,255,255,0.90);
  font-weight: 400;
}

/* Highlight classes adjusted for dark navy background */
.explain-text strong     { color: #ffffff; font-weight: 700; }
.explain-text .hl-teal   { color: #5eead4; font-weight: 700; }
.explain-text .hl-red    { color: #fca5a5; font-weight: 700; }
.explain-text .hl-orange { color: #fcd34d; font-weight: 700; }

/* ── Step footer ─────────────────────────────────────────── */
.step-footer {
  padding: 16px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-progress {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.2px;
  text-align: center;
  text-transform: uppercase;
}

.step-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.nav-btn {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 700;
  padding: 14px;
  min-height: 54px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.07s;
}
.nav-btn:hover:not(:disabled)  { background: var(--bg-2); border-color: var(--blue); }
.nav-btn:active:not(:disabled) { background: var(--bg-2); transform: translateY(1px); }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.nav-btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue-dark);
  box-shadow: 0 3px 12px rgba(34,85,216,0.40);
}
.nav-btn-primary:hover:not(:disabled) {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  box-shadow: 0 5px 16px rgba(34,85,216,0.50);
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-in 0.25s ease forwards; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 780px) {
  .home-screen { grid-template-columns: 1fr; }
  .home-hero { min-height: 280px; }
  .workspace { grid-template-columns: 1fr; }
  .right-panel { position: static; }
  .lab-panel { min-height: auto; }
}

@media (max-width: 480px) {
  body { background: linear-gradient(to bottom, var(--blue-dim) 0px, var(--blue-dim) 140px, var(--bg) 140px); }

  .app-shell { width: calc(100% - 16px); padding: 12px 0 36px; gap: 10px; }

  .app-header { gap: 10px; }
  .brand-name { font-size: 34px; }
  .brand-caption { font-size: 13px; }

  .problem-badge { font-size: 20px; padding: 8px 20px; min-width: 130px; }
  .problem-badge.home-badge { font-size: 16px; }

  .home-hero {
    min-height: 240px;
    padding: 22px;
  }
  .home-hero h1 { font-size: 36px; }
  .home-copy { font-size: 19px; }
  .activity-card {
    grid-template-columns: 64px 1fr auto;
    min-height: 90px;
    padding: 12px;
    gap: 11px;
  }
  .activity-art {
    width: 64px;
    height: 64px;
    border-radius: 15px;
  }
  .division-mark,
  .activity-art-multiply span { font-size: 40px; }
  .pie-slice { width: 40px; height: 40px; }
  .activity-title { font-size: 22px; }
  .activity-desc { font-size: 14px; }
  .activity-meta { padding: 6px 9px; font-size: 12px; }

  .control-bar { gap: 6px; padding: 10px 12px; }
  .menu-btn { min-height: 44px; padding: 0 12px; margin-top: 16px; }
  .divide-symbol { font-size: 20px; }
  .reset-btn { width: 44px; height: 44px; margin-top: 16px; }
  .num-input { font-size: 18px; padding: 6px 8px; }

  /* Single-row scrollable tile strip — no wrapping */
  .place-blocks {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding: 20px 16px 12px;
    scrollbar-width: none;
  }
  .place-blocks::-webkit-scrollbar { display: none; }
  .place-block { flex: 0 0 auto; min-width: 0; }

  .place-digit { width: 58px; height: 58px; font-size: 28px; }
  .current-bubble { font-size: 34px; padding: 6px 20px; }

  .div-grid {
    --cell-w: 40px;
    --divisor-w: 32px;
  }
  .div-cell { font-size: 24px; min-height: 42px; min-width: 40px; }
  .div-cell.divisor-cell { font-size: 20px; }
  .div-op-cell { font-size: 21px; min-height: 36px; }
  .div-op-cell.op-minus { font-size: 22px; }

  .panel-title { font-size: 15px; }
  .explain-text { font-size: 18px; }
}
