/* ============ Design tokens ============ */
:root {
  --bg: #f4f5fa;
  --panel: #ffffff;
  --panel-2: #f8f9fc;
  --border: #e4e7ef;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, .10);
  --accent-text: #ffffff;
  --canvas: #fbfbfe;
  --dot: #cdd3e0;
  --edge: #475569;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .18);
  --radius: 10px;
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0a0e16;
  --panel: #121826;
  --panel-2: #172033;
  --border: #243049;
  --text: #e7ebf3;
  --muted: #8d98ad;
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, .16);
  --accent-text: #0b1020;
  --canvas: #0d1320;
  --dot: #2a3550;
  --edge: #9aa6bd;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
i { display: inline-flex; font-style: normal; }
svg { display: block; }

/* ============ Layout ============ */
.app {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr) 280px;
  grid-template-rows: 58px minmax(0, 1fr);
  grid-template-areas: "top top top" "side stage insp";
  height: 100vh;
}
.topbar { grid-area: top; }
.sidebar { grid-area: side; }
.stage { grid-area: stage; }
.inspector { grid-area: insp; }

/* ============ Top bar ============ */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.logo { color: var(--accent); }
.brand-name { font-size: 15px; font-weight: 500; letter-spacing: -.01em; }
.brand-name b { font-weight: 700; }
.title-input {
  width: 240px; max-width: 28vw;
  border: 1px solid transparent; background: transparent;
  border-radius: 8px; padding: 7px 10px;
  font-weight: 600; font-size: 14px;
  transition: background .15s, border-color .15s;
}
.title-input:hover { background: var(--panel-2); }
.title-input:focus { outline: none; background: var(--panel); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.spacer { flex: 1; }
.group { display: flex; align-items: center; gap: 4px; }
.group + .group { padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--border); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 12px;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel); font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); border-color: var(--border); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 4px 14px var(--accent-soft); }
.btn.danger { color: #dc2626; }
.btn.small { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border-radius: 9px; border: 1px solid transparent; background: transparent;
  color: var(--text);
  transition: background .15s, border-color .15s, color .15s;
}
.icon-btn:hover { background: var(--panel-2); border-color: var(--border); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.icon-btn:disabled { opacity: .35; cursor: default; pointer-events: none; }
button:focus-visible, .shape-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 170px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 5px; z-index: 50;
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; background: transparent; border-radius: 7px; text-align: left;
}
.menu button:hover { background: var(--accent-soft); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-title { padding: 6px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.theme-menu { min-width: 230px; }
.theme-menu button.active { background: var(--accent-soft); }
.theme-menu .tname { flex: 1; display: flex; align-items: center; gap: 8px; }
.theme-menu em { font-style: normal; font-size: 10.5px; font-weight: 600; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 0 6px; }
.chip {
  flex: none; width: 22px; height: 22px; border-radius: 7px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--c1, #fff) 0 42%, var(--c3, #888) 42% 58%, var(--c2, #333) 58%);
}

/* ============ Sidebar ============ */
.sidebar {
  background: var(--panel); border-right: 1px solid var(--border);
  padding: 16px 14px; overflow-y: auto;
}
.side-title, .panel-head h2 {
  margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.side-title { margin-bottom: 12px; }
.palette { display: block; }
.pal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-sub {
  margin: 16px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.side-sub:first-child { margin-top: 0; }
.pal-item {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px;
  min-height: 70px; padding: 10px 4px 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); cursor: grab; user-select: none;
  transition: border-color .15s, box-shadow .15s, transform .1s, background .15s;
}
.pal-item:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); box-shadow: var(--shadow); }
.pal-item:active { cursor: grabbing; }
.tip {
  margin-top: 18px; padding: 12px; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted); line-height: 1.45;
}
.tip b { color: var(--text); display: block; margin-bottom: 6px; }
.tip p { margin: 0 0 6px; display: flex; gap: 6px; }
.tip p:last-child { margin: 0; }
.tip i { color: var(--accent); margin-top: 3px; flex: none; }

/* ============ Stage / canvas ============ */
.stage { position: relative; background: var(--canvas); overflow: hidden; min-width: 0; }
.canvas { width: 100%; height: 100%; touch-action: none; outline: none; user-select: none; -webkit-user-select: none; cursor: default; }
.canvas .dot { fill: var(--dot); }
.stage.pan .canvas, .stage.panmode .canvas { cursor: grab; }
.stage.dragging-pan .canvas { cursor: grabbing; }
.stage.dragging-connect .canvas, .stage.dragging-reconnect .canvas { cursor: crosshair; }
.stage.dragging-move .canvas { cursor: move; }

.node { cursor: move; }
.node .shape { filter: drop-shadow(0 1px 2px rgba(15, 23, 42, .14)); }
.node text { pointer-events: none; user-select: none; }
.node .selbox { fill: none; stroke: var(--accent); stroke-dasharray: 5 4; pointer-events: none; }
.node .port { fill: var(--panel); stroke: var(--accent); opacity: 0; cursor: crosshair; transition: opacity .12s; }
.node:hover .port, .node.selected .port, .node.target .port { opacity: 1; }
.node .port:hover { fill: var(--accent); }
.node.target .shape { stroke: var(--accent) !important; }
.node .rz { fill: var(--panel); stroke: var(--accent); }
.node .rz[data-resize="nw"], .node .rz[data-resize="se"] { cursor: nwse-resize; }
.node .rz[data-resize="ne"], .node .rz[data-resize="sw"] { cursor: nesw-resize; }

.edge { cursor: pointer; }
.edge .hit { fill: none; stroke: transparent; stroke-width: 16; }
.edge .glow { fill: none; stroke: var(--accent); stroke-width: 8; opacity: .22; stroke-linecap: round; }
.edge:hover .line { stroke-width: 3; }
.edge text { pointer-events: none; user-select: none; }
.ehandle { fill: var(--panel); stroke: var(--accent); cursor: crosshair; }
.ehandle:hover { fill: var(--accent); }
.preview { fill: none; stroke: var(--accent); stroke-dasharray: 6 5; pointer-events: none; }
.marquee { fill: var(--accent-soft); stroke: var(--accent); pointer-events: none; }

/* In-place text editor */
.editor {
  position: absolute; z-index: 15;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 6px 10px; border-radius: 8px;
  background: transparent; outline: 2px solid var(--accent); outline-offset: 2px;
  font-family: var(--font); font-weight: 500; line-height: 1.3;
  white-space: pre-wrap; overflow-wrap: anywhere; overflow: hidden;
  caret-color: var(--accent); cursor: text; user-select: text; -webkit-user-select: text;
}
.editor.edge-editor { background: var(--panel); color: var(--text); box-shadow: var(--shadow); min-width: 90px; }

/* Empty state */
.empty { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.empty-card {
  pointer-events: auto; text-align: center; max-width: 360px;
  padding: 30px 28px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.empty-icon { color: var(--accent); display: inline-flex; margin-bottom: 8px; }
.empty-card h1 { margin: 0 0 8px; font-size: 20px; letter-spacing: -.01em; }
.empty-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.drop-hint {
  position: absolute; inset: 14px; z-index: 30; display: grid; place-items: center;
  border: 2px dashed var(--accent); border-radius: 16px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 16px;
  pointer-events: none; backdrop-filter: blur(2px);
}
.drop-hint[hidden] { display: none; }

.status {
  position: absolute; left: 14px; bottom: 12px; font-size: 12px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 11px; box-shadow: var(--shadow); pointer-events: none;
}
.zoombar {
  position: absolute; right: 14px; bottom: 12px; display: flex; align-items: center; gap: 2px;
  padding: 4px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.zoombar .icon-btn { width: 32px; height: 32px; }
.zoombar .sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.zoom-label {
  min-width: 52px; height: 32px; border: 0; background: transparent;
  border-radius: 8px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.zoom-label:hover { background: var(--panel-2); }

/* ============ Inspector ============ */
.inspector {
  background: var(--panel); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 0 0 20px;
}
.panel-head { padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 3px; }
.panel-head .sub { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.insp-sec { padding: 14px 16px; border-top: 1px solid var(--border); }
.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 9px; }
.lbl-row { display: flex; align-items: center; justify-content: space-between; }

.shape-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.shape-btn svg { max-width: 82%; height: auto; }
.shape-btn {
  display: grid; place-items: center; height: 42px; padding: 0;
  border: 1px solid var(--border); border-radius: 9px; background: var(--panel);
  transition: border-color .15s, background .15s;
}
.shape-btn:hover { border-color: var(--accent); }
.shape-btn.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; padding: 0;
  background: var(--f); border: 2.5px solid var(--s);
  transition: transform .1s, box-shadow .15s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.swatch.default {
  background: linear-gradient(135deg, var(--panel) 45%, var(--edge) 45%, var(--edge) 55%, var(--panel) 55%);
  border-color: var(--border);
}

.color-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.color-field { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.color-field input[type="color"] {
  width: 100%; height: 32px; padding: 2px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); cursor: pointer;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }

.seg { display: flex; padding: 3px; gap: 2px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; }
.seg button {
  flex: 1; height: 28px; border: 0; border-radius: 6px; background: transparent;
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg.grid2 { flex-wrap: wrap; }
.seg.grid2 button { flex: 1 1 calc(50% - 2px); }
.seg button.on { background: var(--panel); color: var(--accent); box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.field input[type="text"], .field input[type="number"], .field select {
  width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text); font-size: 13.5px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.num-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; justify-content: center; }
.align-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.align-row .icon-btn { width: 100%; border-color: var(--border); }

.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-weight: 500; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { padding: 12px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--border); }
.stat b { display: block; font-size: 22px; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.logo-box {
  display: grid; place-items: center; height: 84px; padding: 10px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  background: repeating-conic-gradient(var(--panel-2) 0 25%, var(--panel) 0 50%) 0 0 / 14px 14px;
}
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

.brand-preview {
  position: absolute; z-index: 6; display: flex; align-items: center; gap: 9px;
  max-width: 60%; padding: 7px 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  pointer-events: none; opacity: .94;
}
.brand-preview img { display: block; max-width: 160px; object-fit: contain; }
.brand-preview b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-top-left { top: 12px; left: 12px; }
.bp-top-right { top: 12px; right: 12px; }
.bp-bottom-left { bottom: 52px; left: 12px; }
.bp-bottom-right { bottom: 62px; right: 12px; }

#printArea { display: none; }
@media print {
  html, body { height: auto; overflow: visible; background: #fff; }
  .app, .toasts, dialog, .editor { display: none !important; }
  #printArea { display: block; }
  #printArea svg { width: 100%; height: auto; max-height: 100vh; display: block; }
}
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 0; }

/* ============ Toasts & dialog ============ */
.toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; pointer-events: none; }
.toast {
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-weight: 500; box-shadow: var(--shadow-lg); animation: in .2s ease; max-width: 80vw;
}
.toast.error { background: #dc2626; color: #fff; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: .3s; }
@keyframes in { from { opacity: 0; transform: translateY(-8px); } }

.dialog {
  width: min(720px, 92vw); padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 14, 22, .5); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 14px 22px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-body { padding: 18px 22px 22px; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.dialog h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.dialog ul { margin: 0 0 18px; padding-left: 18px; line-height: 1.55; }
.keys { border-collapse: collapse; width: 100%; font-size: 13px; }
.keys td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.keys td:first-child { white-space: nowrap; padding-right: 12px; }
kbd {
  display: inline-block; min-width: 22px; padding: 1px 6px; text-align: center;
  font: 600 11.5px var(--font); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 6px; background: var(--panel-2);
}

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .btn > span:not(.chip) { display: none; }
  .btn { padding: 0 10px; }
  .app { grid-template-columns: 188px minmax(0, 1fr) 260px; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 76px minmax(0, 1fr) 220px; }
  .brand-name, .tip, .pal-label { display: none; }
  .palette { grid-template-columns: 1fr; }
  .title-input { width: 130px; }
  .help-cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .app { grid-template-columns: 64px minmax(0, 1fr); grid-template-areas: "top top" "side stage"; }
  .inspector { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ============ Shape help (?) & tooltip ============ */
.pal-item { position: relative; }
.help-q {
  position: absolute; top: 5px; right: 5px; z-index: 2;
  display: grid; place-items: center; width: 17px; height: 17px;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--muted);
  font-size: 10.5px; font-weight: 700; line-height: 1; cursor: help;
  transition: background .15s, color .15s, border-color .15s;
}
.help-q:hover, .help-q:focus-visible { background: var(--accent); border-color: var(--accent); color: var(--accent-text); outline: none; }
.pal-label { font-size: 11.5px; color: var(--muted); font-weight: 500; text-align: center; line-height: 1.2; }
.tooltip {
  position: fixed; z-index: 300; max-width: 250px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--text); color: var(--bg); border-radius: 10px;
  box-shadow: var(--shadow-lg); font-size: 12.5px; line-height: 1.45;
  pointer-events: none; animation: tip-in .12s ease;
}
.tooltip[hidden] { display: none; }
.tooltip b { font-size: 12.5px; }
.tooltip span { opacity: .9; }
@keyframes tip-in { from { opacity: 0; transform: translateY(2px); } }

.dialog.small { width: min(440px, 92vw); }
.save-hint { margin: 12px 0 0; }
.dialog-actions { margin-top: 16px; justify-content: flex-end; }
.dialog-actions .btn { flex: 0 0 auto; min-width: 88px; }

/* ============ Templates & guides ============ */
.dialog.wide { width: min(900px, 94vw); }
.tpl-note { margin: 0 0 14px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; max-height: 62vh; overflow-y: auto; padding: 2px; }
.tpl-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 10px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--panel);
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.tpl-card:hover, .tpl-card:focus-visible { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); outline: none; }
.tpl-preview { display: block; height: 170px; border-radius: 8px; background: var(--canvas); border: 1px solid var(--border); padding: 6px; margin-bottom: 6px; }
.tpl-preview svg { width: 100%; height: 100%; }
.tpl-title { font-weight: 600; font-size: 14px; }
.tpl-desc { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.guide { stroke: #ec4899; stroke-dasharray: 5 4; pointer-events: none; }

/* ============ Logo ============ */
.brand { display: flex; align-items: center; text-decoration: none; color: inherit; flex: none; }
.brand-logo { display: block; height: 30px; width: auto; }
.empty-logo { display: flex; justify-content: center; margin-bottom: 12px; }
.empty-logo img { display: block; height: 56px; width: auto; }
.logo-on-dark { display: none !important; }
html[data-mode="dark"] .logo-on-light { display: none !important; }
html[data-mode="dark"] .logo-on-dark { display: block !important; }
@media (max-width: 820px) { .brand-logo { height: 24px; } }
@media (max-width: 640px) { .brand-logo { height: 20px; } }

/* export background toggles */
.menu .toggle-item .tick {
  flex: none; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border);
  display: grid; place-items: center; background: var(--panel);
}
.menu .toggle-item.on .tick { background: var(--accent); border-color: var(--accent); }
.menu .toggle-item.on .tick::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px;
  border-left: 2px solid var(--accent-text); border-bottom: 2px solid var(--accent-text); transform: rotate(-45deg);
}

/* ============ Custom theme editor ============ */
.cust-top { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 14px; align-items: end; margin-bottom: 18px; }
.cust-row { grid-template-columns: repeat(5, 1fr); margin: 0 0 18px; }
.cust-lbl { margin-top: 4px; }
.cust-shapes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; max-height: 44vh; overflow-y: auto; padding: 2px; }
.cust-shape {
  display: grid; grid-template-columns: 26px 1fr 78px 78px; gap: 8px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2);
}
.cust-shape .swatch { width: 24px; height: 24px; cursor: default; }
.cust-shape .swatch:hover { transform: none; }
.cust-name { text-transform: capitalize; font-weight: 600; font-size: 13px; }
.cust-shape label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); font-weight: 500; }
.cust-shape input[type="color"] { width: 100%; height: 28px; padding: 2px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); cursor: pointer; }
@media (max-width: 760px) {
  .cust-top { grid-template-columns: 1fr; }
  .cust-row { grid-template-columns: repeat(2, 1fr); }
  .cust-shapes { grid-template-columns: 1fr; }
}

