.profiler-panel {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 19;
  display: none;
  flex-direction: column;
  width: min(380px, calc(100vw - 24px));
  max-height: min(72vh, calc(100% - 32px));
  border-radius: var(--radius-md);
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
  pointer-events: auto;
  font-variant-numeric: tabular-nums;
}

.profiler-panel.is-open {
  display: flex;
}

[data-ui-draggable].profiler-panel.is-ui-dragged {
  z-index: 40;
}

.pf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.profiler-panel.is-dragging .pf-head {
  cursor: grabbing;
}

.profiler-panel.is-dragging {
  opacity: 0.96;
}

.pf-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(120, 220, 160, 0.95);
}

.pf-close {
  padding: 2px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.pf-close:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.pf-body {
  padding: 10px 12px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pf-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pf-frame-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.pf-frame-ms {
  font-size: 1.1rem;
  font-weight: 700;
}

.pf-frame-fps {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.pf-budget {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.pf-budget::before {
  content: '';
  position: absolute;
  left: var(--pf-budget-tick-pct, 33.33%);
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.35);
  z-index: 1;
}

.pf-budget::after {
  content: '';
  display: block;
  height: 100%;
  width: var(--pf-budget-pct, 0%);
  background: linear-gradient(90deg, rgba(80, 200, 120, 0.9), rgba(200, 162, 39, 0.9));
  border-radius: 3px;
  transition: width 0.08s linear;
}

.pf-budget[data-over-budget='true']::after {
  background: linear-gradient(90deg, rgba(200, 162, 39, 0.95), rgba(220, 80, 80, 0.95));
}

.pf-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pf-btn {
  padding: 5px 9px;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  color: var(--color-text-muted);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pf-btn:hover,
.pf-btn.is-active {
  color: var(--color-text);
  border-color: rgba(120, 220, 160, 0.55);
}

.pf-btn.is-recording {
  color: #f66;
  border-color: rgba(255, 80, 80, 0.6);
  animation: pf-pulse 1s ease-in-out infinite;
}

.pf-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@keyframes pf-pulse {
  50% { opacity: 0.65; }
}

.pf-hint {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  line-height: 1.35;
}

.pf-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.pf-scope-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pf-scope-row {
  display: grid;
  grid-template-columns: 88px 1fr 44px;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
}

.pf-scope-label {
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pf-scope-bar-wrap {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.pf-scope-bar {
  display: block;
  height: 100%;
  border-radius: 2px;
  min-width: 1px;
}

.pf-scope-ms {
  text-align: right;
  font-weight: 600;
}

.pf-good { color: rgba(100, 210, 140, 0.95); }
.pf-warn { color: #c9a227; }
.pf-bad { color: var(--color-danger); }

.pf-scope-bar.pf-good { background: rgba(80, 200, 120, 0.85); }
.pf-scope-bar.pf-warn { background: rgba(200, 162, 39, 0.9); }
.pf-scope-bar.pf-bad { background: rgba(220, 80, 80, 0.9); }

.pf-empty {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.pf-counter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
}

.pf-counter {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.pf-counter-label {
  font-size: 0.62rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pf-counter-value {
  font-size: 0.75rem;
  font-weight: 600;
}
