/* ==========================================================================
   LVGL Editor Canvas — Complete Design System & Styles
   ========================================================================== */

:root {
  --bg-primary: #080c14;
  --bg-secondary: #0d1321;
  --bg-tertiary: #131c2e;
  --bg-card: #182238;
  --bg-input: #101726;
  --bg-hover: #1e2b45;
  --bg-active: #253655;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.22);
  --border-focus: #3b82f6;

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

  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.35);
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.35);
  --accent-orange: #ff6b3d;
  --accent-orange-glow: rgba(255, 107, 61, 0.35);
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;

  --canvas-bg: #111827;
  --grid-dot-color: rgba(255, 255, 255, 0.15);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
  --font-mono: 'JetBrains Mono', monospace;

  --topbar-h: 52px;
  --sidebar-w: 240px;
  --inspector-w: 320px;
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* ==========================================================================
   Main App Layout
   ========================================================================== */

.app-root {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* Top Navbar */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  border: 1px solid rgba(59, 130, 246, 0.5);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.35);
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
}

.breadcrumb-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.breadcrumb-crumb {
  color: var(--text-secondary);
}

.breadcrumb-select-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.breadcrumb-select-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

/* Center Mode Switcher */
.mode-switcher {
  display: flex;
  background: var(--bg-primary);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.mode-btn svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

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

.mode-btn.active {
  background: var(--bg-card);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
}

.mode-btn.active svg {
  opacity: 1;
  color: var(--accent-blue);
}

/* Topbar Right Actions */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-pill-subtle {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-pill-subtle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-pill-primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border-color: rgba(96, 165, 250, 0.4);
  box-shadow: 0 1px 8px rgba(37, 99, 235, 0.35);
}

.btn-pill-primary:hover {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.5);
}

.btn-pill-sparkle {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.3);
}

.btn-pill-sparkle:hover {
  background: rgba(168, 85, 247, 0.25);
  color: #e9d5ff;
  border-color: rgba(168, 85, 247, 0.5);
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

/* ==========================================================================
   Workspace Body (Left Sidebar, Canvas, Right Inspector)
   ========================================================================== */

.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Left Sidebar (Widgets) */
.sidebar-left {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
  transition: width 0.2s var(--ease-smooth);
}

.sidebar-header {
  height: 44px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-search {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 6px 10px 6px 30px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-box input:focus {
  border-color: var(--border-focus);
}

.widgets-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.widget-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
}

.group-header svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.group-header.collapsed svg {
  transform: rotate(-90deg);
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.widget-group.is-collapsed .group-grid {
  display: none;
}

.widget-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: grab;
  transition: all 0.15s ease;
  text-align: center;
}

.widget-card:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.widget-card:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.widget-card.featured-card {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.08);
}

.widget-card.featured-card:hover {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.15);
}

.widget-card-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
}

.widget-card-title {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.widget-card:hover .widget-card-title {
  color: var(--text-primary);
}

/* ==========================================================================
   Center Canvas Stage
   ========================================================================== */

.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* Screen Tab Header */
.screen-tabs-bar {
  height: 38px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}

.screen-tabs-left {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
}

.screen-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.screen-tab.active {
  color: #ffffff;
  border-bottom-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.06);
}

