/* ═══ Design tokens ═══════════════════════════════════════════════════════ */
:root {
  --accent: #25d366;
  --accent-ink: #05230f;
  --accent-soft: rgba(37, 211, 102, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.13);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.12);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --sidebar-w: 264px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.16);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0e1117;
  --bg-elev: #151a23;
  --bg-elev-2: #1b2230;
  --bg-input: #10151d;
  --border: #262e3d;
  --border-strong: #35405360;
  --text: #e6edf7;
  --text-dim: #8d9bb0;
  --text-faint: #5f6b7f;
  --canvas: #0b0e14;
  --canvas-grid: #1a2130;
}

:root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-elev: #ffffff;
  --bg-elev-2: #f8fafc;
  --bg-input: #ffffff;
  --border: #dde3ec;
  --border-strong: #c4cddb;
  --text: #16202e;
  --text-dim: #5b6779;
  --text-faint: #8b97a8;
  --canvas: #eef1f6;
  --canvas-grid: #dde3ec;
  --shadow: 0 10px 30px rgba(15, 30, 60, 0.1);
  --shadow-sm: 0 1px 4px rgba(15, 30, 60, 0.08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.center { text-align: center; }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 12px; }
.wrap { flex-wrap: wrap; }
.gap-sm { gap: 8px; }
.gap-lg { gap: 20px; }
.between { justify-content: space-between; }
.right { margin-left: auto; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--bg-elev-2);
  padding: 1px 5px;
  border-radius: 4px;
}

a { color: var(--accent); }

/* ═══ Login ═══════════════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent),
    radial-gradient(700px 400px at 110% 110%, var(--info-soft), transparent);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.login-brand h1 { font-size: 19px; margin: 0; }
.login-brand p { margin: 2px 0 0; font-size: 13px; }

.login-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px;
  flex-shrink: 0;
}
.login-logo.small { width: 32px; height: 32px; font-size: 15px; border-radius: 9px; }

/* ═══ Shell ═══════════════════════════════════════════════════════════════ */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.sidebar-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sidebar-title strong { font-size: 14px; }
.sidebar-close { display: none; margin-left: auto; }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-group {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); padding: 14px 10px 6px; font-weight: 600;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 13.5px;
  font-family: inherit;
}
.nav-item:hover { background: var(--bg-elev-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.nav-icon { width: 18px; text-align: center; flex-shrink: 0; opacity: 0.85; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  border-radius: 20px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--info-soft); color: var(--info);
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(8px);
}
.topbar-title { min-width: 0; }
.topbar-title h2 { margin: 0; font-size: 17px; }
.topbar-title p { margin: 1px 0 0; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.menu-btn { display: none; }

.content { padding: 22px; flex: 1; min-width: 0; }

/* ═══ Buttons ═════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.12s, background 0.12s;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #2a1a00; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.icon-btn {
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim); cursor: pointer;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: grid; place-items: center; font-size: 15px; font-family: inherit;
}
.icon-btn:hover { background: var(--bg-elev-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ═══ Forms ═══════════════════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.field-hint { font-size: 11.5px; color: var(--text-faint); }

input[type="text"], input[type="password"], input[type="number"],
input[type="url"], input[type="search"], input[type="datetime-local"],
input[type="date"], textarea, select {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text);
  font: inherit; font-size: 13.5px;
}
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
select { cursor: pointer; }

.check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.form-grid.one { grid-template-columns: 1fr; }

/* i18n field: three languages side by side */
.i18n { display: grid; gap: 8px; }
.i18n-row { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: start; }
.i18n-tag {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase;
  color: var(--text-faint); background: var(--bg-elev-2);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 0; text-align: center;
}

/* ═══ Cards & layout ══════════════════════════════════════════════════════ */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 15px; }
.card-head .right { margin-left: auto; }

.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-label { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.stat-value { font-size: 27px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.stat-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* ═══ Pills, alerts, tables ═══════════════════════════════════════════════ */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.pill-ok { background: var(--accent-soft); color: var(--accent); }
.pill-err { background: var(--danger-soft); color: var(--danger); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-muted { background: var(--bg-elev-2); color: var(--text-dim); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.alert {
  padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 13px; border: 1px solid transparent;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.alert-ok { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  background: var(--bg-elev-2); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim);
  position: sticky; top: 0; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-elev-2); }
td.actions { text-align: right; white-space: nowrap; }

.empty { padding: 44px 20px; text-align: center; color: var(--text-dim); }
.empty-icon { font-size: 34px; opacity: 0.4; display: block; margin-bottom: 10px; }

.pager { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 14px; }

/* ═══ Modal ═══════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  display: grid; place-items: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 720px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal.wide { max-width: 1000px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
}

/* ═══ Toasts ══════════════════════════════════════════════════════════════ */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm); padding: 11px 15px;
  box-shadow: var(--shadow); max-width: 380px; font-size: 13px;
  animation: slide-in 0.18s ease-out;
}
.toast.ok { border-left-color: var(--accent); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ═══ Tabs ════════════════════════════════════════════════════════════════ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 15px; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ═══ Flow builder ════════════════════════════════════════════════════════ */
.builder {
  display: grid;
  grid-template-columns: 210px 1fr 330px;
  gap: 0;
  height: calc(100vh - 62px);
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
}

.palette { border-right: 1px solid var(--border); overflow-y: auto; padding: 12px; }
.palette h4 {
  margin: 4px 0 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-faint);
}
.palette-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; margin-bottom: 5px;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: grab; font-size: 12.5px; font-weight: 600;
  user-select: none;
}
.palette-item:hover { border-color: var(--accent); }
.palette-item:active { cursor: grabbing; }
.palette-swatch { width: 8px; height: 22px; border-radius: 3px; flex-shrink: 0; }

.canvas-wrap { position: relative; overflow: hidden; background: var(--canvas); }
.canvas {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--canvas-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--canvas-grid) 1px, transparent 1px);
  background-size: 22px 22px;
  transform-origin: 0 0;
  cursor: grab;
}
.canvas.panning { cursor: grabbing; }
.canvas-inner { position: absolute; inset: 0; transform-origin: 0 0; }

