/* SweetDesign — Figma UI3-aligned tokens (PLAN §2.1) */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --blue: #0d99ff;
  --panel: #ffffff;
  --divider: #e5e5e5;
  --text: #333333;
  --text-dim: #757575;
  --hover: #f5f5f5;
  --active-bg: #e5f4ff;
  --radius: 6px;
}
html, body { height: 100%; }
body {
  font: 11px/1.45 Inter, -apple-system, "Segoe UI", 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; }

/* ---------- top bar ---------- */
#topbar {
  height: 40px; flex: 0 0 40px; display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border-bottom: 1px solid var(--divider); padding: 0 8px; position: relative; z-index: 40;
}
.top-left, .top-right { display: flex; align-items: center; gap: 6px; position: relative; }
.top-center { color: var(--text-dim); }
.top-btn { padding: 5px 8px; border-radius: var(--radius); }
.top-btn:hover { background: var(--hover); }
.doc-name { border: 1px solid transparent; border-radius: var(--radius); padding: 4px 6px; font-weight: 600; width: 170px; }
.doc-name:hover { border-color: var(--divider); }
.doc-name:focus { border-color: var(--blue); outline: none; }
.share-btn { background: var(--blue); color: #fff; padding: 6px 14px; border-radius: var(--radius); font-weight: 500; }
.share-btn:hover { background: #0b85dd; }
.share-btn:disabled { background: #b3ddfb; cursor: default; }
.save-status { color: var(--text-dim); margin-right: 2px; }
.zoom-btn { min-width: 52px; }
.dropdown {
  position: absolute; top: 34px; 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; }

/* ---------- layout row ---------- */
#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; }

/* ---------- toolbar ---------- */
#toolbar {
  flex: 0 0 44px; background: var(--panel); border-right: 1px solid var(--divider);
  display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 2px; z-index: 30;
}
.tool-btn { width: 32px; height: 32px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: #444; }
.tool-btn svg { width: 18px; height: 18px; }
.tool-btn:hover { background: var(--hover); }
.tool-btn.active { background: var(--blue); color: #fff; }
.tool-sep { width: 20px; border-top: 1px solid var(--divider); margin: 5px 0; }

/* ---------- left panel ---------- */
#left-panel { flex: 0 0 240px; background: var(--panel); border-right: 1px solid var(--divider); display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px 4px; font-weight: 600; }
#pages { border-bottom: 1px solid var(--divider); padding-bottom: 6px; }
.page-row { padding: 5px 12px; cursor: pointer; border-radius: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-row:hover { background: var(--hover); }
.page-row.active { background: var(--active-bg); color: #0670c9; font-weight: 500; }
.left-tabs { display: flex; gap: 2px; padding: 8px 8px 0; }
.mini-tab { padding: 4px 10px; border-radius: var(--radius); color: var(--text-dim); font-weight: 600; }
.mini-tab.active { color: var(--text); background: var(--hover); }
#layers { overflow-y: auto; flex: 1; padding: 4px 0 16px; }
.layer-row { display: flex; align-items: center; gap: 4px; padding: 3px 6px 3px 8px; cursor: default; white-space: nowrap; }
.layer-row:hover { background: var(--hover); }
.layer-row.selected { background: var(--active-bg); }
.layer-row.hidden-node .layer-name, .layer-row.hidden-node .layer-icon { color: #b3b3b3; }
.layer-icon { width: 14px; text-align: center; color: var(--text-dim); flex: 0 0 14px; }
.layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { padding: 3px 6px; border-radius: 4px; color: var(--text-dim); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.active { background: var(--active-bg); color: #0670c9; }
.icon-btn.tiny { padding: 1px 3px; font-size: 10px; }
.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: #e5e5e5; }
#canvas { display: block; outline: none; }
#toast {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: rgba(30,30,30,.92); color: #fff; padding: 7px 14px; border-radius: 8px; z-index: 20; 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;
}

/* ---------- right panel ---------- */
#right-panel { flex: 0 0 264px; background: var(--panel); border-left: 1px solid var(--divider); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--divider); }
.tabs button { padding: 5px 10px 7px; font-weight: 600; color: var(--text-dim); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--text); }
.tab-body { overflow-y: auto; flex: 1; }
.design-empty { padding: 16px 12px; display: grid; gap: 8px; }
.design-section { padding: 10px 12px; border-bottom: 1px solid var(--divider); display: grid; gap: 8px; }
.section-title { font-weight: 600; }
.btn-row { display: flex; gap: 2px; flex-wrap: wrap; }
.num-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.num-field { display: flex; align-items: center; gap: 6px; }
.num-label { color: var(--text-dim); width: 12px; flex: 0 0 12px; text-align: center; }
.num-input { width: 100%; min-width: 0; border: 1px solid transparent; border-radius: 4px; padding: 4px 6px; background: var(--hover); }
.num-input:hover { border-color: var(--divider); }
.num-input:focus { border-color: var(--blue); background: #fff; outline: none; }
.prop-row { display: flex; align-items: center; gap: 6px; }
.prop-row > span:first-child { color: var(--text-dim); }
.color-input { width: 28px; height: 22px; border: 1px solid var(--divider); border-radius: 4px; padding: 0; background: none; cursor: pointer; }
.hex-input { width: 64px; border: 1px solid transparent; background: var(--hover); border-radius: 4px; padding: 4px 6px; text-transform: uppercase; }
.hex-input:focus { border-color: var(--blue); background: #fff; outline: none; }
.mini-select { border: 1px solid transparent; background: var(--hover); border-radius: 4px; padding: 4px; }
.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; }

[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); }
