@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --topbar-h: 54px;
  --left-w: 272px;
  --right-w: 292px;
  --canvas-bg: #0f1117;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dim: rgba(99, 102, 241, 0.12);
  --surface: #1a1d27;
  --surface2: #21253a;
  --border: rgba(255, 255, 255, 0.07);
  --border-light: rgba(255, 255, 255, 0.04);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --panel-bg: #13151f;
  --panel-hover: rgba(255, 255, 255, 0.04);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--canvas-bg);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ─── App Shell ─────────────────────────────────────────────── */
#appShell {
  display: grid;
  grid-template-columns: var(--left-w) 1fr var(--right-w);
  grid-template-rows: var(--topbar-h) calc(100vh - var(--topbar-h));
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
  grid-column: 1/4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: linear-gradient(135deg, #0d0f1a 0%, #131728 100%);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  backdrop-filter: blur(20px);
}

.brand {
  font-weight: 800;
  font-size: 13.5px;
  white-space: nowrap;
  color: #fff;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--accent-dim);
  color: var(--accent-light);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 5px;
  padding: 2px 7px;
}

.toolbar {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
  align-items: center;
}

/* Topbar buttons - modern minimal */
.toolbar .btn {
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 7px;
  transition: all .15s ease;
  white-space: nowrap;
  line-height: 1.4;
}

.toolbar .btn-outline-secondary {
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
}

.toolbar .btn-outline-secondary:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.toolbar .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.toolbar .btn-primary:hover {
  background: #5254cc;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.toolbar .btn-success {
  background: #059669;
  border-color: #059669;
  color: #fff;
}

.toolbar .btn-success:hover {
  background: #047857;
  transform: translateY(-1px);
}

.toolbar .btn-outline-success {
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
  background: rgba(16, 185, 129, 0.06);
}

.toolbar .btn-outline-success:hover {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
}

.save-status {
  font-size: 10.5px;
  align-self: center;
  color: var(--text-muted);
  min-width: 50px;
  font-weight: 500;
}

/* ─── Panels ─────────────────────────────────────────────────── */
.left-panel,
.right-panel {
  position: relative;
  background: var(--panel-bg);
  height: 100%;
  max-height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
}

.left-panel {
  border-right: 1px solid var(--border);
}

.right-panel {
  border-left: 1px solid var(--border);
}

.panel-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden !important;
  border-bottom: 1px solid var(--border-light);
}

.panel-section>.panel-title {
  margin: 0;
  flex-shrink: 0;
}

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: color .15s, background .15s;
}

.section-toggle::after {
  content: '−';
  margin-left: auto;
  font-size: 15px;
  line-height: 1;
  color: var(--text-muted);
}

.section-toggle[aria-expanded=false]::after {
  content: '+';
}

.section-toggle:hover {
  background: var(--panel-hover);
  color: var(--text-secondary);
}

.section-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.panel-section.is-collapsed {
  flex: 0 0 auto !important;
  height: auto !important;
  min-height: 0 !important;
}

.panel-section:not(.is-collapsed) {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  height: auto;
}

.panel-section-body {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  height: 100%;
  padding: 0 12px 12px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.panel-section-body::-webkit-scrollbar {
  width: 3px;
}

.panel-section-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.panel-section-body[hidden] {
  display: none !important;
}

.panel-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 5px;
  z-index: 20;
  cursor: col-resize;
  touch-action: none;
}

.left-panel>.panel-resizer {
  right: -3px;
}

.right-panel>.panel-resizer {
  left: -3px;
}

.panel-resizer:hover,
.panel-resizer:focus {
  background: rgba(99, 102, 241, 0.3);
}

/* ─── Workspace ──────────────────────────────────────────────── */
.workspace {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.workspace-bar {
  height: 42px;
  flex: 0 0 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 15, 26, 0.95);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  font-size: 12px;
}

.workspace-bar strong {
  color: var(--text-primary);
  font-weight: 600;
}

.workspace-bar>div:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-bar>div:last-child {
  flex-shrink: 0;
}

/* Zoom control */
#zoomRange {
  accent-color: var(--accent);
  width: 90px;
}

#zoomLabel {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.canvas-viewport {
  flex: 1;
  overflow: auto;
  background: var(--canvas-bg);
  padding: 40px 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.canvas-viewport::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.canvas-viewport::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Grid dots background on canvas */
.canvas-viewport {
  background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: var(--canvas-bg);
}

.device-canvas {
  width: 390px;
  height: 844px;
  background: #fff;
  position: relative;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 32px 80px rgba(0, 0, 0, 0.8);
  transform-origin: top center;
  overflow: hidden;
  border-radius: 22px;
}

/* ─── Canvas Components ──────────────────────────────────────── */
.canvas-component {
  position: absolute;
  user-select: none;
  min-width: 20px;
  min-height: 20px;
  border: 1px solid transparent;
  cursor: move;
}

