/* Market-only tools. Native hidden states and the app's private-value masking
   remain authoritative; these controls do not alter data or input values. */
#grocery #marketFloatTools {
  --market-tools-ink: #f7f1fc;
  --market-tools-muted: #c8bdcf;
  --market-tools-border: rgb(230 209 248 / 24%);
  --market-tools-surface: #211a2a;
  --market-tools-glass: rgb(30 23 39 / 64%);
  --market-tools-focus: #d8b0ff;
  position: fixed;
  left: 104px;
  right: 24px;
  bottom: 24px;
  z-index: 451;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
#grocery .market-glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 48px;
  max-width: calc(50% - 6px);
  padding: 12px 15px;
  border: 1px solid var(--market-tools-border);
  border-radius: 16px;
  background: var(--market-tools-surface);
  color: var(--market-tools-ink);
  box-shadow: 0 5px 20px rgb(0 0 0 / 15%);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
#grocery .market-glass-btn svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}
#grocery .market-glass-btn:hover,
#grocery .market-glass-btn[aria-expanded="true"] {
  border-color: #b995d1;
  background-color: #362640;
}
#grocery .market-glass-btn:active { box-shadow: 0 2px 8px rgb(0 0 0 / 13%); }
#grocery #marketAddFloat { margin-left: auto; }
#grocery #marketCalcToggle { margin-right: auto; }
#grocery #marketFloatTools[hidden],
#grocery #marketCalculator[hidden],
body.market-keyboard-open #grocery #marketFloatTools { display: none !important; }

#grocery #marketCalculator {
  --market-tools-ink: #f7f1fc;
  --market-tools-muted: #c8bdcf;
  --market-tools-border: rgb(230 209 248 / 24%);
  --market-tools-surface: #211a2a;
  --market-tools-glass: rgb(30 23 39 / 92%);
  --market-tools-focus: #d8b0ff;
  position: fixed;
  left: 104px;
  bottom: 88px;
  z-index: 460;
  pointer-events: auto;
  width: min(336px, calc(100vw - 128px));
  max-height: min(640px, calc(100dvh - 112px - env(safe-area-inset-top, 0px)));
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #706079 transparent;
  padding: 16px;
  border: 1px solid var(--market-tools-border);
  border-radius: 24px;
  background: var(--market-tools-surface);
  color: var(--market-tools-ink);
  box-shadow: 0 16px 46px rgb(0 0 0 / 24%);
  -webkit-overflow-scrolling: touch;
}
#grocery .market-calc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
#grocery .market-calc-head h3 {
  margin: 0;
  color: var(--market-tools-ink);
  font-size: 17px;
  font-weight: 750;
  line-height: 1.3;
  letter-spacing: -.02em;
}
#grocery #marketCalcClose {
  flex: 0 0 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--market-tools-border);
  border-radius: 13px;
  background: rgb(255 255 255 / 5%);
  color: var(--market-tools-ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
#grocery .market-calc-display {
  min-width: 0;
  min-height: 92px;
  padding: 13px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--market-tools-border);
  border-radius: 16px;
  background: rgb(8 5 13 / 35%);
  color: var(--market-tools-ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  text-align: right;
}
#grocery #marketCalcExpression {
  display: block;
  min-height: 18px;
  margin-bottom: 7px;
  overflow: hidden;
  color: var(--market-tools-muted);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: .025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#grocery #marketCalcResult {
  display: block;
  min-width: 0;
  max-width: 100%;
  color: var(--market-tools-ink);
  font-size: clamp(26px, 7vw, 34px);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
#grocery .market-calc-keypad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
#grocery .market-calc-keypad button[data-calc-key] {
  min-width: 44px;
  min-height: 48px;
  padding: 10px 6px;
  border: 1px solid var(--market-tools-border);
  border-radius: 13px;
  background: rgb(255 255 255 / 7%);
  color: var(--market-tools-ink);
  font-family: inherit;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s ease, border-color .15s ease;
}
#grocery .market-calc-keypad button[data-calc-key]:hover { background-color: rgb(255 255 255 / 13%); }
#grocery .market-calc-keypad button.calc-equals {
  border-color: #429e7c;
  background: #22664f;
  color: #f3fff8;
}
#grocery .market-calc-keypad button.calc-equals:hover { background: #2d785d; }
#grocery .market-calc-note {
  margin: 12px 0 0;
  color: var(--market-tools-muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}
