/* Number Grid — Phase A (ng- prefix) */

.ng-layout {
  height: 100%;
  min-height: 0;
}

.ng-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 16px;
}

.ng-main {
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.ng-grid-wrap {
  display: flex;
  padding: 16px;
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  min-height: 0;
  align-items: stretch;
}

/* Alignment (Top/Centre/Bottom, Left/Centre/Right) applies to the pan — it fills the wrap and
   positions the SVG inside. Putting vj/hj on .ng-grid-wrap had no effect while .ng-grid-pan was full-size. */
.ng-grid-pan.ng-grid-vj-start {
  align-items: flex-start;
}

.ng-grid-pan.ng-grid-vj-center {
  align-items: center;
}

.ng-grid-pan.ng-grid-vj-end {
  align-items: flex-end;
}

.ng-grid-pan.ng-grid-hj-start {
  justify-content: flex-start;
}

.ng-grid-pan.ng-grid-hj-center {
  justify-content: center;
}

.ng-grid-pan.ng-grid-hj-end {
  justify-content: flex-end;
}

/* Fills the flex area so the inner SVG’s max-width/max-height % resolve against a definite box.
   Without this, the pan wrapper had no height and the grid collapsed to invisible. */
.ng-grid-pan {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: row;
  touch-action: manipulation;
  box-sizing: border-box;
}

.ng-grid {
  max-width: calc(100% * var(--ng-grid-screen-scale, 1));
  max-height: calc(100% * var(--ng-grid-screen-scale, 1));
  width: auto;
  height: auto;
  user-select: none;
  touch-action: manipulation;
}

.ng-cell {
  cursor: pointer;
}

/* Numerals sit above the rect; ignore hits on text so the rect receives the click. */
.ng-cell-num {
  font-family: var(--sm-font);
  pointer-events: none;
}

/* Selection ring is painted above cells — must not steal pointer events. */
.ng-overlay,
.ng-overlay-rect {
  pointer-events: none;
}

/* Manual palette (cell fills reference these) */
:root {
  --ng-manual-0: #ef4444;
  --ng-manual-1: #3b82f6;
  --ng-manual-2: #22c55e;
  --ng-manual-3: #eab308;
  --ng-manual-4: #f97316;
  --ng-manual-5: #a855f7;
  --ng-manual-6: #ec4899;
  --ng-manual-7: #94a3b8;

  --ng-cell-fill: var(--sm-surface);
  --ng-cell-stroke: var(--sm-border);
  --ng-cell-text: var(--sm-text);
  --ng-cell-selected-stroke: var(--sm-indigo);
}

[data-theme="dark"] {
  --ng-manual-0: #dc2626;
  --ng-manual-1: #2563eb;
  --ng-manual-2: #16a34a;
  --ng-manual-3: #ca8a04;
  --ng-manual-4: #ea580c;
  --ng-manual-5: #9333ea;
  --ng-manual-6: #db2777;
  --ng-manual-7: #64748b;
}

.ng-sidebar-heading {
  margin: 0 0 4px 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--sm-text);
  letter-spacing: 0.02em;
}

.ng-settings-summary {
  font-size: 0.85rem;
  color: var(--sm-text-muted);
  line-height: 1.4;
  margin-bottom: 8px;
}

.ng-btn-inline {
  margin-top: 6px;
}

.ng-shading-header {
  margin-bottom: 4px;
}

.ng-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.ng-palette-chip {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 2px solid var(--sm-border);
  padding: 0;
  cursor: pointer;
  box-sizing: border-box;
  flex-shrink: 0;
}

.ng-palette-chip:focus-visible {
  outline: 2px solid var(--sm-indigo);
  outline-offset: 2px;
}

.ng-palette-chip.ng-selected {
  box-shadow: 0 0 0 3px var(--sm-indigo);
  border-color: var(--sm-indigo);
}

.ng-palette-chip.ng-chip-eraser {
  background: var(--sm-surface-raised);
  color: var(--sm-text-muted);
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ng-chip-0 { background: var(--ng-manual-0); }
.ng-chip-1 { background: var(--ng-manual-1); }
.ng-chip-2 { background: var(--ng-manual-2); }
.ng-chip-3 { background: var(--ng-manual-3); }
.ng-chip-4 { background: var(--ng-manual-4); }
.ng-chip-5 { background: var(--ng-manual-5); }
.ng-chip-6 { background: var(--ng-manual-6); }
.ng-chip-7 { background: var(--ng-manual-7); }

.ng-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}

