/* The hidden attribute always wins over a component's display rule. */
[hidden] { display: none !important; }

:root {
  --bg: #030712;
  --bg2: #070d1f;
  --glass: rgba(10, 16, 34, 0.62);
  --glass-strong: rgba(9, 14, 30, 0.86);
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.3);
  --text: #e2e8f0;
  --muted: #8b9ab3;
  --dim: #5b6b85;
  --decided: #34d399;
  --proposed: #fbbf24;
  --open: #fb7185;
  --superseded: #64748b;
  --accent: #22d3ee;
  --violet: #a78bfa;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background:
    radial-gradient(1200px 800px at 78% 12%, rgba(124, 58, 237, 0.18), transparent 60%),
    radial-gradient(900px 700px at 12% 85%, rgba(14, 165, 233, 0.14), transparent 60%),
    radial-gradient(700px 500px at 55% 60%, rgba(244, 63, 94, 0.07), transparent 65%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  color: var(--text);
  font: 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

#stars { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage { position: fixed; inset: 0; }
.stage canvas { outline: none; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.topbar {
  position: fixed; top: 14px; left: 14px; right: 14px; height: 58px;
  display: flex; align-items: center; gap: 16px; padding: 0 14px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 190px; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 14.5px; letter-spacing: 0.2px; }
.brand-text small { color: var(--muted); font-size: 11.5px; }
.mark { position: relative; width: 30px; height: 30px; flex: none; }
.mark i {
  position: absolute; border-radius: 50%; inset: 0;
  border: 1.5px solid rgba(34, 211, 238, 0.9);
  animation: spin 14s linear infinite;
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}
.mark i:nth-child(2) { inset: 5px; border-color: rgba(167, 139, 250, 0.9); animation-duration: 9s; animation-direction: reverse; }
.mark i:nth-child(3) { inset: 11px; background: radial-gradient(circle, #fff 0, #34d399 45%, transparent 70%); border: 0; clip-path: none; animation: pulse 3.2s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(0.75); opacity: 0.7; } }

.search { position: relative; flex: 1; max-width: 520px; }
.search input {
  width: 100%; height: 38px; padding: 0 44px 0 38px;
  background: rgba(2, 6, 23, 0.55); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font: inherit; font-size: 13.5px;
}
.search input::placeholder { color: var(--dim); }
.search-icon { position: absolute; left: 12px; top: 11px; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; }
.search kbd {
  position: absolute; right: 10px; top: 9px; font: 11px var(--mono); color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 5px; padding: 1px 6px;
}
.results { position: absolute; top: 46px; left: 0; right: 0; max-height: 60vh; overflow: auto; padding: 6px; background: var(--glass-strong); }
.result { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.result:hover, .result.active { background: rgba(148, 163, 184, 0.1); }
.result .dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.result .r-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .r-id { font: 11px var(--mono); color: var(--muted); }

.lenses { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.lenses button, .views button, .seg button {
  height: 30px; padding: 0 12px; border-radius: 999px; white-space: nowrap;
  background: transparent; border: 1px solid var(--line); color: var(--muted); font-size: 12.5px;
  transition: all 0.18s ease;
}
.lenses button:hover, .views button:hover, .seg button:hover { color: var(--text); border-color: var(--line-strong); }
.lenses button.on, .views button.on, .seg button.on {
  color: #04121a; background: linear-gradient(135deg, #67e8f9, #a7f3d0); border-color: transparent; font-weight: 600;
}
.views { display: flex; gap: 6px; margin-left: auto; }

/* Filters */
.filters {
  position: fixed; top: 86px; left: 14px; bottom: 120px; width: 252px; z-index: 15;
  padding: 14px 14px 10px; overflow: hidden; transition: transform 0.3s ease;
}
.filters.collapsed { transform: translateX(-228px); }
.filters .collapse {
  position: absolute; right: 6px; top: 8px; width: 24px; height: 24px; border-radius: 6px;
  background: transparent; border: 1px solid var(--line); color: var(--muted); z-index: 2;
}
.filters.collapsed .collapse { transform: rotate(180deg); }
.filters-body { height: 100%; overflow: auto; padding-right: 4px; scrollbar-width: thin; }
.filters.collapsed .filters-body { opacity: 0; pointer-events: none; }
.filters section { margin-bottom: 16px; }
.filters h3 {
  margin: 0 0 8px; font-size: 10.5px; font-weight: 600; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted);
}
.filters h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--dim); margin-left: 4px; }
.seg { display: flex; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  background: rgba(148, 163, 184, 0.07); border: 1px solid var(--line); color: var(--text); font-size: 12px;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.chip.off { opacity: 0.38; }
.chip .n { color: var(--muted); font: 11px var(--mono); }
.topics { list-style: none; margin: 0; padding: 0; }
.topics li {
  display: grid; grid-template-columns: 12px 1fr auto; gap: 9px; align-items: center;
  padding: 6px 8px; border-radius: 8px; cursor: pointer; transition: background 0.15s ease, opacity 0.15s ease;
}
.topics li:hover { background: rgba(148, 163, 184, 0.08); }
.topics li.off { opacity: 0.35; }
.topics .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.topics .n { font: 11px var(--mono); color: var(--muted); }

/* Reader */
.reader {
  position: fixed; top: 86px; right: 14px; bottom: 120px; width: min(440px, 42vw); z-index: 16;
  display: flex; flex-direction: column; overflow: hidden;
  animation: slideIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } }
.reader-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); position: relative; }
.reader-head .close {
  position: absolute; right: 12px; top: 12px; width: 28px; height: 28px; border-radius: 8px;
  background: transparent; border: 1px solid var(--line); color: var(--muted); font-size: 16px; line-height: 1;
}
.kicker { display: flex; align-items: center; gap: 8px; font: 11.5px var(--mono); color: var(--muted); }
.status {
  font: 600 10.5px var(--font); letter-spacing: 0.6px; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor;
}
.reader h2 { margin: 10px 0 2px; font-size: 18px; line-height: 1.3; font-weight: 650; padding-right: 30px; }
.reader-body { flex: 1; overflow: auto; padding: 14px 18px 18px; scrollbar-width: thin; }
.meta { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; margin: 0 0 14px; }
.meta dt { color: var(--muted); font-size: 11.5px; }
.meta dd { margin: 0; font-size: 12.5px; word-break: break-word; }
.authority {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; font-size: 12px; color: #cbd5e1;
  background: rgba(167, 139, 250, 0.08); border: 1px solid rgba(167, 139, 250, 0.25);
}
.attention {
  margin: 0 0 14px; padding: 8px 12px; border-radius: 10px; font-size: 12px; color: #fde68a;
  background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.3);
}
.summary { font-size: 14px; line-height: 1.55; margin: 0 0 14px; }
.reader details { margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; }
.reader summary { cursor: pointer; padding: 9px 12px; color: var(--muted); font-size: 12px; }
.reader pre {
  margin: 0; padding: 4px 12px 12px; white-space: pre-wrap; word-break: break-word;
  font: 12px/1.55 var(--mono); color: #cbd5e1; max-height: 42vh; overflow: auto;
}
.reader h4 { margin: 16px 0 8px; font-size: 10.5px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); }
.conn { display: flex; flex-direction: column; gap: 4px; }
.conn button {
  display: grid; grid-template-columns: 10px auto 1fr; gap: 9px; align-items: center; text-align: left;
  padding: 7px 9px; border-radius: 8px; background: rgba(148, 163, 184, 0.05); border: 1px solid transparent;
}
.conn button:hover { border-color: var(--line-strong); background: rgba(148, 163, 184, 0.1); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.conn .cid { font: 11px var(--mono); color: var(--muted); }
.conn .ct { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.actions { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.actions button {
  flex: 1; height: 32px; border-radius: 9px; background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.35); color: #a5f3fc; font-size: 12.5px;
}
.actions button:hover { background: rgba(34, 211, 238, 0.18); }
.actions button.armed { background: linear-gradient(135deg, #67e8f9, #a7f3d0); color: #04121a; font-weight: 600; }

/* Timeline */
.timeline {
  position: fixed; left: 14px; right: 14px; bottom: 14px; height: 92px; z-index: 18;
  display: grid; grid-template-columns: 56px 1fr 190px; align-items: center; gap: 14px; padding: 0 16px;
}
.play {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(52, 211, 153, 0.5);
  background: radial-gradient(circle at 30% 30%, rgba(52, 211, 153, 0.35), rgba(52, 211, 153, 0.08));
  display: grid; place-items: center; box-shadow: 0 0 22px rgba(52, 211, 153, 0.25);
}
.play svg { width: 18px; height: 18px; fill: #a7f3d0; }
.play.playing svg path { d: path("M7 5h4v14H7zM13 5h4v14h-4z"); }
.tl-main { position: relative; height: 64px; }
#histogram { position: absolute; left: 0; right: 0; top: 4px; height: 40px; width: 100%; }
#histogram rect { transition: opacity 0.2s ease; }
#cutoff { position: absolute; left: 0; right: 0; bottom: 4px; width: 100%; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; background: linear-gradient(90deg, rgba(52,211,153,0.6) var(--p, 100%), rgba(148,163,184,0.18) var(--p, 100%)); outline: none; }
#cutoff::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #ecfdf5; box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.3), 0 0 16px rgba(52, 211, 153, 0.7); cursor: grab; }
#cutoff::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #ecfdf5; box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.3); }
.tl-label { display: flex; flex-direction: column; text-align: right; }
.tl-label strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.tl-label small { color: var(--muted); font-size: 11.5px; }

/* Legend */
.legend {
  position: fixed; right: 14px; bottom: 120px; z-index: 14; padding: 10px 12px;
  display: grid; grid-template-columns: repeat(2, auto); gap: 5px 16px; font-size: 11.5px; color: var(--muted);
}
.reader:not([hidden]) ~ .legend { display: none; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.legend .ring { background: transparent !important; border: 1.5px solid currentColor; }

/* Tooltip, hint, empty state */
.tooltip {
  position: fixed; z-index: 30; pointer-events: none; max-width: 340px; padding: 9px 11px;
  background: var(--glass-strong); font-size: 12px;
}
.tooltip .tt-id { font: 11px var(--mono); color: var(--muted); }
.tooltip .tt-title { font-weight: 600; margin: 2px 0; }
.tooltip .tt-sum { color: #cbd5e1; }
.hint {
  position: fixed; left: 50%; top: 86px; transform: translateX(-50%); z-index: 25;
  padding: 7px 14px; border-radius: 999px; font-size: 12px; color: #04121a; font-weight: 600;
  background: linear-gradient(135deg, #67e8f9, #a7f3d0); opacity: 0; transition: opacity 0.25s ease; pointer-events: none;
}
.hint.show { opacity: 1; }
.empty { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; gap: 6px; z-index: 40; }
.empty h1 { margin: 0; font-size: 22px; }
.empty p { color: var(--muted); margin: 0; }
.empty code { font: 12.5px var(--mono); padding: 8px 12px; border-radius: 8px; background: rgba(148, 163, 184, 0.1); }
.empty-actions { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.empty-actions button {
  height: 32px; padding: 0 14px; border-radius: 999px; font-size: 12.5px;
  background: rgba(34, 211, 238, 0.1); border: 1px solid rgba(34, 211, 238, 0.35); color: #a5f3fc;
}
.empty-actions button:hover { background: rgba(34, 211, 238, 0.18); }

@media (max-width: 980px) {
  .lenses { display: none; }
  .filters { width: 220px; }
  .reader { width: calc(100vw - 28px); }
  .timeline { grid-template-columns: 50px 1fr; }
  .tl-label { display: none; }
  .legend { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .mark i { animation: none; }
  * { transition: none !important; animation-duration: 0s !important; }
}