#grocery :is(.market-glass-btn, #marketCalcClose, .market-calc-keypad button):focus-visible {
  outline: 3px solid var(--market-tools-focus);
  outline-offset: 3px;
}

html[data-theme="cream"] #grocery :is(#marketFloatTools, #marketCalculator) {
  --market-tools-ink: #352a20;
  --market-tools-muted: #6e6050;
  --market-tools-border: rgb(113 91 58 / 32%);
  --market-tools-surface: #fffaf0;
  --market-tools-glass: rgb(255 250 240 / 87%);
  --market-tools-focus: #155c4d;
}
html[data-theme="cream"] #grocery #marketCalculator { box-shadow: 0 16px 44px rgb(68 48 23 / 16%); }
html[data-theme="cream"] #grocery #marketFloatTools { --market-tools-glass: rgb(255 250 240 / 62%); }
html[data-theme="cream"] #grocery .market-glass-btn { box-shadow: 0 5px 18px rgb(74 54 28 / 10%); }
html[data-theme="cream"] #grocery .market-glass-btn:hover,
html[data-theme="cream"] #grocery .market-glass-btn[aria-expanded="true"] { background-color: #e6eedf; border-color: #6b8b68; }
html[data-theme="cream"] #grocery #marketCalcClose,
html[data-theme="cream"] #grocery .market-calc-keypad button[data-calc-key] { background: rgb(109 90 57 / 6%); }
html[data-theme="cream"] #grocery .market-calc-keypad button[data-calc-key]:hover { background: #e6eddc; }
html[data-theme="cream"] #grocery .market-calc-display { background: rgb(111 94 59 / 7%); }
html[data-theme="cream"] #grocery .market-calc-keypad button.calc-equals { background: #245f44; border-color: #245f44; color: #fffaf0; }
html[data-theme="cream"] #grocery .market-calc-keypad button.calc-equals:hover { background: #194e37; }

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  #grocery .market-glass-btn,
  #grocery #marketCalculator {
    background-color: var(--market-tools-glass);
    -webkit-backdrop-filter: blur(20px) saturate(125%);
    backdrop-filter: blur(20px) saturate(125%);
  }
  #grocery .market-glass-btn:hover,
  #grocery .market-glass-btn[aria-expanded="true"] { background-color: rgb(53 38 65 / 80%); }
  html[data-theme="cream"] #grocery .market-glass-btn:hover,
  html[data-theme="cream"] #grocery .market-glass-btn[aria-expanded="true"] { background-color: rgb(228 238 220 / 80%); }
}
@media (min-width: 1101px) {
  #grocery #marketFloatTools { left: 270px; }
  #grocery #marketCalculator { left: 270px; width: min(336px, calc(100vw - 294px)); }
}
@media (max-width: 700px) {
  /* Navigation is 84px high and may sit 10px above the safe-area inset. */
  #grocery #marketFloatTools { left: 12px; right: 12px; bottom: calc(108px + env(safe-area-inset-bottom, 0px)); }
  #grocery #marketCalculator {
    left: 12px;
    bottom: calc(172px + env(safe-area-inset-bottom, 0px));
    width: min(336px, calc(100vw - 24px));
    max-height: calc(100dvh - 192px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
}
@media (max-width: 360px) {
  #grocery #marketFloatTools { gap: 8px; }
  #grocery .market-glass-btn { gap: 6px; padding-inline: 12px; font-size: 12px; max-width: calc(50% - 4px); }
  #grocery #marketCalculator { padding: 13px; border-radius: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  #grocery :is(.market-glass-btn, #marketCalculator, .market-calc-keypad button) { animation: none !important; transition: none !important; scroll-behavior: auto; }
}
@media (forced-colors: active) {
  #grocery :is(.market-glass-btn, #marketCalculator, #marketCalcClose, .market-calc-display, .market-calc-keypad button[data-calc-key]) { background: Canvas !important; color: CanvasText !important; border-color: CanvasText !important; box-shadow: none; }
  #grocery :is(.market-glass-btn, #marketCalcClose, .market-calc-keypad button):focus-visible { outline-color: Highlight !important; }
}
