/* SweetDesign — Figma UI3 tokens. Measured on figma.com 2026-12-02 (PLAN §2.3)
   + side-by-side diff pass (DIFF-2026-12-02.md). */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --blue: #0d99ff;
  --panel: #ffffff;
  --divider: #e5e5e5;
  --text: #1e1e1e;
  --text-dim: #757575;
  --hover: #f5f5f5;
  --active-bg: #e5f4ff;
  --sel-bg: #dbeafe;
  --radius: 6px;
}
html, body { height: 100%; }
body {
  font: 11px/1.35 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; color: inherit; }
.hint { color: var(--text-dim); font-size: 11px; }
.hint.pad, .pad { padding: 12px; }

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

/* ---------- layout row (no full-width top bar; canvas runs to the top) ---------- */
#main-row { flex: 1; display: flex; min-height: 0; }
body.ui-hidden #left-panel, body.ui-hidden #right-panel, body.ui-hidden #toolbar { display: none; }
body.left-collapsed #left-panel { display: none; }

/* ---------- shared chrome bits ---------- */
.top-btn { padding: 5px 8px; border-radius: var(--radius); color: var(--text); }
.top-btn:hover { background: var(--hover); }
.mini-caret { width: 14px; height: 14px; color: var(--text-dim); flex: 0 0 14px; }
.share-btn { background: var(--blue); color: #fff; width: 64px; height: 28px; flex: 0 0 64px; border-radius: 6px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.share-btn:hover { background: #0b85dd; }
.share-btn:disabled { background: #b3ddfb; cursor: default; }
#replace-all.share-btn { width: auto; flex: none; padding: 0 14px; }
.dropdown {
  position: absolute; top: 30px; left: 0; background: #fff; border: 1px solid var(--divider);
  border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.16); padding: 6px; min-width: 220px; z-index: 60;
}
.dropdown.right { left: auto; right: 0; }
.dropdown button { display: flex; justify-content: space-between; gap: 24px; width: 100%; text-align: left; padding: 6px 8px; border-radius: 4px; }
.dropdown button:hover { background: var(--blue); color: #fff; }
.dropdown button span { color: var(--text-dim); }
.dropdown button:hover span { color: #dcefff; }
.dropdown hr { border: none; border-top: 1px solid var(--divider); margin: 5px 0; }
.icon-btn { padding: 3px 6px; border-radius: 4px; color: var(--text-dim); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.active { background: var(--active-bg); color: #0670c9; }
.icon-btn.tiny { padding: 0; }
/* Icon display sizes (all icons are Lucide, see js/icons.js): small inline
   buttons 14px by default; panel headers 16px. Toolbar 18px, rail 20px and
   layer rows 16px are set on their own surfaces below. */
.icon-btn svg { width: 14px; height: 14px; }
.panel-head .icon-btn svg, .node-head .icon-btn svg, .section-head .icon-btn svg { width: 16px; height: 16px; }

/* ---------- left sidebar: 240px = 48px rail + 192px main ---------- */
#left-panel { flex: 0 0 240px; background: var(--panel); border-right: 1px solid var(--divider); display: flex; flex-direction: row; min-height: 0; }
#rail {
  flex: 0 0 48px; display: flex; flex-direction: column; align-items: center; padding: 0 0 6px; gap: 2px;
  border-right: 1px solid var(--divider);
}
.rail-mark { width: 48px; height: 48px; flex: 0 0 48px; display: flex; align-items: center; justify-content: center; }
.rail-mark span {
  width: 24px; height: 24px; border-radius: 7px; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
}
.rail-btn {
  width: 44px; height: 46px; border-radius: 8px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; color: var(--text-dim);
}
.rail-btn svg { width: 20px; height: 20px; }
.rail-label { font-size: 9px; line-height: 1; }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.active { background: var(--active-bg); color: var(--blue); }
#left-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#left-top {
  height: 48px; flex: 0 0 48px; display: flex; align-items: center; gap: 4px;
  padding: 0 6px 0 12px; position: relative; border-bottom: 1px solid var(--divider); background: var(--panel);
}
#left-top .dropdown { top: 44px; left: 8px; }
.lt-lines { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.lt-line1 { display: flex; align-items: center; gap: 2px; min-width: 0; }
.doc-name {
  border: 1px solid transparent; border-radius: 4px; padding: 1px 3px; margin-left: -3px;
  font-weight: 600; font-size: 13px; color: var(--text); min-width: 0; flex: 1; background: transparent;
}
.doc-name:hover { border-color: var(--divider); }
.doc-name:focus { border-color: var(--blue); outline: none; }
.lt-caret { width: 16px; height: 16px; flex: 0 0 16px; display: flex; align-items: center; justify-content: center; border-radius: 4px; color: var(--text-dim); }
.lt-caret svg { width: 14px; height: 14px; }
.lt-caret:hover { background: var(--hover); color: var(--text); }
.lt-sub { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-sub .free { color: var(--blue); }
#left-content { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; height: 32px; padding: 0 6px 0 12px; font-weight: 600; font-size: 12px; color: var(--text); }
.panel-head .head-actions { display: flex; align-items: center; gap: 2px; }
.panel-head .icon-btn { color: #444; }
#pages { border-bottom: 1px solid var(--divider); padding: 0 8px 6px; }
#pages .panel-head { padding-left: 4px; padding-right: 0; }
.page-row { height: 28px; display: flex; align-items: center; padding: 0 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.page-row:hover { background: var(--hover); }
.page-row.active { background: var(--hover); font-weight: 500; }
#layers { overflow-y: auto; flex: 1; padding: 2px 0 16px; }
#layers .panel-head { padding-right: 6px; }
#assets, #variables { overflow-y: auto; flex: 1; }

/* ---------- agent panel (left slot, same chrome as Layers/Assets) ---------- */
#agent { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.agent-note { padding: 2px 12px 8px; color: var(--text-dim); border-bottom: 1px solid var(--divider); }
.agent-log { flex: 1; overflow-y: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.agent-line { line-height: 1.45; color: var(--text); overflow-wrap: break-word; }
.agent-line.user { color: var(--text-dim); font-weight: 500; }
.agent-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px 0; }
.agent-chip { border: 1px solid var(--divider); background: var(--panel); border-radius: 999px; padding: 3px 9px; color: var(--text); }
.agent-chip:hover { background: var(--hover); }
.agent-form { display: flex; gap: 6px; padding: 8px 12px 4px; }
.agent-input {
  flex: 1; min-width: 0; height: 28px; border: 1px solid transparent; background: #f5f5f5;
  border-radius: 6px; padding: 0 8px; font-size: 12px;
}
.agent-input:focus { outline: none; border-color: var(--blue); background: #fff; }
.agent-send { background: var(--blue); color: #fff; border-radius: 6px; padding: 0 12px; font-weight: 600; height: 28px; flex: 0 0 auto; }
.agent-send:hover { background: #0b85dd; }
.agent-foot { padding: 4px 12px 10px; color: var(--text-dim); }
.layer-row { display: flex; align-items: center; gap: 4px; height: 32px; padding-right: 6px; cursor: default; white-space: nowrap; color: var(--text); }
.layer-row:hover { background: var(--hover); }
.layer-row.selected { background: var(--sel-bg); }
.layer-row.hidden-node .layer-name, .layer-row.hidden-node .layer-icon { color: #b3b3b3; }
.layer-toggle { width: 18px; height: 18px; flex: 0 0 18px; display: flex; align-items: center; justify-content: center; color: var(--text-dim); border-radius: 3px; }
.layer-toggle svg { width: 14px; height: 14px; }
.layer-toggle:hover { color: var(--text); }
.layer-icon { width: 16px; flex: 0 0 16px; display: flex; align-items: center; justify-content: center; color: var(--text-dim); }
.layer-icon svg { width: 16px; height: 16px; }
.layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.layer-row .row-action { opacity: 0; display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; flex: 0 0 22px; }
.layer-row:hover .row-action { opacity: 1; }
.layer-row .row-action.persistent { opacity: 1; }
.row-action svg { width: 14px; height: 14px; }
.tiny-spacer { width: 18px; flex: 0 0 18px; }
.rename-input { flex: 1; min-width: 60px; border: 1px solid var(--blue); border-radius: 3px; padding: 1px 4px; outline: none; }

/* ---------- canvas ---------- */
#canvas-wrap { flex: 1; position: relative; min-width: 0; background: #f5f5f5; }
#canvas { display: block; outline: none; }
.canvas-corner-btn {
  position: absolute; z-index: 25; width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 1px solid var(--divider); box-shadow: 0 2px 8px rgba(0,0,0,.14);
  display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 13px; font-weight: 600;
}
.canvas-corner-btn:hover { color: var(--text); }
.canvas-corner-btn.br { right: 12px; bottom: 12px; }
.canvas-corner-btn.tl { left: 12px; top: 12px; border-radius: 8px; }
#expand-left svg { width: 16px; height: 16px; }
/* The help button is the Lucide circle-help icon itself — its own circle is
   the visual, so the button chrome (circle bg/border) is stripped. */
#help-btn { background: transparent; border: none; box-shadow: none; }
#help-btn svg { width: 24px; height: 24px; }
#toast {
  position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%);
  background: rgba(30,30,30,.92); color: #fff; padding: 7px 14px; border-radius: 8px; z-index: 40; pointer-events: none;
}
.text-edit-overlay {
  position: absolute; z-index: 15; background: rgba(255,255,255,.65); border: 1px solid var(--blue);
  outline: none; resize: none; overflow: hidden; padding: 0; line-height: 1.25;
}

/* ---------- bottom floating toolbar (DIFF #55-61: ~460 wide, h40, radius 10, bottom 12) ---------- */
#toolbar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; height: 40px; z-index: 30;
  background: var(--panel); border: 1px solid var(--divider); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.12);
  display: flex; align-items: center; gap: 1px; padding: 0 5px;
}
.tool-group { position: relative; display: flex; align-items: center; }
.tool-btn { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #1e1e1e; }
.tool-btn svg { width: 18px; height: 18px; }
.tool-btn:hover { background: var(--hover); }
.tool-btn.active { background: var(--blue); color: #fff; }
.tool-caret { width: 16px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-dim); margin-left: -2px; }
.tool-caret svg { width: 14px; height: 14px; }
.tool-caret:hover { background: var(--hover); color: var(--text); }
.tool-menu {
  position: absolute; bottom: 46px; left: 0; background: #fff; border: 1px solid var(--divider);
  border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.16); padding: 6px; min-width: 190px; z-index: 60;
}
.tool-menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 6px 8px; border-radius: 4px; }
.tool-menu button svg { width: 16px; height: 16px; flex: 0 0 16px; }
.tool-menu button .tm-label { flex: 1; }
.tool-menu button .tm-hint { color: var(--text-dim); }
.tool-menu button:hover { background: var(--blue); color: #fff; }
.tool-menu button:hover .tm-hint { color: #dcefff; }
.tool-menu button.active { color: var(--blue); font-weight: 600; }
.tool-menu button.active:hover { color: #fff; }
.tool-sep { height: 20px; border-left: 1px solid var(--divider); margin: 0 5px; }
.mode-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #1e1e1e; }
.mode-icon svg { width: 18px; height: 18px; }
.mode-icon:hover { background: var(--hover); }
.mode-icon.active { background: #F0F0F0; color: #1e1e1e; }

/* ---------- right sidebar: 240px ---------- */
#right-panel { flex: 0 0 240px; background: var(--panel); border-left: 1px solid var(--divider); display: flex; flex-direction: column; min-height: 0; }
#right-top { padding: 8px 12px; border-bottom: 1px solid var(--divider); display: grid; gap: 6px; }
.rt-row { display: flex; align-items: center; gap: 6px; }
.rt-spacer { flex: 1; }
.avatar-wrap { display: flex; align-items: center; gap: 2px; }
.avatar-circle {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: linear-gradient(135deg, #faa419, #f24822); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600;
}
.present-btn { display: flex; align-items: center; gap: 2px; padding: 5px 6px; border-radius: var(--radius); color: var(--text); }
.present-btn:hover { background: var(--hover); }
.present-btn > svg:first-child { width: 14px; height: 14px; }
.zoom-wrap { position: relative; margin-left: auto; }
.zoom-btn { display: flex; align-items: center; gap: 2px; padding: 4px 6px; border-radius: var(--radius); color: var(--text); font-weight: 500; }
.zoom-btn:hover { background: var(--hover); }
.zoom-wrap .dropdown { top: 28px; }
.tabs-text { display: flex; gap: 2px; }
.tabs-text button { padding: 4px 9px; border-radius: 6px; font-weight: 500; color: var(--text); white-space: nowrap; }
.tabs-text button:hover { background: var(--hover); }
.tabs-text button.active { background: #f0f0f0; font-weight: 600; }
.tab-body { overflow-y: auto; flex: 1; }
.design-empty { padding: 14px 12px; color: var(--text-dim); }
.node-head { display: flex; align-items: center; gap: 4px; padding: 10px 12px 2px; }
.node-name { flex: 1; font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.design-section { padding: 10px 12px 12px; border-bottom: 1px solid var(--divider); display: grid; gap: 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.section-head .head-actions { display: flex; align-items: center; gap: 2px; }
.section-title { font-weight: 600; font-size: 12px; color: var(--text); }
.sub-label { font-size: 11px; color: var(--text-dim); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.align-group { display: flex; gap: 2px; background: var(--hover); border-radius: 6px; padding: 2px; }
.align-group .icon-btn { width: 24px; height: 24px; padding: 0; color: #444; border-radius: 4px; }
.align-group .icon-btn:hover { background: #e9e9e9; color: var(--text); }
.align-group .icon-btn svg { width: 16px; height: 16px; }
.num-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fld {
  display: flex; align-items: center; gap: 6px; height: 24px; min-width: 0;
  background: var(--hover); border: 1px solid transparent; border-radius: 6px; padding: 0 6px;
}
.fld:focus-within { background: #fff; border-color: var(--blue); }
.fld-label { color: var(--text-dim); font-size: 11px; flex: 0 0 auto; }
.fld .num-input { flex: 1; width: 100%; }
.fld-icon { display: flex; align-items: center; color: var(--text-dim); flex: 0 0 auto; }
.fld-icon svg { width: 14px; height: 14px; }
.num-input { width: 100%; min-width: 0; height: 24px; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; background: var(--hover); font-size: 12px; color: var(--text); }
.num-input:hover { border-color: var(--divider); }
.num-input:focus { border-color: var(--blue); background: #fff; outline: none; }
.fld .num-input { height: 22px; padding: 0; background: transparent; border: none; border-radius: 0; }
.fld .num-input:hover, .fld .num-input:focus { border: none; background: transparent; }
.prop-row { display: flex; align-items: center; gap: 6px; }
.prop-row > span:first-child { color: var(--text-dim); font-size: 11px; }
.prop-row .num-input { flex: 1; }
.color-input { width: 24px; height: 24px; flex: 0 0 24px; border: 1px solid var(--divider); border-radius: 6px; padding: 0; background: none; cursor: pointer; }
.hex-input { width: 58px; flex: 0 0 58px; height: 24px; border: 1px solid transparent; background: var(--hover); border-radius: 6px; padding: 2px 6px; text-transform: uppercase; font-size: 12px; color: var(--text); }
.hex-input:focus { border-color: var(--blue); background: #fff; outline: none; }
.paint-eye, .paint-rm { flex: 0 0 auto; }
.mini-select { height: 24px; border: 1px solid transparent; background: var(--hover); border-radius: 6px; padding: 2px 4px; font-size: 12px; color: var(--text); min-width: 0; }
.wide-btn { width: 100%; text-align: left; padding: 6px 8px; border-radius: var(--radius); color: var(--text); }
.wide-btn:hover:not(:disabled) { background: var(--hover); }
.wide-btn:disabled { color: var(--text-dim); cursor: default; }
.collapsed-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--divider); }
.design-section.grid-mode { display: flex; flex-wrap: wrap; gap: 8px; }
.design-section.grid-mode .section-head { flex: 0 0 100%; }
.design-section.grid-mode .paint-row { flex: 0 0 calc(50% - 4px); }
.design-section.grid-mode .paint-row .num-input, .design-section.grid-mode .paint-row .paint-eye, .design-section.grid-mode .paint-row .paint-rm { display: none; }
.text-style-btn { width: 26px; height: 24px; font-size: 12px; }

[hidden] { display: none !important; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.palette-box { width: 520px; max-width: 92vw; background: #fff; border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.3); overflow: hidden; }
#palette-input { width: 100%; border: none; outline: none; padding: 14px 16px; font-size: 14px; border-bottom: 1px solid var(--divider); }
#palette-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; justify-content: space-between; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; font-size: 12px; }
.palette-item.active, .palette-item:hover { background: var(--blue); color: #fff; }
.palette-item span { color: var(--text-dim); }
.palette-item.active span, .palette-item:hover span { color: #dcefff; }
.modal-box { width: 640px; max-width: 94vw; max-height: 76vh; background: #fff; border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.3); display: flex; flex-direction: column; overflow: hidden; }
.modal-box.small { width: 380px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--divider); font-weight: 600; font-size: 12px; }
.shortcuts-list { overflow-y: auto; padding: 10px 16px 16px; columns: 2; column-gap: 32px; }
.shortcuts-list h4 { margin: 10px 0 4px; break-after: avoid; }
.shortcuts-list .sc-row { display: flex; justify-content: space-between; padding: 2px 0; break-inside: avoid; }
.shortcuts-list .sc-row span:last-child { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.find-body { padding: 14px 16px; display: grid; gap: 10px; }
.find-body input { border: 1px solid var(--divider); border-radius: var(--radius); padding: 7px 9px; outline: none; }
.find-body input:focus { border-color: var(--blue); }