.canvas-component.selected {
  border: 1.5px solid var(--accent);
  outline: 2px solid rgba(99, 102, 241, 0.15);
}

.canvas-component .resize-handle {
  display: none;
  position: absolute;
  width: 9px;
  height: 9px;
  right: -5px;
  bottom: -5px;
  background: var(--accent);
  border: 2px solid white;
  border-radius: 50%;
  cursor: nwse-resize;
}

.canvas-component.selected .resize-handle {
  display: block;
}

/* ─── Component Palette ──────────────────────────────────────── */
.component-palette {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.palette-category {
  min-width: 0;
}

.palette-category-title {
  margin: 0 0 7px;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
}

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

.palette-item {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  padding: 0;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  color: var(--text-secondary);
  position: relative;
  transition: all .15s ease;
}

.palette-item:hover {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
}

.palette-item:active {
  transform: translateY(0);
}

.palette-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.palette-item.dragging {
  opacity: .4;
  border-style: dashed;
}

.palette-item[draggable=true] {
  cursor: grab;
}

.palette-item[draggable=true]:active {
  cursor: grabbing;
}

.palette-item:only-child {
  grid-column: 1/-1;
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
}

.palette-preview {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
  pointer-events: none;
  position: relative;
}

.palette-preview-content {
  display: block;
  position: absolute;
  flex-shrink: 0;
  transform-origin: center;
  pointer-events: none;
}

.palette-info {
  display: flex;
  flex-direction: column;
  padding: 5px 7px;
  min-width: 0;
}

.palette-label {
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0;
}

.palette-mapping {
  font-size: 8.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.palette-help,
.palette-count,
.palette-empty {
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.5;
}

.palette-help {
  margin: 0 0 10px;
}

.palette-count {
  margin: 6px 0 12px;
}

.palette-platform {
  float: right;
  text-transform: none;
  letter-spacing: 0;
  font-size: 9px;
  color: #34d399;
  background: rgba(16, 185, 129, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.palette-category-toggle {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .15s;
}

.palette-category-toggle::before {
  content: '▾';
  font-size: 9px;
  color: var(--text-muted);
  transition: transform .2s;
}

.palette-category-toggle.is-collapsed::before {
  transform: rotate(-90deg);
}

.palette-category-toggle:hover {
  color: var(--text-primary);
}

.palette-cat-count {
  font-size: 9.5px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: auto;
}

.palette-fav {
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 12px;
  color: #444;
  cursor: pointer;
  z-index: 2;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s, color .15s;
}

.palette-item:hover .palette-fav,
.palette-fav.is-fav {
  opacity: 1;
}

.palette-fav.is-fav {
  color: #f59e0b;
}

.palette-fav:hover {
  color: #d97706;
  transform: scale(1.2);
}

.palette-pinned {
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 4px;
}

/* ─── Inputs inside right panel ──────────────────────────────── */
.form-control,
.form-select {
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 12px !important;
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(99, 102, 241, 0.5) !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  outline: none !important;
}

.form-control::placeholder {
  color: var(--text-muted) !important;
}

.form-label,
label {
  color: var(--text-secondary) !important;
  font-size: 11px !important;
}

.btn-sm {
  font-size: 11px;
  padding: 4px 10px;
}

.btn-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
}

.btn-primary:hover {
  background: #5254cc !important;
}

.btn-outline-secondary {
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: var(--text-secondary) !important;
  background: transparent !important;
}

.btn-outline-secondary:hover {
  border-color: rgba(255, 255, 255, 0.25) !important;
  color: var(--text-primary) !important;
  background: rgba(255, 255, 255, 0.06) !important;
}

/* ─── Screen list ─────────────────────────────────────────────── */
.screen-list,
.layer-list,
.asset-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
}

.screen-list::-webkit-scrollbar,
.layer-list::-webkit-scrollbar,
.asset-list::-webkit-scrollbar {
  width: 3px;
}

.screen-list::-webkit-scrollbar-thumb,
.layer-list::-webkit-scrollbar-thumb,
.asset-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

.screen-item,
.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 11.5px;
  cursor: pointer;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  transition: all .15s;
}

.screen-item:hover,
.layer-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.screen-item.active {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(99, 102, 241, 0.1);
  color: var(--text-primary);
  font-weight: 600;
}

.screen-item.selected:not(.active) {
  border-color: rgba(99, 102, 241, 0.25);
  background: rgba(99, 102, 241, 0.06);
}

.screen-item .screen-checkbox {
  cursor: pointer;
  accent-color: var(--accent);
}

/* Delete button in screen items */
.screen-delete {
  font-size: 11px;
  opacity: 0.4;
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  padding: 0 2px;
  transition: opacity .15s;
}

.screen-item:hover .screen-delete {
  opacity: 0.8;
}

/* ─── Template List — Modern Cards ─────────────────────────────── */
.template-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.template-item {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  transition: all .2s ease;
  display: flex;
  flex-direction: column;
}

.template-item:hover {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.07);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.template-item.is-selected {
  border-color: rgba(99, 102, 241, 0.6);
  background: rgba(99, 102, 241, 0.12);
}

/* Template preview area (mini mockup) */
.template-preview {
  height: 72px;
  background: linear-gradient(145deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.06));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}

