/* ── Smart Keypad ──────────────────────────────── */

.keypad-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  transform: translateY(100%);
  transition: transform 0.2s ease-out;
  padding: 6px 8px 12px;
  max-width: 480px;
  margin: 0 auto;
}

.keypad-overlay.visible {
  transform: translateY(0);
}

/* ── Quick-adjust row ─────────────────────────── */
.keypad-quick {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  justify-content: center;
}

.keypad-quick button {
  flex: 1;
  max-width: 80px;
  padding: 6px 4px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.keypad-quick button:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
}

.keypad-quick button:active {
  transform: scale(0.95);
}

/* ── Digit grid ───────────────────────────────── */
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.keypad-grid button {
  padding: 12px 0;
  font-size: 1.15rem;
  font-weight: 600;
  background: var(--bg-raised);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s;
}

.keypad-grid button:hover {
  background: var(--border);
}

.keypad-grid button:active {
  transform: scale(0.96);
}

.keypad-grid .key-backspace {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.keypad-grid .key-done {
  background: var(--accent);
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
}

.keypad-grid .key-done:hover {
  background: var(--accent-hover);
}

/* ── Scrim (dim area above keypad) ────────────── */
.keypad-scrim {
  position: fixed;
  inset: 0;
  z-index: 199;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.keypad-scrim.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Input styling when keypad-active ─────────── */
input.keypad-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* Armed = next keypad digit REPLACES this field's value (data-kp-fresh set by
   keypad.js on open of a filled field) — the visible "fresh" cue; native
   selection isn't usable on touch. First write/quick-±/close disarm.
   SPECIFICITY IS LOAD-BEARING (blind-QA finding C): .set-field prefix (0-2-1)
   beats base.css's `.set-saved .set-field input { background: transparent }`,
   and this rule sits AFTER input.keypad-active so the combined shadow (inset
   armed ring + outer focus ring) wins the same-specificity tie. */
/* Next →/Done ✓ advance key — full-width below the grid. Outline = Next
   (just moving, nothing saves); solid accent = Done (this tap SAVES). */
.keypad-advance {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 10px;
}
.keypad-advance[hidden] { display: none; }
.keypad-advance.kp-next {
  background: var(--bg-raised);
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.keypad-advance.kp-done {
  background: var(--accent);
  color: var(--on-accent, #fff);
  border: 1.5px solid var(--accent);
}

input[data-kp-fresh="1"],
.set-field input[data-kp-fresh="1"] {
  background: var(--accent-subtle);
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 2px var(--accent-subtle);
  border-radius: var(--radius);
  color: var(--accent);
  font-weight: 700;
}
