/* app.css — Vecto design editor chrome (Figma-class dark theme) */
@font-face {
  font-family: 'InterVar';
  src: url('../fonts/InterVariable.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: block;
}

:root {
  --bg-panel: #2c2c2c;
  --bg-panel-2: #383838;
  --bg-canvas: #1e1e1e;
  --border: #444444;
  --border-soft: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --text-2: rgba(255, 255, 255, 0.7);
  --text-3: rgba(255, 255, 255, 0.4);
  --accent: #0d99ff;
  --accent-dim: rgba(13, 153, 255, 0.24);
  --accent-hover: rgba(13, 153, 255, 0.12);
  --hover-row: rgba(255, 255, 255, 0.07);
  --danger: #f24822;
  --radius: 5px;
  --toolbar-h: 48px;
  --panel-w: 248px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-canvas);
  font-family: 'InterVar', Inter, system-ui, -apple-system, sans-serif;
  font-size: 11px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ============================== toolbar ============================== */
#toolbar {
  height: var(--toolbar-h);
  min-height: var(--toolbar-h);
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 2px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  z-index: 20;
  position: relative;
}

.tb-logo {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  margin-right: 4px;
  border-radius: var(--radius);
}
.tb-logo:hover { background: var(--hover-row); }
.tb-logo svg { width: 20px; height: 20px; }

.tb-sep { width: 1px; height: 24px; background: var(--border-soft); margin: 0 6px; }

.tb-btn {
  position: relative;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  color: var(--text);
  cursor: default;
}
.tb-btn:hover { background: var(--hover-row); }
.tb-btn.active { background: var(--accent); color: #fff; }
.tb-btn svg { width: 22px; height: 22px; }
.tb-btn .caret {
  position: absolute; right: 1px; bottom: 1px;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-top: 4px solid transparent;
  border-right: 4px solid currentColor;
  border-bottom: 4px solid currentColor;
  opacity: 0.7;
  transform: scale(0.7);
}
.tb-btn.shape-btn { width: 44px; }

.tb-center {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  min-width: 0;
}
#doc-title {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-align: center;
  padding: 5px 10px;
  max-width: 320px;
  outline: none;
}
#doc-title:hover { background: var(--hover-row); }
#doc-title:focus { border-color: var(--accent); background: var(--bg-panel-2); }

.tb-right { display: flex; align-items: center; gap: 2px; }
.zoom-btn {
  display: flex; align-items: center; gap: 4px;
  height: 32px; padding: 0 10px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 11px;
}
.zoom-btn:hover { background: var(--hover-row); color: var(--text); }
.zoom-btn svg { width: 8px; height: 8px; }

/* ============================== layout ============================== */
#main { flex: 1; display: flex; min-height: 0; position: relative; }

#left-panel, #right-panel {
  width: var(--panel-w);
  min-width: var(--panel-w);
  background: var(--bg-panel);
  display: flex; flex-direction: column;
  z-index: 10;
  position: relative;
}
#left-panel { border-right: 1px solid rgba(0, 0, 0, 0.35); }
#right-panel { border-left: 1px solid rgba(0, 0, 0, 0.35); overflow-y: auto; }

#canvas-host {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-canvas);
  min-width: 0;
}
#scene-canvas, #overlay-canvas {
  position: absolute; top: 0; left: 0;
  display: block;
}
#overlay-canvas { pointer-events: none; }

.text-edit-overlay {
  position: absolute;
  top: 0; left: 0;
  outline: none;
  caret-color: var(--accent);
  z-index: 5;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
.text-edit-overlay::selection { background: rgba(13, 153, 255, 0.35); }

/* ============================== left panel ============================== */
.panel-header {
  display: flex; align-items: center;
  padding: 0 8px 0 16px;
  height: 40px; min-height: 40px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.1px;
}
.panel-header .spacer { flex: 1; }
.icon-btn {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--text-2);
}
.icon-btn:hover { background: var(--hover-row); color: var(--text); }
.icon-btn svg { width: 14px; height: 14px; }

#pages-section {
  border-bottom: 1px solid var(--border-soft);
  max-height: 180px;
  display: flex; flex-direction: column;
}
#pages-list { overflow-y: auto; padding-bottom: 8px; }
.page-row {
  display: flex; align-items: center;
  height: 28px;
  padding: 0 16px 0 24px;
  color: var(--text-2);
  gap: 8px;
}
.page-row:hover { background: var(--hover-row); }
.page-row.current { color: var(--text); }
.page-row.current .page-check { visibility: visible; }
.page-check { visibility: hidden; width: 10px; color: var(--text); }
.page-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#layers-section { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#layers-tree { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 24px; position: relative; }