.canvas-toolbar {
  position: absolute; top: 12px; left: 12px; z-index: 10;
  display: flex; gap: 6px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px; box-shadow: var(--shadow-sm);
}
.canvas-hint {
  position: absolute; bottom: 12px; left: 12px; z-index: 10;
  font-size: 11.5px; color: var(--text-faint);
  background: color-mix(in srgb, var(--bg-elev) 85%, transparent);
  padding: 5px 10px; border-radius: 6px; pointer-events: none;
}

.node {
  position: absolute;
  width: 210px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--info);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: move;
  user-select: none;
  font-size: 12px;
}
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.node.invalid { border-color: var(--danger); }
.node-head { padding: 7px 10px; display: flex; align-items: center; gap: 7px; }
.node-type { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); font-weight: 700; }
.node-title { font-weight: 700; font-size: 12.5px; padding: 0 10px 7px; line-height: 1.35; }
.node-preview {
  padding: 0 10px 8px; font-size: 11px; color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.node-ports { border-top: 1px solid var(--border); }
.node-port {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; font-size: 11px; color: var(--text-dim);
  position: relative;
}
.node-port:hover { background: var(--bg-elev-2); }
.port-dot {
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--border-strong); background: var(--bg-elev);
  position: absolute; right: -6px; cursor: crosshair; flex-shrink: 0;
}
.port-dot:hover, .port-dot.linking { border-color: var(--accent); background: var(--accent); }
.port-dot.connected { border-color: var(--accent); }
.port-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-in {
  position: absolute; left: -7px; top: 14px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg-elev); border: 2px solid var(--border-strong);
}
.node-in.target { border-color: var(--accent); background: var(--accent); }

/* transform-origin must match .canvas-inner exactly: the default (50% 50%)
   would scale the edge layer about its centre while blocks scale about their
   top-left corner, so connections drift further from their ports the more the
   canvas is zoomed. */
.edges {
  position: absolute; inset: 0;
  transform-origin: 0 0;
  pointer-events: none; overflow: visible;
}
.edge-path { fill: none; stroke: var(--border-strong); stroke-width: 2; }
.edge-path.hot { stroke: var(--accent); stroke-width: 2.5; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }

.inspector { border-left: 1px solid var(--border); overflow-y: auto; padding: 16px; }
.inspector h4 { margin: 0 0 4px; font-size: 14px; }
.inspector-empty { color: var(--text-faint); text-align: center; padding: 40px 10px; font-size: 13px; }
.inspector .field { margin-bottom: 14px; }

.repeater-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; margin-bottom: 8px; background: var(--bg-elev-2);
}
.repeater-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.repeater-head .key-input { flex: 1; }

/* Simulator */
.sim { display: flex; flex-direction: column; height: 100%; }
.sim-log {
  flex: 1; overflow-y: auto; padding: 14px;
  background: var(--canvas); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 9px; min-height: 260px;
}
.bubble { max-width: 82%; padding: 8px 12px; border-radius: 14px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.bubble.bot { background: var(--bg-elev-2); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.user { background: var(--accent); color: var(--accent-ink); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.meta { align-self: center; background: var(--info-soft); color: var(--info); font-size: 11.5px; border-radius: 8px; }
.sim-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sim-option {
  padding: 5px 11px; border-radius: 16px; font-size: 12px; cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--accent); color: var(--accent);
  font-family: inherit; font-weight: 600;
}
.sim-option:hover { background: var(--accent-soft); }

/* Logs viewer */
.logs {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.65;
  background: var(--canvas); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
  max-height: 460px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.log-line { display: flex; gap: 9px; }
.log-ts { color: var(--text-faint); flex-shrink: 0; }
.log-lvl { font-weight: 700; flex-shrink: 0; width: 42px; }
.log-lvl.error { color: var(--danger); }
.log-lvl.warn { color: var(--warn); }
.log-lvl.info { color: var(--info); }
.log-lvl.debug { color: var(--text-faint); }

.progress { height: 7px; background: var(--bg-elev-2); border-radius: 20px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); transition: width 0.3s; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.media-item { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-elev-2); }
.media-item img { width: 100%; height: 92px; object-fit: cover; display: block; }
.media-item .media-name { padding: 6px 8px; font-size: 11px; word-break: break-all; }
.media-item.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ Responsive ══════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .builder { grid-template-columns: 170px 1fr 290px; }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .sidebar-close, .menu-btn { display: grid; }
  .content { padding: 16px; }
  .builder { grid-template-columns: 1fr; height: auto; }
  .palette, .inspector { border: none; border-bottom: 1px solid var(--border); max-height: 260px; }
  .canvas-wrap { height: 60vh; }
}
