:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: flex; flex-direction: column; height: 100vh; }

header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1.5rem; padding: .8rem 1.2rem; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
header h1 { margin: 0; font-size: 1.25rem; font-weight: 650; }
header .brand p { margin: .25rem 0 0; font-size: .82rem; color: var(--muted); max-width: 70ch; }
header nav { display: flex; flex-direction: column; gap: .25rem; text-align: right; font-size: .82rem; white-space: nowrap; }

.body { flex: 1; display: flex; min-height: 0; }

/* sidebar */
.sidebar {
  width: 340px; flex-shrink: 0; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--panel); min-height: 0;
}
.search-wrap { padding: .8rem; border-bottom: 1px solid var(--line); position: relative; }
#search {
  width: 100%; padding: .55rem .7rem; font-size: .9rem;
  border: 1px solid var(--line); border-radius: 7px; outline: none;
}
#search:focus { border-color: var(--accent); }
.search-results { display: flex; flex-direction: column; margin-top: .4rem; max-height: 220px; overflow: auto; }
.search-results a { padding: .3rem .35rem; border-radius: 5px; font-size: .83rem; color: var(--ink); display: flex; align-items: center; }
.search-results a:hover { background: #f1f5f9; text-decoration: none; }

.panel-block { padding: .8rem; border-bottom: 1px solid var(--line); }
.panel-block.grow { flex: 1; overflow: auto; min-height: 0; }
.panel-block h2 { margin: 0 0 .55rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* category legend (clickable) */
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; }
.legend-item {
  display: flex; align-items: center; gap: .4rem; padding: .35rem .5rem;
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
  cursor: pointer; font-size: .82rem; color: var(--ink); text-align: left; width: 100%;
}
.legend-item:hover { background: #f1f5f9; border-color: #cbd5e1; }
.lg-count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .78rem; }

.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }

/* details */
.details { font-size: .85rem; }
.detail-head { border-left: 4px solid var(--accent); padding-left: .6rem; margin-bottom: .5rem; }
.detail-head h3 { margin: .15rem 0 0; font-size: 1rem; line-height: 1.3; }
.badge { display: inline-block; font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; color: #fff; padding: .1rem .4rem; border-radius: 4px; }
.curie { margin: .2rem 0 .4rem; font-size: .76rem; }
.curie code, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; background: #f1f5f9; padding: .05rem .3rem; border-radius: 4px; }
.meta { margin: .2rem 0 .4rem; font-size: .8rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .72rem; }

.conns { list-style: none; margin: .3rem 0 0; padding: 0; }
.conns li { padding: .25rem .2rem; border-bottom: 1px solid #f1f5f9; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.conns .rel { font-size: .73rem; color: var(--muted); min-width: 4.5rem; }
.conns .prop { font-size: .68rem; color: #7c3aed; background: #f5f3ff; }
.conns a { color: var(--ink); display: inline-flex; align-items: center; gap: .35rem; }
.conns a:hover { color: var(--accent); }

/* RDF triples block */
.rdf { margin-top: .7rem; border-top: 1px solid var(--line); padding-top: .5rem; }
.rdf summary { cursor: pointer; font-size: .78rem; color: var(--accent); }
.rdf pre {
  background: #0f172a; color: #e2e8f0; padding: .6rem .7rem; border-radius: 7px;
  font-size: .72rem; line-height: 1.5; overflow-x: auto; margin: .5rem 0 .3rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.rdf pre code { background: none; }
.t-s { color: #fbbf24; } .t-p { color: #818cf8; } .t-o { color: #34d399; } .t-lit { color: #f9a8d4; }

/* canvas */
.canvas-wrap { flex: 1; position: relative; min-width: 0; }
.graph { position: absolute; inset: 0; background:
  radial-gradient(circle at 1px 1px, #e2e8f0 1px, transparent 0) 0 0 / 26px 26px, var(--bg); }
.canvas-controls { position: absolute; top: .7rem; right: .7rem; z-index: 5; display: flex; gap: .4rem; }
.canvas-controls button {
  padding: .4rem .8rem; font-size: .82rem; border: 1px solid var(--line);
  background: #fff; border-radius: 7px; cursor: pointer; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.canvas-controls button:hover { background: #f1f5f9; }
.status {
  position: absolute; top: .7rem; left: 50%; transform: translateX(-50%); z-index: 5;
  background: #0f172a; color: #fff; padding: .35rem .8rem; border-radius: 999px; font-size: .8rem; display: none;
}

footer { padding: .55rem 1.2rem; font-size: .74rem; color: var(--muted); background: var(--panel); border-top: 1px solid var(--line); }

@media (max-width: 720px) {
  .body { flex-direction: column; }
  .sidebar { width: 100%; max-height: 45%; }
}