.template-preview-icon {
  font-size: 22px;
  opacity: 0.6;
  transition: opacity .2s, transform .2s;
}

.template-item:hover .template-preview-icon {
  opacity: 0.9;
  transform: scale(1.1);
}

/* Mini mockup elements inside preview */
.tpl-mock {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 70%;
}

.tpl-mock-bar {
  height: 7px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
}

.tpl-mock-bar.w-full {
  width: 100%;
}

.tpl-mock-bar.w-half {
  width: 55%;
}

.tpl-mock-bar.w-third {
  width: 35%;
}

.tpl-mock-block {
  height: 24px;
  border-radius: 5px;
  background: rgba(99, 102, 241, 0.25);
}

.tpl-mock-row {
  display: flex;
  gap: 4px;
}

.tpl-mock-row .tpl-mock-bar {
  flex: 1;
}

.tpl-mock-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.3);
  flex-shrink: 0;
}

/* Template info area */
.template-info {
  padding: 7px 9px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.template-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.template-desc {
  font-size: 9.5px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
}

/* The + button to add template as screen */
.template-add-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--accent-light);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s ease;
  flex-shrink: 0;
  font-weight: 600;
}

.template-add-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 3px 8px rgba(99, 102, 241, 0.4);
}

/* Starter kit button */
.template-kit {
  grid-column: 1/-1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
  color: var(--accent-light);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s ease;
  text-align: center;
}

.template-kit:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(139, 92, 246, 0.16));
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}

.template-kit .kit-icon {
  font-size: 16px;
}

/* ─── Properties Panel ────────────────────────────────────────── */
#propertiesForm label {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 2px;
}

#propertiesForm .form-control,
#propertiesForm .form-select {
  font-size: 11.5px !important;
}

/* ─── Preview Mode ────────────────────────────────────────────── */
.preview-mode .canvas-component {
  border-color: transparent !important;
  cursor: default;
}

.preview-mode .resize-handle {
  display: none !important;
}

body.preview-mode .left-panel,
body.preview-mode .right-panel {
  opacity: .25;
  pointer-events: none;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width:1200px) {
  :root {
    --left-w: 240px;
    --right-w: 260px;
  }
}

@media (max-width:1000px) {
  :root {
    --left-w: 210px;
    --right-w: 240px;
  }
}

@media(max-width:900px) {
  #appShell {
    min-width: 840px;
  }

  html,
  body {
    overflow-x: auto;
  }

  .brand .badge {
    display: none;
  }
}

/* ─── Asset Manager ───────────────────────────────────────────── */
.asset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  font-size: 11px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: all .15s;
}

.asset-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.asset-item.dragging {
  opacity: 0.5;
  border-style: dashed;
}

.asset-thumb {
  width: 32px;
  height: 32px;
  border-radius: 5px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
}

.asset-meta {
  min-width: 0;
}

.asset-name {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.asset-badge {
  display: inline-block;
  font-size: 8.5px;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.2;
  margin-top: 2px;
}

.asset-badge-used {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.asset-badge-unused {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.asset-actions button {
  opacity: 0.5;
  transition: opacity .15s, transform .15s;
  font-size: 12px;
  line-height: 1;
  padding: 2px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
}

.asset-item:hover .asset-actions button {
  opacity: 1;
}

.asset-actions button:hover {
  transform: scale(1.2);
}

.asset-empty {
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}

/* ─── Icons Panel — SMALLER FONT ─────────────────────────────── */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 5px;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 2px;
  align-content: start;
}

.icon-grid::-webkit-scrollbar {
  width: 3px;
}

.icon-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

.icon-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  cursor: grab;
  transition: all .15s ease;
  user-select: none;
}

.icon-grid-item:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.55);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.icon-grid-item:active {
  cursor: grabbing;
  transform: scale(0.94);
}

/* Icon SVG — bright & visible */
.icon-grid-item-svg {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #dde3f0;
}

.icon-grid-item-svg svg {
  width: 20px;
  height: 20px;
  stroke: #dde3f0;
}

.icon-grid-item:hover .icon-grid-item-svg {
  color: #a5b4fc;
}

.icon-grid-item:hover .icon-grid-item-svg svg {
  stroke: #a5b4fc;
}

/* Icon label */
.icon-grid-item-name {
  font-size: 8.5px;
  color: #8fa0b8;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  font-weight: 500;
  line-height: 1.2;
}

/* ── Actual icon renderer classes (used by panels.js / icon renderer) ── */
.icon-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: #dde3f0;
}

