/* ── Isolation: reset all inherited WordPress styles ──── */

#app {
  all: initial;
  display: flex !important;
  flex-direction: column;
  position: absolute;
  top: var(--wp-header-height, 0px);
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  box-sizing: border-box;
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;

  /* Dark theme variables (default) */
  --bg: #0d0d0d;
  --surface: #141414;
  --canvas-bg: #111111;
  --pane-bg: #0a0a0a;
  --output-bg: #0f0f0f;
  --canvas-stroke: #ffffff;
  --border: #2a2a2a;
  --text: #e0e0e0;
  --text-muted: #555;
  --status-muted: #777;
  --accent: #f0f0f0;
  --pill-bg: #1e1e1e;
  --pill-active-bg: #f0f0f0;
  --pill-active-text: #0d0d0d;
  --divider: #222;
  --processing-color: #fff;

  background: var(--bg);
  color: var(--text);
}

#app *, #app *::before, #app *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#app * {
  font-family: inherit;
}

/* ── Font Awesome restoration (inside all:initial isolation) ── */
#app [class*="fa-"] {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-style: normal !important;
  font-variant: normal !important;
  text-rendering: auto;
  line-height: 1 !important;
  display: inline-block;
}

#app.light-theme {
  --bg: #f4f4f4;
  --surface: #f9f9f9;
  --canvas-bg: #ffffff;
  --pane-bg: #d0d0d0;
  --output-bg: #fafafa;
  --canvas-stroke: #111111;
  --border: #d7d7d7;
  --text: #222222;
  --text-muted: #737373;
  --status-muted: #9a9a9a;
  --accent: #111111;
  --pill-bg: #ececec;
  --pill-active-bg: #222222;
  --pill-active-text: #f6f6f6;
  --divider: #d8d8d8;
  --processing-color: #333;
}

/* Hard reset for form elements — must beat WordPress theme selectors */
#app button,
#app input,
#app textarea,
#app select {
  font: inherit !important;
  color: inherit !important;
  letter-spacing: inherit;
  text-transform: none !important;
  text-decoration: none !important;
  box-shadow: none !important;
  outline: none;
}

#app button {
  border: none !important;
  background: none !important;
  cursor: pointer;
  padding: 0 !important;
  line-height: inherit !important;
}

#app button:hover,
#app button:focus,
#app button:active {
  outline: none !important;
  box-shadow: none !important;
  text-decoration: none !important;
}

#app a {
  color: inherit;
  text-decoration: none;
}

/* ── Tab bar ──────────────────────────────────────────── */

#app #tab-bar {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 4px;
  height: 44px;
  z-index: 50;
}

#app .tab-btn {
  background: transparent !important;
  border: none !important;
  color: var(--text-muted) !important;
  font-size: 13px !important;
  font-weight: 600;
  padding: 8px 16px !important;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

#app .tab-btn:hover,
#app .tab-btn:focus {
  color: var(--text) !important;
  background: var(--pill-bg) !important;
}

#app .tab-btn.active,
#app .tab-btn.active:hover,
#app .tab-btn.active:focus {
  background: var(--pill-active-bg) !important;
  color: var(--pill-active-text) !important;
}

#app #hangup-btn.connected {
  background: #d32f2f !important;
  color: #fff !important;
}

#app #hangup-btn.connected:hover {
  background: #b71c1c !important;
}

#app #hangup-btn.disconnected {
  opacity: 0.35;
  cursor: default;
}

#app .hd-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

#app #tool-hd-btn.active {
  background: #ff9800 !important;
  color: #fff !important;
}

#app #tool-hd-btn.generating {
  background: #ff9800 !important;
  color: #fff !important;
  animation: hd-pulse 1s ease-in-out infinite;
}

@keyframes hd-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#app .hd-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 30;
  pointer-events: none;
  display: none;
}

#app .hd-badge.visible {
  display: block;
}

#app #status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

