/* ═══ Base ═══ */
[v-cloak] { display: none; }
:root {
  --bg: #111827;
  --surface: #1f2937;
  --surface2: #283141;
  --border: #374151;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --accent: #4FC3F7;
  --accent-bg: rgba(79,195,247,0.12);
  --danger: #ef4444;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  overflow: hidden;
  height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}
input, textarea, select, button { font-family: inherit; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #666; }

/* ═══ App layout ═══ */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ═══ Header ═══ */
.ed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex: 0 0 auto;
  gap: 8px;
  z-index: 10;
}
.ed-face-name {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 4px 6px;
  min-width: 0;
  flex: 1;
  max-width: 200px;
}
.ed-face-name:focus { outline: none; border-bottom-color: var(--accent); }
.ed-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.ed-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.ed-icon-btn:hover { background: var(--surface); color: var(--text); }
.ed-icon-btn:active { background: var(--surface2); }
.ed-icon-btn:disabled { opacity: 0.3; cursor: default; }
.ed-icon-btn:disabled:hover { background: transparent; color: var(--text-muted); }
.ed-sel-badge {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══ Main content ═══ */
.ed-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
@media (min-width: 768px) {
  .ed-main { flex-direction: row; }
}

/* ═══ Canvas column ═══ */
.ed-canvas-col {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
}
@media (min-width: 768px) {
  .ed-canvas-col {
    flex: 0 0 58%;
    min-width: 380px;
  }
}
.ed-canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0f;
  overflow: hidden;
  padding: 8px;
  min-height: 0;
}
@media (max-width: 767px) {
  .ed-canvas-col { flex: 0 0 auto; }
  .ed-canvas-area {
    max-height: 38dvh;
    min-height: 140px;
  }
  .ed-panels-col { flex: 1 1 0; min-height: 0; }
}
canvas#gaugeCanvas {
  border-radius: 8px;
  border: 1px solid #222;
  image-rendering: auto;
  cursor: crosshair;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  touch-action: none;
}
.canvas-wrapper { position: relative; display: inline-block; line-height: 0; }
.ed-no-cell-prompt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}
.ed-no-cell-icon { opacity: 0.4; }
.ed-no-cell-text { color: #ccc; font-size: 14px; font-weight: 500; }
.ed-no-cell-hint { color: #555; font-size: 11px; }
.grid-cell-overlay {
  border-radius: 2px;
  transition: background 0.15s;
}
.grid-cell-overlay:hover {
  background: rgba(79, 195, 247, 0.08);
  outline: 1px solid rgba(79, 195, 247, 0.3);
}

/* Cell context menu */
.cell-context-menu {
  position: absolute;
  z-index: 50;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 4px 0;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.cell-ctx-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 14px;
  font-size: 12px;
  color: #d1d5db;
  background: none;
  border: none;
  cursor: pointer;
}
.cell-ctx-item:hover:not(:disabled) { background: rgba(255,255,255,0.06); }
.cell-ctx-item:disabled { opacity: 0.3; cursor: default; }
.cell-ctx-danger { color: #f87171; }
.cell-ctx-sep { height: 1px; background: #374151; margin: 3px 0; }

/* Cell picker modal */
.ed-cell-picker { max-width: 480px; max-height: 80vh; overflow-y: auto; }
.cell-picker-section { margin-bottom: 16px; }
.cell-picker-label { font-size: 11px; color: #888; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.cell-picker-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  color: #ccc;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 6px;
  transition: background 0.15s;
}
.cell-picker-btn:hover { background: rgba(255,255,255,0.08); border-color: #444; }
.cell-picker-icon { font-size: 18px; width: 24px; text-align: center; }
.cell-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}
.cell-picker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: rgba(255,255,255,0.03);
  border: 1px solid #222;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.cell-picker-card:hover { background: rgba(79,195,247,0.08); border-color: #4FC3F7; }
.cell-picker-thumb { border-radius: 4px; width: 64px; height: 64px; }
.cell-picker-name { font-size: 10px; color: #999; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 76px; }
.selection-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(79,195,247,0.85);
  color: #000;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  pointer-events: none;
}

/* ═══ Preview bar ═══ */
.ed-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex: 0 0 auto;
}
.ed-layout-picker {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.ed-layout-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px;
  cursor: pointer;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.ed-layout-btn:hover { color: #999; border-color: #333; }
.ed-layout-btn.active { color: var(--accent); border-color: var(--accent); }
.ed-preview-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
  -webkit-appearance: auto;
  appearance: auto;
  flex-shrink: 0;
}
.ed-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  min-width: 60px;
}
.ed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}
.ed-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}
/* Play button */
.ed-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.ed-play-btn:hover { background: var(--surface); color: var(--text); }
.ed-play-btn.active { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.ed-slider:disabled { opacity: 0.4; }

.ed-preview-value {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}
.ed-zone-pill {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  font-weight: 500;
}
.zone-normal { background: rgba(75,85,99,0.4); color: var(--text-muted); }
.zone-warning { background: rgba(202,138,4,0.3); color: #fbbf24; }
.zone-danger { background: rgba(239,68,68,0.3); color: #f87171; }

/* ═══ Panels column ═══ */
.ed-panels-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
@media (min-width: 768px) {
  .ed-panels-col {
    border-left: 1px solid var(--border);
  }
}

/* ═══ Tabs (desktop) ═══ */
.ed-desktop-tabs {
  display: none;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
@media (min-width: 768px) {
  .ed-desktop-tabs { display: flex; }
}
.ed-tab {
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.ed-tab:hover { color: #d1d5db; }
.ed-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ═══ Bottom navigation (mobile) ═══ */
.ed-bottom-nav {
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  flex: 0 0 auto;
  z-index: 10;
}
@media (min-width: 768px) {
  .ed-bottom-nav { display: none; }
}
.ed-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px 6px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s;
  font-size: 10px;
  -webkit-tap-highlight-color: transparent;
}
.ed-nav-item:active { background: rgba(255,255,255,0.05); }
.ed-nav-item.active { color: var(--accent); }
.ed-nav-item svg { flex-shrink: 0; }

/* ═══ Panel base ═══ */
.ed-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.ed-panel-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ed-panel-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

/* ═══ Elements panel ═══ */
.ed-panel-layers {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ed-layers-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.ed-layer-list {
  flex: 1 1 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}
@media (max-width: 767px) {
  .ed-layers-body.has-props .ed-layer-list,
  .ed-layers-body.has-props .ed-layer-toolbar { display: none; }
}
@media (min-width: 768px) {
  .ed-layers-body.has-props .ed-layer-list {
    flex: 1 1 0;
    min-height: 60px;
  }
}
.ed-empty {
  padding: 12px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* Layer items */
.el-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  cursor: pointer;
  border-left: 2px solid transparent;
  font-size: 12px;
  transition: background 0.15s;
  min-height: 40px;
}
.el-item:hover { background: rgba(255,255,255,0.04); }
.el-item.active { background: var(--accent-bg); border-left-color: var(--accent) !important; }
.el-thumb {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  border: 1px solid #2a2a3e;
  image-rendering: auto;
  flex-shrink: 0;
}
.el-action-btn {
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 10px;
  border-radius: 3px;
  transition: all 0.15s;
  flex-shrink: 0;
  min-width: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.el-action-btn:hover { color: var(--text-muted); background: rgba(255,255,255,0.06); }
.el-action-btn.el-vis-off { opacity: 0.3; }
.el-action-del:hover { color: var(--danger); background: rgba(239,68,68,0.1); }
.el-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s;
}
.el-collapse-btn:hover { color: var(--text-muted); }
.el-collapse-btn svg { transition: transform 0.15s; }
.el-type-icon { flex-shrink: 0; margin-right: 2px; }
/* ═══ Layer toolbar ═══ */
.ed-layer-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex: 0 0 auto;
}
.ed-layer-toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.ed-layer-toolbar-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-muted); }
.ed-layer-toolbar-btn:active { background: rgba(255,255,255,0.1); }
.ed-layer-toolbar-btn:disabled { opacity: 0.25; pointer-events: none; }
.ed-layer-add-btn { color: var(--accent); }
.ed-layer-add-btn:hover { background: var(--accent-bg); color: var(--accent); }
.ed-layer-toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 2px;
  flex-shrink: 0;
}

/* ═══ Drag and drop ═══ */
.el-item[draggable="true"] { cursor: grab; }
.el-item[draggable="true"]:active { cursor: grabbing; }
.el-item.dragging { opacity: 0.25; }
.el-item.drag-before { box-shadow: inset 0 2px 0 0 var(--accent); }
.el-item.drag-after { box-shadow: inset 0 -2px 0 0 var(--accent); }
.el-item.drag-into { background: var(--accent-bg) !important; border-left-color: var(--accent) !important; }

/* ═══ Property editor ═══ */
.ed-props {
  border-top: 1px solid var(--border);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 0 1 auto;
  max-height: 55%;
  min-height: 0;
}
.ed-props-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(31,41,55,0.8);
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 5;
}
.ed-props-body {
  padding: 8px 10px 12px;
}
.prop-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 4px;
  margin-bottom: 5px;
}
.prop-label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  padding-right: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prop-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 5px 6px;
  font-size: 12px;
  width: 100%;
  min-height: 32px;
}
.prop-input:focus { outline: none; border-color: var(--accent); }
select.prop-input { appearance: auto; -webkit-appearance: auto; }
.prop-section {
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 0 3px;
  margin-top: 6px;
  border-bottom: 1px solid #252a35;
}
.prop-section:first-child { margin-top: 0; }

