:root {
  --bg: #070b14;
  --bg-2: #0a1120;
  --panel: rgba(13, 20, 32, 0.78);
  --panel-solid: #0d1420;
  --panel-2: #111a2a;
  --border: rgba(148, 163, 184, 0.14);
  --border-2: rgba(148, 163, 184, 0.26);
  --text: #e6edf7;
  --muted: #8b9bb4;
  --cyan: #38bdf8;
  --cyan-2: #0ea5e9;
  --violet: #a78bfa;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 600px at 12% -10%, rgba(56, 189, 248, 0.16), transparent 60%),
    radial-gradient(800px 520px at 92% 0%, rgba(167, 139, 250, 0.13), transparent 62%),
    radial-gradient(1000px 700px at 50% 110%, rgba(14, 165, 233, 0.08), transparent 60%),
    var(--bg);
  z-index: -2;
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 75%);
  z-index: -1;
  pointer-events: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.spark { color: var(--cyan); }

h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--cyan); text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.22); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.38); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.view { height: 100%; }

/* ── buttons / inputs ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid var(--border-2);
  background: rgba(148, 163, 184, 0.06);
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.01em;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
  white-space: nowrap;
}
.btn:hover { background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.38); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: #04121f;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.3);
}
.btn.primary:hover { box-shadow: 0 10px 30px rgba(56, 189, 248, 0.42); filter: brightness(1.05); }
.btn.accent {
  border-color: rgba(56, 189, 248, 0.45);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(167, 139, 250, 0.16));
  color: #d8f3ff;
  box-shadow: inset 0 0 22px rgba(56, 189, 248, 0.1);
}
.btn.accent:hover { border-color: rgba(56, 189, 248, 0.75); box-shadow: 0 0 26px rgba(56, 189, 248, 0.22); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(148, 163, 184, 0.1); }
.btn.danger { border-color: rgba(248, 113, 113, 0.35); color: #fecaca; background: rgba(248, 113, 113, 0.08); }
.btn.danger:hover { background: rgba(248, 113, 113, 0.16); border-color: rgba(248, 113, 113, 0.6); }
.btn.tiny { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn.small { height: 34px; padding: 0 12px; font-size: 12.5px; }
.btn.wide { width: 100%; height: 44px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: rgba(148, 163, 184, 0.12); color: var(--text); }

.input, .field input, .field textarea, .field select {
  width: 100%;
  background: rgba(2, 6, 16, 0.55);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.input:focus, .field input:focus, .field textarea:focus, .field select:focus {
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.13);
  background: rgba(2, 6, 16, 0.8);
}
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase; }
.field textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px; border-radius: 11px;
  border: 1px solid var(--border); background: rgba(2, 6, 16, 0.45);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.search-box:focus-within { border-color: rgba(56, 189, 248, 0.55); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1); }
.search-box svg { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search-box input { border: 0; background: transparent; outline: none; height: 100%; width: 190px; padding: 0; }
.search-box.small { height: 36px; }
.search-box.small input { width: 100%; }

/* ── login ────────────────────────────────────────────────────────── */
.login-view { position: relative; display: grid; place-items: center; padding: 24px; overflow: hidden; }
.login-glow {
  position: absolute; width: 720px; height: 720px; border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.16), transparent 62%);
  filter: blur(20px); animation: breathe 9s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(1.12); opacity: 1; } }