.screen-tab-add {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: transparent;
  border: 1px dashed var(--border-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.screen-tab-add:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.screen-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Canvas Subheader / Toolbar */
.canvas-subbar {
  height: 40px;
  background: rgba(13, 19, 33, 0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 10;
}

.canvas-subbar-left,
.canvas-subbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-pill-group {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
}

.tool-pill-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s ease;
}

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

.tool-pill-btn.active {
  background: var(--bg-card);
  color: var(--accent-blue);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.res-dropdown {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.res-dropdown:hover {
  border-color: var(--border-medium);
}

.zoom-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 8px;
  background: var(--bg-input);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* Canvas Viewport (Infinite Pan/Zoom Stage) */
.canvas-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-viewport.is-panning {
  cursor: grab;
}
.canvas-viewport.is-panning:active {
  cursor: grabbing;
}

/* Dots Grid Background */
.canvas-grid-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(circle, var(--grid-dot-color) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.canvas-grid-bg.grid-hidden {
  opacity: 0;
}

/* The Transformable Canvas Container */
.canvas-transform-layer {
  position: absolute;
  transform-origin: 0 0;
  transition: none;
  will-change: transform;
}

/* The Hardware Display Frame (Screen Simulator) */
.display-bezel {
  background: #020408;
  border: 12px solid #1a2233;
  border-radius: 16px;
  box-shadow: 
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 24px 60px rgba(0, 0, 0, 0.8),
    0 0 40px rgba(59, 130, 246, 0.08);
  position: relative;
  overflow: hidden;
}

.display-screen {
  background-color: var(--canvas-bg);
  position: relative;
  overflow: hidden;
  width: 800px;
  height: 480px;
}

/* SVG Rendering Layer for Arcs & Graphics */
.canvas-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* HTML Interactive Widgets Layer */
.canvas-widgets-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
}

/* Selection / Bounding Box Layer */
.canvas-selection-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Canvas Bottom Floating Controls */
.canvas-bottom-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 19, 33, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-medium);
  border-radius: 24px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 50;
}

.canvas-help-btn {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(13, 19, 33, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-medium);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 50;
  transition: all 0.15s ease;
}

.canvas-help-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.zoom-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.zoom-btn.active {
  background: var(--accent-blue);
  color: #ffffff;
  font-weight: 600;
}

/* ==========================================================================
   Widget Rendering & Interactive Elements
   ========================================================================== */

.editor-widget {
  position: absolute;
  cursor: move;
  user-select: none;
  transition: box-shadow 0.15s ease;
}

.editor-widget.is-selected {
  outline: 1.5px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Transform handles for selected widget */
.selection-box {
  position: absolute;
  border: 1.5px solid var(--accent-blue);
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

.selection-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #ffffff;
  border: 1.5px solid var(--accent-blue);
  border-radius: 2px;
  pointer-events: auto;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.handle-n { top: -5px; left: calc(50% - 4px); cursor: ns-resize; }
.handle-s { bottom: -5px; left: calc(50% - 4px); cursor: ns-resize; }
.handle-w { top: calc(50% - 4px); left: -5px; cursor: ew-resize; }
.handle-e { top: calc(50% - 4px); right: -5px; cursor: ew-resize; }

/* Arc Widget Rendering */
.lv-arc-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lv-arc-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.lv-arc-center-content {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.lv-arc-center-val {
  font-family: var(--font-display);
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
}

.lv-arc-center-unit {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Interactive Knob on Arc */
.lv-arc-knob {
  cursor: grab;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.lv-arc-knob:hover {
  filter: brightness(1.2);
}

.lv-arc-knob:active {
  cursor: grabbing;
  transform: scale(1.1);
}

/* Theme Backdrop Layer (e.g. Retrowave perspective road grid) */
.canvas-theme-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

/* Retrowave specific typography and scanline effects */
.retrowave-speed-digits {
  font-family: 'JetBrains Mono', monospace !important;
  font-weight: 800 !important;
  letter-spacing: -2px;
  color: #f026d3 !important;
  text-shadow: 0 0 16px rgba(240, 38, 211, 0.95), 0 0 32px rgba(240, 38, 211, 0.6);
  position: relative;
  display: inline-block;
  /* True transparent mask cutout - NO black overlay box! */
  -webkit-mask-image: repeating-linear-gradient(
    to bottom,
    #000 0px,
    #000 3.5px,
    transparent 3.5px,
    transparent 6px
  );
  mask-image: repeating-linear-gradient(
    to bottom,
    #000 0px,
    #000 3.5px,
    transparent 3.5px,
    transparent 6px
  );
}

.retrowave-mint-badge {
  color: #00f5d4 !important;
  font-family: var(--font-display) !important;
  font-weight: 800 !important;
  letter-spacing: 0.12em;
  text-shadow: 0 0 10px rgba(0, 245, 212, 0.9), 0 0 20px rgba(0, 245, 212, 0.5);
  background: rgba(0, 245, 212, 0.12);
  border: 1px solid rgba(0, 245, 212, 0.45);
  border-radius: 12px;
  padding: 3px 12px;
  box-shadow: 0 0 14px rgba(0, 245, 212, 0.25), inset 0 0 8px rgba(0, 245, 212, 0.15);
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.retrowave-mode-badge {
  color: #f8fafc !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-weight: 700 !important;
  letter-spacing: 0.1em;
  text-shadow: 0 0 8px rgba(240, 38, 211, 0.8);
  background: rgba(240, 38, 211, 0.15);
  border: 1px solid rgba(240, 38, 211, 0.5);
  border-radius: 12px;
  padding: 3px 12px;
  box-shadow: 0 0 12px rgba(240, 38, 211, 0.25), inset 0 0 6px rgba(240, 38, 211, 0.15);
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.retrowave-dock-text {
  color: #00f5d4 !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-weight: 700 !important;
  letter-spacing: 0.08em;
  text-shadow: 0 0 12px rgba(0, 245, 212, 0.8);
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.theme-dropdown {
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  font-weight: 600;
}

.theme-dropdown option[value="retrowave"],
.theme-dropdown option[value="retrovault"],
.theme-dropdown option[value="retrovolt"] {
  color: #f026d3;
  background: #090514;
}

/* Slider Widget Rendering */
.lv-slider-wrap {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lv-slider-track {
  position: relative;
  width: 100%;
  height: 12px;
  background: #1e293b;
  border-radius: 999px;
  cursor: pointer;
  overflow: visible;
}

.lv-slider-indicator {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: #3b82f6;
  border-radius: 999px;
}

.lv-slider-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  background: #ffffff;
  border: 2px solid #3b82f6;
  border-radius: 50%;
  cursor: grab;
  transition: transform 0.1s ease;
  z-index: 5;
}

.lv-slider-thumb:hover {
  transform: translate(-50%, -50%) scale(1.15);
}

.lv-slider-thumb:active {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.25);
}

/* Vertical Slider */
.lv-slider-vertical .lv-slider-track {
  width: 12px;
  height: 100%;
}

.lv-slider-vertical .lv-slider-indicator {
  left: 0;
  bottom: 0;
  top: auto;
  width: 100%;
  background: #3b82f6;
}

.lv-slider-vertical .lv-slider-thumb {
  left: 50%;
  transform: translate(-50%, 50%);
}

/* Button Widget - Flat and Clean by Default */
.lv-btn-widget {
  width: 100%;
  height: 100%;
  background: #2563eb;
  color: #ffffff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.12s ease;
}

.lv-btn-widget:active {
  transform: scale(0.97);
}

/* Switch Widget */
.lv-switch-widget {
  width: 50px;
  height: 28px;
  background: #1e1135;
  border: 1px solid rgba(0, 245, 212, 0.4);
  border-radius: 14px;
  position: relative;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

.lv-switch-widget.is-checked {
  background: #00f5d4;
  border-color: #00f5d4;
  box-shadow: 0 0 18px rgba(0, 245, 212, 0.75), inset 0 0 6px rgba(255, 255, 255, 0.5);
}

.lv-switch-thumb {
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5), 0 0 6px rgba(255, 255, 255, 0.7);
}

.lv-switch-widget.is-checked .lv-switch-thumb {
  transform: translateX(24px);
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5), 0 0 10px #00f5d4;
}

/* LED Widget */
.lv-led-widget {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 16px #10b981;
}

/* Label Widget */
.lv-label-widget {
  font-family: var(--font-sans);
  color: #f8fafc;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  user-select: none;
}

/* Bar Widget */
.lv-bar-widget {
  width: 100%;
  height: 100%;
  background: #1e293b;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.lv-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b3d 0%, #f59e0b 100%);
  border-radius: 6px;
  transition: width 0.2s ease;
}

/* Spinner Widget */
.lv-spinner-widget {
  width: 100%;
  height: 100%;
  animation: lv-spin 1.2s linear infinite;
}

@keyframes lv-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Right Sidebar (Elements Tree & Property Inspector)
   ========================================================================== */

.sidebar-right {
  width: var(--inspector-w);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
}

/* Top Section: ELEMENTS Tree */
.elements-panel {
  max-height: 240px;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border-subtle);
}

.elements-header {
  height: 38px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.elements-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.elements-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.12);
  padding: 2px 6px;
  border-radius: 10px;
}

.elements-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all 0.12s ease;
  border: 1px solid transparent;
}

.tree-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tree-item.is-selected {
  background: var(--bg-card);
  color: #ffffff;
  border-color: rgba(59, 130, 246, 0.4);
  font-weight: 500;
}

.tree-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.tree-item-icon {
  width: 14px;
  height: 14px;
  color: var(--accent-blue);
  flex-shrink: 0;
}

.tree-item-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-item-type {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-left: 4px;
}

.tree-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

.tree-item:hover .tree-item-actions {
  opacity: 1;
}

.tree-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  display: flex;
}

.tree-action-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

/* Bottom Section: PROPERTY INSPECTOR */
.inspector-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inspector-header {
  height: 38px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}

.inspector-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Collapsible Inspector Sections */
.inspect-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.section-head svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.section-head.collapsed svg {
  transform: rotate(-90deg);
}

.inspect-section.is-collapsed .section-content {
  display: none;
}

.section-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Form Controls & Property Rows */
.prop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.prop-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.prop-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.prop-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text-primary);
  font-size: 11px;
  font-family: var(--font-mono);
  outline: none;
  width: 80px;
  text-align: right;
  transition: border-color 0.15s ease;
}

.prop-input:focus {
  border-color: var(--border-focus);
}

.prop-input-full {
  width: 100%;
  text-align: left;
}

.prop-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text-primary);
  font-size: 11px;
  outline: none;
  cursor: pointer;
  width: 100%;
}

