/* ═══════════════════════════════════════════════════════════════
   CalcHub UK — scientific keypad
   Scoped under .chuk-kp so it cannot leak into the theme.
   ═══════════════════════════════════════════════════════════════ */

.chuk-kp {
  --kp-ink: #14281f;
  --kp-panel: #1c3528;
  --kp-face: #244536;
  --kp-face-2: #2e5645;
  --kp-accent: #f97316;
  --kp-accent-hi: #fdba74;
  --kp-text: #eaf2ed;
  --kp-dim: #9fb3a8;

  display: block;
  max-width: 100%;
  padding: 14px;
  background: var(--kp-ink);
  border-radius: 16px;
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  box-sizing: border-box;
}

.chuk-kp *,
.chuk-kp *::before,
.chuk-kp *::after { box-sizing: border-box; }

/* ─── Display ─── */
.chuk-kp-display {
  padding: 14px 16px 12px;
  background: var(--kp-panel);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 11px;
  text-align: right;
  overflow: hidden;
}

.chuk-kp-expr {
  min-height: 1.3em;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: .9rem;
  line-height: 1.3;
  color: var(--kp-dim);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.chuk-kp-expr::-webkit-scrollbar { display: none; }

.chuk-kp-out {
  display: block;
  margin-top: 2px;
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
  color: #fff;
  font-variant-numeric: tabular-nums;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.chuk-kp-out::-webkit-scrollbar { display: none; }
.chuk-kp-out.is-error {
  font-size: 1rem;
  font-weight: 600;
  color: #ff6b6b;
}

/* ─── Deg / Rad ─── */
.chuk-kp-modes {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 12px 0 10px;
}

.chuk-kp-mode {
  appearance: none;
  min-height: 34px;
  padding: 5px 15px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  color: var(--kp-dim);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  cursor: pointer;
}
.chuk-kp-mode[aria-checked="true"] {
  color: var(--kp-ink);
  background: var(--kp-accent-hi);
  border-color: var(--kp-accent-hi);
}

.chuk-kp-memflag {
  margin-left: auto;
  padding: 3px 10px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--kp-accent-hi);
  border: 1px solid rgba(253, 186, 116, .4);
  border-radius: 999px;
}

/* ─── Pad ─── */
.chuk-kp-pad {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 7px;
}

.chuk-kp-key {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 4px 2px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--kp-text);
  background: var(--kp-face);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 9px;
  cursor: pointer;
  transition: background .1s, transform .06s;
}
.chuk-kp-key:hover { background: var(--kp-face-2); }
.chuk-kp-key:active { transform: translateY(1px); }
.chuk-kp-key:focus-visible {
  outline: 3px solid var(--kp-accent-hi);
  outline-offset: 2px;
}

/* Secondary functions sit back */
.chuk-kp-fn {
  font-size: .85rem;
  color: var(--kp-dim);
  background: transparent;
  border-color: rgba(255, 255, 255, .1);
}
.chuk-kp-fn:hover { background: var(--kp-face); color: var(--kp-text); }

/* Digits are the brightest thing after the display */
.chuk-kp-num {
  font-size: 1.05rem;
  font-weight: 600;
  background: var(--kp-face-2);
}

/* Operators carry the accent */
.chuk-kp-op {
  font-size: 1.1rem;
  color: var(--kp-accent-hi);
  background: rgba(249, 115, 22, .18);
  border-color: rgba(253, 186, 116, .28);
}
.chuk-kp-op:hover { background: rgba(249, 115, 22, .3); }

.chuk-kp-eq {
  font-size: 1.2rem;
  color: #241403;
  background: var(--kp-accent-hi);
  border-color: var(--kp-accent-hi);
}
.chuk-kp-eq:hover { background: #fcd0a3; }

.chuk-kp-act {
  font-size: .82rem;
  color: var(--kp-text);
  background: rgba(255, 255, 255, .07);
}

.chuk-kp-mem {
  font-size: .82rem;
  color: var(--kp-dim);
  background: transparent;
  border-color: rgba(255, 255, 255, .1);
}
.chuk-kp-mem:hover { color: var(--kp-text); background: var(--kp-face); }

.chuk-kp-gap { display: block; }

/* ─── Narrow screens ─── */
@media (max-width: 640px) {
  .chuk-kp { padding: 11px; }
  .chuk-kp-pad { gap: 5px; }
  .chuk-kp-key { min-height: 46px; font-size: .85rem; border-radius: 7px; }
  .chuk-kp-fn, .chuk-kp-act, .chuk-kp-mem { font-size: .72rem; }
  .chuk-kp-num { font-size: .95rem; }
  .chuk-kp-out { font-size: 1.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .chuk-kp-key { transition: none; }
  .chuk-kp-key:active { transform: none; }
}