#app #status-bar .status-text {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--status-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Panels ───────────────────────────────────────────── */

#app .panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#app .panel.active {
  display: flex;
}

/* ── Toolbar rows ─────────────────────────────────────── */

#app .toolbar-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
  z-index: 20;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#app .toolbar-row::-webkit-scrollbar {
  display: none;
}

#app .toolbar-row > * {
  flex-shrink: 0;
}

/* ── Tool buttons ─────────────────────────────────────── */

#app .tool-btn {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted) !important;
  font-size: 11px !important;
  letter-spacing: 0.04em;
  padding: 5px 12px !important;
  border-radius: 999px !important;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  line-height: 1.4 !important;
}

#app .tool-btn:hover,
#app .tool-btn:focus {
  color: var(--text) !important;
  border-color: #444 !important;
  background: transparent !important;
}

#app .tool-btn.active {
  background: var(--pill-active-bg) !important;
  color: var(--pill-active-text) !important;
  border-color: var(--pill-active-bg) !important;
}

#app .tool-btn.active:hover,
#app .tool-btn.active:focus {
  background: var(--pill-active-bg) !important;
  color: var(--pill-active-text) !important;
}

#app .tool-btn.danger {
  border-color: #4a2222 !important;
}

#app .tool-btn.danger:hover,
#app .tool-btn.danger:focus {
  background: #2a1515 !important;
  color: #ffb1b1 !important;
}

#app.light-theme .tool-btn.danger {
  border-color: #e0b3b3 !important;
}

#app.light-theme .tool-btn.danger:hover,
#app.light-theme .tool-btn.danger:focus {
  background: #fde8e8 !important;
  color: #b91c1c !important;
}

/* ── Icon buttons ────────────────────────────────────── */

#app .tool-btn i {
  font-size: 13px;
  vertical-align: middle;
}

#app .toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

/* Pin tool: rotate thumbtack when active */
#app #tool-lock-btn i {
  transition: transform 0.2s ease;
}

#app #tool-lock-btn.active i {
  transform: rotate(-45deg);
}

/* Recording icon stays white */
#app .tool-btn.recording i {
  color: #fff !important;
}

#app .tool-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  user-select: none;
}

#app .checkbox-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

#app .checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  width: auto !important;
  height: auto !important;
}

/* (voice text is now in modal textareas — see #voice-text-input / #camera-voice-text-input) */

/* ── Peek row (full-width slider) ────────────────────── */

#app .peek-row {
  padding: 4px 12px;
  gap: 8px;
}

#app .peek-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
  cursor: pointer;
  touch-action: none;
  height: 16px;
}

/* ── Tools dropdown button (floating top-left icon) ──── */

#app .tools-dropdown-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 31;
  width: 40px;
  height: 40px;
  border-radius: 50% !important;
  background: color-mix(in srgb, var(--surface) 85%, transparent) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border) !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  color: var(--text) !important;
  font-size: 16px !important;
  padding: 0 !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}

#app .tools-dropdown-btn:hover {
  background: color-mix(in srgb, var(--surface) 95%, transparent) !important;
}

#app .tools-dropdown-btn.open {
  opacity: 0;
  pointer-events: none;
}

/* ── Floating mic indicator (recording) ──────────────── */

#app .floating-mic-btn {
  position: absolute;
  top: 10px;
  left: 56px;
  z-index: 31;
  width: 40px;
  height: 40px;
  border-radius: 50% !important;
  background: #c0392b !important;
  border: 1px solid #c0392b !important;
  box-shadow: 0 2px 12px rgba(192, 57, 43, 0.4);
  color: #fff !important;
  font-size: 14px !important;
  padding: 0 !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: rec-pulse 1.2s ease-in-out infinite;
}

#app .floating-mic-btn.hidden { display: none; }

#app .floating-mic-btn:hover {
  background: #a93226 !important;
}

/* ── Tools dropdown menu ─────────────────────────────── */

