/* Pop-up calculator (js/calculator.js), shared by the lessons and the Excel Lab. Uses --text/--bg/--muted/--mono from the page. */
.calc-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 900;
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
  background: var(--bg); color: var(--text); cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease;
}
.calc-fab:hover { transform: translateY(-2px); }
.calc-fab.on { background: var(--text); color: var(--bg); }
.calc-fab:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

.calc-win {
  position: fixed; z-index: 901; left: 0; top: 0;
  width: 264px; max-width: calc(100vw - 16px);
  background: color-mix(in srgb, var(--bg) 94%, var(--text));
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden; outline: none;
  user-select: none; -webkit-user-select: none;
}
.calc-win[hidden] { display: none; }
.calc-win:focus-visible { box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28), 0 0 0 2px var(--text); }
.calc-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 6px 6px 14px; cursor: grab; touch-action: none;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
}
.calc-win.dragging .calc-bar { cursor: grabbing; }
.calc-close {
  width: 28px; height: 28px; border: 0; border-radius: 8px; background: none;
  color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.calc-close:hover { background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); }
.calc-screen { padding: 10px 16px 8px; text-align: right; font-family: var(--mono); }
.calc-expr { min-height: 1.1em; font-size: 0.78rem; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.calc-val { font-size: 2rem; line-height: 1.25; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; user-select: text; -webkit-user-select: text; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 8px 10px 12px; }
.calc-keys button {
  height: 46px; border-radius: 10px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  background: var(--bg); color: var(--text);
  font: 500 1.1rem/1 var(--mono);
  transition: background 0.1s ease;
  touch-action: manipulation;
}
.calc-keys button:hover { background: color-mix(in srgb, var(--text) 7%, var(--bg)); }
.calc-keys button.fn { color: var(--muted); font-size: 0.95rem; }
.calc-keys button.op { background: color-mix(in srgb, var(--text) 9%, var(--bg)); font-size: 1.25rem; }
.calc-keys button.eq { background: var(--text); color: var(--bg); font-size: 1.25rem; }
.calc-keys button:active, .calc-keys button.pressed { filter: brightness(0.85); transform: scale(0.97); }

@media (max-width: 600px) {
  .calc-fab { right: 14px; bottom: 14px; width: 48px; height: 48px; }
  .calc-keys button { height: 50px; }
}
@media print { .calc-fab, .calc-win { display: none !important; } }
/* room at the bottom so the calculator button never covers the last line of a page */
body::after { content: ""; display: block; height: 76px; }