.prop-select:focus {
  border-color: var(--border-focus);
}

/* Color Picker with Hex Input */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-swatch-wrap {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border-medium);
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}

.color-swatch-wrap input[type="color"] {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 50px;
  height: 50px;
  opacity: 0;
  cursor: pointer;
}

.color-swatch-display {
  width: 100%;
  height: 100%;
  background: #3b82f6;
}

.color-hex-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text-primary);
  font-size: 11px;
  font-family: var(--font-mono);
  width: 85px;
  text-transform: uppercase;
}

/* Slider Controls */
.slider-control-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.slider-input-range {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #1e293b;
  outline: none;
}

.slider-input-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-blue);
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Toggle Switch Control */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.ui-toggle {
  width: 36px;
  height: 20px;
  background: #334155;
  border-radius: 10px;
  position: relative;
  transition: background 0.2s ease;
  cursor: pointer;
}

.ui-toggle.is-active {
  background: var(--accent-blue);
}

.ui-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ui-toggle.is-active::after {
  transform: translateX(16px);
}

/* Multi-color gradient stops preview */
.gradient-bar-preview {
  height: 18px;
  border-radius: 6px;
  border: 1px solid var(--border-medium);
  margin-top: 4px;
}

.gradient-presets-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.gradient-preset-btn {
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.gradient-preset-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Code Drawer / Split View & Full Code Mode
   ========================================================================== */

.code-view-container {
  display: none;
  flex-direction: column;
  background: #0d1117;
  border-left: 1px solid var(--border-subtle);
  overflow: hidden;
  position: relative;
}

.app-root[data-mode="split"] .code-view-container {
  display: flex;
  width: 450px;
  flex-shrink: 0;
}

.app-root[data-mode="code"] .canvas-area {
  display: none;
}
.app-root[data-mode="code"] .sidebar-left {
  display: none;
}
.app-root[data-mode="code"] .sidebar-right {
  display: none;
}
.app-root[data-mode="code"] .code-view-container {
  display: flex;
  flex: 1;
}

.code-header {
  height: 44px;
  background: #161b22;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.code-tabs {
  display: flex;
  gap: 4px;
}

.code-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.code-tab-btn.active {
  background: var(--bg-card);
  color: #58a6ff;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
}

.code-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-content-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
  padding: 16px;
}