.icon-preview svg {
  width: 22px;
  height: 22px;
  stroke: #dde3f0;
  fill: none;
}

.icon-grid-item:hover .icon-preview {
  color: #a5b4fc;
}

.icon-grid-item:hover .icon-preview svg {
  stroke: #a5b4fc;
}

.icon-label {
  font-size: 8.5px;
  color: #8fa0b8;
  text-align: center;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: block;
  font-weight: 500;
  line-height: 1.2;
}

/* Icon category pills */
.icon-category-pills {
  gap: 5px !important;
}

.icon-category-pills .btn {
  font-size: 9.5px !important;
  padding: 3px 8px !important;
  border-radius: 20px !important;
  font-weight: 600;
}

/* ─── Layer Items ─────────────────────────────────────────────── */
.layer-item {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
}

.layer-item.border-primary {
  border-color: rgba(99, 102, 241, 0.5) !important;
  background: rgba(99, 102, 241, 0.1) !important;
  color: var(--text-primary) !important;
}

.layer-item-actions {
  display: flex;
  align-items: center;
  gap: 1px;
}

.layer-item-actions button {
  opacity: 0.5;
  padding: 2px 3px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 10.5px;
  line-height: 1;
  border-radius: 3px;
  transition: opacity .15s, background .15s;
  color: var(--text-secondary);
}

.layer-item-actions button:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

/* ─── Modals ─────────────────────────────────────────────────── */
.modal-content {
  background: #1a1d27 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: var(--text-primary) !important;
  border-radius: 16px !important;
}

.modal-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
}

.modal-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
}

.modal-title {
  color: var(--text-primary) !important;
  font-weight: 700 !important;
}

.btn-close {
  filter: invert(1) opacity(0.5);
}

.btn-close:hover {
  filter: invert(1) opacity(0.9);
}

/* Output modal textarea */
#outputText {
  background: rgba(0, 0, 0, 0.3) !important;
  color: #e2e8f0 !important;
  border: 1px solid rgba(255, 255, 255, 0.07) !important;
  font-size: 12px !important;
}

/* ─── Component Canvas Styles ────────────────────────────────── */
.cmp-text {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.cmp-button {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 12px;
}

.icon {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 4px;
}

.nav-icon {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  margin-right: 4px;
}

.cmp-card {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .1);
  border: 1px solid #e6e8eb;
  padding: 12px;
}

.cmp-container {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  border: 1px dashed #aab2bc;
  background: rgba(245, 247, 250, .7);
}

.cmp-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  background: #edf0f3;
}

.cmp-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  background: #e9eef3;
  color: #67778a;
  font-size: 12px;
}

.cmp-image-placeholder svg {
  width: 36px;
  height: 36px;
}

.cmp-field {
  width: 100%;
  height: 100%;
  position: relative;
  padding-top: 6px;
}

.cmp-field-label {
  position: absolute;
  top: -2px;
  left: 12px;
  padding: 0 4px;
  background: #fff;
  font-size: 11px;
  color: #59616a;
}

.cmp-appbar {
  width: 100%;
  height: 100%;
  background: #f8f9fb;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-weight: 700;
  border-bottom: 1px solid #e1e5ea;
}

.cmp-nav {
  width: 100%;
  height: 100%;
  background: #fafbf9;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid #e1e5ea;
  padding: 0 4px;
  box-sizing: border-box;
}

.cmp-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #5f6368;
  flex: 1;
  height: 100%;
  cursor: pointer;
  user-select: none;
}

.cmp-nav-item.is-active {
  color: #1e293b;
  font-weight: 600;
}

.cmp-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.cmp-nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.cmp-nav-label {
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
}

