* { box-sizing: border-box; }
:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-2: #0f172a;
  --text: #172033;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --green: #10b981;
  --green-soft: #ecfdf5;
  --amber: #f59e0b;
  --amber-soft: #fffbeb;
  --danger: #dc2626;
  --shadow: 0 12px 30px rgba(16,24,40,.08);
  --shadow-strong: 0 18px 40px rgba(16,24,40,.12);
}
html, body { height: 100%; }
body { margin: 0; font-family: Inter, Arial, sans-serif; background: var(--bg); color: var(--text); }
.app { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, #0f172a 0%, #111827 100%); color: #fff; padding: 22px; overflow: auto; border-right: 1px solid rgba(255,255,255,.06); }
.brand { font-size: 22px; font-weight: 900; margin-bottom: 22px; letter-spacing: -.03em; }
.card { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 18px; padding: 16px; margin-bottom: 14px; backdrop-filter: blur(8px); }
.card h3, .panel h3 { margin: 0 0 8px; font-size: 16px; }
.m0 { margin: 0; }
.mt-10 { margin-top: 10px; }
.mt-14 { margin-top: 14px; }
.stack-md { margin-top: 12px; display: grid; gap: 10px; }
.spacer { height: 14px; }
.muted { color: var(--muted); font-size: 14px; }
.sidebar .muted { color: rgba(255,255,255,.66); }
.row { display: flex; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between-center { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 12px; text-align: center; }
.stat strong { display: block; font-size: 18px; line-height: 1; margin-bottom: 4px; }
.stat span { font-size: 12px; opacity: .74; }
.btn { border: 0; background: var(--primary); color: white; padding: 10px 14px; border-radius: 12px; font-weight: 800; cursor: pointer; transition: transform .12s ease, filter .12s ease, box-shadow .12s ease; box-shadow: 0 8px 18px rgba(37,99,235,.18); }
.btn:hover { filter: brightness(.98); transform: translateY(-1px); }
.btn.secondary { background: #e5e7eb; color: #111827; box-shadow: none; }
.btn.ghost { background: transparent; color: inherit; box-shadow: none; border: 1px solid rgba(148,163,184,.28); }
.btn.danger { background: var(--danger); box-shadow: 0 8px 18px rgba(220,38,38,.18); }
.btn.full { width: 100%; }
.small { min-width: 42px; padding-inline: 10px; }
.input, .select, textarea { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid #d1d5db; background: #fff; color: var(--text); font: inherit; outline: none; }
.input:focus, .select:focus, textarea:focus { border-color: rgba(37,99,235,.55); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
textarea { min-height: 100px; resize: vertical; }
.maps { margin-top: 12px; display: grid; gap: 10px; }
.map-item { padding: 13px 14px; border-radius: 16px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); cursor: pointer; transition: .15s ease; position: relative; overflow: hidden; }
.map-item:hover { background: rgba(255,255,255,.09); }
.map-item.active { background: linear-gradient(135deg, rgba(37,99,235,.95) 0%, rgba(59,130,246,.92) 100%); border-color: rgba(255,255,255,.15); }
.map-item-title { font-weight: 800; padding-right: 60px; }
.map-item-sub { font-size: 13px; opacity: .78; margin-top: 4px; }
.map-actions { position: absolute; top: 10px; right: 10px; display: none; gap: 6px; }
.map-item:hover .map-actions, .map-item.active .map-actions { display: flex; }
.icon-btn, .node-tool { border: 0; width: 28px; height: 28px; border-radius: 10px; cursor: pointer; font-weight: 800; }
.icon-btn { background: rgba(255,255,255,.18); color: white; }
.icon-btn:hover { background: rgba(255,255,255,.28); }
.main { padding: 22px; display: flex; flex-direction: column; min-width: 0; gap: 18px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.title { font-size: 30px; font-weight: 900; letter-spacing: -.04em; margin-bottom: 6px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar-group { display: flex; gap: 10px; flex-wrap: wrap; padding: 10px; background: rgba(255,255,255,.75); border: 1px solid #e5e7eb; border-radius: 16px; box-shadow: var(--shadow); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; min-height: 760px; }
.canvas-wrap { position: relative; background: var(--panel); border: 1px solid #e5e7eb; border-radius: 26px; overflow: hidden; box-shadow: var(--shadow); min-height: 760px; isolation: isolate; }
.canvas-controls { position: absolute; top: 16px; left: 16px; z-index: 20; display: flex; gap: 8px; flex-wrap: wrap; padding: 10px; background: rgba(255,255,255,.92); border: 1px solid #e5e7eb; border-radius: 16px; box-shadow: var(--shadow); }
.canvas-surface { position: absolute; inset: 0; overflow: hidden; cursor: grab; background-image: linear-gradient(to right, rgba(148,163,184,.12) 1px, transparent 1px), linear-gradient(to bottom, rgba(148,163,184,.12) 1px, transparent 1px); background-size: 28px 28px; background-position: center; }
.surface-content { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
svg.lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.node-layer { position: absolute; inset: 0; }
.node { position: absolute; min-width: 190px; max-width: 260px; background: #fff; border: 2px solid #dbeafe; border-radius: 18px; padding: 14px 14px 12px; box-shadow: 0 12px 28px rgba(37,99,235,.08); cursor: grab; user-select: none; transition: box-shadow .14s ease, transform .14s ease; }
.node:hover { box-shadow: 0 18px 34px rgba(37,99,235,.12); }
.node.dragging { cursor: grabbing; z-index: 15; box-shadow: var(--shadow-strong); }
.node.active { outline: 3px solid rgba(37,99,235,.16); }
.node h4 { margin: 0 0 8px; font-size: 16px; line-height: 1.2; letter-spacing: -.02em; }
.node p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.node.root { border-color: var(--primary); background: var(--primary-soft); }
.node.section { border-color: var(--green); background: var(--green-soft); }
.node.page { border-color: var(--amber); background: var(--amber-soft); }
.node small { display: inline-flex; margin-top: 10px; font-size: 11px; font-weight: 800; color: #64748b; text-transform: uppercase; letter-spacing: .08em; }
.node-tools { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; opacity: 0; transition: opacity .12s ease; }
.node:hover .node-tools, .node.active .node-tools { opacity: 1; }
.node-tool { background: rgba(255,255,255,.82); box-shadow: 0 6px 12px rgba(15,23,42,.08); color: #334155; }
.node-tool:hover { background: white; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: 32px; z-index: 1; }
.empty-card { background: rgba(255,255,255,.88); border: 1px solid #e5e7eb; border-radius: 22px; padding: 26px; max-width: 420px; box-shadow: var(--shadow); }
.empty-title { margin: 0 0 8px; font-size: 20px; }
.empty-text { font-size: 15px; line-height: 1.5; }
.panel { background: var(--panel); border: 1px solid #e5e7eb; border-radius: 24px; padding: 18px; box-shadow: var(--shadow); align-self: start; position: sticky; top: 22px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 700; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.legend { display: flex; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #e5e7eb; border-radius: 999px; padding: 8px 12px; font-size: 13px; box-shadow: 0 6px 16px rgba(15,23,42,.04); }
.dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.dot.blue { background: #2563eb; }
.dot.green { background: #10b981; }
.dot.amber { background: #f59e0b; }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.tag { display: inline-flex; align-items: center; gap: 8px; background: #eef2ff; color: #4338ca; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.subtle { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 16px; padding: 12px; }
.badge-row { display: flex; gap: 8px; flex-wrap: wrap; }
.note { margin-top: 10px; padding: 10px 12px; border-radius: 14px; background: #f8fafc; border: 1px dashed #cbd5e1; font-size: 12px; color: #475569; line-height: 1.45; }
.flash { padding: 12px 14px; border-radius: 14px; border: 1px solid #cbd5e1; background: #fff; box-shadow: var(--shadow); }
.flash.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash.success { background: #ecfdf5; border-color: #bbf7d0; color: #166534; }
.hidden { display: none !important; }
@media (max-width: 1180px) { .workspace { grid-template-columns: 1fr; } .panel { position: static; } }
@media (max-width: 980px) { .app { grid-template-columns: 1fr; } .topbar { flex-direction: column; align-items: stretch; } .toolbar { justify-content: flex-start; } }