.ng-modal-cancel {
  padding: 6px 14px;
  border: 1.5px solid var(--sm-border);
  border-radius: 6px;
  background: var(--sm-surface);
  color: var(--sm-text);
  font-family: var(--sm-font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ng-modal-cancel:hover {
  background: var(--sm-bg);
}

.ng-control-error .sm-number-input {
  border-color: var(--sm-incorrect) !important;
  box-shadow: 0 0 0 1px var(--sm-incorrect);
}

.ng-control-error .ng-modal-num-row {
  border-color: var(--sm-incorrect) !important;
  box-shadow: 0 0 0 1px var(--sm-incorrect);
}

.ng-control-error .ng-modal-num-row .sm-number-input {
  box-shadow: none;
}

/* Grid settings modal: pair Rows/Columns and Start/Step horizontally */
.ng-settings-modal {
  max-width: 560px;
}

.ng-modal-view-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--sm-border);
}

.ng-modal-view-section .ng-btn-inline {
  margin-top: 8px;
}

.ng-modal-hint {
  font-size: 0.82rem;
  color: var(--sm-text-muted);
  line-height: 1.4;
  margin: 10px 0 0 0;
}

.ng-modal-fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  align-items: start;
  margin-bottom: 8px;
}

.ng-modal-fields-grid .sm-control {
  min-width: 0;
}

/* Settings number row: full-width field + visible ▲▼ steppers (native spinners are unreliable). */
.ng-modal-fields-grid .ng-modal-num-row {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.ng-modal-num-row {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: var(--sm-touch-min);
  border: 1.5px solid var(--sm-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--sm-surface);
  box-sizing: border-box;
}

.ng-modal-num-row:focus-within {
  border-color: var(--sm-indigo);
}

.ng-modal-num-row .sm-number-input {
  flex: 1;
  min-width: 0;
  width: auto;
  max-width: none;
  border: none !important;
  border-radius: 0;
  box-shadow: none !important;
}

.ng-modal-num-row .sm-number-input:focus {
  outline: none;
}

.ng-modal-step-stack {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-left: 1px solid var(--sm-border);
  background: var(--sm-bg);
}

.ng-modal-step-btn {
  flex: 1;
  min-height: 22px;
  min-width: 36px;
  padding: 0 6px;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--sm-text-muted);
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  font-family: var(--sm-font);
  transition: background var(--sm-transition-fast), color var(--sm-transition-fast);
}

.ng-modal-step-btn:hover:not(:disabled) {
  background: var(--sm-indigo-light);
  color: var(--sm-indigo);
}

.ng-modal-step-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.ng-modal-step-up {
  border-bottom: 1px solid var(--sm-border);
}

