.ideology-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Header: total + actions ──────────────────────────────────────────── */
.ie-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #1e2024 0%, #131518 100%);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}
.ie-sum {
  display: flex; align-items: baseline; gap: 6px;
  color: var(--text-dim);
}
.ie-sum-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}
.ie-sum-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 46px;
  text-align: right;
  transition: color 0.15s;
}
.ie-sum.is-valid .ie-sum-value {
  color: #8bc97a;
  text-shadow: 0 0 12px rgba(139, 201, 122, 0.35);
}
.ie-actions { margin-left: auto; display: flex; gap: 6px; }
.ie-btn {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 6px 12px;
  font-weight: 600;
}

/* ── Group list body ─────────────────────────────────────────────────── */
.ie-body {
  display: flex; flex-direction: column;
  max-height: 70vh;
  overflow-y: auto;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  background: #13110c;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.4);
}
.ie-body::-webkit-scrollbar { width: 10px; }
.ie-body::-webkit-scrollbar-track { background: #0e0c08; }
.ie-body::-webkit-scrollbar-thumb {
  background: #2f3236;
  border: 2px solid #0e0c08;
  border-radius: 5px;
}
.ie-body::-webkit-scrollbar-thumb:hover { background: #5a5d61; }

.ie-group {
  border-bottom: 1px solid rgba(88, 81, 63, 0.3);
}
.ie-group:last-child { border-bottom: none; }

/* ── Group header with icon + label + subtotal ──────────────────────── */
.ie-group-head {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 14px;
  background: linear-gradient(90deg, rgba(212,210,202,0.06) 0%, transparent 60%),
              linear-gradient(180deg, #24272b 0%, #16181b 100%);
  border-bottom: 1px solid var(--panel-border);
  border-top: 1px solid rgba(255,255,255,0.03);
  position: sticky; top: 0; z-index: 2;
  cursor: default;
}
.ie-group-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.12s, box-shadow 0.12s;
}
.ie-group-icon-wrap:hover,
.ie-group-icon-wrap:focus-within {
  background: rgba(212, 210, 202, 0.08);
  box-shadow: 0 0 0 1px rgba(212, 210, 202, 0.35);
}
.ie-group-icon {
  width: 28px; height: 28px;
  object-fit: contain;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
  pointer-events: none;  /* clicks fall through to the wrapping <label> */
}
/* Pencil hint that surfaces on hover — tells the user this icon is
   click-to-replace. Positioned corner so it doesn't obscure the icon
   itself. Hidden on touch devices (hover-capable-only) so it doesn't
   permanently stick open on phones. */
.ie-group-icon-hint {
  position: absolute;
  right: -6px; bottom: -6px;
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  background: #1b1d20;
  color: var(--accent);
  font-size: 9px;
  border: 1px solid var(--panel-border-strong);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}
.ie-group-icon-wrap:hover .ie-group-icon-hint,
.ie-group-icon-wrap:focus-within .ie-group-icon-hint {
  opacity: 1;
}
.ie-group-label {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}
.ie-group-sum {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 42px;
  text-align: right;
}

.ie-group-rows { padding: 4px 0; }

/* ── Row: color stripe + swatch + label + value + color-picker ─────── */
.ie-row {
  --row-color: #555;
  display: grid;
  grid-template-columns: 4px 14px 1fr 78px 40px;
  gap: 10px;
  align-items: center;
  padding: 5px 14px 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.015);
  transition: background 0.1s, transform 0.05s;
  position: relative;
}
.ie-row::before {
  content: '';
  display: block;
  width: 4px;
  height: 100%;
  background: var(--row-color);
  opacity: 0.7;
  transition: opacity 0.1s, width 0.1s;
}
.ie-row:last-child { border-bottom: none; }
.ie-row:hover {
  background: linear-gradient(90deg, rgba(212,210,202,0.04) 0%, transparent 70%);
}
.ie-row:hover::before {
  opacity: 1;
  width: 5px;
}
.ie-row:focus-within {
  background: rgba(212,210,202,0.06);
}

.ie-swatch {
  width: 12px; height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.7);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12),
              0 1px 2px rgba(0,0,0,0.3);
}
.ie-label {
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ie-value {
  padding: 4px 8px;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  background: #0c0d10;
  border: 1px solid #2f3236;
  color: var(--text);
  border-radius: 2px;
}
.ie-value:hover { border-color: #3c3f43; }
.ie-value:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(212,210,202,0.2);
}
/* Kill the ugly native spinner — still accessible via keyboard arrows */
.ie-value::-webkit-inner-spin-button,
.ie-value::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ie-value { -moz-appearance: textfield; }

.ie-color {
  height: 24px; width: 40px;
  border-radius: 2px;
  border: 1px solid #2f3236;
  padding: 1px;
  background: #0c0d10;
  cursor: pointer;
}
.ie-color:hover { border-color: var(--accent); }