.cmp-input {
  width: 100%;
  height: 100%;
  border: 1px solid #cfd5dc;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}

/* ─── Mobile Component Styles ────────────────────────────────── */
.mobile-icon,
.mobile-avatar {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: #eaf0eb;
  color: #365743;
  font-size: 22px;
  font-weight: 600;
}

.mobile-avatar {
  border-radius: 50%;
}

.mobile-spacer {
  width: 100%;
  height: 100%;
}

.palette-preview .mobile-spacer {
  border: 1px dashed rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6c7864;
  font-size: 20px;
}

.palette-preview .mobile-spacer::after {
  content: 'Spacing';
}

.mobile-search {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: #f4f6f3;
  border-radius: 8px;
  color: #6d766f;
  font-size: 14px;
}

.mobile-search>span {
  font-size: 24px;
}

.mobile-dropdown {
  height: 100%;
  border: 1px solid #d7ded8;
  border-radius: 8px;
  padding: 6px 14px;
}

.mobile-dropdown small {
  display: block;
  font-size: 10px;
  color: #6d766f;
}

.mobile-dropdown>span {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.mobile-choice {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}

.mobile-checkbox,
.mobile-radio {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border: 1px solid #8b978f;
  border-radius: 4px;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.mobile-radio {
  border-radius: 50%;
}

.mobile-choice .is-on {
  background: #42624c;
  border-color: #42624c;
}

.mobile-switch {
  width: 42px;
  height: 24px;
  border-radius: 16px;
  background: #dce2dd;
  padding: 3px;
}

.mobile-switch::after {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
}

.mobile-switch.is-on::after {
  margin-left: 18px;
}

.mobile-slider {
  margin-top: 16px;
  height: 6px;
  border-radius: 4px;
  background: #e2e8e1;
}

.mobile-slider>span {
  display: block;
  height: 100%;
  background: #42624c;
  position: relative;
}

.mobile-slider>span::after {
  content: '';
  position: absolute;
  right: -8px;
  top: -5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #42624c;
}

.mobile-listtile {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #edf0ed;
}

.mobile-tile-icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #eef2eb;
  color: #516348;
  font-size: 12px;
  font-weight: 600;
}

.mobile-listtile>div {
  min-width: 0;
}

.mobile-listtile strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-listtile small {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: #70786f;
}

.mobile-chevron {
  margin-left: auto;
  color: #788276;
}

.mobile-stat {
  height: 100%;
  padding: 16px;
  border: 1px solid #e4e9e1;
  background: #f8faf6;
  border-radius: 12px;
}

.mobile-stat small {
  display: block;
  font-size: 12px;
  color: #697363;
}

.mobile-stat strong {
  display: block;
  font-size: 30px;
  line-height: 1.5;
  letter-spacing: -1px;
  color: #29352b;
}

.mobile-stat>span {
  font-size: 11px;
  color: #57724f;
}

.mobile-badge,
.mobile-chip {
  display: inline-flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 6px;
  background: #edf3e9;
  color: #44623a;
  font-size: 12px;
}

.mobile-chip {
  border: 1px solid #dce5d6;
}

.mobile-tabs {
  height: 100%;
  display: flex;
  border-bottom: 1px solid #e5e9e2;
}

.mobile-tabs>span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #6a7565;
}

.mobile-tabs>.active {
  color: #2f4929;
  border-bottom: 2px solid #47643d;
  font-weight: 600;
}

.mobile-drawer {
  height: 100%;
  padding: 24px 16px;
  background: #f6f8f3;
  border-radius: 12px;
}

.mobile-drawer>strong {
  display: block;
  padding: 0 12px 24px;
}

.mobile-drawer>span {
  display: block;
  margin-bottom: 8px;
  padding: 12px;
  font-size: 14px;
}

.mobile-drawer>.active {
  background: #e4ecde;
  border-radius: 8px;
}

.mobile-dialog {
  height: 100%;
  padding: 28px 24px;
  background: #fff;
  border: 1px solid #e5e9e2;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
}

.mobile-dialog>strong {
  font-size: 22px;
  font-weight: 600;
}

.mobile-dialog>p {
  margin-top: 16px;
  color: #6e7669;
  font-size: 14px;
  line-height: 1.6;
}

.mobile-dialog-action {
  margin-top: auto;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: #395b2d;
}

.mobile-sheet {
  border-radius: 20px 20px 0 0;
}

.mobile-sheet .mobile-sheet-handle {
  width: 32px;
  height: 4px;
  background: #cbd4c5;
  border-radius: 4px;
  margin: -16px auto 20px;
}

.mobile-alert {
  height: 100%;
  padding: 14px 16px;
  background: #eef5e9;
  border-radius: 8px;
  color: #3f6032;
}

.mobile-alert strong,
.mobile-alert small {
  display: block;
  font-size: 13px;
}

.mobile-alert small {
  margin-top: 5px;
  font-size: 12px;
}

.mobile-progress {
  width: 100%;
  height: 100%;
  background: #e9eee5;
  border-radius: 4px;
  overflow: hidden;
}

.mobile-progress>span {
  display: block;
  height: 100%;
  background: #57774b;
}

.mobile-skeleton {
  padding: 12px;
}

.mobile-skeleton>span {
  display: block;
  height: 12px;
  margin: 10px 0;
  width: 100%;
  background: #e9ede6;
  border-radius: 3px;
}

.mobile-skeleton>span:last-child {
  width: 60%;
}

.mobile-empty {
  height: 100%;
  text-align: center;
  padding: 16px;
}

.mobile-empty>span {
  display: block;
  font-size: 36px;
  color: #8d9c85;
}

.mobile-empty>strong {
  display: block;
  font-size: 18px;
}

.mobile-empty>p {
  margin-top: 10px;
  font-size: 13px;
  color: #6c7864;
}

@keyframes skeleton-pulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .4
  }
}

.mobile-richtext {
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 4px;
}

.mobile-textarea {
  height: 100%;
}

.mobile-textarea small {
  display: block;
  font-size: 10px;
  color: #6d766f;
  margin-bottom: 4px;
}