.code-pre {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: #c9d1d9;
  white-space: pre;
  tab-size: 2;
  user-select: text;
}

/* Syntax Highlighting Colors */
.code-pre .hl-keyword { color: #ff7b72; font-weight: 600; }
.code-pre .hl-type { color: #79c0ff; }
.code-pre .hl-function { color: #d2a8ff; }
.code-pre .hl-string { color: #a5d6ff; }
.code-pre .hl-number { color: #79c0ff; }
.code-pre .hl-comment { color: #8b949e; font-style: italic; }

/* ==========================================================================
   Preview Mode Simulation
   ========================================================================== */

.app-root[data-mode="preview"] .sidebar-left,
.app-root[data-mode="preview"] .sidebar-right,
.app-root[data-mode="preview"] .canvas-subbar,
.app-root[data-mode="preview"] .screen-tabs-bar,
.app-root[data-mode="preview"] .canvas-bottom-bar,
.app-root[data-mode="preview"] .canvas-selection-layer {
  display: none !important;
}

.app-root[data-mode="preview"] .display-bezel {
  box-shadow: 
    0 0 0 1px rgba(255, 255, 255, 0.15),
    0 30px 80px rgba(0, 0, 0, 0.9),
    0 0 60px rgba(59, 130, 246, 0.2);
}

.preview-pill-notice {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 19, 33, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.app-root[data-mode="preview"] .preview-pill-notice {
  display: flex;
}

/* ==========================================================================
   Modals & Overlays (Presets, Help, Export)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  width: 90%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s var(--ease-smooth);
}

.modal-backdrop.is-open .modal-dialog {
  transform: scale(1);
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

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

/* Presets Grid */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.preset-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-card:hover {
  background: var(--bg-card);
  border-color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.preset-card-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.preset-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.preset-card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-tag {
  font-size: 10px;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

/* Keyboard Shortcuts Grid */
.shortcuts-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.shortcut-key {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--accent-blue);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast-msg {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toast-in 0.25s var(--ease-smooth);
}

@keyframes toast-in {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
