:root {
  --bg: #07090f;
  --bg-2: #0d111b;
  --panel: rgba(16, 21, 34, 0.86);
  --line: rgba(148, 163, 196, 0.16);
  --text: #e6e9f2;
  --muted: #8b93a8;
  --accent: #f5c45e;
  --accent-2: #7cc4ff;
  --radius: 10px;
  --side: 330px;
  --note: 420px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 800px at 60% 40%, #111830 0%, var(--bg) 70%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent-2); }

/* -- top bar ---------------------------------------------------------------------- */
.top {
  position: relative; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 15, 0.7); backdrop-filter: blur(8px);
}
.brand { font-weight: 700; letter-spacing: 0.18em; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.brand .mark { width: 28px; height: 28px; border-radius: 50%; }
.hero { display: block; width: calc(100% + 28px); margin: -12px -14px 12px; border-radius: var(--radius) var(--radius) 0 0; }
.brand .sub { font-weight: 400; letter-spacing: 0; color: var(--muted); margin-left: 8px; font-size: 12px; }
.search { position: relative; flex: 0 1 300px; }
.search input {
  width: 100%; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text); outline: none;
}
.search input:focus { border-color: var(--accent); }
.results {
  position: absolute; top: 38px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); max-height: 50vh; overflow: auto;
}
.results li { padding: 6px 10px; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.results li:hover, .results li.active { background: rgba(245, 196, 94, 0.12); }
.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; font-size: 12px; white-space: nowrap; color: var(--muted);
}
.chip[aria-pressed="true"] { color: var(--text); border-color: rgba(230, 233, 242, 0.35); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* -- layout ----------------------------------------------------------------------- */
.layout { position: relative; height: calc(100% - 53px); }
.stage { position: absolute; inset: 0; }
#graph { width: 100%; height: 100%; display: block; cursor: grab; }
#graph:active { cursor: grabbing; }

.panel-toggle {
  position: relative; flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font-size: 16px; line-height: 1;
}
.panel-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.panel-toggle .count {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--accent); color: #111; font-size: 10px; font-weight: 700; line-height: 16px;
}
.panel-toggle .count:empty { display: none; }
.side-close { position: absolute; top: 6px; right: 8px; z-index: 1; background: none; border: 0; font-size: 20px; color: var(--muted); }
.side .tabs { padding-right: 30px; }
body:not(.side-open) .side { opacity: 0; transform: translateX(calc(-100% - 24px)); pointer-events: none; }
.side {
  position: absolute; z-index: 3; top: 12px; left: 12px; bottom: 64px; width: var(--side);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(10px);
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; padding: 10px 4px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 12.5px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.pane { overflow: auto; padding: 12px 14px 16px; flex: 1; }
.pane h3 { margin: 14px 0 6px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.pane h3:first-child { margin-top: 0; }
.pane .empty { color: var(--muted); }
.item {
  display: flex; gap: 8px; align-items: baseline; padding: 5px 6px; margin: 0 -6px; border-radius: 6px; cursor: pointer;
}
.item:hover { background: rgba(255, 255, 255, 0.05); }
.item .meta { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.item .dot { transform: translateY(-1px); }
.q { padding: 8px 10px; margin: 6px 0; border: 1px dashed rgba(245, 196, 94, 0.35); border-radius: 8px; cursor: pointer; }
.q:hover { background: rgba(245, 196, 94, 0.06); }
.q small { display: block; color: var(--muted); }
.big { font-size: 28px; font-weight: 700; }
.kpis { display: flex; gap: 18px; margin-bottom: 4px; }
.kpis span { display: block; color: var(--muted); font-size: 12px; }

.tl { position: relative; margin-left: 6px; padding-left: 16px; border-left: 1px solid var(--line); }
.tl .year { margin: 12px 0 4px -16px; color: var(--accent); font-weight: 600; font-size: 12px; }
.tl .item::before {
  content: ""; position: absolute; left: -4px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2);
  margin-top: 7px;
}

/* -- time slider ------------------------------------------------------------------ */
.time {
  position: absolute; z-index: 3; left: 16px; right: 16px; bottom: 14px;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(10px);
}
.time button { background: none; border: 0; color: var(--accent); width: 22px; }
.time input { flex: 1; accent-color: var(--accent); }
.side-open .time { left: calc(var(--side) + 28px); }
.reading .time { right: calc(var(--note) + 28px); }
#time-label { color: var(--muted); font-size: 12px; min-width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
.legend {
  position: absolute; z-index: 2; right: 16px; top: 12px; color: var(--muted); font-size: 11.5px;
  display: grid; gap: 3px; text-align: right;
}

/* -- note panel ------------------------------------------------------------------- */
.note {
  position: absolute; z-index: 4; top: 12px; right: 12px; bottom: 12px; width: var(--note);
  overflow: auto; padding: 18px 20px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(12px);
}
.note .close { position: absolute; top: 8px; right: 10px; background: none; border: 0; font-size: 22px; color: var(--muted); }
.note h1 { font-size: 20px; margin: 0 28px 6px 0; line-height: 1.25; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.private { border-color: rgba(255, 122, 122, 0.5); color: #ff9a9a; }
.badge.inferred { border-style: dashed; border-color: rgba(245, 196, 94, 0.55); color: var(--accent); }
.note .content h2 { font-size: 14px; margin: 18px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.note .content img { max-width: 100%; border-radius: 8px; }
.note .content code { background: rgba(255, 255, 255, 0.06); padding: 1px 5px; border-radius: 4px; }
.note .content table { border-collapse: collapse; }
.note .content td, .note .content th { border: 1px solid var(--line); padding: 4px 8px; }
.note .content a.missing { color: var(--muted); text-decoration: none; cursor: default; }
.note .section { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.note .section h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.note .sources { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; word-break: break-word; }
.open-obsidian {
  display: inline-block; margin-top: 16px; padding: 7px 14px; border-radius: 999px; text-decoration: none;
  border: 1px solid rgba(124, 196, 255, 0.4);
}

/* -- phone ------------------------------------------------------------------------ */
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 16px; }
  .search { flex: 1 1 auto; }
  .filters { width: 100%; }
  .layout { height: calc(100% - 92px); }
  .side { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 42%; border-radius: var(--radius) var(--radius) 0 0; }
  .time, .side-open .time { left: 16px; right: 16px; }
  .side-open .time { bottom: calc(42% + 10px); }
  body:not(.side-open) .side { transform: translateY(100%); }
  .legend { display: none; }
  .note { inset: 0; width: auto; border-radius: 0; }
  .reading .time { right: 16px; }
}

/* -- opening animation (intro.js) ------------------------------------------------- */
.intro-canvas { position: fixed; inset: 0; z-index: 50; width: 100%; height: 100%; cursor: pointer; transition: opacity 0.6s; }
.intro-canvas.out { opacity: 0; pointer-events: none; }
.top, .side, .time, .legend, #graph { transition: opacity 0.4s ease, transform 0.4s ease, left 0.4s ease, bottom 0.4s ease; }
body.intro .top, body.intro .side, body.intro .time, body.intro .legend, body.intro #graph { opacity: 0; }
body.intro .side { transform: translateX(-24px); }
body.intro .time { transform: translateY(16px); }