.mobile-textarea-box {
  flex: 1;
  border: 1px solid #d7ded8;
  border-radius: 8px;
  padding: 8px 12px;
  color: #8e958d;
  font-size: 13px;
  min-height: 50px;
}

.mobile-datefield,
.mobile-timefield {
  height: 100%;
  border: 1px solid #d7ded8;
  border-radius: 8px;
  padding: 6px 14px;
}

.mobile-datefield small,
.mobile-timefield small {
  display: block;
  font-size: 10px;
  color: #6d766f;
}

.mobile-datefield>span,
.mobile-timefield>span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.mobile-info-card {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid #e4e9e1;
  border-radius: 12px;
  background: #f8faf6;
}

.mobile-info-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: #eef2eb;
  border-radius: 10px;
  font-size: 18px;
}

.mobile-info-card div {
  min-width: 0;
}

.mobile-info-card strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.mobile-info-card small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #70786f;
}

.mobile-metric-card {
  height: 100%;
  padding: 16px;
  border: 1px solid #e4e9e1;
  background: #f8faf6;
  border-radius: 12px;
}

.mobile-metric-card small {
  display: block;
  font-size: 12px;
  color: #697363;
}

.mobile-metric-card strong {
  display: block;
  font-size: 28px;
  line-height: 1.5;
  letter-spacing: -1px;
  color: #29352b;
}

.trend-up {
  font-size: 12px;
  color: #2e7d32;
  font-weight: 600;
}

.trend-down {
  font-size: 12px;
  color: #c62828;
  font-weight: 600;
}

.mobile-kpi-card {
  height: 100%;
  padding: 16px;
  border: 1px solid #e4e9e1;
  background: #f8faf6;
  border-radius: 12px;
}

.mobile-kpi-card small {
  display: block;
  font-size: 12px;
  color: #697363;
}

.mobile-kpi-card strong {
  display: block;
  font-size: 26px;
  line-height: 1.5;
  color: #29352b;
}

.mobile-progress-card {
  height: 100%;
  padding: 14px 16px;
  border: 1px solid #e4e9e1;
  background: #f8faf6;
  border-radius: 12px;
  font-size: 13px;
}

.mobile-key-value {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 14px;
  border-bottom: 1px solid #edf0ed;
}

.mobile-navrail {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  background: #fafbf9;
  border-right: 1px solid #e5e9e2;
}

.mobile-navrail>span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 12px;
  cursor: pointer;
}

.mobile-navrail>span.active {
  background: #e4ecde;
}

.navrail-icon {
  font-size: 20px;
}

.mobile-navrail small {
  font-size: 10px;
  color: #6a7565;
}

/* Rich Media Component Styles */
.mobile-media-placeholder {
  background: #eef2f6;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-avatar {
  background: #42624c;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  border-radius: 50%;
}

.mobile-thumbnail {
  background: #eef2f6;
}

.mobile-cover-image {
  background: #eef2f6;
}

.mobile-logo {
  background: transparent;
}

.mobile-hero-image {
  background-color: #1e293b;
}

.mobile-image-card {
  transition: box-shadow .15s;
}

.mobile-image-text {
  transition: border-color .15s;
}

.mobile-image-overlay-card {
  background-color: #0f172a;
}

.mobile-image-gallery::-webkit-scrollbar {
  height: 4px;
}

.mobile-image-gallery::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Prevent native browser dragging on canvas images/vectors */
.canvas-component img,
.canvas-component svg {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

/* Image component & fallback wrapper */
.cmp-image-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.cmp-image-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #edf2f7;
  color: #64748b;
  font-size: 11px;
  position: absolute;
  inset: 0;
}

/* Modern Bottom Navigation Styles */
.cmp-nav-floating {
  box-shadow: 0 8px 24px -4px rgba(15, 23, 42, 0.16), 0 2px 6px -1px rgba(15, 23, 42, 0.08) !important;
  border-radius: 24px !important;
  margin: 4px 10px;
}

.cmp-nav-curved {
  position: relative;
  box-shadow: 0 -3px 16px rgba(15, 23, 42, 0.08);
}

.cmp-nav-fab {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.38);
  border: 3px solid #fff;
  cursor: pointer;
  transition: transform .15s ease;
}

.cmp-nav-fab:hover {
  transform: translateX(-50%) scale(1.08);
}

.cmp-nav-fab svg {
  width: 22px;
  height: 22px;
}

/* Modern Sidebar Component */
.cmp-sidebar {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
}

.cmp-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  color: #475569;
}

.cmp-sidebar-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.cmp-sidebar-item.active {
  background: #eff6ff;
  color: #2563eb;
  font-weight: 600;
}

.cmp-sidebar-header {
  border-bottom: 1px solid #f1f5f9;
}

