:root {
  --bg-base: #0a0b10;
  --bg-surface: #12141e;
  --bg-elevated: #1a1d2d;
  --bg-glass: rgba(26, 29, 45, 0.7);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --accent-primary: #6366f1;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* App Container Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.badge-ai {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
  margin-left: 6px;
  vertical-align: middle;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.canvas-mode-selector {
  display: flex;
  background: var(--bg-elevated);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  color: var(--text-primary);
}

.mode-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.mode-dot.dark { background: #181b26; border: 1px solid #334155; }
.mode-dot.checker {
  background: repeating-conic-gradient(#64748b 0% 25%, #334155 0% 50%) 50% / 6px 6px;
}
.mode-dot.light { background: #f8fafc; }

.mcp-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-size: 0.75rem;
  color: #34d399;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
}

/* Studio Grid Layout */
.studio-grid {
  display: grid;
  grid-template-columns: 1fr 400px;
  height: calc(100vh - 65px);
  overflow: hidden;
}

/* Left: Canvas Studio */
.canvas-section {
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  border-right: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}

.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.tool-group, .quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
}

.btn-action {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}
.btn-action:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
}

/* Tracing Profile Preset Pill */
.preset-pill-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  transition: all 0.2s ease;
}
.preset-pill-group:hover {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.06);
}

.preset-pill-icon {
  font-size: 0.8rem;
  opacity: 0.85;
}

.preset-select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  padding: 4px 2px;
}
.preset-select option {
  background: #181a26;
  color: #f8fafc;
}

/* Canvas Area */
.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background-color: #121420;
  transition: background 0.3s ease;
}

/* Canvas Theme Backgrounds */
.theme-dark .canvas-wrapper {
  background-color: #121420;
}
.theme-check .canvas-wrapper {
  background-color: #1e2230;
  background-image: 
    linear-gradient(45deg, #181a24 25%, transparent 25%), 
    linear-gradient(-45deg, #181a24 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #181a24 75%), 
    linear-gradient(-45deg, transparent 75%, #181a24 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}
.theme-light .canvas-wrapper {
  background-color: #f1f5f9;
}

/* Drop Zone */
.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80%;
  max-width: 600px;
  height: 320px;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: var(--shadow-glow);
}

.upload-icon-circle {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--accent-cyan);
}

.drop-content h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-bottom: 6px;
}
.drop-content p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* Split Viewer */
.split-viewer {
  position: relative;
  max-width: 90%;
  max-height: 85%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-md);
  overflow: hidden;
  user-select: none;
}

.view-layer {
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-layer img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.original-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%; /* controlled dynamically by JS slider */
  height: 100%;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.5);
}

.original-layer img {
  max-width: none; /* keep full image dimensions for perfect overlay */
}

.badge-tag {
  position: absolute;
  bottom: 12px;
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.tag-before {
  left: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.tag-after {
  right: 12px;
  background: rgba(99, 102, 241, 0.7);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Split Handle */
.split-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 40px;
  margin-left: -20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  z-index: 10;
}

.handle-line {
  width: 2px;
  flex: 1;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
}

.handle-grip {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #ffffff;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--accent-primary);
}

/* Output Footer */
.output-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

.meta-specs {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.meta-sep {
  margin: 0 8px;
}

.download-group {
  display: flex;
  gap: 10px;
}

.btn-download {
  font-weight: 600;
}

.btn-svg {
  background: #0ea5e9;
  color: #fff;
}
.btn-svg:hover {
  background: #0284c7;
}

.btn-png {
  background: #8b5cf6;
  color: #fff;
}
.btn-png:hover {
  background: #7c3aed;
}

/* Spinner Overlay */
.spinner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 11, 16, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.spinner-box {
  background: var(--bg-elevated);
  padding: 24px 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-subtle);
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Right: Agent Panel */
.agent-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  height: 100%;
}

.agent-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.agent-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-pulse {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1.5px solid #6366f1;
  animation: pulse-ring 2.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(0.95); opacity: 0; }
}

.agent-title h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}

.agent-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Chat Messages */
.agent-messages {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.5;
}

.agent-bubble {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.agent-bubble ul {
  margin-top: 8px;
  padding-left: 18px;
}
.agent-bubble li {
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.user-bubble {
  align-self: flex-end;
  background: var(--accent-gradient);
  color: #ffffff;
  border-radius: 12px 12px 2px 12px;
}

.tool-invocation-bubble {
  align-self: center;
  width: 95%;
  background: rgba(99, 102, 241, 0.08);
  border: 1px dashed rgba(99, 102, 241, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: #c7d2fe;
}

/* Suggested Chips */
.suggested-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.01);
}

.chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

/* Agent Input Form */
.agent-input-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

.agent-input-form input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s ease;
}

.agent-input-form input:focus {
  border-color: var(--accent-primary);
}

.btn-send {
  padding: 0 14px;
  border-radius: var(--radius-sm);
}

/* ============================================================= */
/* Generative UI Action Cards & Tool Execution Badges             */
/* ============================================================= */
.tool-call-badge {
  align-self: center;
  width: 95%;
  background: rgba(99, 102, 241, 0.12);
  border: 1px dashed rgba(99, 102, 241, 0.4);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: #c7d2fe;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.3s ease;
}