@media (max-width: 420px) {
  .ng-modal-fields-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Phase B: categories, wedges, legend, tools, sums, arrows ── */

:root {
  --ng-sum-font: 12px;

  --ng-cat-even: #60a5fa;
  --ng-cat-odd: #f87171;
  --ng-cat-m3: #fbbf24;
  --ng-cat-m4: #34d399;
  --ng-cat-m5: #a78bfa;
  --ng-cat-m6: #fb923c;
  --ng-cat-m7: #f472b6;
  --ng-cat-m8: #06b6d4;
  --ng-cat-m9: #84cc16;
  --ng-cat-m10: #e879f9;
  --ng-cat-m11: #fcd34d;
  --ng-cat-m12: #4ade80;
  --ng-cat-primes: #14b8a6;
  --ng-cat-squares: #6366f1;
  --ng-cat-cubes: #8b5cf6;
  --ng-cat-triangular: #ef4444;
  --ng-cat-fibonacci: #d97706;

  --ng-hidden-fill: var(--sm-bg);
  --ng-overflow-text: var(--sm-text-muted);

  /* Phase C: Number Card */
  --ng-cat-palindrome: #0ea5e9;
  --ng-cat-composite: #64748b;
  --ng-tree-node-bg: var(--sm-surface);
  --ng-tree-node-stroke: var(--sm-border);
  --ng-tree-node-text: var(--sm-text);
  --ng-tree-prime-bg: var(--ng-cat-primes);
  --ng-tree-prime-stroke: var(--sm-indigo);
  --ng-tree-connector: var(--sm-border);
  --ng-dienes-fill: #fbbf24;
  --ng-dienes-stroke: #b45309;
  --ng-dot-fill: var(--sm-indigo);
  --ng-bar-fill: var(--sm-indigo);
  /* ~40% lighter grouping divider so card panels read as groupings, not hard boxes */
  --ng-border-subtle: color-mix(in srgb, var(--sm-border) 55%, transparent);
  --ng-card-subpanel-bg: color-mix(in srgb, var(--sm-bg) 60%, transparent);
}

[data-theme="dark"] {
  --ng-cat-even: #3b82f6;
  --ng-cat-odd: #dc2626;
  --ng-cat-m3: #d97706;
  --ng-cat-m4: #10b981;
  --ng-cat-m5: #7c3aed;
  --ng-cat-m6: #ea580c;
  --ng-cat-m7: #db2777;
  --ng-cat-m8: #0891b2;
  --ng-cat-m9: #65a30d;
  --ng-cat-m10: #c026d3;
  --ng-cat-m11: #ca8a04;
  --ng-cat-m12: #16a34a;
  --ng-cat-primes: #0d9488;
  --ng-cat-squares: #4f46e5;
  --ng-cat-cubes: #7c3aed;
  --ng-cat-triangular: #dc2626;
  --ng-cat-fibonacci: #b45309;

  --ng-hidden-fill: #1e293b;

  --ng-cat-palindrome: #0284c7;
  --ng-cat-composite: #475569;
  --ng-dienes-fill: #d97706;
  --ng-dienes-stroke: #92400e;
}

.ng-wedge {
  pointer-events: none;
}

/* Single category, no manual shade: fill entire cell (not a corner wedge). */
.ng-wedge-full {
  pointer-events: none;
}

.ng-cell-overflow {
  font-family: var(--sm-font);
  font-weight: 700;
  pointer-events: none;
}

.ng-sums {
  pointer-events: none;
}

.ng-sum-label {
  font-family: var(--sm-font);
  font-weight: 600;
  font-size: var(--ng-sum-font, 12px);
  fill: var(--sm-text-muted);
  pointer-events: none;
}

.ng-cat-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ng-cat-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ng-cat-group-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--sm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.ng-cat-btn {
  padding: 3px 7px;
  border: 1.5px solid var(--sm-border);
  border-radius: 5px;
  background: var(--sm-surface);
  color: var(--sm-text);
  font-family: var(--sm-font);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  box-sizing: border-box;
  transition: background var(--sm-transition-fast), border-color var(--sm-transition-fast);
}

.ng-cat-btn:hover {
  background: var(--sm-bg);
}

.ng-cat-btn-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
  background: var(--ng-cat-swatch, var(--sm-border));
}

.ng-cat-btn.ng-active {
  background: var(--ng-cat-swatch);
  border-color: var(--ng-cat-swatch);
  color: #0b1220;
}

.ng-cat-btn.ng-active .ng-cat-btn-swatch {
  background: rgba(255, 255, 255, 0.7);
}

.ng-cat-btn-m3.ng-active,
.ng-cat-btn-m11.ng-active,
.ng-cat-btn-m4.ng-active,
.ng-cat-btn-m9.ng-active,
.ng-cat-btn-m12.ng-active {
  color: #0b1220;
}

.ng-cat-btn-primes.ng-active,
.ng-cat-btn-m5.ng-active,
.ng-cat-btn-m7.ng-active,
.ng-cat-btn-m10.ng-active,
.ng-cat-btn-squares.ng-active,
.ng-cat-btn-cubes.ng-active {
  color: #fff;
}

.ng-hide-btn {
  padding: 8px 14px;
  border: 1.5px solid var(--sm-border);
  border-radius: 6px;
  background: var(--sm-surface);
  color: var(--sm-text);
  font-family: var(--sm-font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--sm-touch-min);
  box-sizing: border-box;
  width: 100%;
  margin-bottom: 10px;
}