/* ─── Add Screen Button ────────────────────────────────────────── */
#btnAddScreen {
  background: linear-gradient(135deg, var(--accent), #7c3aed) !important;
  border: none !important;
  border-radius: var(--radius-sm) !important;
  font-weight: 600 !important;
  font-size: 11.5px !important;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3) !important;
  transition: all .2s ease !important;
}

#btnAddScreen:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45) !important;
}

/* ─── Misc ─────────────────────────────────────────────────────── */
.text-secondary {
  color: var(--text-muted) !important;
}

.badge {
  font-family: 'Inter', sans-serif;
}

/* Component search input */
#componentSearch,
#assetSearch,
#iconSearch {
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.07) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 11.5px !important;
}

#componentSearch::placeholder,
#assetSearch::placeholder,
#iconSearch::placeholder {
  color: var(--text-muted) !important;
}

#componentSearch:focus,
#assetSearch:focus,
#iconSearch:focus {
  border-color: rgba(99, 102, 241, 0.4) !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08) !important;
  outline: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   THEME TOGGLE BUTTON
═══════════════════════════════════════════════════════════════ */
.theme-toggle-wrap {
  display: flex;
  align-items: center;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 22px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: #fff;
  transition: background .2s, border-color .2s, transform .15s;
  padding: 0;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
  transform: scale(1.08);
}

.theme-icon-dark {
  display: flex;
}