#app .tools-dropdown {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 32;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  animation: dropdownSlideDown 0.15s ease-out;
}

#app .tools-dropdown.hidden { display: none; }

@keyframes dropdownSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

#app .tools-dropdown .tool-btn {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none !important;
  border-radius: 50% !important;
  flex-shrink: 0;
}

#app .tools-dropdown .tool-btn i {
  font-size: 14px;
}

#app .tools-dropdown-close {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none !important;
  border-radius: 50% !important;
  flex-shrink: 0;
  color: var(--text-muted) !important;
}

#app .tools-dropdown-close i {
  font-size: 14px;
}

#app .tools-dropdown-close:hover {
  color: var(--text) !important;
}

#app .tools-dropdown-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#app .tools-dropdown-divider {
  width: 22px;
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
  margin: 3px 0;
}

/* ── Color swatch ────────────────────────────────────── */

#app .color-swatch {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #111111;
  transition: background 0.1s;
}

#app.light-theme .color-swatch {
  border-color: #ccc;
}

/* ── Brush size dot (Procreate-inspired) ─────────────── */

#app .size-dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
  transition: width 0.12s, height 0.12s;
}

/* ── Opacity indicator (partial fill circle) ─────────── */

#app .opacity-indicator {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  position: relative;
  overflow: hidden;
}

#app .opacity-indicator::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--fill-pct, 50%);
  background: var(--text);
  transition: height 0.12s;
}

/* ── Custom gradient color picker ────────────────────── */

#app .color-picker-popup {
  position: fixed;
  z-index: 10000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: slideOutFromLeft 0.15s ease-out;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app .color-picker-popup.hidden { display: none; }

#app .color-picker-popup-inner {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

#app .color-picker-gradient-area {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 8px;
  overflow: hidden;
  cursor: crosshair;
}

#app .color-picker-gradient-area canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#app .color-gradient-cursor {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.4);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

#app .color-picker-hue-strip {
  position: relative;
  width: 24px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
}

#app .color-picker-hue-strip canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#app .color-hue-cursor {
  position: absolute;
  left: -2px;
  right: -2px;
  height: 6px;
  border-radius: 3px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3), 0 1px 4px rgba(0,0,0,0.4);
  pointer-events: none;
  transform: translateY(-50%);
}

#app .color-picker-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 48px;
}

#app .color-preview-large {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

#app .color-hex-input {
  width: 72px !important;
  background: var(--pill-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  color: var(--text) !important;
  font-size: 11px !important;
  padding: 4px 6px !important;
  text-align: center;
  font-family: "SF Mono", "Fira Mono", monospace !important;
}

#app .color-picker-controls .tool-btn {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes slideOutFromLeft {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Slider toggle buttons (now visual) ──────────────── */

/* (peek slider is now a full-width toolbar row — see .peek-row above) */

/* ── Slider popovers ─────────────────────────────────── */

#app .slider-popover {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  animation: slideOutFromLeft 0.15s ease-out;
}

#app .slider-popover.hidden { display: none; }

#app .slider-popover-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
}

#app .slider-popover input[type="range"] {
  width: 140px;
  accent-color: var(--accent);
  cursor: pointer;
  touch-action: none;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  margin: 0;
  height: 20px;
}

#app .slider-popover input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}

#app .slider-popover input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  margin-top: -7px;
  cursor: pointer;
}

#app .slider-popover-value {
  font-size: 11px;
  color: var(--text);
  min-width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Top bar: single row, no wrapping */
#app .draw-top-bar {
  flex-wrap: nowrap;
}

/* ── Decay input ──────────────────────────────────────── */

#app #decay-input,
#app #build-input,
#app #lock-opacity-input {
  width: 40px !important;
  background: var(--pill-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  color: var(--text) !important;
  font-size: 11px !important;
  padding: 3px 4px !important;
  text-align: center;
  -moz-appearance: textfield;
}

