.pp-swatches { position: relative; }
.pp-pkbtn { font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.pp-colorpick { position: relative; width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.pp-cp-preview { height: 18px; border-radius: 6px; border: 1px solid var(--line); }
.pp-cp-pad { position: relative; height: 116px; border-radius: 8px; border: 1px solid var(--line); touch-action: none; }

.pp-cp-knob { position: absolute; width: 14px; height: 14px; border: 2px solid #fff; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 1px rgba(0,0,0,.5); pointer-events: none; }
.pp-cp-hue { width: 100%; appearance: none; height: 14px; border-radius: 7px; background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); outline: none; }
.pp-cp-hue::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid #7c5cff; }
.pp-cp-close { position: absolute; top: 4px; right: 8px; background: none; border: 0; color: var(--muted); font-size: 12px; padding: 2px 4px; }

/* ================= light theme ================= */
body.theme-light {
  --bg: #f2f3f7;
  --panel: #ffffff;
  --panel-2: #eef0f5;
  --line: #d9dbe3;
  --text: #1b1c22;
  --muted: #6a6b76;
  --accent: #6a4cf0;
  --accent-soft: rgba(106, 76, 240, .14);
  --danger: #e0335b;
  --shadow: 0 8px 24px rgba(25, 25, 50, .12);
}
body.theme-light .text-edit-ta { background: rgba(255,255,255,.94); color: #1b1c22; }
body.theme-light #propsPanel { box-shadow: 0 8px 28px rgba(25,25,50,.14); }
body.theme-light #selBar { box-shadow: 0 4px 18px rgba(25,25,50,.14); }
body.theme-light .land-hero, body.theme-light .modal-card { box-shadow: 0 10px 30px rgba(25,25,50,.10); }
body.theme-light .proj-card { box-shadow: 0 3px 12px rgba(25,25,50,.08); }
.theme-seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.theme-btn { border: 0; background: var(--panel-2); color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; padding: 6px 14px; cursor: pointer; }
.theme-btn.on { background: var(--accent); color: #fff; }
.theme-btn + .theme-btn { border-left: 1px solid var(--line); }

/* ================= Vektor — commercial dark theme ================= */
:root {
  --bg: #17171c;
  --panel: #202027;
  --panel-2: #2a2a33;
  --line: #32323d;
  --text: #ececf1;
  --muted: #9a9aa6;
  --accent: #7c5cff;
  --accent-soft: rgba(124, 92, 255, .18);
  --danger: #ff5c7a;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0,0,0,.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
#app { height: 100dvh; display: flex; flex-direction: column; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }
.flex-spacer { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 10px; padding: 11px 18px;
  font: inherit; font-weight: 600; color: var(--text);
  background: var(--panel-2); cursor: pointer; min-height: 44px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:active { transform: scale(.97); }
.icon-btn {
  width: 2.1em; height: 2.1em; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--text);
  cursor: pointer; font: inherit;
}
.icon-btn svg { width: 1.15em; height: 1.15em; }
.icon-btn:disabled { color: #4c4c58; }
.icon-btn:active { background: var(--panel-2); }
.icon-btn.small { width: 26px; height: 26px; }
.icon-btn.small svg { width: 14px; height: 14px; }

/* ---------- landing (project browser) ---------- */
#projects { display: flex; flex-direction: column; overflow-y: auto; }
.land-hero { padding: 34px 20px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.land-logo { width: 76px; height: 76px; border-radius: 18px; box-shadow: var(--shadow); }
.land-title { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin: 4px 0 0; }
.land-tag { color: var(--muted); font-size: 14px; margin: 0; }
.land-actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.btn.big { padding: 12px 26px; font-size: 16px; border-radius: 12px; }
.icon-btn.ghost { width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.modal-card { position: relative; }
.land-foot { margin-top: auto; display: flex; align-items: center; gap: 16px; padding: 14px 20px calc(16px + var(--safe-bottom)); }
@media (orientation: landscape) {
  .land-hero { padding: 10px 20px 2px; flex-direction: row; gap: 14px; align-items: center; }
  .land-logo { width: 40px; height: 40px; border-radius: 10px; }
  .land-title { font-size: 20px; margin: 0; }
  .land-tag { display: none; }
  .land-actions { margin: 0 0 0 auto; }
  .btn.big { padding: 10px 20px; font-size: 14px; }
  .icon-btn.ghost { width: 40px; height: 40px; }
  .proj-thumb { height: 64px; }
  .land-foot { padding-top: 8px; }
}
.foot-link { background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; padding: 0; }
.foot-link:active { color: var(--text); }
.foot-ver { margin-left: auto; color: var(--muted); font-size: 12px; }

/* new-canvas type menu */
#canvasMenu {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%);
  width: min(320px, calc(100vw - 32px)); z-index: 30;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.cm-opt {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); cursor: pointer; text-align: left;
}
.cm-opt:active { border-color: var(--accent); }
.cm-icon { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.cm-icon svg { width: 20px; height: 20px; }
.cm-text { display: flex; flex-direction: column; gap: 2px; }
.cm-text strong { font-size: 14px; }
.cm-text small { color: var(--muted); font-size: 12px; }
.cm-opt.soon { opacity: .45; cursor: not-allowed; }

#confirmModal { z-index: 80; } /* must sit above the settings modal */

/* settings modal */
.modal-card.settings-card { max-width: none; width: min(430px, calc(100vw - 28px)); max-height: calc(100dvh - 40px); overflow-y: auto; padding: 18px; }
    @media (min-width: 768px) { .modal-card.settings-card { width: min(620px, calc(100vw - 48px)); padding: 24px 28px; border-radius: 18px; } }
    .set-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
    .set-head h3 { margin: 0; font-size: 18px; }
    .set-ver { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
    .set-section { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; margin-bottom: 12px; }
    .set-h { font-size: 10.5px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); padding: 9px 0 2px; }
    .set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
    .set-section > .set-row:last-child { border-bottom: 0; }
    .set-name { font-size: 14px; font-weight: 600; }
    .set-sub { color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.45; }
    .set-note { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin: 6px 0 10px; }
    .set-slider { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; width: 46%; max-width: 230px; }
    .set-slider .slider { flex: 1; }
    .set-val { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 2px 7px; min-width: 42px; text-align: center; }
    .set-actions { display: flex; gap: 8px; margin: 14px 0; }
    .set-actions .btn { flex: 1; }
    .set-credits { color: var(--muted); font-size: 11.5px; text-align: center; margin: 12px 0 0; }
    .settings-log { max-height: 240px; overflow-y: auto; }
    .set-x {
      position: absolute; top: 10px; right: 10px; width: 34px; height: 34px;
      border: 0; border-radius: 10px; background: transparent; color: var(--muted);
      cursor: pointer; display: grid; place-items: center;
    }
    .set-x svg { width: 20px; height: 20px; }
    .set-x:active { background: var(--panel-2); color: var(--text); }
    .slider { width: 130px; accent-color: var(--accent); }
    .switch { appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--panel-2); border: 1px solid var(--line); position: relative; cursor: pointer; transition: background .15s; }
    .switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: left .15s, background .15s; }
    .switch:checked { background: var(--accent-soft); border-color: var(--accent); }
    .switch:checked::after { left: 20px; background: var(--accent); }
    .btn.full { width: 100%; margin-top: 12px; }

/* ---------- project browser ---------- */
#projects { background: var(--bg); z-index: 5; }
.proj-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 18px 14px;
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-img { width: 34px; height: 34px; border-radius: 9px; display: block; }
.logo-word { font-weight: 700; font-size: 19px; letter-spacing: .3px; }
.proj-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px; padding: 18px; overflow-y: auto; align-content: start; flex: 1;
}
.proj-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; position: relative;
}
.proj-card:active { border-color: var(--accent); }
.proj-thumb { height: 110px; display: grid; place-items: center; background: var(--panel-2); }
.proj-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.proj-thumb .ph-letter { font-size: 40px; font-weight: 800; color: var(--accent); opacity: .8; }
.proj-meta { padding: 10px 12px; }
.proj-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-date { font-size: 12px; color: var(--muted); }
.proj-menu {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px;
  border: 0; border-radius: 8px; background: rgba(0,0,0,.55); color: #fff;
  font-size: 18px; cursor: pointer; display: grid; place-items: center;
}
.empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--muted); text-align: center; padding: 24px;
}
.empty h2 { color: var(--text); margin: 8px 0 0; }
.empty-art {
  width: 84px; height: 84px; border-radius: 20px; margin-bottom: 8px;
  background:
    radial-gradient(120px 120px at 30% 20%, rgba(124,92,255,.5), transparent 60%),
    radial-gradient(120px 120px at 75% 80%, rgba(180,76,255,.35), transparent 60%),
    var(--panel);
  border: 1px solid var(--line);
}

/* ---------- editor ---------- */
#editor { z-index: 4; display: flex; flex-direction: row; }
#sideRail {
  width: 54px; flex: none;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: calc(10px + var(--safe-top)) 0 12px;
  background: var(--panel); border-right: 1px solid var(--line); z-index: 6;
}
.rail-logo { width: 30px; height: 30px; margin: 2px 0 8px; border-radius: 8px; pointer-events: none; }
.rail-btn {
  width: 38px; height: 38px; flex: none; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.rail-btn svg { width: 19px; height: 19px; }
.rail-btn:active { background: var(--panel-2); color: var(--text); }
.rail-btn:disabled { opacity: .35; }
#layersPanel {
  width: 238px; flex: none;
  background: var(--panel); border-right: 1px solid var(--line); z-index: 5;
  display: flex; flex-direction: column;
}
.lp-top { display: flex; align-items: center; gap: 4px; padding: calc(8px + var(--safe-top)) 8px 4px; }
.lp-top .proj-title { flex: 1; min-width: 0; }
.lp-close { display: none; }
.lp-actions { display: flex; gap: 2px; padding: 2px 6px 8px; border-bottom: 1px solid var(--line); }
.lp-actions .rail-btn { width: 34px; height: 34px; border-radius: 8px; }
#layersPanel.sel-active .lp-top { opacity: .45; }
#layersPanel.sel-active .lp-actions { opacity: .45; }
.lp-head {
  padding: 10px 14px 4px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
.proj-title {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--text); font-family: inherit; font-size: .93em; font-weight: 600; line-height: 1.2;
  padding: 3px 7px;
  min-width: 0;
}
.proj-title:focus { outline: none; border-color: var(--line); background: var(--panel-2); }

#canvasWrap { position: relative; flex: 1; overflow: hidden; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

/* selection quick-actions */
#selBar {
  position: fixed; top: calc(2px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 2px; justify-content: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 2px; z-index: 10; box-shadow: var(--shadow);
  width: max-content; max-width: calc(100vw - 12px);
}
.selbar-btn {
  width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center;
  border: 0; border-radius: 7px; background: transparent; color: var(--text); cursor: pointer;
  white-space: nowrap;
}
.selbar-btn svg { width: 15px; height: 15px; }
.selbar-btn.done { width: auto; min-width: 26px; padding: 0 9px; font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); }
.selbar-btn.text-btn { width: auto; min-width: 26px; padding: 0 9px; font-size: 11px; font-weight: 700; color: var(--accent); background: rgba(124, 92, 255, .12); }
.selbar-btn.hidden { display: none; }