.login-grid {
  position: absolute; inset: -20%;
  background-image:
    repeating-linear-gradient(30deg, rgba(56, 189, 248, 0.07) 0 1px, transparent 1px 54px),
    repeating-linear-gradient(-30deg, rgba(56, 189, 248, 0.07) 0 1px, transparent 1px 54px);
  mask-image: radial-gradient(circle at 50% 50%, #000 10%, transparent 62%);
}
.login-card {
  position: relative; width: min(430px, 100%); padding: 38px 36px 28px;
  border-radius: 22px; border: 1px solid var(--border-2);
  background: linear-gradient(180deg, rgba(17, 26, 42, 0.9), rgba(10, 16, 28, 0.92));
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.logo-cube { width: 82px; height: 82px; margin: 0 auto 16px; filter: drop-shadow(0 12px 26px rgba(56, 189, 248, 0.4)); animation: float 6s ease-in-out infinite; }
.logo-cube svg { width: 100%; height: 100%; display: block; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-7px) rotate(-2deg); } }
.login-card h1 { text-align: center; font-size: 27px; letter-spacing: -0.02em; font-weight: 700; }
.login-card h1 span { background: linear-gradient(90deg, #67e8f9, #818cf8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-sub { text-align: center; font-size: 13.5px; margin: 8px 0 26px; }
.login-card .field span { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.login-card .field input { height: 44px; }
.form-error { min-height: 20px; color: #fca5a5; font-size: 13px; margin: 2px 0 10px; }
.login-foot { text-align: center; margin-top: 20px; font-size: 12px; color: var(--muted); }
.login-foot span { color: rgba(56, 189, 248, 0.8); font-family: var(--mono); font-size: 11.5px; }

/* ── app shell ────────────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 18px;
  height: 62px; padding: 0 18px; flex: none;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 13, 23, 0.82);
  backdrop-filter: blur(16px);
  z-index: 20;
}
.brand-mini {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; color: var(--text); padding: 0;
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
}
.brand-mini svg { width: 34px; height: 34px; filter: drop-shadow(0 6px 14px rgba(56, 189, 248, 0.35)); }
.brand-mini b { color: var(--cyan); font-weight: 700; }
.topbar-title { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; padding-left: 8px; border-left: 1px solid var(--border); }
.diagram-name {
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  font-size: 14.5px; font-weight: 600; padding: 3px 8px; margin-left: -8px; max-width: 520px; width: 100%;
  outline: none; transition: background 0.16s ease, border-color 0.16s ease;
}
.diagram-name:hover { background: rgba(148, 163, 184, 0.07); }
.diagram-name:focus { background: rgba(2, 6, 16, 0.6); border-color: rgba(56, 189, 248, 0.5); }
.diagram-meta { font-size: 11.5px; color: var(--muted); padding-left: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.editor-actions { display: flex; align-items: center; gap: 8px; }
.save-indicator { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.save-indicator::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: 0.5; }
.save-indicator.dirty::before { background: var(--amber); opacity: 1; animation: pulse 1.6s infinite; }
.save-indicator.saving::before { background: var(--cyan); opacity: 1; animation: pulse 1s infinite; }
.save-indicator.saved::before { background: var(--green); opacity: 1; }
.save-indicator.error::before { background: var(--red); opacity: 1; animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 12px; border-left: 1px solid var(--border); }
.avatar {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #38bdf8, #6366f1); color: #04121f; font-weight: 800; font-size: 13px;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}
.user-name { font-size: 13px; font-weight: 600; color: #cbd5e1; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; padding: 6px;
  border-radius: 12px; border: 1px solid var(--border-2);
  background: #0e1626; box-shadow: var(--shadow); z-index: 60;
  animation: pop 0.14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.menu button {
  display: block; width: 100%; text-align: left; padding: 9px 11px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font-size: 13px;
}
.menu button:hover { background: rgba(56, 189, 248, 0.12); }
.menu-sep { display: block; height: 1px; background: var(--border); margin: 5px 4px; }

/* ── pages ────────────────────────────────────────────────────────── */
.page { flex: 1; min-height: 0; overflow: auto; }
.dashboard { padding: 34px 38px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head h1 { font-size: 28px; letter-spacing: -0.025em; font-weight: 700; }
.page-head p { margin-top: 7px; font-size: 13.5px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 18px; }
.card {
  position: relative; border-radius: var(--radius); border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(17, 26, 42, 0.75), rgba(10, 16, 28, 0.85));
  overflow: hidden; cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  animation: rise 0.35s ease both;
}
.card:hover { transform: translateY(-3px); border-color: rgba(56, 189, 248, 0.45); box-shadow: 0 20px 46px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(56, 189, 248, 0.12); }
.card-thumb {
  position: relative; height: 168px; display: grid; place-items: center; overflow: hidden;
  background:
    radial-gradient(circle at 50% 120%, rgba(56, 189, 248, 0.14), transparent 62%),
    repeating-linear-gradient(30deg, rgba(148, 163, 184, 0.05) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(-30deg, rgba(148, 163, 184, 0.05) 0 1px, transparent 1px 26px),
    #0a1120;
  border-bottom: 1px solid var(--border);
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-thumb .thumb-fallback svg { width: 104px; height: 104px; opacity: 0.85; }
.card-body { padding: 13px 15px 15px; }
.card-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { margin-top: 5px; display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--muted); }
.card-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); opacity: 0.6; }
.card-actions {
  position: absolute; top: 10px; right: 10px; display: flex; gap: 5px; opacity: 0; transform: translateY(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.card:hover .card-actions { opacity: 1; transform: none; }
.card-actions button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border-2);
  background: rgba(7, 11, 20, 0.8); backdrop-filter: blur(8px); color: #cbd5e1;
  display: grid; place-items: center;
}
.card-actions button:hover { border-color: rgba(56, 189, 248, 0.5); color: var(--cyan); }
.card-actions button.del:hover { border-color: rgba(248, 113, 113, 0.6); color: var(--red); }
.card-actions svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-icon svg { width: 118px; height: 118px; filter: drop-shadow(0 16px 34px rgba(56, 189, 248, 0.18)); }
.empty h2 { color: var(--text); font-size: 20px; margin: 18px 0 8px; }
.empty p { max-width: 420px; font-size: 13.5px; line-height: 1.6; }
.empty-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ── editor layout ────────────────────────────────────────────────── */
.editor {
  display: grid; grid-template-columns: 286px minmax(0, 1fr) 312px;
  overflow: hidden; height: 100%;
}
.palette, .inspector {
  display: flex; flex-direction: column; min-height: 0;
  background: rgba(9, 15, 26, 0.72);
  backdrop-filter: blur(12px);
}
.palette { border-right: 1px solid var(--border); }
.inspector { border-left: 1px solid var(--border); overflow-y: auto; }
.palette-head { padding: 12px; border-bottom: 1px solid var(--border); flex: none; }
.palette-body { flex: 1; overflow-y: auto; padding: 8px 10px 30px; }
.palette-group { margin-top: 12px; }
.palette-group h3 {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted);
  padding: 0 6px 7px; font-weight: 700;
}
.palette-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.icon-tile {
  position: relative; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 8px 4px 7px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.12s ease;
  cursor: grab; user-select: none;
}
.icon-tile:hover { background: rgba(148, 163, 184, 0.08); border-color: var(--border); transform: translateY(-1px); }
.icon-tile:active { cursor: grabbing; }
.icon-tile.dragging { opacity: 0.4; }
.tile-art { width: 62px; height: 62px; display: grid; place-items: center; }
.tile-art svg { width: 62px; height: 62px; overflow: visible; }
.tile-name { font-size: 10.5px; color: #b6c2d4; text-align: center; line-height: 1.15; max-width: 100%; }
.palette-empty { padding: 30px 12px; text-align: center; color: var(--muted); font-size: 13px; }

.canvas-wrap { position: relative; min-width: 0; overflow: hidden; background: radial-gradient(circle at 50% 40%, rgba(56, 189, 248, 0.04), transparent 70%); }
#canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: default; }
#canvas.tool-pan { cursor: grab; }
#canvas.tool-pan.panning { cursor: grabbing; }
#canvas.tool-connect { cursor: crosshair; }
#canvas.tool-marquee { cursor: crosshair; }
.marquee-rect { fill: rgba(56, 189, 248, 0.12); stroke: #38bdf8; stroke-width: 1; stroke-dasharray: 6 4; pointer-events: none; }
#canvas.drop-active { box-shadow: inset 0 0 0 2px rgba(56, 189, 248, 0.5); }

.node { cursor: grab; }
.node:active { cursor: grabbing; }
.node .node-hit { fill: transparent; }
.node .node-art { color: var(--node-color, #38bdf8); transition: filter 0.15s ease; }
.node:hover .node-art { filter: brightness(1.12); }
.node.selected .node-art { filter: drop-shadow(0 0 12px color-mix(in srgb, var(--node-color, #38bdf8) 55%, transparent)); }
.node.selected .node-ring { opacity: 1; }
.node-ring {
  fill: none; stroke: var(--node-color, #38bdf8); stroke-width: 2; stroke-dasharray: 4 5;
  opacity: 0; transition: opacity 0.15s ease; pointer-events: none;
}
.node-label {
  font-weight: 600; fill: #e8eef8; text-anchor: middle;
  paint-order: stroke; stroke: rgba(7, 11, 20, 0.92); stroke-width: 4px; stroke-linejoin: round;
  pointer-events: none;
}
.node-sub { font-size: 10.5px; fill: #93a3ba; text-anchor: middle; paint-order: stroke; stroke: rgba(7, 11, 20, 0.9); stroke-width: 3px; pointer-events: none; }
.node-label-bg { fill: rgba(7, 11, 20, 0.55); pointer-events: none; }

.link-path { fill: none; stroke: var(--link-color, #5b708c); stroke-linecap: round; stroke-linejoin: round; transition: filter 0.15s ease, stroke 0.15s ease; }
.link-path.dashed { stroke-dasharray: 9 7; }
.link-path.dotted { stroke-dasharray: 2 6; }
.link-arrow { fill: var(--link-color, #5b708c); transition: fill 0.15s ease; }
.link-hit { fill: none; stroke: transparent; stroke-width: 18; stroke-linecap: round; cursor: pointer; }
.link.selected .link-path { stroke: var(--link-color, var(--cyan)); filter: url(#linkGlow) brightness(1.3); }
.link.selected .link-arrow { fill: var(--link-color, var(--cyan)); }
.link.selected .link-hit { stroke: rgba(56, 189, 248, 0.2); }
.link:hover .link-path { filter: brightness(1.3); }
.link-label-group { cursor: move; }
.link-label-group:hover .link-label-bg { stroke: rgba(56, 189, 248, 0.65); }
.link-label { fill: #b8c7db; text-anchor: middle; paint-order: stroke; stroke: rgba(7, 11, 20, 0.9); stroke-width: 3px; pointer-events: none; }
.link-label-bg { fill: rgba(7, 11, 20, 0.72); stroke: rgba(148, 163, 184, 0.18); rx: 5; pointer-events: all; }

.canvas-empty {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
}
.canvas-empty-inner {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 22px 26px; border-radius: 16px; border: 1px dashed rgba(56, 189, 248, 0.28);
  background: rgba(9, 15, 26, 0.55); backdrop-filter: blur(6px); pointer-events: auto;
  max-width: 340px;
}
.canvas-empty-inner strong { font-size: 15px; }
.canvas-empty-inner span { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.editor-toolbar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 6px;
  border-radius: 13px; border: 1px solid var(--border-2);
  background: rgba(10, 16, 28, 0.88); backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  z-index: 10;
}
.tool {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--muted); display: grid; place-items: center; font-size: 15px;
  transition: background 0.14s ease, color 0.14s ease;
}
.tool svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { background: rgba(148, 163, 184, 0.12); color: var(--text); }
.tool.active { background: rgba(56, 189, 248, 0.16); border-color: rgba(56, 189, 248, 0.4); color: var(--cyan); }
.tool.disabled { opacity: 0.35; pointer-events: none; }
.tool-sep { width: 1px; height: 20px; background: var(--border); margin: 0 3px; }
.zoom-label { font-size: 11px; color: var(--muted); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }

/* ── inspector ────────────────────────────────────────────────────── */
.inspector-head { padding: 16px 16px 10px; flex: none; }
.inspector-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; }
.insp-empty { padding: 8px 16px 20px; font-size: 13px; line-height: 1.6; }
.hints { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 9px; font-size: 12px; color: var(--muted); }
.hints li { display: flex; gap: 8px; align-items: baseline; }
.hints li::before { content: "›"; color: var(--cyan); font-weight: 700; }
.hints b { color: #cbd5e1; font-weight: 600; }
.insp-section { padding: 6px 16px 24px; }
.insp-preview { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.insp-icon { width: 66px; height: 66px; border-radius: 13px; border: 1px solid var(--border); background: rgba(2, 6, 16, 0.5); display: grid; place-items: center; overflow: hidden; }
.insp-icon svg { width: 62px; height: 62px; overflow: visible; }
.insp-icon.link-icon svg { width: 40px; height: 40px; }
.insp-type { font-size: 14px; font-weight: 600; }
.insp-id { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 3px; word-break: break-all; }
.color-row { display: flex; align-items: center; gap: 10px; }
.scale-value { color: var(--cyan); font-family: var(--mono); font-size: 11px; margin-left: 6px; letter-spacing: 0; }
.field input.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.75), rgba(148, 163, 184, 0.18));
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
  cursor: pointer;
}
.field input.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px; height: 17px; border-radius: 50%;
  background: #38bdf8; border: 2px solid #04121f;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
}
.field input.range::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: #38bdf8; border: 2px solid #04121f;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
}
.color-row input[type="color"] {
  width: 42px; height: 34px; padding: 2px; border-radius: 9px; border: 1px solid var(--border);
  background: rgba(2, 6, 16, 0.5); cursor: pointer;
}
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch:hover { border-color: rgba(255, 255, 255, 0.5); }
.insp-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }

/* ── modals / toasts ──────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 22px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 6, 12, 0.72); backdrop-filter: blur(8px); animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative; width: min(660px, 100%); max-height: 88vh; overflow-y: auto;
  padding: 24px; border-radius: 18px; border: 1px solid var(--border-2);
  background: linear-gradient(180deg, #101a2b, #0a111e);
  box-shadow: var(--shadow); animation: rise 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-card.small { width: min(460px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.modal-head h2 { font-size: 19px; letter-spacing: -0.02em; }
.modal-head p { font-size: 13px; margin-top: 5px; }
.modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions > div { display: flex; gap: 8px; }
.ai-status { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; min-height: 18px; }
.ai-status.warn { color: #fcd34d; }
.ai-status.err { color: #fca5a5; }
.ai-status.ok { color: #6ee7b7; }
.ai-model { font-size: 11px; font-family: var(--mono); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.chip {
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.06); color: #b9c7da; font-size: 11.5px;
}
.chip:hover { border-color: rgba(56, 189, 248, 0.45); color: var(--cyan); }
.export-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.export-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px 14px; border-radius: 11px; border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.05); text-align: left;
}
.export-item:hover { border-color: rgba(56, 189, 248, 0.45); background: rgba(56, 189, 248, 0.08); }
.export-item b { font-size: 13.5px; }
.export-item span { font-size: 11.5px; color: var(--muted); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; min-width: 210px; max-width: 360px; padding: 11px 14px;
  border-radius: 11px; border: 1px solid var(--border-2);
  background: rgba(13, 20, 32, 0.94); backdrop-filter: blur(12px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4); font-size: 12.5px; line-height: 1.45;
  animation: rise 0.22s ease;
}
.toast.ok { border-color: rgba(52, 211, 153, 0.45); }
.toast.err { border-color: rgba(248, 113, 113, 0.5); }
.toast.info { border-color: rgba(56, 189, 248, 0.4); }
.toast b { display: block; font-size: 12.5px; margin-bottom: 2px; }
.toast span { color: var(--muted); }

/* ── responsive ───────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .editor { grid-template-columns: 250px minmax(0, 1fr); }
  .inspector { display: none; }
}
@media (max-width: 860px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .palette { display: none; }
  .dashboard { padding: 22px 18px 50px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand-mini span { display: none; }
  .diagram-name { max-width: 100%; }
  .user-name { display: none; }
  .page-head h1 { font-size: 23px; }
  .search-box input { width: 130px; }
}
@media (max-width: 560px) {
  .btn { padding: 0 12px; }
  .page-actions .search-box { display: none; }
  .editor-actions .btn span.spark { display: none; }
  .modal-card { padding: 18px; }
}

/* ── áreas, textos y puntos de ruta ───────────────────────────────── */
.insp-hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 0 0 10px; }
.checkbox-field { flex-direction: row; align-items: center; gap: 9px; }
.checkbox-field > span { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }
.checkbox-field input { width: 16px; height: 16px; accent-color: var(--cyan); }
.tool-text { font-weight: 800; font-family: var(--mono); font-size: 14px; }
.tool-area { font-size: 17px; }
.area-shape { transition: opacity 0.15s ease; }
.area.selected .area-shape { stroke: #38bdf8; stroke-dasharray: 7 5; stroke-opacity: 1; }
.area-hit { fill: rgba(0, 0, 0, 0); cursor: move; }
.area-label {
  font-weight: 700; letter-spacing: 0.04em; text-anchor: middle;
  paint-order: stroke; stroke: rgba(7, 11, 20, 0.9); stroke-width: 4px; pointer-events: none;
}
.diagram-text { cursor: move; }
.text-hit { fill: rgba(56, 189, 248, 0); stroke: transparent; }
.diagram-text.selected .text-hit {
  fill: rgba(56, 189, 248, 0.08);
  stroke: rgba(56, 189, 248, 0.55);
  stroke-dasharray: 4 4;
}
.text-shape { pointer-events: visiblePainted; cursor: move; user-select: none; }
.link-wp { cursor: grab; }
.link-wp:active { cursor: grabbing; }
.link-wp-hit { fill: transparent; }
.link-wp-dot { fill: #0b1220; stroke: #38bdf8; stroke-width: 2; }
.area-icon, .text-icon { font-size: 26px; color: var(--cyan); font-weight: 700; }
