:root {
    --bg: #0a0a0f;
    --bg-panel: #12121a;
    --border: #26263a;
    --text: #e6e9ef;
    --dim: #7a7f8c;
    --accent: #00f0ff;
    --accent-warm: #ff6b6b;
    --accent-moss: #00ff41;
    --danger: #ff4d6d;
    --font-ui: "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

#app { position: relative; width: 100vw; height: 100vh; }

canvas#graph {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse at 50% 50%, #131324 0%, var(--bg) 70%);
    cursor: grab;
    touch-action: none;
}
canvas#graph.grabbing { cursor: grabbing; }
canvas#graph.linking { cursor: crosshair; }

/* ─── Bars ─── */
.bar {
    position: absolute;
    left: 50%; transform: translateX(-50%);
    background: rgba(18, 18, 26, 0.78);
    border: 1px solid var(--border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 10px 14px;
    display: flex; align-items: center; gap: 14px;
    border-radius: 14px;
    z-index: 10;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.bar-top { top: 14px; }
.bar-bottom { bottom: 14px; flex-wrap: wrap; max-width: 96vw; }

.brand {
    font-family: var(--font-mono);
    font-weight: 700; font-size: 12px;
    letter-spacing: 2.5px;
    color: var(--accent);
    display: flex; align-items: center; gap: 8px;
}
.brand-mark {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent);
}

.stats {
    display: flex; gap: 18px;
    padding: 0 12px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.stats > div {
    display: flex; flex-direction: column; gap: 2px;
    font-family: var(--font-mono);
}
.stats label {
    font-size: 9px; letter-spacing: 1.5px;
    color: var(--dim);
}
.stats span {
    font-size: 16px; font-weight: 700;
    color: var(--text);
}

.sync {
    display: flex; align-items: center; gap: 6px;
    font-family: var(--font-mono);
    font-size: 10px; letter-spacing: 1.5px;
    padding: 4px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    color: var(--dim);
}
.sync .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--dim);
}
.sync[data-state="syncing"] { color: var(--accent); }
.sync[data-state="syncing"] .dot { background: var(--accent); animation: pulse 1.2s infinite; }
.sync[data-state="synced"] { color: var(--accent-moss); }
.sync[data-state="synced"] .dot { background: var(--accent-moss); }
.sync[data-state="error"] { color: var(--danger); }
.sync[data-state="error"] .dot { background: var(--danger); }
.sync[data-state="offline"] { color: var(--accent-warm); }
.sync[data-state="offline"] .dot { background: var(--accent-warm); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ─── Buttons ─── */
.tool {
    font-family: var(--font-mono);
    font-size: 11px; letter-spacing: 1.3px;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: rgba(30, 30, 46, 0.6);
    color: var(--text);
    cursor: pointer;
    transition: transform 80ms, background 120ms, border-color 120ms, color 120ms;
}
.tool:hover {
    background: rgba(0, 240, 255, 0.08);
    border-color: var(--accent);
    color: var(--accent);
}
.tool:active { transform: translateY(1px); }
.tool.danger:hover { background: rgba(255, 77, 109, 0.1); border-color: var(--danger); color: var(--danger); }
.tool.primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}
.tool.primary:hover { background: #4af5ff; color: var(--bg); }
.tool[data-active="true"] {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(0, 240, 255, 0.4);
}
.divider {
    width: 1px; height: 20px; background: var(--border); align-self: center;
}

/* ─── Banner ─── */
.banner {
    position: absolute; top: 72px; left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 240, 255, 0.12);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 11px; letter-spacing: 1.5px;
    padding: 8px 16px;
    border-radius: 10px;
    z-index: 20;
    pointer-events: none;
}
.banner b { color: #fff; font-weight: 700; }

/* ─── Search ─── */
.floating {
    position: absolute; top: 72px; left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    background: rgba(18, 18, 26, 0.9);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    backdrop-filter: blur(10px);
}
.search-box input {
    background: transparent; border: none; outline: none;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 6px 10px;
    width: 260px;
}

/* ─── Modal ─── */
.modal {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}
.modal-inner {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    width: 420px;
    max-width: 94vw;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
.modal-inner.wide { width: 640px; }
.modal-inner > header {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}
.modal-inner h2 {
    font-family: var(--font-mono);
    font-size: 13px; letter-spacing: 2px;
    color: var(--accent);
}
.modal-inner .close {
    background: transparent; border: none; cursor: pointer;
    font-size: 22px; color: var(--dim);
    width: 28px; height: 28px;
    border-radius: 6px;
}
.modal-inner .close:hover { background: var(--border); color: var(--text); }
.modal-inner .fields { display: flex; flex-direction: column; gap: 10px; }
.modal-inner label {
    display: flex; flex-direction: column; gap: 4px;
    font-family: var(--font-mono);
    font-size: 9px; letter-spacing: 1.5px;
    color: var(--dim);
}
.modal-inner input, .modal-inner select {
    background: rgba(30, 30, 46, 0.6);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 8px 10px;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 13px;
    outline: none;
}
.modal-inner input:focus, .modal-inner select:focus { border-color: var(--accent); }
.modal-inner input[type="color"] { padding: 2px; height: 36px; cursor: pointer; }
.modal-inner .row { display: flex; gap: 10px; }
.modal-inner .row > label { flex: 1; }
.modal-inner > footer {
    margin-top: 16px;
    display: flex; justify-content: flex-end; gap: 8px;
}

/* ─── History list ─── */
.history-list {
    display: flex; flex-direction: column; gap: 6px;
    max-height: 60vh; overflow-y: auto;
    font-family: var(--font-mono);
}
.history-list .item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(30, 30, 46, 0.4);
    font-size: 12px;
}
.history-list .item:hover { border-color: var(--accent); }
.history-list .item .meta { color: var(--dim); font-size: 10px; letter-spacing: 1px; }
.history-list .item .label { color: var(--text); }
.history-list .item button { font-size: 10px; padding: 6px 10px; }

/* ─── Toast ─── */
.toast {
    position: absolute; bottom: 88px; left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 10px 16px;
    font-family: var(--font-mono);
    font-size: 11px; letter-spacing: 1.2px;
    color: var(--text);
    z-index: 200;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    animation: toast-in 240ms ease-out;
}
.toast.danger { color: var(--danger); border-color: var(--danger); }
.toast.success { color: var(--accent-moss); border-color: var(--accent-moss); }
@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ─── Mobile ─── */
@media (max-width: 720px) {
    .bar-top { gap: 8px; padding: 8px 10px; }
    .stats { gap: 10px; padding: 0 8px; }
    .stats span { font-size: 13px; }
    .bar-bottom .tool { padding: 6px 8px; font-size: 10px; }
    .modal-inner { width: 92vw; padding: 14px; }
}