.ng-hide-btn.ng-active {
  background: var(--sm-indigo);
  border-color: var(--sm-indigo);
  color: #fff;
}

.ng-tools-section .sm-control {
  margin-bottom: 8px;
}

.ng-legend {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
  /* Grid row aligns with .ng-grid-wrap (16px); extra space clears fixed .sm-help-btn (sm-drawer.css) over top-right */
  padding: calc(16px + 8px + 2.75rem + 8px) 14px 12px;
  border-left: 1px solid var(--sm-border);
  background: var(--sm-surface);
  font-size: 0.85rem;
  color: var(--sm-text);
  flex-shrink: 0;
  width: min(200px, 28vw);
  max-height: 100%;
  box-sizing: border-box;
  overflow-y: auto;
}

.ng-legend.ng-hidden {
  display: none;
}

.ng-legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--sm-bg);
  border: 1px solid var(--sm-border);
  max-width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}

.ng-legend-chip:focus-visible {
  outline: 2px solid var(--sm-indigo);
  outline-offset: 2px;
}

.ng-legend-chip.ng-isolate-active {
  border-color: var(--sm-indigo);
  box-shadow: 0 0 0 2px var(--sm-indigo-light);
  background: var(--sm-surface-raised);
}

.ng-legend-chip-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--ng-cat-swatch, var(--sm-border));
}

.ng-legend-total {
  margin-top: auto;
  margin-left: 0;
  padding-top: 6px;
  font-weight: 600;
  color: var(--sm-text-muted);
}

/* ── Phase C: Number Card ── */

.sm-toolbar-btn.sm-toolbar-active {
  background: var(--sm-indigo-light);
  color: var(--sm-indigo);
}

.ng-card {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--sm-surface);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-y: auto;
  box-sizing: border-box;
}

.ng-card.ng-hidden {
  display: none;
}

.ng-grid-wrap.ng-card-hidden {
  display: none;
}

.ng-legend.ng-card-legend-hidden {
  display: none;
}

.ng-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.ng-card-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1.5px solid var(--sm-border);
  border-radius: 6px;
  background: var(--sm-surface);
  color: var(--sm-text);
  font-family: var(--sm-font);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: var(--sm-touch-min);
}

.ng-card-back:hover {
  background: var(--sm-bg);
}

.ng-card-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--sm-bg);
  border-radius: 6px;
}

.ng-card-nav-btn {
  min-width: var(--sm-touch-min);
  min-height: var(--sm-touch-min);
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--sm-text);
  font-family: var(--sm-font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
}

.ng-card-nav-btn:hover:not(:disabled) {
  background: var(--sm-surface);
}

.ng-card-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.ng-card-nav-label {
  min-width: 2.5em;
  text-align: center;
  font-weight: 700;
  padding: 0 4px;
}

.ng-card-nav-sep {
  color: var(--sm-text-muted);
  padding: 0 4px;
}

.ng-card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.ng-card-row {
  display: grid;
  gap: 14px;
  min-height: 0;
}

.ng-card-row-main {
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  flex: 1;
  min-height: 0;
}

.ng-card-row-footer {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 899px) {
  .ng-card-row-main,
  .ng-card-row-footer {
    grid-template-columns: 1fr;
  }
}

