:root {
  --bm-popup-ink: #17140f;
  --bm-popup-panel: #211d17;
  --bm-popup-panel-edge: #4b3e2a;
  --bm-popup-cream: #f4ead7;
  --bm-popup-muted: #cdbfa8;
  --bm-popup-gold: #d6a84b;
  --bm-popup-gold-light: #f1cf7a;
  --bm-popup-focus: #fff0bc;
}

.bm-tester-popup[hidden] { display: none; }
.bm-tester-popup, .bm-tester-popup * { box-sizing: border-box; }

.bm-tester-popup {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10000;
  width: min(420px, calc(100vw - 36px));
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.34));
  animation: bm-tester-arrive 260ms ease-out both;
}

.bm-tester-popup__dialog {
  position: relative;
  max-height: min(680px, calc(100vh - 36px));
  overflow-y: auto;
  padding: 22px 22px 18px;
  color: var(--bm-popup-cream);
  background:
    radial-gradient(circle at 90% 0%, rgba(214, 168, 75, 0.16), transparent 38%),
    var(--bm-popup-panel);
  border: 1px solid var(--bm-popup-panel-edge);
  border-top: 4px solid var(--bm-popup-gold);
  border-radius: 16px;
  box-shadow: 0 12px 0 rgba(23, 20, 15, 0.12);
  font-family: Georgia, "Times New Roman", serif;
}

.bm-tester-popup__drag-handle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  margin: -8px auto 8px;
  padding: 5px 9px;
  color: var(--bm-popup-muted);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(214, 168, 75, 0.2);
  border-radius: 999px;
  font: 700 0.67rem/1 Arial, sans-serif;
  letter-spacing: 0.04em;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.bm-tester-popup__drag-handle span,
.bm-tester-popup__drag-handle span::before,
.bm-tester-popup__drag-handle span::after {
  width: 3px;
  height: 3px;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 6px 0 currentColor;
}

.bm-tester-popup__drag-handle span {
  position: relative;
  display: block;
  margin-right: 6px;
}

.bm-tester-popup__drag-handle span::before,
.bm-tester-popup__drag-handle span::after {
  content: "";
  position: absolute;
  left: 0;
}

.bm-tester-popup__drag-handle span::before { top: -5px; }
.bm-tester-popup__drag-handle span::after { top: 5px; }
.bm-tester-popup__drag-handle:hover { color: var(--bm-popup-gold-light); }
.bm-tester-popup__drag-handle:active,
.bm-tester-popup.is-dragging .bm-tester-popup__drag-handle { cursor: grabbing; }
.bm-tester-popup.is-dragging { filter: drop-shadow(0 22px 38px rgba(0, 0, 0, 0.42)); }

.bm-tester-popup__close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--bm-popup-cream);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  font: 28px/1 Arial, sans-serif;
  cursor: pointer;
}

.bm-tester-popup__close:hover {
  color: var(--bm-popup-gold-light);
  background: rgba(255, 255, 255, 0.07);
}

.bm-tester-popup__eyebrow {
  margin: 0 42px 6px 0;
  color: var(--bm-popup-gold-light);
  font: 800 0.7rem/1.3 Arial, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.bm-tester-popup__title {
  margin: 0 38px 7px 0;
  color: var(--bm-popup-cream);
  font-size: clamp(1.35rem, 4vw, 1.7rem);
  line-height: 1.08;
}

.bm-tester-popup__intro {
  margin: 0 0 14px;
  color: var(--bm-popup-muted);
  font: 0.94rem/1.45 Arial, sans-serif;
}

.bm-tester-popup__details {
  margin-top: 4px;
  font-family: Arial, sans-serif;
}

.bm-tester-popup__details summary {
  width: fit-content;
  color: var(--bm-popup-ink);
  background: var(--bm-popup-gold);
  border: 1px solid var(--bm-popup-gold-light);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 850;
  cursor: pointer;
  list-style-position: inside;
}

.bm-tester-popup__details summary:hover { background: var(--bm-popup-gold-light); }

.bm-tester-popup__steps {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
  counter-reset: bm-step;
}

.bm-tester-popup__steps li {
  position: relative;
  min-height: 36px;
  padding: 8px 9px 8px 44px;
  color: var(--bm-popup-cream);
  background: rgba(244, 234, 215, 0.055);
  border: 1px solid rgba(214, 168, 75, 0.18);
  border-radius: 9px;
  font: 0.84rem/1.4 Arial, sans-serif;
  counter-increment: bm-step;
}

.bm-tester-popup__steps li::before {
  content: counter(bm-step);
  position: absolute;
  top: 7px;
  left: 8px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--bm-popup-ink);
  background: var(--bm-popup-gold);
  border-radius: 50%;
  font-weight: 800;
}

.bm-tester-popup__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.bm-tester-popup__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--bm-popup-gold);
  border-radius: 8px;
  font: 800 0.8rem/1.2 Arial, sans-serif;
  text-align: center;
  text-decoration: none;
  transition: transform 150ms ease, background-color 150ms ease, color 150ms ease;
}

.bm-tester-popup__button:hover { transform: translateY(-1px); }
.bm-tester-popup__button--primary {
  color: var(--bm-popup-ink);
  background: var(--bm-popup-gold);
}
.bm-tester-popup__button--primary:hover { background: var(--bm-popup-gold-light); }
.bm-tester-popup__button--secondary { color: var(--bm-popup-gold-light); background: transparent; }
.bm-tester-popup__button--secondary:hover { color: var(--bm-popup-ink); background: var(--bm-popup-gold-light); }

.bm-tester-popup__button--confirm {
  grid-column: 1 / -1;
  color: var(--bm-popup-cream);
  background: rgba(244, 234, 215, 0.08);
  cursor: pointer;
}

.bm-tester-popup__button--confirm:hover:not(:disabled) {
  color: var(--bm-popup-ink);
  background: var(--bm-popup-gold-light);
}

.bm-tester-popup__button--confirm:disabled {
  color: var(--bm-popup-muted);
  border-color: var(--bm-popup-panel-edge);
  cursor: wait;
  opacity: 0.78;
}

.bm-tester-popup__status {
  min-height: 1.2em;
  margin: 8px 0 0;
  color: var(--bm-popup-gold-light);
  font: 700 0.78rem/1.4 Arial, sans-serif;
  text-align: center;
}

.bm-tester-popup__status--error { color: #ffb4a8; }

.bm-tester-popup__note {
  margin: 9px 0 0;
  color: var(--bm-popup-muted);
  font: 0.74rem/1.4 Arial, sans-serif;
  text-align: center;
}

.bm-tester-popup__apple-note {
  margin: 13px 0 0;
  color: var(--bm-popup-muted);
  font: 0.78rem/1.4 Arial, sans-serif;
}

.bm-tester-popup__apple-note a {
  color: var(--bm-popup-gold-light);
  font-weight: 700;
  text-underline-offset: 3px;
}

.bm-tester-popup :focus-visible {
  outline: 3px solid var(--bm-popup-focus);
  outline-offset: 3px;
}

@keyframes bm-tester-arrive {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 540px) {
  .bm-tester-popup {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
  .bm-tester-popup__dialog {
    max-height: calc(100vh - 20px);
    padding: 19px 18px 16px;
    border-radius: 13px;
  }
  .bm-tester-popup__actions { grid-template-columns: 1fr; }
  .bm-tester-popup__button--confirm { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .bm-tester-popup { animation: none; }
  .bm-tester-popup__button { transition: none; }
}
