/* =========================================================
   ZAR CALCULATOR — RETRO SCIENTIFIC PANEL
   Cleaned / Organized Final Cascade
   Targets:
   .zar-retro-calc
   .zar-retro-display
   .zar-calc-pills
========================================================= */

/* =========================================================
   ROOT TOKENS
========================================================= */

:root {
  --zar-retro-body-bg: #22252b;
  --zar-retro-shell-top: #d8d1c3;
  --zar-retro-shell-bottom: #b9b09f;
  --zar-retro-border: #7d7568;

  --zar-retro-panel-dark: #4a4d52;
  --zar-retro-panel-mid: #676b70;

  --zar-retro-lcd-1: #93a17b;
  --zar-retro-lcd-2: #b6c29d;
  --zar-retro-lcd-text: #1f2a1e;

  --zar-retro-num-top: #2e3136;
  --zar-retro-num-bottom: #16181b;
  --zar-retro-num-text: #f2f2f2;

  --zar-retro-fn-top: #8e8477;
  --zar-retro-fn-bottom: #6f665b;
  --zar-retro-fn-text: #fff8eb;

  --zar-retro-op-top: #6d7788;
  --zar-retro-op-bottom: #4f5867;
  --zar-retro-op-text: #f6fbff;

  --zar-retro-sys-top: #a96e59;
  --zar-retro-sys-bottom: #7b4e40;
  --zar-retro-sys-text: #fff7f3;

  --zar-retro-eval-top: #6b8f5e;
  --zar-retro-eval-bottom: #4b6941;
  --zar-retro-eval-text: #f6fff2;

  --zar-retro-shadow-deep: rgba(0, 0, 0, 0.45);
  --zar-retro-screen-glare: rgba(255, 255, 255, 0.16);
  --zar-retro-gold: #c7a866;
}

/* =========================================================
   HELP PANEL / GLOBAL SAFE STYLES
========================================================= */

.zar-help-advanced {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(120, 160, 255, 0.1);
  font-size: 12px;
}

.zar-help-filter {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(120, 160, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  font-size: 13px;
  outline: none;
}

.zar-help-mini-title {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 6px;
}

.zar-help-groups span {
  display: block;
  opacity: 0.8;
  cursor: pointer;
}

.zar-help-groups span:hover {
  opacity: 1;
}

.zar-help-compute-actions,
.zar-help-compute-triggers {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  margin-bottom: 0.3rem;
}

/* =========================================================
   CALCULATOR TRIGGER / TOOLTIP
========================================================= */

.zar-help-expand--calculator {
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: rgba(200, 220, 255, 0.85);
  background: rgba(120, 140, 255, 0.08);
  border: 1px solid rgba(120, 140, 255, 0.25);
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  z-index: 3;
}

.zar-help-expand--calculator:hover {
  background: rgba(120, 160, 255, 0.18);
  color: #fff;
  border-color: rgba(120, 160, 255, 0.4);
}

.zar-expand-icon {
  font-size: 10px;
  transition: transform 0.25s ease;
}

.zar-help-expand--calculator.open .zar-expand-icon {
  transform: rotate(180deg);
}

.zar-help-tooltip {
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  padding: 5px 8px;
  font-size: 10.5px;
  background: rgba(10, 15, 30, 0.95);
  border: 1px solid rgba(120, 160, 255, 0.2);
  border-radius: 6px;
  color: rgba(200, 220, 255, 0.85);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.zar-help-expand--calculator:hover .zar-help-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================================
   CALCULATOR WRAPPER / POPOVER
========================================================= */

.zar-help-advanced--calculator {
  padding-top: 0.75rem;
}

.zar-calculator-wrapper {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.zar-help-advanced--calculator {
  position: fixed;
  bottom: calc(100%);
  left: 0;
  min-width: 0;
  width: min(300px, calc(100vw - 24px));
  max-width: min(300px, calc(100vw - 24px));
  padding: 0;
  margin: 0;
  border-radius: 18px;
  background: transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px) scale(0.985);
  z-index: 9999;
  transition:
    opacity 180ms ease,
    transform 220ms ease,
    visibility 0s linear 220ms;
}

.zar-help-advanced--calculator.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition:
    opacity 180ms ease,
    transform 220ms ease,
    visibility 0s linear 0s;
}

.zar-help-advanced--calculator[hidden] {
  display: block !important;
}

.zar-help-advanced--calculator .zar-retro-calc {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* =========================================================
   RETRO CALCULATOR SHELL
========================================================= */

.zar-retro-calc {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  padding: 10px 8px 8px;
  border-radius: 16px;
  background: linear-gradient(
    180deg,
    var(--zar-retro-shell-top),
    var(--zar-retro-shell-bottom)
  );
  border: 2px solid var(--zar-retro-border);
  box-shadow:
    0 28px 60px var(--zar-retro-shadow-deep),
    inset 0 2px 1px rgba(255, 255, 255, 0.65),
    inset 0 -3px 6px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.zar-retro-calc::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 13px;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 22%),
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.18), transparent 34%);
  opacity: 0.8;
}

