body { margin: 0; background: var(--bg); color: var(--text); font-family: 'JetBrains Mono', monospace; min-height: 100dvh; overflow-x: hidden; }

.graph-page { position: relative; z-index: 10; display: flex; flex-direction: column; gap: 14px; min-height: 100dvh; padding: 22px; box-sizing: border-box; }

.graph-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
a.back { color: var(--muted); text-decoration: none; font-weight: bold; border: 1px solid var(--dim); padding: 5px 10px; transition: 0.2s; }
a.back:hover { color: var(--primary); border-color: var(--primary); background: rgba(255,0,0,0.1); }
.graph-title { color: var(--primary); margin: 0; text-transform: uppercase; font-size: 20px; letter-spacing: -1px; }
.graph-meta { font-size: 12px; color: var(--muted); }
.kuzu-note { color: #00ffaa; }

.graph-toolbar { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border); padding: 10px 12px; flex-wrap: wrap; }
.query-input { flex: 1; min-width: 220px; background: transparent; border: none; color: #fff; outline: none; font-family: inherit; font-size: 14px; }
.search-input { flex: 0 0 auto; width: 190px; background: rgba(0,0,0,0.4); border: 1px solid var(--dim); color: #fff; outline: none; font-family: inherit; font-size: 13px; padding: 5px 8px; border-radius: 2px; }
.search-input:focus { border-color: var(--primary); }
.search-input::placeholder { color: var(--text); opacity: 1; }
.gbtn { display: inline-block; background: rgba(0,0,0,0.5); border: 1px solid var(--dim); color: #ddd; font-family: inherit; font-size: 12px; font-weight: 700; text-transform: uppercase; text-decoration: none; padding: 6px 12px; border-radius: 2px; cursor: pointer; transition: 0.2s; }
.gbtn:hover { color: #000; background: var(--primary); border-color: var(--primary); }
.gbtn-run { color: #000; background: var(--primary); border-color: var(--primary); }
.gbtn-run:hover { box-shadow: 0 0 8px var(--primary); }
.gbtn-x { padding: 2px 8px; }

.limit-ctl { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.limit-ctl input { width: 66px; background: rgba(0,0,0,0.5); border: 1px solid var(--dim); color: #ddd; font-family: inherit; font-size: 12px; padding: 5px 6px; border-radius: 2px; }
.limit-warn { position: relative; color: #ffcc00; cursor: help; font-size: 19px; line-height: 1; }
.limit-warn[hidden] { display: none; }
.limit-warn::after { content: attr(data-tip); position: absolute; top: 150%; right: 0; width: 210px; background: rgba(5,1,1,0.97); border: 1px solid #ffcc00; color: #ffe9a8; font-size: 11px; text-transform: none; line-height: 1.4; padding: 7px 9px; border-radius: 2px; white-space: normal; opacity: 0; pointer-events: none; transition: opacity 0.15s; z-index: 40; }
.limit-warn:hover::after, .limit-warn:focus::after { opacity: 1; }

.graph-status { font-size: 12px; color: var(--muted); min-height: 1.2em; }
.graph-status.is-error { color: #ff5555; }

.graph-main { position: relative; flex: 1 1 auto; min-height: 62vh; border: 1px solid var(--border); background: rgba(8,0,0,0.5); overflow: hidden; }
.graph-canvas { position: absolute; inset: 0; }

.graph-legend { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 4px; max-height: 60%; overflow: auto; }
.legend-item { display: flex; align-items: center; gap: 7px; background: rgba(5,1,1,0.8); border: 1px solid var(--border); color: var(--text); font-family: inherit; font-size: 11px; padding: 3px 8px; border-radius: 2px; cursor: pointer; }
.legend-item.off { opacity: 0.4; text-decoration: line-through; }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }

.graph-inspector { position: absolute; top: 10px; right: 10px; width: 280px; max-width: 80%; max-height: calc(100% - 20px); overflow: auto; background: rgba(5,1,1,0.95); border: 1px solid var(--dim); backdrop-filter: blur(4px); }
.inspector-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--primary); font-size: 12px; text-transform: uppercase; font-weight: 700; }
.inspector-props { margin: 0; padding: 10px; font-size: 12px; }
.inspector-props dt { color: var(--muted); margin-top: 8px; }
.inspector-props dt:first-child { margin-top: 0; }
.inspector-props dd { margin: 2px 0 0 0; color: var(--text); word-break: break-word; }

.graph-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(5,1,1,0.85); color: var(--text); font-size: 13px; text-align: center; padding: 20px; }
.graph-overlay[hidden], .graph-inspector[hidden] { display: none; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: graph-spin 0.8s linear infinite; }

@keyframes graph-spin { to { transform: rotate(360deg); } }

.graph-examples { display: flex; flex-wrap: wrap; gap: 8px; }
.graph-examples:empty { display: none; }
.example-chip { background: rgba(0,0,0,0.5); border: 1px solid var(--dim); color: #ddd; font-family: inherit; font-size: 11px; padding: 4px 9px; border-radius: 2px; cursor: pointer; transition: 0.2s; }
.example-chip:hover { color: #000; background: var(--primary); border-color: var(--primary); }

.graph-ctx { position: absolute; z-index: 30; min-width: 190px; max-height: 60%; overflow: auto; background: rgba(5,1,1,0.97); border: 1px solid var(--dim); backdrop-filter: blur(4px); }
.graph-ctx[hidden] { display: none; }
.ctx-head { padding: 6px 10px; border-bottom: 1px solid var(--border); color: var(--primary); text-transform: uppercase; font-weight: 700; font-size: 11px; }
.ctx-item { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); font-family: inherit; font-size: 12px; padding: 6px 10px; cursor: pointer; }
.ctx-item:hover:not(:disabled) { background: rgba(255,0,0,0.12); color: var(--primary); }
.ctx-item:disabled { color: var(--muted); cursor: default; opacity: 0.65; }

@media (max-width: 768px) {
    .graph-page { padding: 12px; gap: 10px; }
    .graph-title { font-size: 17px; }
    .graph-toolbar { padding: 10px; }
    .query-input { font-size: 16px; min-width: 140px; }
    .search-input { font-size: 16px; width: 100%; }
    .graph-main { min-height: 60vh; }
    .graph-inspector { width: auto; left: 10px; right: 10px; max-width: none; top: auto; bottom: 10px; max-height: 45%; }
    .graph-legend { max-width: 45%; }
}

@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; }
}