.layer-row {
  display: flex; align-items: center;
  height: 28px;
  padding-right: 6px;
  color: var(--text-2);
  position: relative;
  white-space: nowrap;
}
.layer-row:hover { background: var(--hover-row); }
.layer-row.hovered { box-shadow: inset 0 0 0 1px var(--accent); }
.layer-row.selected { background: var(--accent-dim); color: var(--text); }
.layer-row.hidden-layer .layer-name, .layer-row.hidden-layer .layer-icon { opacity: 0.4; }
.layer-row .chevron {
  width: 16px; height: 16px; min-width: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.layer-row .chevron svg { width: 8px; height: 8px; transition: transform 0.1s; }
.layer-row .chevron.expanded svg { transform: rotate(90deg); }
.layer-row .chevron:hover { color: var(--text); }
.layer-icon {
  width: 18px; min-width: 18px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  margin-right: 5px;
  color: inherit;
  opacity: 0.85;
}
.layer-icon svg { width: 12px; height: 12px; }
.layer-name {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis;
  font-size: 11px;
}
.layer-row.selected .layer-name { color: var(--text); }
.layer-name-input {
  flex: 1;
  background: var(--bg-panel-2);
  border: 1px solid var(--accent);
  border-radius: 2px;
  color: var(--text);
  font: inherit;
  padding: 1px 4px;
  outline: none;
  min-width: 0;
}
.layer-actions { display: none; align-items: center; gap: 2px; }
.layer-row:hover .layer-actions, .layer-row.locked .layer-actions, .layer-row.hidden-layer .layer-actions { display: flex; }
.layer-actions .icon-btn { width: 20px; height: 20px; }
.layer-actions .icon-btn.on { color: var(--text); display: flex; }

.drop-indicator {
  position: absolute;
  height: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 5;
  border-radius: 1px;
}
.drop-into {
  position: absolute;
  pointer-events: none;
  border: 1.5px solid var(--accent);
  border-radius: 3px;
  z-index: 5;
}

/* ============================== inspector ============================== */
#inspector { display: flex; flex-direction: column; }

.insp-section {
  border-bottom: 1px solid var(--border-soft);
  padding: 10px 14px 12px;
}
.insp-section-title {
  display: flex; align-items: center;
  font-weight: 600;
  margin-bottom: 10px;
  height: 20px;
}
.insp-section-title .spacer { flex: 1; }

.insp-empty {
  padding: 24px 16px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.6;
}

.insp-row { display: flex; gap: 8px; margin-bottom: 8px; }
.insp-row:last-child { margin-bottom: 0; }

.num-field {
  display: flex; align-items: center;
  background: var(--bg-panel-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  height: 28px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.num-field:hover { border-color: var(--border); }
.num-field:focus-within { border-color: var(--accent); }
.num-field.disabled { opacity: 0.4; pointer-events: none; }
.num-field .nf-label {
  min-width: 22px;
  padding: 0 2px 0 7px;
  color: var(--text-3);
  cursor: ew-resize;
  font-size: 10px;
  display: flex; align-items: center; justify-content: flex-start;
  height: 100%;
}
.num-field .nf-label svg { width: 12px; height: 12px; }
.num-field input {
  flex: 1;
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font: inherit;
  height: 100%;
  padding-right: 6px;
}
.num-field .nf-unit { color: var(--text-3); padding-right: 7px; font-size: 10px; }

.select-field {
  background: var(--bg-panel-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  height: 28px;
  color: var(--text);
  font: inherit;
  padding: 0 6px;
  flex: 1;
  min-width: 0;
  outline: none;
}
.select-field:hover { border-color: var(--border); }
.select-field:focus { border-color: var(--accent); }
.select-field option { background: var(--bg-panel-2); }

.align-row { display: flex; justify-content: space-between; }
.align-row .icon-btn { width: 28px; height: 28px; color: var(--text-2); }
.align-row .icon-btn svg { width: 16px; height: 16px; }
.align-row .icon-btn.disabled { opacity: 0.3; pointer-events: none; }

.seg-control {
  display: flex; flex: 1;
  background: var(--bg-panel-2);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}
.seg-control .seg {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  height: 24px;
  border-radius: 3px;
  color: var(--text-2);
}
.seg-control .seg:hover { color: var(--text); }
.seg-control .seg.active { background: #545454; color: var(--text); }
.seg-control .seg svg { width: 14px; height: 14px; }

.paint-row {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
  height: 28px;
}
.paint-row .swatch {
  width: 22px; height: 22px; min-width: 22px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background-image:
    linear-gradient(45deg, #666 25%, transparent 25%, transparent 75%, #666 75%),
    linear-gradient(45deg, #666 25%, #999 25%, #999 75%, #666 75%);
  background-size: 8px 8px;
  background-position: 0 0, 4px 4px;
  position: relative;
  overflow: hidden;
}
.paint-row .swatch::after {
  content: '';
  position: absolute; inset: 0;
  background: var(--swatch-color, #000);
}
.paint-row .hex-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-panel-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  height: 28px;
  color: var(--text);
  font: inherit;
  padding: 0 8px;
  outline: none;
  text-transform: uppercase;
}
.paint-row .hex-input:hover { border-color: var(--border); }
.paint-row .hex-input:focus { border-color: var(--accent); }
.paint-row .num-field { max-width: 62px; }
.paint-row .gradient-label { flex: 1; color: var(--text-2); padding-left: 2px; }

.effect-block { margin-bottom: 8px; }
.effect-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; color: var(--text-2); }
.effect-head .eff-name { flex: 1; color: var(--text); }
.effect-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-left: 2px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; color: var(--text-2); margin-bottom: 4px; }
.checkbox-row input[type="checkbox"] { accent-color: var(--accent); width: 13px; height: 13px; }
.checkbox-row:hover { color: var(--text); }

.mini-note { color: var(--text-3); font-size: 10px; margin-top: 6px; line-height: 1.5; }

/* ============================== popovers / menus ============================== */
#popover-root { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
#popover-root > * { pointer-events: auto; }

.menu {
  position: fixed;
  min-width: 200px;
  background: #1e1e1e;
  border: 1px solid #383838;
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  z-index: 200;
  font-size: 12px;
}
.menu-item {
  display: flex; align-items: center;
  padding: 5px 24px 5px 10px;
  border-radius: 6px;
  color: var(--text);
  gap: 10px;
  position: relative;
}
.menu-item:hover:not(.disabled) { background: var(--accent); color: #fff; }
.menu-item.disabled { color: var(--text-3); }
.menu-item .mi-label { flex: 1; }
.menu-item .mi-shortcut { color: var(--text-3); font-size: 11px; }
.menu-item:hover:not(.disabled) .mi-shortcut { color: rgba(255, 255, 255, 0.7); }
.menu-item .mi-check { width: 12px; margin-left: -4px; }
.menu-sep { height: 1px; background: var(--border-soft); margin: 5px 8px; }

.color-picker {
  position: fixed;
  width: 240px;
  background: #1e1e1e;
  border: 1px solid #383838;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  z-index: 210;
  padding: 12px;
}
.cp-sv {
  width: 216px; height: 160px;
  border-radius: 6px;
  position: relative;
  margin-bottom: 10px;
  overflow: hidden;
}
.cp-thumb {
  position: absolute;
  width: 12px; height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
  transform: translate(-6px, -6px);
  pointer-events: none;
}
.cp-slider {
  position: relative;
  height: 12px;
  border-radius: 6px;
  margin-bottom: 10px;
}
.cp-slider .cp-thumb { top: 50%; margin-top: -6px; }
.cp-hue { background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.cp-alpha-track { position: absolute; inset: 0; border-radius: 6px; }
.cp-fields { display: flex; gap: 6px; }
.cp-fields .hex-input {
  flex: 1;
  background: var(--bg-panel-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  height: 28px;
  color: var(--text);
  font: inherit;
  padding: 0 8px;
  outline: none;
  text-transform: uppercase;
  min-width: 0;
}
.cp-fields .hex-input:focus { border-color: var(--accent); }
.cp-fields .num-field { max-width: 64px; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); background-clip: content-box; border: 2px solid transparent; }
::-webkit-scrollbar-corner { background: transparent; }

/* small screens: collapse panels gracefully */
@media (max-width: 860px) {
  :root { --panel-w: 200px; }
}

/* compact numeric fields inside paint rows */
.paint-row .num-field .nf-label { min-width: 4px; padding: 0 1px 0 5px; }
.paint-row .num-field { max-width: 70px; }