.action-card {
  align-self: flex-start;
  width: 95%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 4px 0;
  animation: slideUp 0.3s ease;
}

.action-card h4 {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.action-card .card-description {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.action-card .card-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.78rem;
}

.action-card input[type="range"] {
  flex: 1;
  accent-color: var(--accent-primary);
  height: 6px;
  border-radius: 3px;
  cursor: pointer;
}

.action-card select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  outline: none;
}

.action-card .card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.action-card .btn-card-action {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-card-primary {
  background: var(--accent-gradient);
  color: #fff;
}
.btn-card-primary:hover {
  filter: brightness(1.1);
}

.btn-card-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.btn-card-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.meta-stats-row {
  display: flex;
  gap: 16px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-family: var(--font-mono);
  color: #94a3b8;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Interactive On-Canvas Bounding Box & Typography Popover
   ============================================================ */

/* Selection mode active state on toolbar button */
.btn-action.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.6);
  color: #7dd3fc;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

/* Bounding Box Overlay Layer */
.bbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  cursor: crosshair;
  user-select: none;
}

/* Active Bounding Box Rectangle */
.bbox-selection {
  position: absolute;
  border: 2px dashed #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.35), inset 0 0 15px rgba(56, 189, 248, 0.15);
  border-radius: 4px;
  pointer-events: auto;
  cursor: move;
}

/* Corner Resizing Handles */
.bbox-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #38bdf8;
  border: 2px solid #0f172a;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.8);
}
.bbox-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.bbox-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.bbox-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.bbox-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* Coordinates & Dimensions Badge */
.bbox-badge {
  position: absolute;
  top: -26px;
  left: 0;
  background: rgba(15, 23, 42, 0.9);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 2px 8px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 600;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Floating Typography Popover */
.typography-popover {
  position: absolute;
  z-index: 30;
  width: 320px;
  background: rgba(18, 20, 32, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.15);
  animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 14px 16px;
  color: var(--text-primary);
}

.popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.popover-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: #f8fafc;
}

.popover-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}
.popover-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.popover-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.popover-body .form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.popover-body label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.popover-body input[type="text"],
.popover-body select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s ease;
}
.popover-body input[type="text"]:focus,
.popover-body select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.popover-body .form-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.color-picker-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-picker-group input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  padding: 0;
}
.color-picker-group input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
.color-picker-group input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: var(--radius-sm);
}

.color-presets {
  display: flex;
  gap: 5px;
}
.preset-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease;
}
.preset-dot:hover {
  transform: scale(1.25);
}

/* Canvas Eyedropper Loupe (Magnifier) */
.canvas-loupe {
  position: absolute;
  pointer-events: none;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transform: translate(-50%, -120%);
  transition: transform 0.05s linear;
}

.loupe-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid #38bdf8;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6), 0 8px 24px rgba(0, 0, 0, 0.7), 0 0 16px rgba(56, 189, 248, 0.4);
  overflow: hidden;
  position: relative;
  background: #000;
}

.loupe-ring canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: block;
}

.loupe-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.loupe-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-full);
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: #f8fafc;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.loupe-preview-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  display: inline-block;
}

/* Eyedropper Active Mode on Canvas */
.eyedropper-active {
  cursor: crosshair !important;
}
.eyedropper-active * {
  cursor: crosshair !important;
}

/* Auto-Detected Palette Ribbon */
.palette-auto-detect {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.08) 0%, rgba(99, 102, 241, 0.08) 100%);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.palette-detect-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #38bdf8;
  letter-spacing: 0.02em;
}

.palette-chips-row {
  display: flex;
  gap: 8px;
}

.palette-chip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.72rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
}
.palette-chip:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}
.palette-chip.active {
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

.chip-color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-label strong {
  font-family: var(--font-mono);
  color: #f1f5f9;
}

.label-with-tool {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.btn-picker-eye {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 1px 5px;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s ease;
}
.btn-picker-eye:hover,
.btn-picker-eye.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #38bdf8;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.checkbox-inline input[type="checkbox"] {
  cursor: pointer;
  accent-color: #38bdf8;
  width: 14px;
  height: 14px;
}

.bbox-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.bbox-coords-display {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #38bdf8;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(56, 189, 248, 0.2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popover-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

/* ============================================================
   Penpot Export & Integration Modal
   ============================================================ */

.btn-penpot {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.25);
}
.btn-penpot:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 16, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

/* Modal Card */
.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--bg-surface);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 25px rgba(16, 185, 129, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.penpot-icon-circle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.modal-title-group h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: #f8fafc;
}

.modal-subtitle {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 80vh;
  overflow-y: auto;
}

.penpot-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: #a7f3d0;
}
.penpot-status-row .status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.export-method-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.method-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.method-header h4 {
  font-size: 0.86rem;
  font-weight: 600;
  color: #e2e8f0;
  margin: 0;
}

.badge-pill {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-pill.secondary {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.3);
}

.method-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.input-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
}
.input-hint strong {
  color: var(--text-secondary);
}

.btn-block {
  width: 100%;
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 4px;
}

.method-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.method-actions .btn {
  flex: 1;
  justify-content: center;
}
.btn-link {
  text-decoration: none;
}

.inject-status-msg {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.4;
  margin-top: 6px;
}
.inject-status-msg.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}
.inject-status-msg.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}


