/* Figma-class editor — light UI theme */
@font-face { font-family: 'Inter'; src: url('fonts/inter-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter-800.woff2') format('woff2'); font-weight: 800; font-display: swap; }
:root {
  --accent: #0D99FF;
  --accent-dim: #BFE3FF;
  --panel: #FFFFFF;
  --panel2: #FBFBFB;
  --border: #E5E5E5;
  --text: #1E1E1E;
  --text2: #5A5A5A;
  --text3: #999;
  --hover: #F1F1F1;
  --sel: #E8F4FF;
  --radius: 6px;
  --font: "Inter", -apple-system, "SF Pro Text", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; }
html, body, #app { height: 100%; overflow: hidden; }
body { font-family: var(--font); font-size: 12px; color: var(--text); background: #f5f5f5; }
button { font-family: inherit; font-size: inherit; border: none; background: none; cursor: pointer; color: inherit; }
button:disabled { opacity: 0.35; cursor: default; }
input, select, textarea { font-family: inherit; font-size: 12px; color: var(--text); }
select:focus, input:focus { outline: none; }
.ic { width: 16px; height: 16px; display: block; flex: 0 0 16px; }
.kbd { color: var(--text3); font-size: 11px; }

#app { display: flex; flex-direction: column; }
#main { flex: 1; display: flex; min-height: 0; }

/* ---------- topbar ---------- */
#topbar {
  height: 44px; background: #2C2C2C; color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px; z-index: 40; position: relative;
}
.tb-left, .tb-right, .tb-center { display: flex; align-items: center; gap: 4px; }
.tb-center { position: absolute; left: 50%; transform: translateX(-50%); background: #383838; border-radius: 8px; padding: 3px; gap: 1px; }
.logo-btn { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.logo-btn:hover { background: #444; }
.logo-btn .ic { color: #fff; }
.tb-name {
  background: transparent; border: none; color: #ddd; font-size: 12px; width: 150px;
  padding: 4px 6px; border-radius: 4px;
}
.tb-name:hover { background: #3a3a3a; }
.tb-name:focus { background: #454545; color: #fff; }
.tb-saved { color: #8a8a8a; font-size: 11px; padding: 0 4px; }
.tb-saved.saving { color: #bbb; }
.tool-wrap { position: relative; display: flex; }
.tool-btn {
  width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  color: #cfcfcf;
}
.tool-wrap .tool-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tool-btn:hover { background: #4a4a4a; color: #fff; }
.tool-btn.active { background: var(--accent); color: #fff; }
.tool-chev {
  width: 12px; height: 32px; border-radius: 0 6px 6px 0; display: flex; align-items: center; justify-content: center;
  color: #8a8a8a; padding: 0;
}
.tool-chev:hover { background: #4a4a4a; color: #fff; }
.tool-chev .ic { width: 10px; height: 10px; }
.tool-btn.active + .tool-chev, .tool-wrap:has(.tool-btn.active) .tool-chev { background: var(--accent); color: #fff; }
.tb-divider { width: 1px; height: 20px; background: #555; margin: 0 4px; }
.zoom-btn {
  height: 30px; padding: 0 8px; border-radius: 6px; color: #ddd; font-size: 12px;
  display: flex; align-items: center; gap: 4px;
}
.zoom-btn:hover { background: #444; }
.zoom-btn .ic { width: 10px; height: 10px; }
.tb-collab { display: flex; margin: 0 6px; }
.collab-avatar {
  width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: 9px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; border: 2px solid #2c2c2c; margin-left: -6px;
}
.share-btn {
  background: var(--accent); color: #fff; font-weight: 500; height: 30px; padding: 0 12px;
  border-radius: 6px; display: flex; align-items: center; gap: 6px;
}
.share-btn:hover { background: #28a5ff; }
.share-btn .ic { width: 12px; height: 12px; }

/* ---------- left panel ---------- */
#layers-panel {
  width: 240px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  transition: margin-left 0.15s ease;
}
#layers-panel.closed { margin-left: -241px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px 12px; }
.panel-title { font-weight: 600; font-size: 11px; color: var(--text2); }
.panel-head .tb-btn { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.panel-head .tb-btn:hover { background: var(--hover); }
.panel-subhead { padding: 6px 12px 4px; font-size: 10px; color: var(--text3); font-weight: 600; display: none; }
.pages { padding: 0 6px 4px; border-bottom: 1px solid var(--border); }
.page-row {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 5px;
  color: var(--text2); cursor: pointer;
}
.page-row .ic { width: 13px; height: 13px; }
.page-row:hover { background: var(--hover); }
.page-row.active { color: var(--text); font-weight: 500; background: var(--sel); }
.tree { flex: 1; overflow-y: auto; padding: 4px 6px 40px; }
.tree-empty { color: var(--text3); padding: 20px 12px; line-height: 1.6; font-size: 11px; }
.layer-row {
  display: flex; align-items: center; height: 28px; border-radius: 5px;
  cursor: pointer; position: relative; gap: 2px; padding-right: 4px;
  color: var(--text2);
}
.layer-row:hover { background: var(--hover); }
.layer-row.hovered { background: var(--sel); }
.layer-row.selected { background: var(--accent); color: #fff; }
.layer-row.selected .layer-name { color: #fff; }
.layer-chev { width: 14px; height: 14px; display: flex; align-items: center; justify-content: center; flex: 0 0 14px; }
.layer-chev .ic { width: 10px; height: 10px; }
.layer-icon { width: 16px; display: flex; align-items: center; flex: 0 0 16px; opacity: 0.8; }
.layer-icon .ic { width: 12px; height: 12px; }
.layer-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.layer-name.layer-hidden { text-decoration: line-through; opacity: 0.6; }
.layer-actions { display: none; gap: 0; }
.layer-row:hover .layer-actions, .layer-row .layer-act.on { display: flex; }
.layer-row .layer-act.on { display: flex; }
.layer-act { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border-radius: 4px; opacity: 0.7; }
.layer-act:hover { background: rgba(0,0,0,0.1); opacity: 1; }
.layer-row.selected .layer-act:hover { background: rgba(255,255,255,0.25); }
.layer-act .ic { width: 12px; height: 12px; }
.layer-row.drop-before::before, .layer-row.drop-after::after {
  content: ''; position: absolute; left: 4px; right: 4px; height: 2px; background: var(--accent); border-radius: 1px;
}
.layer-row.drop-before::before { top: -1px; }
.layer-row.drop-after::after { bottom: -1px; }
.layer-row.drop-inside { box-shadow: inset 0 0 0 1.5px var(--accent); }
.rename-input {
  flex: 1; min-width: 0; border: 1px solid var(--accent); border-radius: 3px; padding: 2px 4px;
  font-size: 12px; background: #fff; color: var(--text);
}

/* ---------- canvas ---------- */
#canvas-wrap { flex: 1; position: relative; min-width: 0; overflow: hidden; }
#canvas { position: absolute; inset: 0; display: block; outline: none; }
#overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#mobile-hint { display: none; }
.text-overlay {
  position: absolute; pointer-events: auto; border: 1.5px solid var(--accent); border-radius: 2px;
  background: rgba(255,255,255,0.02); resize: none; outline: none; overflow: hidden;
  padding: 0; margin: 0; caret-color: var(--accent);
}

/* ---------- inspector ---------- */
#inspector {
  width: 256px; background: var(--panel); border-left: 1px solid var(--border);
  overflow-y: auto; min-height: 0;
  transition: margin-right 0.15s ease;
}
#inspector.closed { margin-right: -257px; }
.insp-tabs { display: flex; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 5; }
.insp-tab { flex: 1; padding: 10px 0; font-size: 11px; color: var(--text2); font-weight: 500; }
.insp-tab:hover { color: var(--text); }
.insp-tab.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.insp-section { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }
.insp-section-title {
  font-size: 11px; font-weight: 600; color: var(--text); margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.insp-section-title .add-btn { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border-radius: 4px; color: var(--text2); }
.insp-section-title .add-btn:hover { background: var(--hover); color: var(--text); }
.insp-align { display: flex; align-items: center; gap: 2px; padding: 8px 12px; border-bottom: 1px solid #f0f0f0; }
.align-btn { width: 26px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 4px; color: var(--text2); }
.align-btn:hover { background: var(--hover); color: var(--text); }
.align-btn.on { color: var(--accent); }
.insp-sep { width: 1px; height: 16px; background: var(--border); margin: 0 6px; }
.insp-pos { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; }
.insp-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.insp-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.insp-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.field {
  display: flex; align-items: center; height: 28px; border: 1px solid transparent; border-radius: 5px;
  background: #f5f5f5; padding: 0 6px; gap: 4px; min-width: 0;
}
.field:hover { border-color: var(--border); }
.field:focus-within { border-color: var(--accent); background: #fff; }
.field.disabled { opacity: 0.4; }
.field.span2 { grid-column: span 2; }
.field-label { color: var(--text3); font-size: 11px; display: flex; align-items: center; flex: 0 0 auto; user-select: none; }
.field-label .ic { width: 14px; height: 14px; }
.field-input {
  flex: 1; min-width: 0; border: none; background: transparent; font-size: 11px; color: var(--text);
  height: 100%;
}
.field-suffix { color: var(--text3); font-size: 11px; }
.field-select {
  flex: 1; min-width: 0; border: none; background: transparent; font-size: 11px; color: var(--text);
  appearance: none; height: 100%;
}
.field-select.wide { width: 100%; }
.insp-check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); }
.insp-empty { padding: 4px 0; color: var(--text2); line-height: 1.7; }
.insp-empty .dim { color: var(--text3); margin-top: 10px; line-height: 1.9; }
.insp-hint { font-size: 11px; color: var(--text3); padding: 4px 0; line-height: 1.5; }
.insp-hint2 { font-size: 11px; color: var(--text3); padding: 2px 0 6px; }
.insp-mini-btn {
  display: flex; align-items: center; gap: 6px; height: 26px; border-radius: 5px; padding: 0 8px;
  background: #f5f5f5; color: var(--text2); font-size: 11px; width: 100%; justify-content: center;
}
.insp-mini-btn:hover { background: var(--hover); color: var(--text); }
.insp-mini-btn .ic { width: 13px; height: 13px; }
.txt-ic { font-size: 11px; font-weight: 600; letter-spacing: -0.5px; }

/* paint rows */
.paint-list { display: flex; flex-direction: column; gap: 4px; }
.paint-row { display: flex; align-items: center; gap: 5px; min-height: 28px; }
.paint-row.off { opacity: 0.5; }
.paint-sw {
  width: 24px; height: 24px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.12); flex: 0 0 24px;
  background-image: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%); background-size: 8px 8px;
  position: relative; overflow: hidden;
}
.paint-sw::after { content: ''; position: absolute; inset: 0; background: var(--paint, transparent); }
.paint-type { width: 62px; border: none; background: transparent; font-size: 11px; color: var(--text2); }
.paint-hex { width: 52px; border: none; background: #f5f5f5; border-radius: 4px; padding: 4px 5px; font-size: 11px; }
.paint-hex:focus { outline: 1px solid var(--accent); }
.paint-a { width: 36px; border: none; background: #f5f5f5; border-radius: 4px; padding: 4px 5px; font-size: 11px; }
.paint-pos { width: 42px; border: none; background: #f5f5f5; border-radius: 4px; padding: 4px 5px; font-size: 11px; }
.paint-grad { font-size: 10px; padding: 4px 6px; border-radius: 4px; background: #f0f0f0; color: var(--text2); }
.paint-grad:hover { background: var(--hover); }
.paint-eye, .paint-rm { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border-radius: 4px; color: var(--text3); }
.paint-eye:hover, .paint-rm:hover { background: var(--hover); color: var(--text); }
.paint-eye .ic, .paint-rm .ic { width: 12px; height: 12px; }
.paint-add { padding-top: 4px; }
.paint-add-btn { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 5px; color: var(--text2); }
.paint-add-btn:hover { background: var(--hover); color: var(--text); }
.fx-block { border: 1px solid #eee; border-radius: 6px; padding: 4px 6px; }
.fx-block.off { opacity: 0.5; }
.fx-ic { display: flex; color: var(--text3); }
.fx-ic .ic { width: 13px; height: 13px; }
.fx-type { flex: 1; }
.fx-params { padding: 4px 0 2px; }
.export-btn {
  height: 30px; border-radius: 6px; padding: 0 12px; background: var(--accent); color: #fff;
  font-weight: 500; font-size: 12px; flex: 1;
}
.export-btn:hover { background: #28a5ff; }
.inspect-code {
  font-family: "SF Mono", Menlo, monospace; font-size: 10.5px; line-height: 1.6; color: var(--text2);
  background: #f7f7f7; border-radius: 6px; padding: 10px; overflow-x: auto; white-space: pre-wrap;
  margin-bottom: 8px;
}

/* ---------- menus ---------- */
.menu {
  position: fixed; z-index: 100; min-width: 200px; background: #fff; border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06); padding: 5px;
}
.menu-item {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 6px 10px; border-radius: 5px; font-size: 12px; color: var(--text); text-align: left;
}
.menu-item:hover:not(.disabled) { background: var(--accent); color: #fff; }
.menu-item:hover:not(.disabled) .menu-sc { color: rgba(255,255,255,0.7); }
.menu-item-left { display: flex; align-items: center; gap: 8px; }
.menu-ic { width: 16px; display: flex; align-items: center; color: var(--text2); }
.menu-item:hover:not(.disabled) .menu-ic { color: #fff; }
.menu-sc { color: var(--text3); font-size: 11px; margin-left: 24px; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 8px; }
.menu-label { padding: 6px 10px 2px; font-size: 10px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.mini-menu {
  position: fixed; z-index: 100; min-width: 150px; background: #fff; border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06); padding: 5px;
}
.mini-item { display: block; width: 100%; padding: 6px 10px; border-radius: 5px; font-size: 12px; text-align: left; }
.mini-item:hover { background: var(--accent); color: #fff; }

/* ---------- color picker ---------- */
.picker-pop {
  position: fixed; z-index: 120; width: 224px; background: #fff; border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.08); padding: 10px;
}
.picker-sv {
  height: 140px; border-radius: 6px; position: relative; cursor: crosshair; margin-bottom: 8px;
}
.picker-cur {
  position: absolute; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3); transform: translate(-50%, -50%); pointer-events: none;
}
.picker-hue {
  height: 12px; border-radius: 6px; position: relative; cursor: ew-resize; margin-bottom: 8px;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.picker-hcur, .picker-acur {
  position: absolute; top: -2px; width: 8px; height: 16px; border-radius: 4px; background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25); transform: translateX(-50%); pointer-events: none;
}
.picker-alpha { height: 12px; border-radius: 6px; position: relative; cursor: ew-resize; margin-bottom: 8px; }
.picker-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.picker-hex { flex: 1; border: 1px solid var(--border); border-radius: 4px; padding: 4px 6px; font-size: 11px; }
.picker-a { border: 1px solid var(--border); border-radius: 4px; padding: 4px 6px; font-size: 11px; }
.picker-pct { font-size: 11px; color: var(--text3); }
.picker-eye { font-size: 10px; color: var(--text2); padding: 4px 6px; border-radius: 4px; background: #f0f0f0; }
.picker-swatches { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.picker-sw { aspect-ratio: 1; border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); }
.picker-sw:hover { transform: scale(1.15); }
.grad-pop { width: 230px; }
.grad-bar { height: 14px; border-radius: 7px; margin-bottom: 6px; border: 1px solid rgba(0,0,0,0.1); }
.grad-stop-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.grad-stops { padding: 4px 0; }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast {
  background: #1e1e1e; color: #fff; font-size: 12px; padding: 8px 16px; border-radius: 8px;
  opacity: 0; transform: translateY(8px); transition: all 0.25s ease; box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfcfcf; border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #aaa; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- narrow screens ---------- */
@media (max-width: 760px) {
  #layers-panel { position: absolute; z-index: 30; height: calc(100% - 44px); box-shadow: 4px 0 16px rgba(0,0,0,0.15); }
  #layers-panel.closed { margin-left: -250px; }
  #inspector { position: absolute; right: 0; z-index: 30; height: calc(100% - 44px); box-shadow: -4px 0 16px rgba(0,0,0,0.15); }
  #inspector.closed { margin-right: -265px; }
  .tb-center { position: static; transform: none; overflow-x: auto; }
  #topbar { flex-wrap: wrap; height: auto; min-height: 44px; padding: 4px 6px; gap: 4px; }
  .tb-name { width: 90px; }
  .tb-collab { display: none; }
  #mobile-hint {
    display: block; position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
    background: rgba(30,30,30,0.85); color: #fff; font-size: 11px; padding: 6px 12px; border-radius: 14px;
    pointer-events: none; white-space: nowrap;
  }
}