.ng-card-panel {
  background: var(--sm-bg);
  border: 1px solid var(--ng-border-subtle, var(--sm-border));
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.ng-card-panel > h4 {
  margin: 0 0 4px 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ng-card-hero {
  flex-direction: row;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  min-height: 0;
}

.ng-hero-left {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-shrink: 0;
}

.ng-hero-numeral {
  font-family: var(--sm-font);
  font-weight: 800;
  font-size: clamp(48px, 8vw, 96px);
  line-height: 1;
  color: var(--sm-text);
}

.ng-hero-word-roman {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ng-hero-word {
  font-size: 1rem;
  color: var(--sm-text);
  font-weight: 400;
}

.ng-hero-roman {
  font-size: 0.85rem;
  color: var(--sm-text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.ng-hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  align-content: center;
}

/* Nav inside hero: sits on the right */
.ng-card-hero .ng-card-nav {
  flex-shrink: 0;
  margin-left: auto;
}

@media (max-width: 899px) {
  .ng-card-hero {
    flex-wrap: wrap;
  }
  .ng-hero-numeral {
    font-size: clamp(40px, 12vw, 72px);
  }
  .ng-card-hero .ng-card-nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
}

.ng-card-factorisation {
  overflow-y: auto;
  min-height: 0;
}

.ng-card-pf-string {
  /* Demoted from hero role to small caption above the tree. */
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--sm-text);
  text-align: center;
  margin: 0;
}

.ng-card-pf-msg {
  font-size: 0.95rem;
  color: var(--sm-text-muted);
  margin: 0;
}

.ng-tree-host {
  flex: 1;
  width: 100%;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ng-tree-host svg,
.ng-tree-svg {
  width: 100%;
  height: 100%;
  max-height: 320px;
}

.ng-tree-node-bg {
  fill: var(--ng-tree-node-bg);
  stroke: var(--ng-tree-node-stroke);
  stroke-width: 1.5;
}

.ng-tree-node-prime .ng-tree-node-bg {
  fill: var(--ng-tree-prime-bg);
  stroke: var(--ng-tree-prime-stroke);
}

.ng-tree-node-text {
  font-family: var(--sm-font);
  font-weight: 600;
  font-size: 13px;
  fill: var(--ng-tree-node-text);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.ng-tree-connector {
  stroke: var(--ng-tree-connector);
  stroke-width: 1.5;
  fill: none;
}

.ng-card-factor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.95rem;
  color: var(--sm-text);
}

.ng-card-factor-pill {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--sm-surface-raised);
  font-variant-numeric: tabular-nums;
}

.ng-card-factor-count {
  font-size: 0.85rem;
  color: var(--sm-text-muted);
  margin-top: 4px;
}

.ng-card-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ng-cat-swatch, var(--sm-surface-raised));
  color: #0b1220;
  font-family: var(--sm-font);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  min-height: var(--sm-touch-min);
}

.ng-card-chip-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--ng-cat-swatch, var(--sm-border));
  flex-shrink: 0;
}

.ng-card-chip.ng-card-chip-noninteractive {
  cursor: default;
  opacity: 0.9;
}

.ng-card-chip:hover:not(.ng-card-chip-noninteractive) {
  filter: brightness(1.05);
}

.ng-card-chip:focus-visible {
  outline: 2px solid var(--sm-indigo);
  outline-offset: 2px;
}

.ng-card-chip-primes,
.ng-card-chip-squares,
.ng-card-chip-cubes,
.ng-card-chip-m5,
.ng-card-chip-m7,
.ng-card-chip-m10,
.ng-card-chip-composite,
.ng-card-chip-palindrome {
  color: #fff;
}

.ng-card-representations {
  gap: 14px;
  overflow-y: auto;
  min-height: 0;
}

.ng-rep-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ng-rep-caption {
  font-size: 0.82rem;
  color: var(--sm-text-muted);
}

.ng-rep-placeholder {
  font-size: 0.85rem;
  color: var(--sm-text-muted);
  margin: 0;
}

.ng-rep-dienes-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.ng-dienes-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ng-dienes-svg {
  display: block;
}

.ng-dienes-more {
  font-size: 9px;
  fill: var(--sm-text-muted);
}

.ng-dienes-label {
  font-size: 0.75rem;
  color: var(--sm-text-muted);
  text-align: center;
}

.ng-dienes-unit {
  fill: var(--ng-dienes-fill);
  stroke: var(--ng-dienes-stroke);
  stroke-width: 0.5;
}

.ng-rep-dots {
  justify-content: start;
}

.ng-rep-dot {
  border-radius: 50%;
  background: var(--ng-dot-fill);
}

.ng-rep-pairs-heading {
  font-size: 0.82rem;
  color: var(--sm-text-muted);
}

.ng-rep-pairs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.ng-rep-pair-text {
  font-family: var(--sm-font);
  font-size: 0.95rem;
  color: var(--sm-text);
}

.ng-rep-pair-text-toowide {
  color: var(--sm-text-muted);
  font-style: italic;
  font-size: 0.82rem;
}

.ng-rep-dot-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  align-items: start;
}

.ng-rep-dot-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 6px;
  border-radius: 6px;
  background: var(--ng-card-subpanel-bg, transparent);
  align-items: flex-start;
}