#app #decay-input::-webkit-inner-spin-button,
#app #decay-input::-webkit-outer-spin-button,
#app #build-input::-webkit-inner-spin-button,
#app #build-input::-webkit-outer-spin-button,
#app #lock-opacity-input::-webkit-inner-spin-button,
#app #lock-opacity-input::-webkit-outer-spin-button { opacity: 1; }

/* ── Voice recording button ───────────────────────────── */

#app .tool-btn.recording {
  background: #c0392b !important;
  color: #fff !important;
  border-color: #c0392b !important;
  animation: rec-pulse 1.2s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

/* ── Preset dropdown ──────────────────────────────────── */

#app .dropdown {
  position: fixed;
  min-width: 220px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 0;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#app .dropdown.hidden { display: none; }

#app .dropdown::-webkit-scrollbar { width: 5px; }
#app .dropdown::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#app .dropdown-heading {
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 14px 4px;
  user-select: none;
}

#app .dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none !important;
  border: none !important;
  color: var(--text) !important;
  font-size: 12px !important;
  padding: 6px 14px !important;
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 0 !important;
}

#app .dropdown-item:hover,
#app .dropdown-item:focus {
  background: var(--pill-bg) !important;
  color: var(--text) !important;
}

#app .dropdown-item.active {
  color: var(--accent) !important;
  font-weight: 600;
}

#app .dropdown-prompt-item {
  border-bottom: 1px solid var(--border) !important;
  margin-bottom: 4px;
  color: var(--accent) !important;
  font-weight: 600;
}

/* ── Workspace ─────────────────────────────────────────── */

#app .workspace {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--pane-bg);
  min-height: 0;
  z-index: 1;
}

/* ── Draw workspace (overlay mode) ────────────────────── */

#app #draw-container {
  position: relative;
  cursor: crosshair;
  will-change: transform;
  transform-origin: 0 0;
}

#app #draw-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  position: relative;
  z-index: 2;
  opacity: 0.8; /* default; overridden by peek slider JS */
}

#app .overlay-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

#app #overlay-output-old {
  z-index: 1;
}

#app #overlay-output-img {
  z-index: 2;
  transition: opacity 500ms ease;
}

#app #overlay-output-img.just-updated {
  animation: blobPop 480ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── Camera workspace (fullscreen output + camera inset) ─ */

#app #camera-output-wrapper {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app .camera-layer {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  position: absolute;
}

#app #camera-output-old {
  opacity: 0;
  z-index: 1;
}

#app #camera-output-img {
  opacity: 0;
  z-index: 2;
  transition: opacity 500ms ease;
}

#app #camera-output-img.just-updated {
  animation: blobPop 480ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

#app #camera-output-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.06em;
  pointer-events: none;
}

#app #camera-output-placeholder.hidden {
  display: none;
}

/* ── Processing indicator ─────────────────────────────── */

#app #processing-indicator,
#app .processing-dot {
  position: absolute;
  top: 14px;
  right: 18px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--processing-color);
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
}

#app #processing-indicator.active,
#app .processing-dot.active {
  opacity: 0.7;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%       { opacity: 0.3; transform: scale(0.75); }
}

@keyframes blobPop {
  0%   { transform: scale(0.94); filter: saturate(1.04) contrast(1.01); }
  45%  { transform: scale(1.025); filter: saturate(1.12) contrast(1.03); }
  100% { transform: scale(1); filter: saturate(1) contrast(1); }
}

/* ── Reconnect overlay ────────────────────────────────── */

#app #reconnect-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
  transition: opacity 0.2s;
}

#app #reconnect-overlay.hidden {
  display: none;
}

/* ── Inline 3D canvas (inside draw container) ─────────── */

#app #inline-3d-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: none;
  z-index: 10;
  touch-action: none;
  background: #222;
}

#app #inline-3d-canvas.active {
  display: block;
}