.zar-retro-calc::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 10px;
  right: 10px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.5), transparent);
  opacity: 0.35;
  pointer-events: none;
}

/* =========================================================
   TOP BAR
========================================================= */

.zar-retro-calc-topbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.zar-retro-brand-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.zar-retro-brand {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #33302c;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.zar-retro-model {
    font-size: 0.48rem;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: #f5f5dc87;
    text-transform: uppercase;
    line-height: 1.2;
}

.zar-retro-meta {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.zar-retro-mode-lights {
  display: flex;
  gap: 4px;
}

.zar-retro-mode-chip {
  min-width: 32px;
  text-align: center;
  padding: 2px 5px;
  border-radius: 999px;
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #403a34;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  cursor: pointer;
}

.zar-retro-mode-chip.active {
  color: #1d2719;
  background: linear-gradient(180deg, #dce8c9, #a9b98e);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 0 10px rgba(194, 230, 154, 0.28);
}

.zar-retro-solar {
  width: 60px;
  height: 15px;
  border-radius: 4px;
  background:
    repeating-linear-gradient(
      90deg,
      #1c2126 0 12px,
      #39424c 12px 14px
    );
  border: 2px solid #575e65;
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.08),
    inset 0 -2px 4px rgba(0, 0, 0, 0.45);
}

/* =========================================================
   DISPLAY
========================================================= */
#zarCalcCurrent {
  caret-color: #ffffff; /* bright white */
}
#zarCalcCurrent {
  caret-color: #ffffff;
  text-shadow: 0 0 6px rgba(255,255,255,0.4);
}
.zar-retro-display-wrap {
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, #50555b, #35383d);
  border-radius: 10px;
  padding: 7px;
  border: 2px solid #272b2f;
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.08),
    inset 0 -3px 8px rgba(0, 0, 0, 0.45),
    0 8px 16px rgba(0, 0, 0, 0.2);
  margin-bottom: 8px;
}

.zar-retro-display {
  min-height: 58px;
  border-radius: 8px;
  padding: 7px 8px;
  background: linear-gradient(180deg, var(--zar-retro-lcd-2), var(--zar-retro-lcd-1));
  color: var(--zar-retro-lcd-text);
  border: 2px solid #5f6853;
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.18),
    inset 0 -3px 8px rgba(0, 0, 0, 0.14);
  position: relative;
  overflow: hidden;
}

.zar-retro-display::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--zar-retro-screen-glare), transparent 32%);
  pointer-events: none;
}

.zar-retro-display::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.02) 0 2px,
      rgba(255, 255, 255, 0.02) 2px 4px
    );
  mix-blend-mode: multiply;
  pointer-events: none;
}

.zar-retro-display-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 12px;
  margin-bottom: 3px;
  font-size: 0.56rem;
  font-weight: 700;
  opacity: 0.8;
  letter-spacing: 0.06em;
}

.zar-retro-status {
  display: flex;
  gap: 6px;
  align-items: center;
}

.zar-retro-status small, #zarCalcMemoryIndicator {
    color: #070607;
    font-size: 0.5rem;
    letter-spacing: 0.05em;
    font-weight: 800;
}
#zarCalcMemoryIndicator {
    color: #af2ad0;
}
#zarCalModLabel {
    color: #2f6967;
}
.zar-retro-history {
    color: #ac46c0;
    min-height: 12px;
    text-align: right;
    font-size: 0.85rem;
    opacity: 0.85;
    overflow-wrap: anywhere;
    line-height: 1.1;
}
.zar-retro-current {
    scrollbar-width: none;
    scroll-behavior: auto;
    overflow-y: auto;
    max-height: 56px;
    min-height: 22px;
    margin-top: 2px;
    text-align: right;
    font-family: "Courier New", monospace;
    font-size: clamp(1.1rem, 1.4vw, 1rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0;
    word-break: break-word;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    outline: none;
    caret-color: #182018;
}

/* hidden storage input */
.zar-calc-hidden-input {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* =========================================================
   PANEL LABEL
========================================================= */

.zar-retro-panel-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 1px 7px;
  position: relative;
  z-index: 1;
  color: #574f46;
  font-size: 0.5rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.zar-retro-gold-line {
  height: 2px;
  flex: 1;
  margin-left: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--zar-retro-gold), transparent);
  opacity: 0.8;
}

/* =========================================================
   SUGGESTIONS
========================================================= */

.zar-suggestion {
  padding: 0.22rem 0.42rem;
  border-radius: 999px;
  font-size: 0.58rem;
  color: rgba(61, 55, 49, 0.92);
  background: rgba(255, 255, 255, 0.24);
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: 140ms ease;
}

.zar-suggestion:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

/* =========================================================
   KEYPAD LAYOUT
========================================================= */

