.pb-root {
  --pb-bg: #fff;
  --pb-bg-muted: #f8fafc;
  --pb-border: #e2e8f0;
  --pb-text: #0f172a;
  --pb-text-muted: #64748b;
  --pb-primary: #6366f1;
  --pb-primary-light: rgba(99,102,241,0.1);
  --pb-shadow: rgba(0,0,0,0.06);
  --pb-toolbar-bg: rgba(255,255,255,0.92);
  --pb-radius: 1.25rem;

  width: 100%;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 90vh;
  min-height: 600px;
}

.theme-dark .pb-root {
  --pb-bg: #09090b;
  --pb-bg-muted: #18181b;
  --pb-border: #27272a;
  --pb-text: #fafafa;
  --pb-text-muted: #71717a;
  --pb-primary: #818cf8;
  --pb-primary-light: rgba(129,140,248,0.12);
  --pb-shadow: rgba(0,0,0,0.4);
  --pb-toolbar-bg: rgba(9,9,11,0.92);
}

.pb-toolbar {
  position: sticky;
  top: 0.5rem;
  z-index: 100;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  background: var(--pb-toolbar-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--pb-border);
  border-radius: var(--pb-radius);
  padding: 0.5rem 1rem;
  box-shadow: 0 8px 32px var(--pb-shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.pb-tool-selector {
  display: flex;
  gap: 0.25rem;
  background: var(--pb-bg-muted);
  border-radius: 0.75rem;
  padding: 0.25rem;
}

.pb-tool-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.875rem;
  border-radius: 0.625rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--pb-text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.pb-tool-btn-active {
  background: var(--pb-bg);
  color: var(--pb-text);
  box-shadow: 0 2px 8px var(--pb-shadow);
}

.pb-settings-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.pb-intensity-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--pb-text-muted);
}

.pb-slider {
  width: 90px;
  accent-color: var(--pb-primary);
}

.pb-auto-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.875rem;
  background: var(--pb-primary-light);
  color: var(--pb-primary);
  border: none;
  border-radius: 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.pb-auto-btn:hover {
  opacity: 0.8;
}

.pb-action-group {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.pb-undo-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  background: var(--pb-bg-muted);
  border: 1px solid var(--pb-border);
  color: var(--pb-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.pb-undo-btn:hover:not(:disabled) {
  border-color: var(--pb-primary);
  color: var(--pb-primary);
}

.pb-undo-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pb-download-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  background: var(--pb-primary);
  color: #fff;
  border: none;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99,102,241,0.35);
  transition: all 0.2s;
}

.pb-download-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.45);
}

.pb-download-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.pb-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.pb-workspace {
  flex: 1;
  position: relative;
  background: var(--pb-bg-muted);
  border: 2px dashed var(--pb-border);
  border-radius: var(--pb-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.2s;
}

.pb-dragging .pb-workspace {
  border-color: var(--pb-primary);
  background: var(--pb-primary-light);
}

.pb-empty {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  padding: 2rem;
  gap: 0.75rem;
}

.pb-upload-icon {
  width: 5rem;
  height: 5rem;
  background: var(--pb-bg);
  border: 1px solid var(--pb-border);
  border-radius: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pb-primary);
  box-shadow: 0 8px 24px var(--pb-shadow);
  margin-bottom: 0.5rem;
}

.pb-icon-lg {
  width: 2.5rem;
  height: 2.5rem;
}

.pb-empty-title {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--pb-text);
  margin: 0;
}

.pb-empty-sub {
  font-size: 1rem;
  color: var(--pb-text-muted);
  margin: 0;
}

.pb-badges {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.pb-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--pb-bg);
  border: 1px solid var(--pb-border);
  border-radius: 9999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--pb-text-muted);
}

.pb-badge-icon {
  width: 0.875rem;
  height: 0.875rem;
}

.pb-loader {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 10;
}

.pb-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pb-spin 0.7s linear infinite;
}

@keyframes pb-spin {
  to { transform: rotate(360deg); }
}

.pb-loader-text {
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  margin: 0;
}

.pb-canvas-wrap {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pb-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: crosshair;
}

.pb-hidden {
  display: none;
}

@media (max-width: 640px) {
  .pb-root {
    padding: 0.5rem;
    height: auto;
    min-height: 500px;
  }
  .pb-empty-title {
    font-size: 1.25rem;
  }
}