#app #draw-container.mode-3d #draw-canvas {
  visibility: hidden;
  pointer-events: none;
}

#app #draw-container.mode-3d #overlay-output-old {
  z-index: 11;
}

#app #draw-container.mode-3d #overlay-output-img {
  z-index: 12;
}

#app #reconnect-btn {
  font-size: 15px !important;
  padding: 12px 28px !important;
  border-radius: 10px;
  background: var(--pill-active-bg) !important;
  color: var(--pill-active-text) !important;
  font-weight: 700;
  gap: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

#app #reconnect-btn:hover {
  opacity: 0.85;
}

/* ── Timeline scrub bar ────────────────────────────────── */

#app .timeline-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 25;
  user-select: none;
  -webkit-user-select: none;
}

#app.light-theme .timeline-bar {
  background: rgba(255, 255, 255, 0.7);
}

#app .timeline-bar.hidden {
  display: none;
}

#app .timeline-btn {
  background: transparent !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: #fff !important;
  font-size: 11px !important;
  padding: 4px 10px !important;
  border-radius: 999px !important;
  cursor: pointer;
  white-space: nowrap;
}

#app.light-theme .timeline-btn {
  border-color: rgba(0, 0, 0, 0.15) !important;
  color: #222 !important;
}

#app .timeline-btn:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}

#app .timeline-btn.active {
  background: var(--pill-active-bg) !important;
  color: var(--pill-active-text) !important;
}

#app #timeline-scrubber {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
  cursor: pointer;
  touch-action: none;
  height: 20px;
}

#app .timeline-position {
  font-size: 10px;
  color: #ccc;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: center;
  white-space: nowrap;
}

#app.light-theme .timeline-position {
  color: #555;
}

/* ── Camera input inset ────────────────────────────────── */

#app .input-inset {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 160px;
  height: 160px;
  border-radius: 14px;
  overflow: hidden;
  z-index: 10;
  box-shadow: 0 2px 16px rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.1);
  background: var(--canvas-bg);
  display: none;
}

#app .input-inset.visible {
  display: block;
}

#app.light-theme .input-inset {
  border-color: rgba(0,0,0,0.12);
  box-shadow: 0 2px 16px rgba(0,0,0,0.15);
}

#app .input-inset video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Console panel ────────────────────────────────────── */

#app #panel-console {
  overflow: hidden;
}

#app #console-output {
  flex: 1;
  overflow-y: auto;
  background: #0a0a0a;
  padding: 8px 12px;
  font-family: "SF Mono", "Fira Mono", "Cascadia Mono", monospace;
  font-size: 11px;
  line-height: 1.5;
  color: #ccc;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#app.light-theme #console-output {
  background: #f0f0f0;
  color: #333;
}

#app #console-output::-webkit-scrollbar { width: 5px; }
#app #console-output::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#app .console-line {
  white-space: pre-wrap;
  word-break: break-all;
  border-bottom: 1px solid #1a1a1a;
  padding: 2px 0;
}

#app.light-theme .console-line { border-bottom-color: #ddd; }

#app .console-line.log   { color: #ccc; }
#app .console-line.info  { color: #6cb6ff; }
#app .console-line.warn  { color: #d4a72c; }
#app .console-line.error { color: #f85149; }

#app.light-theme .console-line.log   { color: #333; }
#app.light-theme .console-line.info  { color: #0969da; }
#app.light-theme .console-line.warn  { color: #9a6700; }
#app.light-theme .console-line.error { color: #cf222e; }

/* ── Prompt modal ─────────────────────────────────────── */

#app .modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#app .modal-overlay.hidden { display: none; }

#app .modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  width: 90%;
  max-width: 500px;
}

#app .modal-header {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

#app #prompt-textarea,
#app #voice-text-input,
#app #camera-voice-text-input {
  width: 100% !important;
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  color: var(--text) !important;
  font-size: 12px !important;
  padding: 10px !important;
  resize: vertical;
  line-height: 1.5;
}

