/* ════════════════════════════════════════════════════════════════════
   Debug overlay  ·  bottom-right, only visible after caught error
   ════════════════════════════════════════════════════════════════════ */

.debug-overlay {
  position: fixed;
  bottom: 42px;
  right: 14px;
  z-index: 9999;
  width: min(540px, 92vw);
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--bad);
  border-radius: 5px;
  box-shadow: 0 24px 60px -12px rgba(220, 38, 38, 0.4),
              0 1px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chip-in 0.22s;
  font-family: var(--font-ui);
}

.debug-overlay[hidden] { display: none; }

/* Developer-Mode gate (B-5): runtime error overlay + Copy-debug-bundle UI is
   a debug surface. Even if a runtime error fires and toggles `hidden=false`,
   we keep it visually hidden when dev mode is off so end users never see
   internal stack traces. The error is still captured (window.onerror); the
   user just doesn't see the bundle UI. */
body:not(.dev-mode) #debug-overlay { display: none !important; }

.debug-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, var(--bad-bg) 0%, transparent 100%);
  border-bottom: 1px solid var(--bad);
  color: var(--bad-ink);
}

.debug-icon {
  font-size: 15px;
  font-weight: 600;
}

.debug-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.debug-spacer { flex: 1; }

.debug-close {
  width: 24px;
  height: 24px;
  border: 1px solid var(--bad);
  border-radius: 50%;
  background: transparent;
  color: var(--bad);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 2px;
}

.debug-close:hover {
  background: var(--bad);
  color: var(--surface);   /* theme-aware reverse ink (DESIGN.md §3.3) */
}

.debug-body {
  flex: 1 1 auto;
  padding: 12px 16px;
  overflow-y: auto;
  font-size: 11px;
}

.debug-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 4px 0;
}

.debug-row .debug-key {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.debug-row .debug-val {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink);
  word-break: break-all;
}

.debug-row .debug-msg {
  color: var(--bad);
  font-weight: 500;
}

.debug-stack {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.5;
}

.debug-actions {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--paper-soft);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.debug-copy {
  height: 32px;
  padding: 0 16px;
  background: var(--ink-1);
  color: var(--surface);   /* theme-aware reverse ink (DESIGN.md §3.3) */
  border: none;
  border-radius: 3px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}

.debug-copy:hover { background: var(--ink-1); }

.debug-copy.flash {
  background: var(--good);
}

.debug-dismiss {
  height: 32px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
}

.debug-dismiss:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* ════════════════════════════════════════════════════════════════════
   Invalid-placement floating chip
   ════════════════════════════════════════════════════════════════════ */

/* Top-of-viewport chip (was: cursor-follow). Centered above breadboard. */
.invalid-chip {
  position: absolute;
  top: calc(var(--topbar-h) + 14px);   /* clear the fixed topbar (full-bleed layout) */
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;   /* above glass chrome so the placement warning is never hidden */
  background: var(--bad);
  color: var(--surface);   /* theme-aware reverse ink — --bad flips light pink in dark theme (DESIGN.md §3.3) */
  padding: 8px 16px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 18px -2px rgba(220, 38, 38, 0.45),
              0 1px 2px rgba(0, 0, 0, 0.08);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  animation: chip-in 0.18s;
}

.invalid-chip[hidden] { display: none; }

.invalid-chip .chip-icon {
  font-size: 13px;
  line-height: 1;
}

.invalid-chip .chip-detail {
  font-family: var(--font-mono);
  font-size: 10.5px;
  opacity: 0.85;
  letter-spacing: 0.04em;
}

@keyframes chip-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