/* layers drag-to-group */
.lp-row.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: 8px; }
.lp-row.picked { background: rgba(124, 92, 255, .18); }
.lp-row.lp-dragging { opacity: .4; }
.lp-row.lp-drop-above { box-shadow: inset 0 2px 0 var(--accent); }
.lp-row.lp-drop-below { box-shadow: inset 0 -2px 0 var(--accent); }

/* properties panel (Figma-style) */
#propsPanel {
  position: fixed; top: calc(2px + var(--safe-top)); right: 6px; width: 236px; max-height: calc(100vh - 120px);
  /* ---- properties panel (uses theme vars) ---- */
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; z-index: 9;
  display: none; flex-direction: column; overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
}
#propsPanel.open { display: flex; }
.pp-top { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; font-size: 12px; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line); }
#propsClose { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 2px 6px; cursor: pointer; }
#propsBody { overflow-y: auto; padding: 4px 12px 14px; }
.pp-head { font-size: 13px; font-weight: 700; padding: 10px 0 4px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-title { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #8f8fa0; margin: 12px 0 4px; }
.pp-row { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.pp-lab { font-size: 11px; color: var(--muted); width: 52px; flex: none; }
.pp-val { font-size: 10px; color: #8f8fa0; width: 34px; text-align: right; flex: none; }
.pp-slider { flex: 1; min-width: 40px; accent-color: var(--accent); height: 26px; }
.pp-swatches { display: flex; flex-wrap: wrap; gap: 5px; padding: 5px 0 8px; align-items: center; }
.pp-swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; padding: 0; }
.pp-swatch:active { transform: scale(.9); }
.pp-hex { width: 62px; height: 24px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; font-size: 11px; padding: 0 6px; }
.pp-colorchip { width: 54px; height: 24px; border-radius: 7px; border: 1px solid var(--line); cursor: pointer; }
.pp-tabs { display: flex; gap: 4px; padding: 4px 0 6px; }
.pp-tab { flex: 1; padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.pp-tab.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pp-seg { display: flex; gap: 4px; padding: 4px 0; }
.pp-segbtn { flex: 1; padding: 5px 0; font-size: 11px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.pp-segbtn.on { background: rgba(124,92,255,.25); color: #fff; border-color: var(--accent); }
.pp-btns { display: flex; gap: 6px; }
.pp-btns.align { flex-wrap: wrap; }
.pp-btns.align .pp-btn { flex: 1 1 26px; min-width: 26px; text-align: center; font-size: 13px; }
.pp-btn { padding: 4px 12px; min-width: 34px; font-size: 12px; font-weight: 700; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.pp-btn.ital { font-style: italic; font-family: Georgia, serif; }
.pp-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pp-btn.wide { width: 100%; margin: 3px 0; }
.pp-btn.big { padding: 10px 0; }
.pp-switch { padding: 3px 14px; font-size: 11px; font-weight: 700; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); cursor: pointer; }
.pp-switch.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pp-gradwrap { padding: 6px 0 2px; }
.pp-gradbar { position: relative; height: 26px; border-radius: 8px; border: 1px solid var(--line); }
.pp-gradstop { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); cursor: grab; }
.pp-gradstop.sel { border-color: var(--accent); transform: scale(1.15); }
.pp-hint { font-size: 10px; color: #77778a; padding: 2px 0 4px; }
.pp-stroke { border: 1px solid var(--line); border-radius: 10px; padding: 2px 8px 6px; margin: 4px -4px; }
#layersPanel.shifted { display: none; }
@media (min-width: 901px) { #layersPanel.shifted { display: flex; margin-right: 244px; } }

/* text editor overlay */
.text-edit { position: absolute; z-index: 12; display: flex; align-items: flex-start; gap: 6px; }
.text-edit-ta {
  min-width: 70px; padding: 2px 4px; border: 1px solid var(--accent); border-radius: 8px;
  background: rgba(23,23,28,.92); color: #fff; font-family: inherit; line-height: 1.3; resize: none; overflow: hidden;
}
.text-edit-done {
  padding: 0 10px; height: 30px; border: 0; border-radius: 8px; background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.selbar-btn svg { width: 21px; height: 21px; }
.selbar-btn:active { background: var(--panel-2); }
.selbar-btn.danger { color: var(--danger); }
.swatch { width: 22px; height: 22px; border-radius: 6px; border: 2px solid rgba(255,255,255,.35); display: block; }

/* zoom controls */
#zoomCtl {
  position: absolute; right: 12px; bottom: calc(12px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 6px; z-index: 2;
}
.zoom-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 20px; cursor: pointer;
  box-shadow: var(--shadow); display: grid; place-items: center; padding: 0;
}
.zoom-btn svg { width: 20px; height: 20px; display: block; }
.zoom-btn:active { background: var(--panel-2); }

/* color popover */
#colorPop {
  position: absolute; z-index: 6; width: 232px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; box-shadow: var(--shadow);
}
.cp-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.cp-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.cp-swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid rgba(255,255,255,.12); cursor: pointer; }
.cp-swatch.sel { border-color: #fff; }
.cp-hexrow { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.cp-hash { color: var(--muted); font-weight: 600; }
.cp-hex {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font: 600 14px ui-monospace, monospace; padding: 9px 10px; min-width: 0;
}
.cp-hex:focus { outline: none; border-color: var(--accent); }

/* tool dock */
#toolDock {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + var(--safe-bottom));
  display: flex; justify-content: center; gap: 2px;
  padding: 4px 7px; width: max-content;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); z-index: 8;
  font-size: calc(14px * var(--dock-scale, 1));
}
#toolDock.collapsed { display: none; }
.tool-btn {
  width: 2.6em; height: 2.6em; border: 0; border-radius: 11px;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; font: inherit;
}
.tool-btn svg { width: 1.2em; height: 1.2em; }
.tool-btn.active { background: var(--accent-soft); color: var(--accent); }
.tool-btn:active { background: var(--panel-2); }

/* dock hide/show handle */
#dockToggle {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(62px + var(--safe-bottom)); z-index: 8;
  width: 30px; height: 30px; border-radius: 15px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); cursor: pointer;
  display: grid; place-items: center; box-shadow: var(--shadow); z-index: 2;
  transition: transform .15s ease;
}
#dockToggle svg { width: 16px; height: 16px; }
#dockToggle:active { background: var(--panel-2); }
#dockToggle.open svg { transform: rotate(180deg); }
#dockToggle.open { transform: translateX(-50%) rotate(180deg); }

/* line-width popover */
#widthPop {
  position: absolute; z-index: 6; width: 200px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; box-shadow: var(--shadow);
}
.wp-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.wp-opt {
  height: 36px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel-2); color: var(--text); cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.wp-opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.wp-opt .wp-line { display: block; width: 26px; border-radius: 2px; background: var(--text); }
.wp-opt:active { border-color: var(--accent); }

/* layers panel */

.lp-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.lp-row {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 8px; cursor: pointer; min-height: 28px;
}
.lp-row.sel { background: var(--accent-soft); }
.lp-row .lp-icon { width: 9px; height: 9px; border-radius: 3px; background: var(--muted); flex: none; }
.lp-row .lp-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.lp-row.hidden-node { opacity: .4; }
.lp-row .lp-arrow {
  width: 20px; height: 20px; flex: none; margin-left: -4px;
  border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
  transition: transform .12s ease;
}
.lp-row .lp-arrow svg { width: 14px; height: 14px; }
.lp-row .lp-arrow.open { transform: rotate(90deg); }
.lp-row .lp-arrow:active { background: var(--panel-2); }
.lp-row .lp-arrow-spacer { width: 14px; flex: 0 0 auto; }
.lp-rename {
  flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--accent);
  border-radius: 6px; color: var(--text); font: 500 13px inherit; font-family: inherit;
  padding: 4px 8px;
}
.lp-rename:focus { outline: none; }
.lp-eye { width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.lp-eye svg { width: 14px; height: 14px; }

/* modal + toast */
.modal {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(10,10,14,.6); display: grid; place-items: center; padding: 24px;
}
.modal-card {
  width: 100%; max-width: 340px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 6px; }
.modal-card p { margin: 0 0 16px; color: var(--muted); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

#toast {
  position: absolute; left: 50%; bottom: calc(86px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 16px; font-size: 14px; z-index: 30; box-shadow: var(--shadow);
  pointer-events: none; white-space: nowrap;
}

/* ---------- welcome / tutorial ---------- */
.welcome-card {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px 24px;
}
.welcome-logo { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 14px; }
.welcome-card h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.welcome-sub { margin: 0 0 18px; text-align: center; color: var(--muted); font-size: 14px; }
.tut { margin: 0 0 20px; padding-left: 22px; display: grid; gap: 12px; }
.tut li { font-size: 14px; line-height: 1.5; color: var(--text); }
.tut b { color: var(--accent); }
.welcome-card .btn.primary { width: 100%; justify-content: center; display: flex; }

/* selection bar extras */
/* version chip + update log */
#sideRail .ver-chip {
  position: static; background: transparent; border: 0;
  color: var(--muted); font-size: 8.5px; font-weight: 700; padding: 2px; cursor: pointer;
}

/* landscape overrides (must come after base rules) */
@media (orientation: landscape) {
  .proj-thumb { height: 64px; }
}
.updatelog { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 14px; max-height: 200px; overflow-y: auto; }
.ul-entry { margin-bottom: 12px; }
.ul-entry.current .ul-head { color: var(--accent); }
.ul-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.updatelog ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; }
.updatelog li { font-size: 13px; color: var(--text); line-height: 1.4; }
/* ================= phone overrides ================= */
@media (max-width: 900px) {
  #sideRail {
    position: fixed; top: calc(6px + var(--safe-top)); right: 6px;
    flex-direction: row; width: auto; padding: 3px;
    border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  }
  .rail-logo, #sideRail .flex-spacer, #sideRail .ver-chip { display: none; }
  #layersPanel {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: min(284px, 80vw); max-width: 80vw;
    border-right: 1px solid var(--line); box-shadow: var(--shadow); z-index: 26;
  }
  #layersPanel:not(.hidden) .lp-close { display: grid; }
  #selBar { top: calc(6px + var(--safe-top)); }
  #propsPanel { top: calc(52px + var(--safe-top)); max-height: calc(100vh - 150px); }
  #zoomCtl { bottom: calc(70px + var(--safe-bottom)); }
}

/* ---------- import / export pop ---------- */
.export-pop {
  position: absolute; top: calc(50px * var(--hs, 1)); right: 10px; z-index: 12;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; width: 218px;
}
.export-h { font-size: 10.5px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); padding: 6px 8px 4px; }
.export-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; padding: 7px 8px; border-radius: 9px; cursor: pointer; }
.export-item b { font-size: 13px; }
.export-item span { font-size: 11px; color: var(--muted); }
.export-item:hover:not(:disabled) { background: var(--panel-2); }
.export-item:disabled { opacity: .45; cursor: default; }

/* v25: transform section (rotate + mirror) */
.pp-angle-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.pp-angle-lbl { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.pp-angle {
  flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); padding: 6px 9px; font-size: 12.5px;
}