#app #prompt-textarea:focus,
#app #voice-text-input:focus,
#app #camera-voice-text-input:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  box-shadow: none !important;
}

#app .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* ── Settings modal ──────────────────────────────────── */

#app .settings-modal-box {
  max-height: 80vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#app .settings-modal-box::-webkit-scrollbar { width: 5px; }
#app .settings-modal-box::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#app .settings-section {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

#app .settings-section:last-of-type {
  border-bottom: none;
}

#app .settings-section-title {
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

#app .settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

#app .settings-row:last-child {
  margin-bottom: 0;
}

#app .settings-label {
  font-size: 12px;
  color: var(--text);
}

#app .settings-label i {
  margin-right: 6px;
  color: var(--text-muted);
}

#app .settings-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

#app .settings-danger {
  padding-top: 12px;
}

#app .settings-section .checkbox-label {
  margin-bottom: 6px;
}

#app .settings-section .checkbox-label:last-child {
  margin-bottom: 0;
}

#app .settings-section select {
  background: var(--pill-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  color: var(--text) !important;
  font-size: 11px !important;
  padding: 4px 8px !important;
  cursor: pointer;
}

/* ── Mobile ───────────────────────────────────────────── */

/* ── 3D generation status ─────────────────────────────── */

#app .settings-3d-status {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

#app .settings-3d-status.hidden { display: none; }

#app .settings-3d-status .spinner-3d {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin3d 0.8s linear infinite;
}

@keyframes spin3d {
  to { transform: rotate(360deg); }
}

/* ── 3D viewer modal ─────────────────────────────────── */

#app .viewer-3d-modal-box {
  max-width: 90vw;
  max-height: 90vh;
  width: 600px;
  display: flex;
  flex-direction: column;
}

#app .viewer-3d-modal-box .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#app .viewer-3d-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #222;
}

#app #viewer-3d-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  touch-action: none;
}

@media (max-width: 600px) {
  #app .input-inset {
    width: 120px;
    height: 120px;
    border-radius: 10px;
    top: 8px;
    right: 8px;
  }

  #app .tab-btn {
    padding: 8px 12px !important;
    font-size: 12px !important;
  }
}

/* ── Mobile: tools dropdown ──────────────────────────── */

@media (max-width: 480px) {
  #app .tools-dropdown-btn {
    top: 8px;
    left: 8px;
    width: 36px;
    height: 36px;
    font-size: 14px !important;
  }

  #app .floating-mic-btn {
    top: 8px;
    left: 50px;
    width: 36px;
    height: 36px;
    font-size: 12px !important;
  }

  #app .tools-dropdown {
    top: 8px;
    left: 8px;
  }

  #app .tools-dropdown .tool-btn {
    width: 32px;
    height: 32px;
  }

  #app .tools-dropdown .tool-btn i {
    font-size: 12px;
  }

  /* Color picker popup: smaller on mobile */
  #app .color-picker-popup {
    max-width: calc(100vw - 24px);
  }

  #app .color-picker-gradient-area {
    width: 150px;
    height: 150px;
  }

  /* Slider popovers: constrain to screen */
  #app .slider-popover {
    max-width: calc(100vw - 24px);
  }

  #app .slider-popover input[type="range"] {
    width: 100px;
  }
}

@media (max-width: 360px) {
  #app .tools-dropdown .tool-btn {
    width: 28px;
    height: 28px;
  }

  #app .tools-dropdown .tool-btn i {
    font-size: 11px;
  }

  #app .color-swatch {
    width: 16px;
    height: 16px;
  }

  #app .size-dot {
    max-width: 16px;
    max-height: 16px;
  }

  #app .opacity-indicator {
    width: 16px;
    height: 16px;
  }
}

@media (min-width: 768px) {
  #app .input-inset {
    width: 200px;
    height: 200px;
  }
}