.theme-icon-light {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════
   LIGHT THEME — applied via body.theme-light
═══════════════════════════════════════════════════════════════ */
body.theme-light {
  background: #e8eaed;
}

body.theme-light .topbar {
  background: linear-gradient(135deg, #ffffff, #f8f9fc);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.theme-light .brand {
  color: #1a1d27;
}

body.theme-light .brand .badge {
  background: rgba(91, 94, 220, 0.1);
  color: #5b5edc;
  border-color: rgba(91, 94, 220, 0.2);
}

body.theme-light .toolbar .btn-outline-secondary {
  border-color: rgba(0, 0, 0, 0.15);
  color: #4a5568;
  background: #fff;
}

body.theme-light .toolbar .btn-outline-secondary:hover {
  border-color: rgba(0, 0, 0, 0.28);
  color: #1a1d27;
  background: #f1f3f5;
}

body.theme-light .theme-toggle-btn {
  border-color: rgba(0, 0, 0, 0.18);
  background: rgba(0, 0, 0, 0.06);
  color: #1a1d27;
}

body.theme-light .theme-icon-dark {
  display: none;
}

body.theme-light .theme-icon-light {
  display: flex;
}

body.theme-light .left-panel,
body.theme-light .right-panel {
  background: #ffffff;
}

body.theme-light .left-panel {
  border-right: 1px solid rgba(0, 0, 0, 0.09);
}

body.theme-light .right-panel {
  border-left: 1px solid rgba(0, 0, 0, 0.09);
}

body.theme-light .panel-section {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

body.theme-light .section-toggle {
  color: #718096;
}

body.theme-light .section-toggle:hover {
  background: rgba(0, 0, 0, 0.03);
  color: #4a5568;
}

body.theme-light .workspace-bar {
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.09);
  color: #4a5568;
}

body.theme-light .workspace-bar strong {
  color: #1a1d27;
}

body.theme-light .canvas-viewport {
  background-color: #e2e5ea;
  background-image: radial-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px);
}

body.theme-light .device-canvas {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 24px 60px rgba(0, 0, 0, 0.2);
}

/* Light items */
body.theme-light .screen-item,
body.theme-light .layer-item {
  border-color: rgba(0, 0, 0, 0.08);
  background: #f8f9fb;
  color: #4a5568;
}

body.theme-light .screen-item:hover,
body.theme-light .layer-item:hover {
  border-color: rgba(0, 0, 0, 0.16);
  background: #f0f2f5;
  color: #1a1d27;
}

body.theme-light .screen-item.active {
  border-color: rgba(91, 94, 220, 0.5);
  background: rgba(91, 94, 220, 0.08);
  color: #1a1d27;
}

body.theme-light .screen-item.border-primary,
body.theme-light .layer-item.border-primary {
  border-color: rgba(91, 94, 220, 0.5) !important;
  background: rgba(91, 94, 220, 0.08) !important;
  color: #1a1d27 !important;
}

body.theme-light .palette-item {
  border-color: rgba(0, 0, 0, 0.09);
  background: #f8f9fb;
  color: #4a5568;
}

body.theme-light .palette-item:hover {
  border-color: rgba(91, 94, 220, 0.4);
  background: rgba(91, 94, 220, 0.06);
  color: #1a1d27;
}

body.theme-light .palette-preview {
  background: #eff1f5;
}

body.theme-light .palette-label {
  color: #1a1d27;
}

body.theme-light .palette-category-title {
  color: #718096;
}

body.theme-light .palette-help,
body.theme-light .palette-count,
body.theme-light .palette-mapping {
  color: #718096;
}

body.theme-light .template-item {
  border-color: rgba(0, 0, 0, 0.09);
  background: #f8f9fb;
  color: #4a5568;
}

body.theme-light .template-item:hover {
  border-color: rgba(91, 94, 220, 0.4);
  background: rgba(91, 94, 220, 0.06);
}

body.theme-light .template-preview {
  background: linear-gradient(145deg, rgba(91, 94, 220, 0.07), rgba(139, 92, 246, 0.05));
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.theme-light .tpl-mock-bar {
  background: rgba(0, 0, 0, 0.14);
}

body.theme-light .tpl-mock-block {
  background: rgba(91, 94, 220, 0.2);
}

body.theme-light .template-name {
  color: #1a1d27;
}

body.theme-light .template-desc {
  color: #718096;
}

body.theme-light .template-add-btn {
  background: rgba(91, 94, 220, 0.1);
  border-color: rgba(91, 94, 220, 0.25);
  color: #5b5edc;
}

body.theme-light .template-add-btn:hover {
  background: #5b5edc;
  border-color: #5b5edc;
  color: #fff;
}

body.theme-light .template-kit {
  border-color: rgba(91, 94, 220, 0.2);
  background: linear-gradient(135deg, rgba(91, 94, 220, 0.07), rgba(139, 92, 246, 0.07));
  color: #5b5edc;
}

body.theme-light .template-kit:hover {
  background: linear-gradient(135deg, rgba(91, 94, 220, 0.14), rgba(139, 92, 246, 0.14));
  border-color: rgba(91, 94, 220, 0.4);
  color: #3f42aa;
}

body.theme-light .icon-grid-item {
  border-color: rgba(0, 0, 0, 0.1);
  background: #f2f4f8;
}

body.theme-light .icon-grid-item:hover {
  background: rgba(91, 94, 220, 0.1);
  border-color: rgba(91, 94, 220, 0.4);
}

body.theme-light .icon-preview,
body.theme-light .icon-preview svg {
  color: #334155 !important;
  stroke: #334155 !important;
}

body.theme-light .icon-grid-item:hover .icon-preview,
body.theme-light .icon-grid-item:hover .icon-preview svg {
  color: #5b5edc !important;
  stroke: #5b5edc !important;
}

body.theme-light .icon-label {
  color: #718096;
}

body.theme-light .asset-item {
  border-color: rgba(0, 0, 0, 0.08);
  background: #f8f9fb;
}

body.theme-light .asset-item:hover {
  border-color: rgba(91, 94, 220, 0.3);
  background: #f0f2f5;
}

body.theme-light .asset-name {
  color: #1a1d27;
}

body.theme-light .layer-item-actions button {
  color: #4a5568;
}

body.theme-light .layer-item-actions button:hover {
  background: rgba(0, 0, 0, 0.07);
}

body.theme-light .save-status {
  color: #718096;
}

/* Light form controls */
body.theme-light .form-control,
body.theme-light .form-select {
  background: #f8f9fb !important;
  border: 1px solid rgba(0, 0, 0, 0.14) !important;
  color: #1a1d27 !important;
}

body.theme-light .form-control:focus,
body.theme-light .form-select:focus {
  border-color: rgba(91, 94, 220, 0.5) !important;
  box-shadow: 0 0 0 3px rgba(91, 94, 220, 0.1) !important;
  background: #fff !important;
}

body.theme-light .form-control::placeholder {
  color: #a0aec0 !important;
}

body.theme-light .form-label,
body.theme-light label {
  color: #4a5568 !important;
}

body.theme-light #componentSearch,
body.theme-light #assetSearch,
body.theme-light #iconSearch {
  background: #f4f6f9 !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
  color: #1a1d27 !important;
}

body.theme-light #componentSearch::placeholder,
body.theme-light #assetSearch::placeholder,
body.theme-light #iconSearch::placeholder {
  color: #a0aec0 !important;
}

body.theme-light #componentSearch:focus,
body.theme-light #assetSearch:focus,
body.theme-light #iconSearch:focus {
  border-color: rgba(91, 94, 220, 0.4) !important;
  box-shadow: 0 0 0 3px rgba(91, 94, 220, 0.08) !important;
}

/* Light modals */
body.theme-light .modal-content {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: #1a1d27 !important;
}

body.theme-light .modal-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.07) !important;
}

body.theme-light .modal-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.07) !important;
}

body.theme-light .modal-title {
  color: #1a1d27 !important;
}

body.theme-light .btn-close {
  filter: none;
}

body.theme-light #outputText {
  background: #f4f6f9 !important;
  color: #1a1d27 !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

/* Light scrollbars */
body.theme-light .screen-list::-webkit-scrollbar-thumb,
body.theme-light .layer-list::-webkit-scrollbar-thumb,
body.theme-light .asset-list::-webkit-scrollbar-thumb,
body.theme-light .panel-section-body::-webkit-scrollbar-thumb,
body.theme-light .icon-grid::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}