/* Resolved value display */
.ed-resolved {
  font-size: 10px;
  color: var(--accent);
  opacity: 0.7;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  padding: 1px 0 0;
}
.ed-resolved-pill {
  font-size: 9px;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #555;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

/* ═══ Palette ═══ */
.palette-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px 0;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  border: 1px solid transparent;
  min-height: 40px;
}
.palette-item:hover { background: var(--accent-bg); border-color: var(--border); }
.palette-item:active { background: rgba(79,195,247,0.18); }
.palette-icon { width: 22px; text-align: center; font-size: 13px; flex-shrink: 0; color: var(--accent); }
.palette-info { overflow: hidden; }
.palette-name { font-size: 11px; color: var(--text); font-weight: 500; }
.palette-desc { font-size: 9px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-header {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 4px 3px;
  margin-top: 4px;
  border-bottom: 1px solid var(--surface);
}

/* ═══ Code panel ═══ */
.ed-panel-code {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ed-code-area {
  flex: 1;
  background: #0d1117;
  color: #c9d1d9;
  padding: 10px;
  width: 100%;
  border: none;
  resize: none;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  tab-size: 2;
  -webkit-overflow-scrolling: touch;
}
.ed-code-area:focus { outline: none; }

/* ═══ Variables ═══ */
.var-row { display: flex; align-items: center; gap: 4px; margin-bottom: 3px; }
.var-row input { font-size: 11px; }
.var-row .hl-back { font-size: 11px; }
.var-name { width: 100%; font-family: monospace; }
.var-name-hl { width: 80px; }
.var-name-hl .hl-back { font-family: monospace; font-size: 11px; }
.var-expr { width: 100%; }
.var-expr-hl { flex: 1; }
.var-expr-hl .hl-back { font-size: 11px; }

/* ═══ Preset cards ═══ */
.preset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  color: inherit;
}
.preset-card:hover { background: var(--surface); border-color: var(--accent); }
.preset-card:active { background: var(--surface2); }
.preset-thumb { border-radius: 6px; width: 80px; height: 80px; image-rendering: auto; }
.preset-name { font-size: 10px; color: #d1d5db; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.preset-tags { font-size: 8px; color: var(--accent); opacity: 0.6; }

/* ═══ Syntax highlight overlay ═══ */
.hl-wrap { position: relative; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.hl-wrap.hl-flex1 { flex: 1; }
.hl-back {
  position: absolute;
  left: 1px; top: 1px; right: 1px; bottom: 1px;
  padding: 5px 6px;
  font-size: 12px;
  font-family: inherit;
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  line-height: normal;
  border-radius: 3px;
}
.hl-wrap > .prop-input {
  background: transparent !important;
  color: transparent !important;
  caret-color: var(--text);
  position: relative;
  z-index: 2;
  width: 100%;
  border: none !important;
}
.hl-wrap:focus-within { border-color: var(--accent); }
.hl-wrap > .prop-input:focus { border: none !important; outline: none; }
.hl-v { color: #67e8f9; }
.hl-f { color: #86efac; }
.hl-c { color: #fdba74; }
.hl-op { color: var(--text-muted); }
.hl-s { color: #fcd34d; }
.hl-n { color: var(--text); }

/* ═══ Buttons ═══ */
.btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-primary { background: var(--accent); color: #000; font-weight: 500; }
.btn-primary:hover { background: #81D4FA; }
.btn-primary:active { background: #29B6F6; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-ghost:active { background: var(--surface2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* ═══ Autocomplete ═══ */
.ac-dropdown {
  position: fixed;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 0;
  min-width: 200px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.ac-item {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.1s;
}
.ac-item:hover, .ac-item:focus { background: var(--accent-bg); outline: none; }

/* ═══ Context menu ═══ */
.ctx-menu {
  position: fixed;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.ctx-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 12px;
  color: #d1d5db;
  cursor: pointer;
  transition: background 0.1s;
}
.ctx-menu-item:hover { background: var(--accent-bg); color: #fff; }
.ctx-menu-item.danger { color: var(--danger); }
.ctx-menu-item.danger:hover { background: rgba(239,68,68,0.12); }
.ctx-menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.ctx-menu-shortcut { font-size: 10px; color: var(--text-dim); margin-left: 16px; }

/* ═══ Settings sheet ═══ */
.ed-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
@media (min-width: 768px) {
  .ed-overlay { align-items: center; }
}
.ed-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 100%;
  border-radius: 16px 16px 0 0;
  padding: 12px 20px calc(16px + var(--safe-bottom));
  animation: sheetUp 0.3s ease-out;
}
@media (min-width: 768px) {
  .ed-sheet {
    max-width: 380px;
    border-radius: 12px;
    padding: 16px 20px;
    animation: fadeScale 0.2s ease-out;
  }
}
.ed-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 12px;
}
@media (min-width: 768px) { .ed-sheet-handle { display: none; } }
.ed-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(55,65,81,0.5);
  gap: 8px;
}
.ed-color-input {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.ed-num-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  width: 70px;
  text-align: center;
}
.ed-num-input:focus { outline: none; border-color: var(--accent); }

/* Toggle switch */
.ed-switch {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}
.ed-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ed-switch-track {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
}
.ed-switch input:checked + .ed-switch-track { background: var(--accent); }
.ed-switch-thumb {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.ed-switch input:checked + .ed-switch-track .ed-switch-thumb {
  transform: translateX(20px);
}

/* ═══ Modals ═══ */
.ed-modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  max-width: 380px;
  width: calc(100% - 32px);
  animation: fadeScale 0.2s ease-out;
}

/* ═══ Toast ═══ */
.ed-toast {
  position: fixed;
  z-index: 60;
  background: var(--accent);
  color: #000;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(70px + var(--safe-bottom));
  animation: toastIn 0.25s ease-out;
}
@media (min-width: 768px) {
  .ed-toast {
    bottom: 16px;
    right: 16px;
    left: auto;
    transform: none;
  }
}

/* ═══ Animations ═══ */
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes fadeScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@media (min-width: 768px) {
  @keyframes toastIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ═══ Responsive helpers ═══ */
@media (max-width: 767px) {
  .ed-hide-mobile { display: none !important; }
}
@media (min-width: 768px) {
  .ed-mobile-only { display: none !important; }
}
.ed-btn-accent {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}
.ed-btn-accent:hover { background: var(--accent-bg); }

/* ═══ Menu bar (desktop) ═══ */
.ed-menubar {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}
@media (max-width: 767px) {
  .ed-menubar { display: none; }
}
.ed-menubar-btn {
  padding: 4px 10px;
  font-size: 13px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  line-height: 1.6;
}
.ed-menubar-btn:hover:not(:disabled) { background: rgba(255,255,255,0.06); color: var(--text); }
.ed-menubar-btn.active { background: rgba(255,255,255,0.1); color: var(--text); }
.ed-menubar-btn:disabled { opacity: 0.3; cursor: default; }

/* Hamburger (mobile) */
.ed-hamburger { display: none; }
@media (max-width: 767px) {
  .ed-hamburger { display: flex; }
}

/* ═══ Desktop dropdown ═══ */
.ed-dropdown {
  position: fixed;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  min-width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: fadeScale 0.12s ease-out;
}
.ed-dropdown-insert {
  min-width: 260px;
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ed-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.08s;
}
.ed-dropdown-item:hover { background: var(--accent-bg); }
.ed-dropdown-item:active { background: rgba(79,195,247,0.18); }
.ed-dropdown-item:disabled { opacity: 0.3; pointer-events: none; }
.ed-dropdown-danger { color: var(--danger); }
.ed-dropdown-danger:hover { background: rgba(239,68,68,0.1); }
.ed-dropdown-sep { height: 1px; background: var(--border); margin: 4px 8px; }
.ed-dropdown-sc { margin-left: auto; font-size: 10px; color: var(--text-dim); padding-left: 16px; }
.ed-dropdown-header {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 14px 3px;
}
.ed-dropdown-header:first-child { padding-top: 4px; }
.ed-dropdown-icon {
  width: 18px;
  text-align: center;
  font-size: 12px;
  flex-shrink: 0;
  color: var(--accent);
}
.ed-dropdown-desc {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}
.ed-menu-clickaway {
  position: fixed;
  inset: 0;
  z-index: 199;
}

/* ═══ Mobile menu sheet ═══ */
.ed-mobile-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 14px 20px 4px;
}
.ed-mobile-section:first-of-type { padding-top: 4px; }
.ed-mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.ed-mobile-menu-item:hover { background: var(--accent-bg); }
.ed-mobile-menu-item:active { background: rgba(79,195,247,0.18); }
.ed-mobile-menu-item:disabled { opacity: 0.35; pointer-events: none; }
.ed-mobile-shortcuts {
  padding: 12px 20px 4px;
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.8;
}
.ed-mobile-shortcuts kbd {
  font-family: inherit;
  color: var(--text-muted);
}

/* ═══ Close button ═══ */
.ed-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.ed-close-btn:hover { background: var(--surface2); color: var(--text); }

/* ═══ Empty layers state ═══ */
.ed-empty-layers {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 8px;
}

/* ═══ Add element modal (mobile + empty state CTA) ═══ */
.ed-add-panel {
  background: var(--surface);
  width: 100%;
  max-width: 100%;
  border-radius: 16px 16px 0 0;
  padding: 8px 0 calc(12px + var(--safe-bottom));
  animation: sheetUp 0.3s ease-out;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) {
  .ed-add-panel {
    max-width: 520px;
    border-radius: 12px;
    padding: 8px 0 12px;
    animation: fadeScale 0.2s ease-out;
    max-height: 70vh;
  }
}
.ed-add-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 8px;
  flex: 0 0 auto;
}
.ed-add-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px;
}
.ed-add-conditional {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 8px 4px 0;
  border-radius: 8px;
  border: 1px dashed var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.ed-add-conditional:hover { background: rgba(250,204,21,0.08); border-color: rgba(250,204,21,0.3); }
.ed-add-conditional:active { background: rgba(250,204,21,0.12); }


/* ═══ Utilities ═══ */
.hidden { display: none !important; }