/* font controls */
.color-row.two { grid-template-columns: 1fr 1fr; }
.fc-row { display: grid; grid-template-columns: 1fr 44px; gap: 8px; }
.fc-row select { min-width: 0; }
.fc-row input[type="color"] {
  width: 100%; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); cursor: pointer;
}

/* ============ Right-click menu ============ */
.ctx {
  position: fixed; z-index: 400; min-width: 220px; padding: 5px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); animation: tip-in .1s ease;
}
.ctx button {
  display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent;
  text-align: left; font-size: 13.5px; color: var(--text);
}
.ctx button:hover:not(:disabled), .ctx button:focus-visible { background: var(--accent-soft); outline: none; }
.ctx button:disabled { opacity: .4; cursor: default; }
.ctx button.danger { color: #dc2626; }
.ctx button svg { color: var(--muted); }
.ctx button.danger svg { color: #dc2626; }
.ctx kbd { border: 0; background: transparent; padding: 0; min-width: 0; font: 500 11.5px var(--font); color: var(--muted); }
.ctx-sep { height: 1px; margin: 5px 6px; background: var(--border); }

/* ============ SEO helpers ============ */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.noscript { position: fixed; inset: 0 0 auto 0; z-index: 1000; padding: 14px 20px; background: #fff7ed; color: #7c2d12; border-bottom: 1px solid #fed7aa; font-size: 14px; }
.noscript a { color: inherit; }
.side-nav { margin-top: 14px; }
.side-nav a { display: block; font-size: 12.5px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.side-nav a:hover { color: var(--accent); }
.help-link { margin: 0 0 14px; }
.help-link a { color: var(--accent); }