.zar-calc-pills {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.zar-calc-pill-row {
  display: contents;
}

/* =========================================================
   CALCULATOR KEYS
========================================================= */

.zar-pill,
.zar-pill--calc {
  position: relative;
  min-height: 24px;
  padding: 0.18rem 0.08rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.01em;
  transition:
    transform 80ms ease,
    box-shadow 80ms ease,
    filter 120ms ease;
  box-shadow:
    0 7px 0 rgba(0, 0, 0, 0.32),
    0 12px 18px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  opacity: 1;
  font-size: 0.95rem;
  line-height: 1;
}

.zar-pill::before,
.zar-pill--calc::before {
  content: "";
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 45%;
  border-radius: 7px 7px 10px 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent);
  pointer-events: none;
}

.zar-pill:hover,
.zar-pill--calc:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.zar-pill:active,
.zar-pill--calc:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 rgba(0, 0, 0, 0.34),
    0 6px 10px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* key tones */

.zar-pill--calc.const {
  color: var(--zar-retro-num-text);
  background: linear-gradient(180deg, var(--zar-retro-num-top), var(--zar-retro-num-bottom));
}

.zar-pill--calc.trig, .zar-pill--calc.log {
    color: var(--zar-retro-fn-text);
    background: linear-gradient(180deg, var(--zar-retro-fn-top), var(--zar-retro-fn-bottom));
    font-size: 0.65rem;
}

.zar-pill--calc.alg {
    color: #40e0d0;
    background: linear-gradient(180deg, var(--zar-retro-fn-top), var(--zar-retro-fn-bottom));
    font-size: 0.75rem;
}

.zar-pill--calc.op {
    align-items: self-end;
    color: var(--zar-retro-op-text);
    background: linear-gradient(180deg, var(--zar-retro-op-top), var(--zar-retro-op-bottom));
    font-size: 1rem;
}

/* generic fallback */

.zar-pill--calc:not(.const):not(.trig):not(.log):not(.alg):not(.op) {
  color: var(--zar-retro-fn-text);
  background: linear-gradient(180deg, var(--zar-retro-fn-top), var(--zar-retro-fn-bottom));
}

/* =========================================================
   ACTION BUTTONS
========================================================= */

.zar-calc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  padding-top: 7px;
  position: relative;
  z-index: 1;
}