.ng-rep-dot-caption {
  font-size: 0.82rem;
  color: var(--sm-text-muted);
}

.ng-card-neighbours {
  gap: 10px;
}

.ng-card-sequences {
  gap: 6px;
}

/* Number-line SVG */
.ng-neigh-line {
  width: 100%;
  height: auto;
  max-height: 110px;
}

.ng-neigh-axis {
  stroke: var(--sm-border);
  stroke-width: 1.5;
}

.ng-neigh-tick {
  stroke: var(--sm-text);
  stroke-width: 1.5;
}

.ng-neigh-marker-self .ng-neigh-tick {
  stroke: var(--sm-text);
  stroke-width: 3;
}

.ng-neigh-marker-prime .ng-neigh-tick {
  stroke: var(--ng-cat-primes);
  stroke-width: 2;
}

.ng-neigh-marker-square .ng-neigh-tick {
  stroke: var(--ng-cat-squares);
  stroke-width: 2;
}

.ng-neigh-value {
  font-family: var(--sm-font);
  font-size: 11px;
  font-weight: 600;
  fill: var(--sm-text);
}

.ng-neigh-marker-self .ng-neigh-value {
  font-size: 14px;
  font-weight: 800;
}

.ng-neigh-kind {
  font-family: var(--sm-font);
  font-size: 9px;
  fill: var(--sm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ng-neigh-summary {
  font-size: 0.82rem;
  color: var(--sm-text-muted);
  line-height: 1.5;
}

/* Sequences list */
.ng-card-seq-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ng-card-seq-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.95rem;
  color: var(--sm-text);
  padding: 4px 0;
  border-bottom: 1px dashed var(--ng-border-subtle, var(--sm-border));
}

.ng-card-seq-row:last-child {
  border-bottom: none;
}

.ng-card-seq-name {
  color: var(--sm-text);
}

.ng-card-seq-index-detail {
  color: var(--sm-text-muted);
  font-size: 0.85rem;
}

/* Collapsed empty sequences panel */
.ng-card-sequences-empty {
  min-height: 0;
  padding: 10px 16px;
  background: var(--ng-card-subpanel-bg, var(--sm-bg));
}

.ng-card-sequences-empty .ng-card-empty-sequences {
  margin: 0;
}

.ng-card-empty-sequences {
  color: var(--sm-text-muted);
  font-style: italic;
  font-size: 0.9rem;
  margin: 0;
}

@media print {
  .sm-toolbar,
  .sm-sidebar-toggle,
  .sm-header,
  .sm-fs-exit-pill {
    display: none !important;
  }

  .sm-layout.collapsed .sm-sidebar {
    display: flex !important;
    width: auto !important;
    max-height: none !important;
  }

  .ng-layout,
  .sm-layout,
  .ng-main,
  .ng-grid-wrap,
  .ng-legend {
    height: auto !important;
    overflow: visible !important;
  }

  .ng-legend {
    padding-top: 16px;
  }

  .ng-card {
    background: var(--sm-surface) !important;
    overflow: visible !important;
    max-height: none !important;
  }

  .ng-card-back,
  .ng-card-nav {
    display: none !important;
  }

  body {
    background: var(--sm-surface) !important;
  }
}

/* Drawer sub-headings and helper text (drawer CSS only styles h3; we use h4 for
   classroom routines and a small muted hint for "see the Guide tab" type asides). */
.sm-drawer-body h4 {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--sm-text);
  margin: 10px 0 4px;
}

.sm-drawer-body .ng-hint {
  font-size: 12px;
  color: var(--sm-text-muted);
  margin: -4px 0 14px;
}

/* ── Framework floating toolbar (this sheet loads on Number Grid only) ──
   Default toolbar uses low opacity until hover; with a right-hand legend strip
   the corner can look empty or crowded. Keep the main toolbar readable and
   clearly above grid/legend paint (z-index stays below .sm-header at 1000). */
.sm-toolbar {
  z-index: 960;
  opacity: 0.9;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
}

.sm-toolbar:hover,
.sm-toolbar:focus-within,
.sm-toolbar.sm-toolbar-active {
  opacity: 1;
}

[data-theme="dark"] .sm-toolbar {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}
