#metrics-overlay {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 9999;
  background: rgba(10, 10, 10, 0.92);
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.7rem;
  color: #e8e8e8;
  min-width: 220px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s, transform 0.2s;
}

#metrics-overlay.hidden {
  opacity: 0;
  transform: translateY(0.5rem);
  pointer-events: none;
}

#metrics-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #2a2a2a;
}

#metrics-overlay-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #666;
}

#metrics-toggle-btn {
  background: none;
  border: 1px solid #333;
  border-radius: 4px;
  color: #666;
  font-size: 0.6rem;
  padding: 0.1rem 0.4rem;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}

#metrics-toggle-btn:hover { color: #aaa; border-color: #555; }

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0;
}

.metric-label {
  color: #666;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  min-width: 42px;
}

.metric-value {
  font-weight: 700;
  font-size: 0.75rem;
  transition: color 0.3s;
}

.metric-value.good    { color: #52c07a; }
.metric-value.needs-improvement { color: #f0a04a; }
.metric-value.poor    { color: #e05252; }
.metric-value.pending { color: #555; }

.metric-bar {
  flex: 1;
  height: 3px;
  background: #1e1e1e;
  border-radius: 2px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease, background 0.3s;
  background: #555;
}

#metrics-overlay-divider {
  border: none;
  border-top: 1px solid #1e1e1e;
  margin: 0.5rem 0;
}

.metric-badge {
  font-size: 0.6rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: 700;
}

.metric-badge.bfcache {
  background: #1a3a28;
  color: #52c07a;
  border: 1px solid #2a5a3a;
}

/* ─── Light theme ────────────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) #metrics-overlay {
    background: rgba(255, 255, 255, 0.96);
    border-color: #e2e2e2;
    color: #111111;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  }

  :root:not([data-theme="dark"]) #metrics-overlay-header {
    border-bottom-color: #e2e2e2;
  }

  :root:not([data-theme="dark"]) #metrics-overlay-title { color: #999; }
  :root:not([data-theme="dark"]) #metrics-toggle-btn {
    border-color: #ddd;
    color: #999;
  }
  :root:not([data-theme="dark"]) #metrics-toggle-btn:hover { color: #555; border-color: #bbb; }

  :root:not([data-theme="dark"]) .metric-label { color: #999; }
  :root:not([data-theme="dark"]) .metric-value.pending { color: #bbb; }

  :root:not([data-theme="dark"]) .metric-bar { background: #e8e8e8; }
  :root:not([data-theme="dark"]) .metric-bar-fill { background: #bbb; }

  :root:not([data-theme="dark"]) #metrics-overlay-divider { border-top-color: #e8e8e8; }

  :root:not([data-theme="dark"]) .metric-badge.bfcache {
    background: #e8f5ee;
    border-color: #b8e5c8;
  }
}

html[data-theme="light"] #metrics-overlay {
  background: rgba(255, 255, 255, 0.96);
  border-color: #e2e2e2;
  color: #111111;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] #metrics-overlay-header { border-bottom-color: #e2e2e2; }
html[data-theme="light"] #metrics-overlay-title { color: #999; }
html[data-theme="light"] #metrics-toggle-btn { border-color: #ddd; color: #999; }
html[data-theme="light"] #metrics-toggle-btn:hover { color: #555; border-color: #bbb; }
html[data-theme="light"] .metric-label { color: #999; }
html[data-theme="light"] .metric-value.pending { color: #bbb; }
html[data-theme="light"] .metric-bar { background: #e8e8e8; }
html[data-theme="light"] .metric-bar-fill { background: #bbb; }
html[data-theme="light"] #metrics-overlay-divider { border-top-color: #e8e8e8; }
html[data-theme="light"] .metric-badge.bfcache { background: #e8f5ee; border-color: #b8e5c8; }