.zar-calc-action {
  appearance: none;
  min-width: 0;
  border-radius: 9px;
  padding: 0.45rem 0.5rem;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: 160ms ease;
  border: none;
  box-shadow:
    0 7px 0 rgba(0, 0, 0, 0.32),
    0 12px 18px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.zar-calc-action--ghost {
  color: var(--zar-retro-sys-text);
  background: linear-gradient(180deg, var(--zar-retro-sys-top), var(--zar-retro-sys-bottom));
}

.zar-calc-action--primary {
  color: var(--zar-retro-eval-text);
  background: linear-gradient(180deg, var(--zar-retro-eval-top), var(--zar-retro-eval-bottom));
}

.zar-calc-action:hover {
  filter: brightness(1.04);
}

.zar-calc-action:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 rgba(0, 0, 0, 0.34),
    0 6px 10px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* =========================================================
   FOOTER
========================================================= */

.zar-retro-footer-note {
  margin-top: 7px;
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: 0.45rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #60584f;
  font-weight: 800;
}

/* =========================================================
   COMPUTE TOOLS PLACEHOLDER
========================================================= */

.zar-compute-tools-shell {
  display: grid;
  gap: 0.9rem;
}

.zar-compute-tools-head {
  display: grid;
  gap: 0.3rem;
}

.zar-compute-tools-title {
  font-size: 1rem;
  color: #e7ecff;
}

.zar-compute-tools-subtitle {
  font-size: 0.9rem;
  line-height: 1.45;
  color: rgba(231, 236, 255, 0.62);
}

.zar-compute-tools-placeholder {
  padding: 1rem 1.1rem;
  border-radius: 1.1rem;
  border: 1px solid rgba(126, 150, 255, 0.16);
  background: rgba(25, 31, 60, 0.48);
}

.zar-compute-tools-placeholder-title {
  margin-bottom: 0.7rem;
  font-size: 0.92rem;
  color: #dce5ff;
}

.zar-compute-tools-preview {
  margin: 0;
  padding-left: 1.1rem;
  color: rgba(231, 236, 255, 0.78);
  display: grid;
  gap: 0.45rem;
}

/* =========================================================
   CALCULATOR CLOSE BUTTON
========================================================= */

.zar-retro-meta-bottom {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.zar-calc-close {
    appearance: none;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.22);
    color: #433d36;
    /* width: 24px; */
    /* height: 24px; */
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transition: transform 120ms ease, filter 160ms ease;
}

.zar-calc-close:hover {
  filter: brightness(1.04);
}

.zar-calc-close:active {
  transform: scale(0.96);
}

.zar-calc-close:focus-visible {
  outline: 2px solid rgba(120, 140, 255, 0.45);
  outline-offset: 2px;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 768px) {
  .zar-help-filter {
    font-size: 12.5px;
    padding: 9px 10px;
  }

  .zar-help-tooltip {
    white-space: normal;
    max-width: 85vw;
    text-align: center;
  }

  .zar-help-advanced--calculator {
    bottom: calc(100% + 10px);
  }

  .zar-help-advanced--calculator.is-open {
    transform: translateY(0) scale(1);
  }

  .zar-calculator-wrapper {
    position: inherit;
    height: 100%;
  }
}

@media (max-width: 480px) {
  .zar-help-expand--calculator {
    border-radius: 10px;
  }
}

/* =========================================================
   ZAR CALCULATOR — LAYOUT OVERRIDES
   Goal:
   - more natural scientific calculator layout
   - compact numeric block
   - grouped functions via small menus
========================================================= */

/* overall body slightly wider for more natural balance */
.zar-help-advanced--calculator {
    width: min(270px, calc(100vw - 24px));
    max-width: min(360px, calc(100vw - 24px));
}
.zar-retro-calc {
  max-width: 320px;
  padding: 12px 10px 10px;
}

/* main keypad area */
.zar-calc-pills {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

/* default keys */
.zar-pill,
.zar-pill--calc {
  min-height: 40px;
  padding: 0.25rem 0.2rem;
  font-size: 0.72rem;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* numeric keys a bit stronger */
.zar-pill--calc.const {
  font-size: 0.82rem;
}

/* operators */
.zar-pill--calc.op {
  font-size: 0.95rem;
}

/* algorithm/function keys */
.zar-pill--calc.alg,
.zar-pill--calc.trig,
.zar-pill--calc.log {
  font-size: 0.62rem;
}

/* action buttons */
.zar-calc-actions {
  justify-content: flex-end;
  gap: 8px;
  padding-top: 10px;
}

.zar-calc-action {
  min-height: 42px;
  padding: 0.55rem 0.8rem;
  font-size: 0.72rem;
}

/* display gets a bit more room */
.zar-retro-display {
  min-height: 86px;
  padding: 10px 12px;
}

.zar-retro-history {
  font-size: 0.85rem;
}

.zar-retro-current {
    max-height: 72px;
    min-height: 34px;
    font-size: clamp(1rem, 2vw, 1.2rem);
    /* line-height: 1.14; */
}

/* top meta balance */
.zar-retro-solar {
  width: 82px;
  height: 20px;
}

.zar-calc-close {
    align-items: self-end;
    margin: 0;
    width: 20px;
    height: 20px;
    font-size: 22px;
}

/* mobile */
@media (max-width: 768px) {
/*   .zar-help-advanced--calculator {
    width: min(340px, calc(100vw - 20px));
    max-width: min(340px, calc(100vw - 20px));
  } */

  .zar-retro-calc {
    max-width: 340px;
  }

  .zar-pill,
  .zar-pill--calc {
    min-height: 36px;
    font-size: 0.66rem;
  }

  .zar-pill--calc.const {
    font-size: 0.78rem;
  }

  .zar-pill--calc.op {
    font-size: 0.88rem;
  }
}

/* =========================================================
   CALCULATOR GROUP MENUS
========================================================= */

.zar-calc-group-row {
  grid-column: 2 / 3;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.zar-calc-group {
  position: relative;
  min-width: 0;
}

.zar-calc-group-trigger {
  width: 100%;
  min-height: 34px;
  padding: 0.3rem 0.35rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;

  color: #fff8eb;
  background: linear-gradient(180deg, var(--zar-retro-fn-top), var(--zar-retro-fn-bottom));

  box-shadow:
    0 5px 0 rgba(0,0,0,0.28),
    inset 0 1px 0 rgba(255,255,255,0.16);

  transition: transform 100ms ease, filter 120ms ease;
}

.zar-calc-group-trigger:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.zar-calc-group-trigger:active {
  transform: translateY(2px);
}

.zar-calc-group-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 30;

  min-width: 92px;
  padding: 6px;
  border-radius: 10px;

  display: none;
  flex-direction: column;
  gap: 5px;

  background: rgba(28, 31, 43, 0.96);
  border: 1px solid rgba(120,140,255,0.18);
  box-shadow:
    0 14px 28px rgba(0,0,0,0.4),
    0 0 0 1px rgba(120,140,255,0.08);
}

.zar-calc-group.is-open .zar-calc-group-menu {
  display: flex;
}

.zar-calc-group-menu button {
  width: 100%;
  min-height: 30px;
  padding: 0.3rem 0.45rem;
  border: 1px solid rgba(120,140,255,0.12);
  border-radius: 8px;

  text-align: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #eef3ff;

  background: rgba(255,255,255,0.05);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.zar-calc-group-menu button:hover {
  background: rgba(120,140,255,0.16);
  border-color: rgba(120,140,255,0.28);
}

@media (max-width: 768px) {
  .zar-calc-group-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .zar-calc-group-menu {
    min-width: 84px;
  }
}
.zar-calc-group {
  position: relative;
}

.zar-calc-group-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  z-index: 50;
}

.zar-calc-group-menu.is-open {
  display: flex;
}
/* =========================================================
   SAFE UPGRADE LAYER — DO NOT BREAK EXISTING CONTRACT
   (append at END of file)
========================================================= */

/* =========================
   1. DEFAULT DARK THEME
========================= */

:root {
  /* override ONLY visuals, not structure */
  --zar-retro-shell-top: #2a2f36;
  --zar-retro-shell-bottom: #1b1f24;
  --zar-retro-border: #0f1216;

  --zar-retro-lcd-1: #1c2a1f;
  --zar-retro-lcd-2: #2e4231;
  --zar-retro-lcd-text: #b7d1a8;

  --zar-retro-num-top: #2c3138;
  --zar-retro-num-bottom: #15181c;

  --zar-retro-fn-top: #3b342c;
  --zar-retro-fn-bottom: #24201b;

  --zar-retro-op-top: #2f3f57;
  --zar-retro-op-bottom: #1b2433;

  --zar-retro-shadow-deep: rgba(0,0,0,0.65);
}

/* optional LIGHT mode toggle later */
:root[data-theme="light"] {
  /* fallback to your original palette automatically */
}

/* =========================
   2. DISPLAY IMPROVEMENT (SAFE)
========================= */

.zar-retro-display {
  min-height: 70px;
  padding: 8px 10px;
}

.zar-retro-current {
  max-height: 80px; /* allow more expression space */
}


/* =========================
   5. KEYS — MORE REALISTIC (NO STRUCTURE CHANGE)
========================= */

.zar-pill,
.zar-pill--calc {
  border-radius: 10px;
  box-shadow:
    0 6px 0 rgba(0,0,0,0.5),
    0 10px 14px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.08);
}

/* press depth */
.zar-pill:active,
.zar-pill--calc:active {
  transform: translateY(2px);
}

/* =========================
   6. FUNCTION GROUP BUTTONS (LESS "CHEAP")
========================= */

.zar-calc-group-trigger {
  background: linear-gradient(180deg, #3a342e, #1f1b17);
  border: 1px solid rgba(255,255,255,0.05);
}

/* =========================
   7. POPUP MENU DARK POLISH
========================= */

.zar-calc-group-menu {
  background: rgba(18, 20, 30, 0.96);
  border: 1px solid rgba(120,140,255,0.12);
}

/* =========================
   8. ACTION BUTTONS (LESS TOY-LIKE)
========================= */

.zar-calc-action--ghost {
  background: linear-gradient(180deg, #7b4e40, #4f2f26);
}

.zar-calc-action--primary {
  background: linear-gradient(180deg, #3f6b4f, #284433);
}

/* =========================
   9. SCREEN CONTRAST FIX
========================= */

.zar-retro-history {
  color: #9e6cff;
}

#zarCalcMemoryIndicator {
  color: #c86cff;
}

#zarCalModLabel {
  color: #4bd6d0;
}

/* =========================
   10. SMALL BUT IMPORTANT
========================= */

/* keep pills aligned nicely */
.zar-calc-pills {
  align-items: stretch;
}

/* avoid weird overflow glitches */
.zar-pill,
.zar-pill--calc {
  overflow: hidden;
}

/* first 4 rows = numbers + operators */
.zar-calc-pills {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

/* make numpad feel like a block */
.zar-calc-pills .zar-pill:nth-child(-n+20) {
  border-radius: 8px;
}

/* function rows (TRIG, INV, etc.) */
.zar-calc-pills .zar-pill:nth-child(n+21) {
  background: linear-gradient(180deg, #3a342e, #1f1b17);
  font-size: 0.65rem;
}
/* 5th column = operators */
.zar-calc-pills .zar-pill:nth-child(5n) {
  background: linear-gradient(180deg, #2f3f57, #1b2433);
  font-weight: 900;
}
.zar-calc-pills {
  gap: 6px;
}

/* =========================
   COMPACT MODE (FIT SCREEN)
========================= */

.zar-pill, .zar-pill--calc {
    box-shadow: 0 6px 0 rgba(0,0,0,0.55),
    0 12px 16px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

.zar-pill--calc.const {
  min-height: 36px;
  font-size: 0.78rem;
}

.zar-pill--calc.op {
  font-size: 0.85rem;
}

/* function row smaller */
.zar-calc-pills .zar-pill:nth-child(n+21) {
  min-height: 30px;
  font-size: 0.6rem;
}

/* reduce spacing */
.zar-calc-pills {
  gap: 4px;
}
/* =========================================================
   TI VISUAL GROUPING (NO STRUCTURE CHANGE)
========================================================= */

/* ---------- NUMPAD BLOCK ---------- */

/* first 4 rows = 20 keys */
.zar-calc-pills .zar-pill:nth-child(-n+20) {
  background: linear-gradient(180deg, #2c3138, #15181c);
  border-radius: 8px;
}

/* create block feel */
.zar-calc-pills {
  position: relative;
}

.zar-calc-pills::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 20%;
    height: calc(4 * 42px + 18px);
    border-radius: 12px;
    background: rgba(0,0,0,0.25);
    z-index: 0;
}

.zar-calc-pills > * {
  position: relative;
  z-index: 1;
}


/* ---------- OPERATOR COLUMN (5th column) ---------- */

.zar-calc-pills .zar-pill:nth-child(5n) {
  background: linear-gradient(180deg, #3a4b66, #1c2533);
  font-weight: 900;
  color: #eaf2ff;
}


/* ---------- FUNCTION ROW ---------- */

.zar-calc-pills .zar-pill:nth-child(n+21):nth-child(-n+25) {
  margin-top: 10px;

  background: linear-gradient(180deg, #3b342c, #1f1b17);
  box-shadow:
    0 6px 0 rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.08);
}


/* ---------- CONSTANT ROW ---------- */

.zar-calc-pills .zar-pill:nth-child(n+26) {
  background: linear-gradient(180deg, #26303a, #141a20);
}


/* ---------- CREATE VISUAL GAP BETWEEN ZONES ---------- */

.zar-calc-pills .zar-pill:nth-child(21) {
  margin-top: 14px;
}


/* ---------- BUTTON SCALE HIERARCHY ---------- */

/* numpad slightly bigger */
.zar-calc-pills .zar-pill:nth-child(-n+20) {
    min-height: 25px;
    font-size: 0.75rem;
}
/* functions smaller */
.zar-calc-pills .zar-pill:nth-child(n+21) {
  min-height: 40px;
  font-size: 0.7rem;
}


/* ---------- DEPTH (IMPORTANT FOR TI FEEL) ---------- */

.zar-pill,
.zar-pill--calc {
  box-shadow:
    0 6px 0 rgba(0,0,0,0.55),
    0 12px 16px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.06);
}


/* ---------- SCREEN MORE "REAL" ---------- */

.zar-retro-display {
  border-radius: 12px;
  box-shadow:
    inset 0 0 0 2px rgba(0,0,0,0.4),
    inset 0 8px 16px rgba(0,0,0,0.6);
}

/* =========================================================
   NEW TOP CONTROLS (CASIO / TI STYLE)
========================================================= */

.zar-retro-controls {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  margin: 6px 4px 10px;
}

/* small label above round keys */
.zar-tiny-label {
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-align: center;
    color: rgb(202 174 244 / 54%);
}

/* wrapper */
.zar-round-key-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

/* round buttons */
.zar-round-key {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  cursor: pointer;

  background:
    radial-gradient(circle at 30% 20%, #454950, #0d0f12 70%);

  box-shadow:
    0 4px 0 #000,
    0 6px 8px rgba(0,0,0,0.4),
    inset 0 2px 2px rgba(255,255,255,0.15),
    inset 0 -3px 4px rgba(0,0,0,0.6);
}

.zar-round-key:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #000,
    0 3px 6px rgba(0,0,0,0.45),
    inset 0 2px 6px rgba(0,0,0,0.7);
}

/* special SEND button */
.zar-round-key--send {
  background:
    linear-gradient(180deg, #b9ed4e, #396d0c);
}

/* =========================================================
   NAV PAD (CENTERED)
========================================================= */

.zar-nav-pad {
  justify-self: center;
  width: 70px;
  height: 60px;
  position: relative;
}

.zar-nav-pad::before {
  content: "";
  position: absolute;
  inset: 14px 20px;
  border-radius: 10px;
  background: linear-gradient(145deg, #33373f, #111318);
  box-shadow: inset 0 2px 2px rgba(255,255,255,0.08);
}

.zar-nav-btn {
  color: white;
  position: absolute;
  border: none;
  cursor: pointer;

  background:
    linear-gradient(180deg, rgba(255,255,255,0.1), transparent 45%),
    linear-gradient(160deg, #282c34, #08090c);

  box-shadow:
    0 3px 0 #000,
    inset 0 1px 1px rgba(255,255,255,0.1);
}

/* shapes */
.zar-nav-btn.up,
.zar-nav-btn.down {
  left: 25px;
  width: 22px;
  height: 26px;
  clip-path: polygon(50% 0, 100% 22%, 100% 78%, 50% 100%, 0 78%, 0 22%);
}

.zar-nav-btn.up { top: 0; }
.zar-nav-btn.down { bottom: 0; }

.zar-nav-btn.left,
.zar-nav-btn.right {
  top: 21px;
  width: 28px;
  height: 20px;
  clip-path: polygon(0 50%, 25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%);
}

.zar-nav-btn.left { left: 0; }
.zar-nav-btn.right { right: 0; }

.zar-nav-btn:active {
  transform: translateY(2px);
}

/* =========================================================
   KEYPAD (SIMPLIFIED — NO LEFT COLUMN)
========================================================= */

.zar-retro-keys {
  display: block;
}

.zar-calc-pills {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

/* =========================================================
   BUBBLE MENU (NEW — CASIO STYLE)
========================================================= */

/* arrow */
.zar-bubble-menu::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 10px;
  height: 10px;
  background: #111318;
  transform: translateX(-50%) rotate(45deg);
}

/* buttons */
.zar-bubble-item {
  border: none;
  min-width: 46px;
  height: 32px;
  border-radius: 8px;

  background:
    linear-gradient(180deg, rgba(255,255,255,0.15), transparent 40%),
    linear-gradient(180deg, #3a3f46, #15181c);

  color: #fff;
  font-weight: 800;
  font-size: 0.7rem;

  cursor: pointer;

  box-shadow:
    0 3px 0 #000,
    inset 0 1px 1px rgba(255,255,255,0.15);
}

.zar-bubble-item:active {
  transform: translateY(2px);
}

.zar-bubble-menu {
  position: absolute;
  transform: translate(-50%, -100%) scale(0.95);
  display: flex;
  gap: 6px;
  padding: 6px;

  border-radius: 12px;

  background:
    linear-gradient(145deg, rgba(50,55,65,0.95), rgba(15,17,20,0.98));

  border: 1px solid rgba(255,255,255,0.08);

  box-shadow:
    0 14px 28px rgba(0,0,0,0.55),
    inset 0 1px 1px rgba(255,255,255,0.1);

  z-index: 9999;

  opacity: 0;
  pointer-events: none;
  transition: all 140ms ease;
}
.zar-bubble-menu {
  transform-origin: bottom center;
  background: rgba(25, 28, 40, 0.95);
  backdrop-filter: blur(8px);

  border: 1px solid rgba(120,140,255,0.15);

  box-shadow:
    0 12px 24px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.08);

  opacity: 0;
  pointer-events: none;
  transition: 120ms ease;
  z-index: 9999;
}
/* open state */
.zar-bubble-menu.open {
    height: 100px;
    /* flex-wrap: wrap; */
    /* width: 100px; */
    flex-direction: column;
    display: flex;
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.9);
    pointer-events: auto;
}

.zar-bubble-item {
  min-width: 44px;
  height: 34px;

  border-radius: 8px;
  border: none;

  font-size: 0.75rem;
  font-weight: 700;

  color: #fff;

  background: linear-gradient(180deg, #3a3f46, #1f2328);

  box-shadow:
    0 4px 0 rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.1);

  cursor: pointer;
}

.zar-bubble-item:active {
  transform: translateY(2px);
}
/* =========================================================
   FIX: BUBBLE MENU POSITIONING (FINAL)
========================================================= */

/* anchor container */
.zar-calc-group {
  position: relative;
}

/* bubble menu — RESET BAD BEHAVIOR */
.zar-bubble-menu {
  position: absolute !important;

  /* anchor directly above button */
  bottom: calc(100% + 6px);
  left: 50%;

  /* 🔥 critical: only horizontal centering */
  transform: translateX(-50%) scale(0.96);

  /* remove conflicting transforms */
  top: auto !important;
  right: auto !important;

  /* stable sizing */
  width: max-content;
  min-width: 70px;

  /* layout */
  display: flex;
  flex-direction: column;
  gap: 4px;

  /* visibility */
  opacity: 0;
  pointer-events: none;

  z-index: 999;
  transition: transform 120ms ease, opacity 120ms ease;
}

/* OPEN STATE — clean animation */
.zar-bubble-menu.open {
  opacity: 1;
  pointer-events: auto;

  /* 🔥 FIX: DO NOT MOVE VERTICALLY */
  transform: translateX(-50%) scale(1);
}

/* arrow fix (must match new positioning) */
.zar-bubble-menu::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);

  width: 8px;
  height: 8px;

  background: inherit;
}

/* =========================================================
   🔥 CRITICAL CLEANUP (REMOVE OLD CONFLICTS)
========================================================= */

/* REMOVE old translate(-50%, -50%) behavior */
.zar-bubble-menu {
  transform-origin: bottom center;
}

/* prevent layout jumps */
.zar-calc-pills,
.zar-retro-calc {
  overflow: visible !important;
}
/* 🔥 make bubble visible when group is open */
.zar-calc-group.is-open .zar-bubble-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}
/* MINI UTILITIES (REPLACES GRID) */
.zar-utils-mini {
  display: flex;
  gap: 6px;
  padding: 6px;
}

/* MINI PILLS */
.zar-mini-pill {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: none;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 0.9rem;
  font-weight: 700;

  color: rgba(220,230,255,0.7);

  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(0,0,0,0.25));

  box-shadow:
    0 4px 10px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.08);

  cursor: pointer;
  transition: all 120ms ease;
}

.zar-mini-pill:hover {
  color: #fff;
  transform: translateY(-1px);
  box-shadow:
    0 6px 14px rgba(0,0,0,0.5),
    0 0 10px rgba(120,140,255,0.25);
}

.zar-mini-pill.active {
  color: #eaffd5;

  background:
    linear-gradient(180deg, #6b8f5e, #3c5d33);

  box-shadow:
    0 6px 14px rgba(0,0,0,0.5),
    0 0 14px rgba(120,255,120,0.35);
}

/* DISABLED */
.zar-mini-pill:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.zar-calc-drag-handle {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.zar-help-advanced--calculator.is-dragging {
  cursor: grabbing;
  transition: none !important;
}

.zar-help-advanced--calculator.is-dragging .zar-calc-drag-handle {
  cursor: grabbing;
}
/* =========================================================
   DRAGGABLE CALCULATOR — SAFE CSS VARIABLE OFFSET
========================================================= */

.zar-help-advanced--calculator {
  --zar-calc-drag-x: 0px;
  --zar-calc-drag-y: 0px;
}

.zar-help-advanced--calculator {
  transform:
    translate(var(--zar-calc-drag-x), calc(var(--zar-calc-drag-y) + 6px))
    scale(0.985);
}

.zar-help-advanced--calculator.is-open {
  transform:
    translate(var(--zar-calc-drag-x), var(--zar-calc-drag-y))
    scale(1);
}

.zar-calc-drag-handle {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.zar-help-advanced--calculator.is-dragging {
  cursor: grabbing;
  transition: none !important;
}

.zar-help-advanced--calculator.is-dragging .zar-calc-drag-handle {
  cursor: grabbing;
}
.zar-help-advanced--calculator {
  position: fixed !important;
  right: auto !important;
  bottom: auto !important;
  z-index: 99999;
}

/* The calculator should float above the input container, not size it */
.zar-help-advanced--calculator {
  position: fixed !important;
}

/* The calculator shell remains the visual app */
.zar-help-advanced--calculator .zar-retro-calc {
  position: relative;
}

/* The drag perimeter is only an invisible hit-area, never layout */
.zar-drag-perimeter {
  position: absolute !important;
  inset: 0 !important;
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;

  display: block !important;
  box-sizing: border-box !important;

  pointer-events: none;
  z-index: 40;

  overflow: visible !important;
  transform: none !important;
}

/* Only the edges receive drag events */
.zar-drag-perimeter__edge {
  position: absolute !important;
  pointer-events: auto;
  touch-action: none;
  background: transparent !important;
}

/* Keep the hit area thin so it does not block buttons/body */
.zar-drag-perimeter__edge--top {
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
}

.zar-drag-perimeter__edge--right {
  top: 0;
  right: 0;
  bottom: 0;
  width: 8px;
}

.zar-drag-perimeter__edge--bottom {
  left: 0;
  right: 0;
  bottom: 0;
  height: 8px;
}

.zar-drag-perimeter__edge--left {
  top: 0;
  left: 0;
  bottom: 0;
  width: 8px;
}
/* =========================================================
   ZAR CALCULATOR — APP RAIL FLOATING HOST FIX
   Works after moving calculator into app-side-rail.php
========================================================= */

.zar-calculator-tool-window {
  position: fixed !important;
  inset: 0 auto auto 0 !important;

  width: 0 !important;
  height: 0 !important;

  overflow: visible !important;
  pointer-events: none !important;

  z-index: 100000 !important;
}

.zar-calculator-tool-window[hidden] {
  display: none !important;
}

.zar-calculator-tool-window > .zar-help-advanced--calculator,
.zar-calculator-tool-window > * {
  pointer-events: auto;
}

/* The actual calculator is the floating panel */
.zar-help-advanced--calculator {
  position: fixed !important;

  right: auto !important;
  bottom: auto !important;

  z-index: 100001 !important;

  /* avoid square clipping of shadow/glow */
  contain: layout !important;

  overflow: visible !important;
}

/* Keep calculator internals visual, not layout-host clipping */
.zar-help-advanced--calculator .zar-retro-calc {
  position: relative;
  overflow: visible;
}

/* Mobile: calculator should overlay, not resize or push app shell */
@media (max-width: 768px) {
  .zar-calculator-tool-window {
    position: fixed !important;
    inset: 0 !important;

    width: 100vw !important;
    height: 100dvh !important;

    pointer-events: none !important;
    z-index: 100000 !important;
  }

  .zar-help-advanced--calculator {
    position: fixed !important;

    left: 50% !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;

    width: min(340px, calc(100vw - 28px)) !important;
    max-width: min(340px, calc(100vw - 28px)) !important;

    transform:
      translate(
        calc(-50% + var(--zar-calc-drag-x, 0px)),
        calc(-50% + var(--zar-calc-drag-y, 0px))
      )
      scale(0.985) !important;
  }

  .zar-help-advanced--calculator.is-open {
    transform:
      translate(
        calc(-50% + var(--zar-calc-drag-x, 0px)),
        calc(-50% + var(--zar-calc-drag-y, 0px))
      )
      scale(1) !important;
  }
}
button.zom-app-menu-link.zom-app-menu-link--button.zar-calculator-launcher {
    cursor: pointer;
}