/* MFT Pictogram — concrete-first, compact, tablet-friendly */
:root {
  --pg-bg: #f0f9ff;
  --pg-text: #0c4a6e;
  --pg-muted: #64748b;
  --pg-primary: #0ea5e9;
  --pg-dark: #0369a1;
  --pg-soft: #e0f2fe;
  --pg-accent: #f59e0b;
  --pg-green: #22c55e;
  --pg-border: #bae6fd;
  --pg-font: var(--pe-font-ui, "Vazirmatn", system-ui, sans-serif);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.pg-body {
  font-family: var(--pg-font);
  color: var(--pg-text);
  background:
    radial-gradient(700px 360px at 6% 0%, #e0f2fe 0%, transparent 55%),
    radial-gradient(520px 300px at 94% 6%, #fef3c7 0%, transparent 50%),
    var(--pg-bg);
  font-size: 13px;
}
.hidden { display: none !important; }
button, input, select { font: inherit; }

/* Top — compact */
.pg-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 6px 12px; background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--pg-border); position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
}
.pg-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.pg-brand img { border-radius: 8px; background: var(--pg-soft); width: 32px; height: 32px; }
.pg-brand strong { display: block; font-size: .85rem; }
.pg-brand small { color: var(--pg-muted); font-size: 10px; }
.pg-nav { display: flex; gap: 2px; flex-wrap: wrap; }
.pg-nav-link {
  text-decoration: none; color: var(--pg-muted); font-weight: 800; font-size: 12px;
  padding: 6px 10px; border-radius: 999px;
}
.pg-nav-link:hover { color: var(--pg-dark); background: var(--pg-soft); }
.pg-top-actions { display: flex; align-items: center; gap: 6px; }

.pg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid var(--pg-border); border-radius: 999px;
  padding: 7px 12px; font-weight: 800; font-size: 12px; cursor: pointer;
  background: #fff; color: inherit;
}
.pg-btn:hover { transform: translateY(-1px); }
.pg-btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #38bdf8); color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px rgba(14,165,233,.22);
}
.pg-btn-soft { background: var(--pg-soft); color: var(--pg-dark); border-color: transparent; }
.pg-btn-outline { background: #fff; border-color: #7dd3fc; color: var(--pg-dark); }
.pg-btn-block { width: 100%; margin-top: 6px; }
.pg-btn-sm { padding: 6px 10px; font-size: 11px; }

/* Intro compact */
.pg-intro {
  max-width: 1100px; margin: 0 auto; padding: .6rem 1rem .25rem;
}
.pg-kicker {
  display: inline-block; margin: 0 0 .2rem; font-size: 10px; font-weight: 800;
  color: var(--pg-dark); background: var(--pg-soft); padding: 2px 8px; border-radius: 999px;
}
.pg-intro h1 {
  margin: 0 0 .2rem; font-size: clamp(1.05rem, 2.4vw, 1.35rem); font-weight: 900;
  color: var(--pg-dark); line-height: 1.35;
}
.pg-sub { margin: 0; color: var(--pg-muted); font-size: 12px; line-height: 1.5; }

.pg-app {
  max-width: 1120px; margin: 0 auto 1.5rem;
  background: #fff; border: 1px solid var(--pg-border); border-radius: 16px;
  box-shadow: 0 10px 32px rgba(14,165,233,.1); overflow: hidden;
}

/* Stepper compact — 7 steps */
.pg-stepper {
  display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 8px;
  background: linear-gradient(180deg, #f0f9ff, #fff);
  border-bottom: 1px solid var(--pg-border);
}
.pg-step {
  flex: 1 1 70px; display: flex; align-items: center; gap: 5px;
  border: 1px solid transparent; background: transparent; border-radius: 10px;
  padding: 5px 6px; cursor: pointer; text-align: start; color: var(--pg-muted);
  font-weight: 800; font-size: 10px;
}
.pg-step:hover { background: var(--pg-soft); color: var(--pg-dark); }
.pg-step.is-active {
  background: #fff; border-color: var(--pg-border); color: var(--pg-dark);
  box-shadow: 0 2px 8px rgba(14,165,233,.1);
}
.pg-step.is-done .pg-step-num { background: var(--pg-green); color: #fff; }
.pg-step-num {
  width: 20px; height: 20px; border-radius: 999px; flex-shrink: 0;
  display: grid; place-items: center; background: #e2e8f0; color: #334155; font-size: 10px;
}
.pg-step.is-active .pg-step-num { background: var(--pg-primary); color: #fff; }
.pg-step-label { line-height: 1.2; }

.pg-dataset-bar {
  padding: 5px 10px; font-size: 11px; font-weight: 700; color: var(--pg-muted);
  background: #f8fafc; border-bottom: 1px solid #e2e8f0;
}
.pg-dataset-bar strong { color: var(--pg-dark); font-weight: 900; }

.pg-panel-step { display: none; padding: 10px 12px 14px; }
.pg-panel-step.is-active { display: block; }
.pg-step-head { margin-bottom: 8px; }
.pg-step-head-sm h2 { margin: 0 0 .2rem; font-size: 1rem; font-weight: 900; color: var(--pg-dark); }
.pg-step-head-sm p { margin: 0; color: var(--pg-muted); font-size: 12px; line-height: 1.45; }

/* Family chips compact */
.pg-family-strip {
  display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px;
  padding: 6px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px;
}
.pg-family-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1.5px solid transparent; background: #fff; border-radius: 999px;
  padding: 5px 9px; cursor: pointer; font-weight: 800; font-size: 11px; color: #334155;
}
.pg-family-chip:hover { border-color: var(--pg-border); background: var(--pg-soft); }
.pg-family-chip.is-active {
  border-color: var(--pg-primary); background: var(--pg-soft); color: var(--pg-dark);
}
.pg-family-chip .ico { font-size: 1rem; }

.pg-hint { font-size: 11px; color: var(--pg-muted); line-height: 1.4; margin: 4px 0; }
.pg-hint.sm { font-size: 10px; }
.pg-hint.center { text-align: center; padding: 1.5rem; }
.pg-col-title {
  font-size: 11px; font-weight: 900; color: var(--pg-dark); margin-bottom: 6px;
}

/* ========== Step 1: Concrete visual ========== */
.pg-concrete-layout {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px;
  min-height: 360px;
}
.pg-palette-col {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 8px;
  max-height: min(58vh, 480px); overflow: auto;
}
.pg-palette {
  display: flex; flex-direction: column; gap: 5px;
}
.pg-palette-item {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 5px 6px; border-radius: 10px; border: 1.5px solid transparent;
  background: #fff; cursor: grab; text-align: start; font-weight: 800; font-size: 10px;
  color: var(--pg-dark);
}
.pg-palette-item:hover { border-color: var(--pg-primary); background: var(--pg-soft); }
.pg-palette-item:active { cursor: grabbing; }
.pg-palette-item img {
  width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; pointer-events: none;
}
.pg-palette-item span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.pg-scene-col { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.pg-concrete-scene {
  flex: 1; min-height: 320px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  border: 2px dashed #7dd3fc;
  background: linear-gradient(180deg, #e0f2fe, #fef9c3 65%, #d1fae5);
  align-content: start;
  overflow: auto;
  max-height: min(58vh, 480px);
}

.pg-pile {
  background: rgba(255,255,255,.72);
  border: 1.5px solid rgba(14,165,233,.2);
  border-radius: 12px;
  padding: 6px;
  min-height: 100px;
  transition: border-color .12s, box-shadow .12s;
}
.pg-pile.is-dragover,
.pg-pile-tray.is-dragover {
  border-color: var(--pg-accent) !important;
  box-shadow: inset 0 0 0 2px rgba(245,158,11,.25);
  background: rgba(254,243,199,.85);
}
.pg-pile-head {
  display: flex; align-items: center; gap: 5px; margin-bottom: 4px; flex-wrap: wrap;
}
.pg-pile-ico {
  width: 24px; height: 24px; object-fit: contain; background: #fff;
  border-radius: 6px; padding: 2px;
}
.pg-pile-name {
  font-size: 11px; font-weight: 900; color: var(--pg-dark);
  max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pg-pile-dots {
  font-size: 8px; letter-spacing: 1px; color: var(--pg-primary); opacity: .7;
  margin-inline-start: auto;
}
.pg-pile-tray {
  min-height: 56px;
  display: flex; flex-wrap: wrap; gap: 3px; align-content: flex-start;
  border-radius: 8px; padding: 3px;
  border: 1.5px dashed transparent;
}
.pg-tray-ph {
  width: 100%; text-align: center; font-size: 10px; font-weight: 700;
  color: #94a3b8; padding: 10px 4px;
}

/* Objects — compact sizes */
.pg-obj {
  width: 30px; height: 30px; border-radius: 7px; background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.08); display: flex; align-items: center; justify-content: center;
  position: relative; cursor: pointer;
  animation: pg-pop .3s cubic-bezier(.22,1,.36,1) both;
  user-select: none; touch-action: manipulation;
}
.pg-obj.sm { width: 28px; height: 28px; border-radius: 6px; }
.pg-obj.xs { width: 22px; height: 22px; border-radius: 5px; }
.pg-obj img { width: 78%; height: 78%; object-fit: contain; pointer-events: none; }
.pg-obj.is-enter { animation: pg-enter .4s cubic-bezier(.22,1,.36,1) both; }
.pg-obj-more {
  min-width: 28px; height: 28px; border-radius: 8px; background: var(--pg-dark);
  color: #fff; font-weight: 900; font-size: 10px; display: grid; place-items: center;
  padding: 0 5px;
}

/* ========== Step 2: Compact count rows ========== */
.pg-item-rows {
  display: flex; flex-direction: column; gap: 6px;
  max-height: min(62vh, 520px); overflow: auto;
}
.pg-item-row {
  display: grid;
  grid-template-columns: 88px 118px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
}
.pg-item-meta {
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.pg-item-thumb {
  width: 36px; height: 36px; object-fit: contain;
  background: #fff; border-radius: 8px; padding: 3px;
  border: 1px solid var(--pg-border); flex-shrink: 0;
}
.pg-item-name {
  font-size: 11px; font-weight: 900; color: var(--pg-dark);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pg-item-controls {
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.pg-qty-btn {
  width: 32px; height: 32px; border-radius: 9px; border: none; cursor: pointer;
  background: var(--pg-primary); color: #fff; font-size: 16px; font-weight: 900;
  flex-shrink: 0;
}
.pg-qty-btn.minus { background: #94a3b8; }
.pg-qty-btn:active { transform: scale(.94); }
.pg-qty-input {
  width: 44px; min-height: 32px; border-radius: 8px; border: 1.5px solid var(--pg-border);
  text-align: center; font-size: 1rem; font-weight: 900; color: var(--pg-dark);
  background: #fff; padding: 0;
}
.pg-item-tray {
  min-height: 40px;
  border-radius: 10px;
  border: 2px dashed #7dd3fc;
  background: linear-gradient(180deg, #e0f2fe, #fef9c3);
  padding: 4px 6px;
  display: flex; flex-wrap: wrap; gap: 3px; align-items: center;
}
.pg-item-tray.is-dragover {
  border-color: var(--pg-accent);
  box-shadow: inset 0 0 0 2px rgba(245,158,11,.25);
}

.pg-step-nav-row {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between;
  align-items: center; margin-top: 8px;
}

/* Side controls & later stages */
.pg-side-ctrl {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 10px;
}
.pg-group-layout, .pg-pict-layout, .pg-chart-layout, .pg-play-layout {
  display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 10px; min-height: 300px;
}
.pg-field { display: block; font-size: 10px; font-weight: 800; color: var(--pg-muted); margin-bottom: 6px; }
.pg-group-presets { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 2px; }
.pg-chip {
  border: 1px solid var(--pg-border); background: #fff; border-radius: 999px;
  padding: 5px 9px; font-size: 11px; font-weight: 800; cursor: pointer; color: var(--pg-dark);
}
.pg-chip.is-active { background: var(--pg-primary); color: #fff; border-color: transparent; }
.pg-check {
  display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800;
  color: #334155; margin: 5px 0; cursor: pointer;
}
.pg-math-line {
  font-weight: 900; font-size: 11px; color: var(--pg-dark); background: #fff;
  border-radius: 8px; padding: 7px; border: 1px solid var(--pg-border); margin: 8px 0;
  line-height: 1.4; word-break: break-word;
}

/* Groups */
.pg-groups-board {
  display: flex; flex-direction: column; gap: 8px;
  min-height: 280px; padding: 8px; border-radius: 14px;
  background: linear-gradient(180deg, #e0f2fe, #fef3c7 55%, #d1fae5);
  border: 1px solid var(--pg-border); overflow: auto; max-height: min(62vh, 520px);
}
.pg-group-item-block {
  background: rgba(255,255,255,.75); border-radius: 12px; padding: 8px;
  border: 1px solid rgba(14,165,233,.18);
}
.pg-group-item-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px;
}
.pg-group-item-head img {
  width: 28px; height: 28px; object-fit: contain; background: #fff;
  border-radius: 6px; padding: 2px;
}
.pg-group-item-head strong { font-size: 12px; color: var(--pg-dark); }
.pg-group-eq {
  font-weight: 900; font-size: 11px; background: #fff; padding: 2px 8px;
  border-radius: 999px; color: var(--pg-primary);
}
.pg-group-tu {
  font-size: 10px; font-weight: 800; color: var(--pg-muted);
  margin-inline-start: auto;
}
.pg-group-bundles { display: flex; flex-wrap: wrap; gap: 6px; }
.pg-bundle {
  background: rgba(255,255,255,.88); border-radius: 10px; padding: 6px;
  border: 1.5px solid rgba(14,165,233,.22); min-width: 90px;
}
.pg-bundle.is-rem { border-style: dashed; border-color: var(--pg-accent); }
.pg-bundle-title {
  font-size: 10px; font-weight: 900; color: var(--pg-dark); margin-bottom: 4px; text-align: center;
}
.pg-bundle-items { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; min-height: 28px; }
.pg-bundle.is-pulse { animation: pg-bounce .5s ease; }

/* Pictogram */
.pg-pict-board {
  min-height: 280px; padding: 10px; border-radius: 14px;
  background: linear-gradient(135deg, #e0f2fe, #fce7f3 50%, #fef3c7);
  border: 1px solid var(--pg-border);
  display: flex; flex-direction: column; gap: 8px; overflow: auto;
  max-height: min(62vh, 520px);
}
.pg-pict-legend {
  text-align: center; font-weight: 800; font-size: 12px; color: var(--pg-dark);
  background: rgba(255,255,255,.75); border-radius: 999px; padding: 5px 12px; align-self: center;
}
.pg-pict-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  background: rgba(255,255,255,.55); border-radius: 10px; padding: 6px 8px;
}
.pg-pict-label {
  display: flex; align-items: center; gap: 5px; min-width: 72px; font-weight: 900; font-size: 11px;
}
.pg-pict-label img { width: 24px; height: 24px; object-fit: contain; }
.pg-pict-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; flex: 1; }
.pg-pict-sym {
  width: 32px; height: 32px; border-radius: 7px; background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.06); display: grid; place-items: center; position: relative;
}
.pg-pict-sym img { width: 24px; height: 24px; object-fit: contain; }
.pg-pict-sym .pg-v {
  position: absolute; bottom: -3px; inset-inline-end: -3px; background: var(--pg-primary);
  color: #fff; font-size: 8px; font-weight: 900; border-radius: 999px; padding: 1px 4px;
}
.pg-pict-eq {
  font-weight: 900; font-size: 10px; color: var(--pg-dark);
  background: rgba(255,255,255,.85); border-radius: 999px; padding: 2px 7px;
}

/* Charts */
.pg-chart-stage {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 14px; padding: 8px;
  min-height: 300px; display: flex; flex-direction: column; align-items: center;
}
#pg-bar-canvas, #pg-pie-canvas, #pg-play-canvas {
  width: 100%; max-width: 720px; height: auto; border-radius: 10px; background: #fff;
}
.pg-legend {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px;
  font-size: 11px; font-weight: 800;
}
.pg-legend span { display: inline-flex; align-items: center; gap: 4px; }
.pg-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Play */
.pg-play-stage {
  min-height: 300px; border-radius: 14px; border: 1px solid var(--pg-border);
  background: linear-gradient(180deg, #e0f2fe, #fef9c3 55%, #d1fae5); padding: 10px;
  overflow: auto;
}
.pg-play-body { min-height: 160px; display: flex; flex-direction: column; gap: 8px; }
.pg-play-row {
  background: rgba(255,255,255,.65); border-radius: 10px; padding: 6px 8px;
}
.pg-play-row strong { display: block; margin-bottom: 4px; color: var(--pg-dark); font-size: 11px; }
.pg-play-icons { display: flex; flex-wrap: wrap; gap: 3px; }

@keyframes pg-pop {
  from { opacity: 0; transform: scale(.4); }
  to { opacity: 1; transform: none; }
}
@keyframes pg-enter {
  from { opacity: 0; transform: translateY(8px) scale(.5); }
  to { opacity: 1; transform: none; }
}
@keyframes pg-bounce {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.06); }
  70% { transform: scale(.98); }
}

/* Welcome */
.pg-welcome {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(12,74,110,.35); padding: 12px;
}
.pg-welcome[hidden] { display: none !important; }
.pg-welcome-card {
  max-width: 360px; width: 100%; background: #fff; border-radius: 18px; padding: 1.1rem 1rem;
  text-align: center; box-shadow: 0 18px 48px rgba(0,0,0,.22);
}
.pg-welcome-ico { font-size: 1.8rem; }
.pg-welcome-card h2 { margin: .3rem 0; color: var(--pg-dark); font-size: 1.1rem; }
.pg-welcome-card p { color: #475569; line-height: 1.55; font-size: 13px; }
.pg-welcome-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }

.pg-toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 220;
  background: #0c4a6e; color: #fff; padding: 9px 16px; border-radius: 999px;
  font-weight: 800; font-size: 12px; box-shadow: 0 8px 22px rgba(0,0,0,.22);
}

/* Tablet / mobile */
@media (max-width: 900px) {
  .pg-concrete-layout { grid-template-columns: 1fr; }
  .pg-palette-col {
    max-height: none; overflow: visible;
  }
  .pg-palette {
    flex-direction: row; flex-wrap: wrap; overflow-x: auto;
  }
  .pg-palette-item {
    flex: 0 0 auto; width: auto; flex-direction: column; max-width: 64px;
    padding: 4px;
  }
  .pg-palette-item span { max-width: 56px; font-size: 9px; }
  .pg-concrete-scene {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    max-height: min(50vh, 400px);
  }
  .pg-item-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .pg-item-controls { justify-content: flex-start; }
  .pg-group-layout, .pg-pict-layout, .pg-chart-layout, .pg-play-layout {
    grid-template-columns: 1fr;
  }
  .pg-step-label { display: none; }
  .pg-step { flex: 0 0 auto; justify-content: center; min-width: 36px; }
  .pg-step.is-active .pg-step-label { display: inline; font-size: 10px; }
}

@media (max-width: 520px) {
  .pg-obj, .pg-obj.sm { width: 28px; height: 28px; }
  .pg-qty-btn { width: 28px; height: 28px; font-size: 14px; }
  .pg-qty-input { width: 38px; min-height: 28px; font-size: .9rem; }
  .pg-item-thumb { width: 30px; height: 30px; }
}

/* Pictogram mobile — larger play area, compact steps */
@media (max-width: 767.98px) {
  .pg-top { padding: 8px 10px; }
  .pg-nav { display: none; }
  .pg-intro { padding: 0.65rem 0.85rem 0.35rem; }
  .pg-intro h1 { font-size: 1.15rem; }
  .pg-sub { font-size: 0.85rem; }
  .pg-stepper {
    gap: 4px;
    padding: 6px 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .pg-step {
    min-width: 36px;
    padding: 6px 8px;
    flex: 0 0 auto;
  }
  .pg-step-label { display: none; }
  .pg-step.is-active .pg-step-label {
    display: inline;
    font-size: 10px;
    max-width: 4.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .pg-dataset-bar { font-size: 12px; padding: 6px 10px; }
  .pg-app { padding: 0 0.65rem calc(1rem + env(safe-area-inset-bottom, 0px)); }
  .pg-concrete-layout { grid-template-columns: 1fr; gap: 8px; }
  .pg-palette {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    max-height: none;
  }
  .pg-palette-item {
    flex: 0 0 auto;
    min-width: 52px;
    min-height: 52px;
  }
  .pg-concrete-scene {
    min-height: min(48dvh, 380px);
    max-height: min(52dvh, 420px);
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
  .pg-obj, .pg-obj.sm { width: 26px; height: 26px; }
  .pg-step-nav-row { flex-wrap: wrap; gap: 8px; }
  .pg-btn { min-height: 44px; }
  .pg-group-layout, .pg-pict-layout, .pg-chart-layout, .pg-play-layout {
    grid-template-columns: 1fr;
  }
}
@media (min-width: 768px) and (max-width: 1199.98px) {
  .pg-concrete-scene { min-height: 360px; }
}

/* Numeric LTR if any ranges appear */
body.pg-body input[type="range"] {
  direction: ltr !important;
}


/* =========================================================
   Educational flow — tens grouping + place value (2026-08-02)
   ========================================================= */

/* Navigation always physical LTR: Previous left, Next right — never RTL-mirrored */
.pg-nav-ltr,
.pg-step-nav-row.pg-nav-ltr,
.pg-step-nav-col.pg-nav-ltr {
  direction: ltr !important;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  width: 100%;
  margin-top: 10px;
  box-sizing: border-box;
}
/* Full-width block buttons would stack and share the same left edge — force auto width */
.pg-nav-ltr > .pg-btn,
.pg-nav-ltr .pg-nav-prev,
.pg-nav-ltr .pg-nav-next {
  width: auto !important;
  max-width: none;
  margin-top: 0 !important;
  flex: 0 0 auto;
  white-space: nowrap;
}
.pg-nav-ltr .pg-nav-prev {
  order: 1;
  margin-inline-end: auto;
  margin-right: auto;
  margin-left: 0 !important;
}
.pg-nav-ltr .pg-nav-next {
  order: 3;
  margin-inline-start: auto;
  margin-left: auto;
  margin-right: 0 !important;
}
.pg-nav-ltr #pg-rows-reset,
.pg-nav-ltr .pg-btn-soft:not(.pg-nav-prev):not(.pg-nav-next) { order: 2; flex: 0 0 auto; }

/* Side-ctrl nav rows still need room; prefer full-width footer nav when present */
.pg-side-ctrl .pg-nav-ltr {
  flex-wrap: wrap;
  min-width: 0;
}
.pg-panel-step > .pg-nav-ltr {
  min-height: 36px;
}

/* Stage 2: visual tens groups */
.pg-count-group-row {
  display: grid !important;
  grid-template-columns: minmax(120px, 180px) auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--pg-border, #e2e8f0);
  border-radius: 14px;
  margin-bottom: 10px;
}
.pg-count-soft { flex-direction: column; gap: 6px; }
.pg-count-soft .pg-qty-btn {
  width: 40px; height: 40px; border-radius: 10px;
  border: none; color: #fff; font-size: 18px; font-weight: 800; cursor: pointer;
}
.pg-count-soft .pg-qty-btn.plus { background: #0ea5e9; }
.pg-count-soft .pg-qty-btn.minus { background: #94a3b8; }
.pg-item-total { display: block; font-size: 11px; color: #64748b; margin-top: 4px; }
.pg-item-total b { color: #0f172a; font-size: 14px; }

.pg-ten-visual { width: 100%; }
.pg-ten-bundles {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  min-height: 72px;
}
.pg-ten-box {
  border: 2px solid #7dd3fc;
  background: linear-gradient(180deg, #f0f9ff, #e0f2fe);
  border-radius: 12px;
  padding: 8px;
  position: relative;
  animation: pgTenPop .35s ease;
}
.pg-ten-box.is-ten {
  border-color: #38bdf8;
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.18);
}
.pg-ten-box.is-ones {
  border-color: #fbbf24;
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
}
.pg-ten-box-grid {
  display: grid;
  grid-template-columns: repeat(5, 22px);
  grid-template-rows: repeat(2, 22px);
  gap: 3px;
}
.pg-ten-box-grid.ones {
  grid-template-columns: repeat(5, 22px);
  grid-template-rows: auto;
}
.pg-ten-box-label {
  display: block;
  text-align: center;
  font-size: 11px;
  font-weight: 900;
  color: #0369a1;
  margin-top: 4px;
}
.pg-ten-box.is-ones .pg-ten-box-label { color: #b45309; }
.pg-ten-meta { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pg-ten-eq { font-size: 14px; font-weight: 800; color: #0f172a; }
.pg-ten-eq strong { color: #0284c7; font-size: 16px; }
.pg-ten-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.pg-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.pg-badge-ten { background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc; }
.pg-badge-one { background: #fef3c7; color: #b45309; border: 1px solid #fcd34d; }
.pg-badge-muted { background: #f1f5f9; color: #94a3b8; }

@keyframes pgTenPop {
  from { transform: scale(.92); opacity: .5; }
  to { transform: scale(1); opacity: 1; }
}

/* Stage 3 place value */
.pg-place-head { margin-bottom: 10px; }
.pg-place-title {
  display: inline-block;
  font-weight: 900;
  font-size: 14px;
  color: #0c4a6e;
  background: #e0f2fe;
  padding: 6px 12px;
  border-radius: 999px;
}
.pg-place-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(15,23,42,.06);
}
.pg-place-card-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.pg-place-card-head img {
  width: 32px; height: 32px; object-fit: contain; border-radius: 8px; background: #f8fafc;
}
.pg-place-total {
  margin-inline-start: auto;
  font-weight: 900; font-size: 18px; color: #0284c7;
}
.pg-place-eq { font-size: 13px; font-weight: 700; color: #475569; margin-bottom: 10px; }
.pg-place-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.pg-place-col {
  border-radius: 12px;
  padding: 10px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
}
.pg-place-col.tens { background: #f0f9ff; border-color: #7dd3fc; }
.pg-place-col.ones { background: #fffbeb; border-color: #fcd34d; }
.pg-place-col-title {
  font-size: 12px; font-weight: 900; margin-bottom: 8px; color: #0f172a;
}
.pg-place-col-body {
  display: flex; flex-wrap: wrap; gap: 8px; min-height: 48px; align-items: flex-start;
}
.pg-place-col-body.ones-row { align-items: center; }
.pg-ten-block {
  border: 2px solid #38bdf8;
  border-radius: 10px;
  padding: 6px;
  background: #fff;
  animation: pgTenPop .35s ease;
}
.pg-ten-block-grid {
  display: grid;
  grid-template-columns: repeat(5, 18px);
  grid-template-rows: repeat(2, 18px);
  gap: 2px;
}
.pg-ten-block-lab {
  display: block; text-align: center; font-size: 10px; font-weight: 900; color: #0369a1; margin-top: 2px;
}
.pg-one-block {
  width: 28px; height: 28px; border-radius: 8px; overflow: hidden;
  border: 1px solid #fbbf24; background: #fff;
}
.pg-one-block img { width: 100%; height: 100%; object-fit: contain; }
.pg-place-empty { color: #94a3b8; font-weight: 800; font-size: 14px; }

/* Stage 1: ensure no accidental number badges on objects */
#pg-panel-1 .pg-qty-input,
#pg-panel-1 .pg-item-total { display: none !important; }

@media (max-width: 767.98px) {
  .pg-count-group-row {
    grid-template-columns: 1fr;
  }
  .pg-count-soft { flex-direction: row; }
  .pg-place-cols { grid-template-columns: 1fr; }
  .pg-ten-box-grid {
    grid-template-columns: repeat(5, 18px);
    grid-template-rows: repeat(2, 18px);
  }
}

