* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --bg: #05070d;
  --panel: #111a2a;
  --panel2: #162235;
  --text: #edf7ff;
  --muted: #aabbd0;
  --soft: #75869b;
  --line: rgba(155, 197, 255, 0.18);
  --accent: #45f0c2;
  --accent2: #76a9ff;
  --gold: #ffcc66;
  --red: #ff6b7a;
  --purple: #c18cff;
  --radius: 18px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(69, 240, 194, 0.16), transparent 32rem),
    radial-gradient(circle at 88% 4%, rgba(118, 169, 255, 0.14), transparent 30rem),
    linear-gradient(180deg, #060914, #070b12 48%, #04060b);
  color: var(--text);
  font: 16px/1.62 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration-color: rgba(69, 240, 194, 0.45); text-underline-offset: 0.18em; }
a:hover { color: var(--accent); }
.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--accent); color: #04110d; padding: 0.55rem 0.8rem; border-radius: 999px;
}
.skip-link:focus { left: 8px; }
.site-topbar {
  position: sticky; top: 0; z-index: 20;
  min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1.15rem; border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 18, 0.86); backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 0.75rem; color: var(--text); text-decoration: none; font-weight: 950; letter-spacing: -0.035em; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center; overflow: hidden; border-radius: 13px;
  background: linear-gradient(135deg, rgba(69, 240, 194, 0.25), rgba(118, 169, 255, 0.20));
  border: 1px solid rgba(69, 240, 194, 0.38); box-shadow: 0 0 28px rgba(69, 240, 194, 0.14);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand small { display: block; color: var(--muted); font-weight: 650; letter-spacing: 0; margin-top: -5px; font-size: 0.74rem; }
.top-nav, .site-footer nav { display: flex; align-items: center; gap: 0.2rem; flex-wrap: wrap; justify-content: flex-end; }
.top-nav a, .site-footer a { color: var(--muted); padding: 0.44rem 0.58rem; border-radius: 999px; font-weight: 850; font-size: 0.82rem; text-decoration: none; }
.top-nav a:hover, .site-footer a:hover { color: var(--text); background: rgba(255, 255, 255, 0.075); }
.site-frame { display: grid; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.sidebar { position: sticky; top: 66px; height: calc(100vh - 66px); overflow: auto; border-right: 1px solid var(--line); background: rgba(6, 10, 18, 0.86); backdrop-filter: blur(18px); }
.sidebar-inner { padding: 1rem; }
.side-nav { display: grid; gap: 0.75rem; }
.side-nav details { border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px; background: rgba(255, 255, 255, 0.035); overflow: hidden; }
.side-nav summary { cursor: pointer; color: var(--text); font-size: 0.78rem; font-weight: 950; text-transform: uppercase; letter-spacing: 0.12em; padding: 0.72rem 0.78rem; }
.side-nav a { display: block; color: var(--muted); border-left: 2px solid transparent; padding: 0.46rem 0.5rem 0.46rem 0.78rem; font-size: 0.92rem; font-weight: 780; text-decoration: none; }
.side-nav a:hover { color: var(--text); border-left-color: var(--accent); background: rgba(69, 240, 194, 0.07); }
.content { min-width: 0; padding: clamp(1.25rem, 3vw, 2.8rem); }
.intro {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.75fr); gap: clamp(1rem, 3vw, 2rem); align-items: start;
  padding-bottom: 2rem; border-bottom: 1px solid var(--line);
}
h1, h2, h3 { line-height: 1.07; margin: 0 0 1rem; letter-spacing: -0.046em; }
h1 { font-size: clamp(2.35rem, 5.2vw, 5rem); }
h2 { font-size: clamp(1.45rem, 2.8vw, 2.35rem); margin-top: 2.2rem; }
h3 { font-size: clamp(1.04rem, 1.5vw, 1.28rem); }
p { color: var(--muted); margin: 0 0 1rem; }
.lede { max-width: 76ch; color: #d6e6f7; font-size: clamp(1.02rem, 1.55vw, 1.22rem); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.stat, .unit-card, .panel, .search-item {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(17, 26, 42, 0.88), rgba(13, 19, 32, 0.88));
  box-shadow: var(--shadow);
}
.stat { padding: 1rem; }
.stat strong { display: block; color: var(--accent); font-size: clamp(1.45rem, 2.5vw, 2rem); line-height: 1; }
.stat span { color: var(--muted); font-size: 0.82rem; font-weight: 850; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.unit-card { padding: 1.05rem; min-height: 132px; }
.unit-card:hover, .search-item:hover { border-color: rgba(69, 240, 194, 0.36); background: linear-gradient(180deg, rgba(22, 34, 53, 0.88), rgba(14, 22, 36, 0.9)); }
.unit-card p, .search-item p { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.9rem; }
.badge {
  display: inline-flex; margin-bottom: 0.65rem; color: #04110d; background: var(--accent);
  border-radius: 999px; padding: 0.2rem 0.55rem; font-size: 0.74rem; font-weight: 950; text-transform: uppercase; letter-spacing: 0.06em;
}
.badge.pattern { background: var(--accent2); }
.badge.concept { background: var(--gold); }
.badge.case-study { background: var(--red); color: #fff; }
.badge.reference-architecture { background: var(--purple); color: #fff; }
.badge.diagram, .badge.reference { background: var(--soft); color: #fff; }
.panel { padding: 1rem; overflow: auto; }
.content-article {
  max-width: 86ch; margin: 1rem 0 1.4rem; padding: clamp(1rem, 2vw, 1.6rem);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}
.content-article h2, .content-article h3, .content-article h4 { letter-spacing: 0; }
.content-article h2 { margin-top: 1.6rem; font-size: clamp(1.25rem, 2vw, 1.75rem); }
.content-article h3 { margin-top: 1.35rem; color: var(--text); }
.content-article p, .content-article li { color: #d3e0ef; }
.content-article ul { padding-left: 1.25rem; color: #d3e0ef; }
.content-article blockquote { margin: 1.2rem 0; padding: 0.8rem 1rem; border-left: 3px solid var(--accent); background: rgba(69, 240, 194, 0.065); color: var(--text); }
.content-article .table-scroll { margin: 1.2rem 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.content-article table { width: 100%; border-collapse: collapse; min-width: 560px; background: rgba(5, 7, 13, 0.62); }
.content-article th, .content-article td { padding: 0.72rem 0.85rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.content-article th { color: var(--accent); background: rgba(69, 240, 194, 0.08); font-size: 0.82rem; text-transform: uppercase; }
.content-article td { color: #d3e0ef; }
.content-article tr:last-child td { border-bottom: 0; }
.content-article pre { overflow: auto; padding: 1rem; border-radius: 12px; border: 1px solid var(--line); background: #05070d; }
.content-article code { color: #dffcf4; }
.content-article .mermaid {
  margin: 1.25rem 0; padding: 1rem; min-height: 220px; text-align: center;
  border-radius: 12px; border: 1px solid var(--line); background: #05070d;
}
.content-article .mermaid svg { max-width: 100%; height: auto; }
.diagram-gallery { display: grid; gap: 1rem; margin-top: 1.25rem; }
.diagram-card { padding: 1rem; }
.diagram-card h2 { margin-top: 0; font-size: 1.12rem; }
.diagram-card .mermaid {
  margin: 0.85rem 0 0; padding: 1rem; min-height: 220px; overflow: auto; text-align: center;
  border-radius: 12px; border: 1px solid var(--line); background: #05070d;
}
.diagram-card .mermaid svg { max-width: 100%; height: auto; }
.graph-map { width: 100%; min-height: 420px; border: 1px solid var(--line); border-radius: 14px; background: #05070d; }
.graph-map text { font: 12px system-ui, sans-serif; fill: #d6e6f7; }
.graph-map line { stroke: rgba(155, 197, 255, 0.25); stroke-width: 1.2; }
.graph-map circle { fill: #05070d; stroke-width: 2; }
.graph-explorer { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(180deg, rgba(17, 26, 42, 0.88), rgba(7, 11, 18, 0.94)); box-shadow: var(--shadow); overflow: hidden; }
.graph-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(140px, 180px) minmax(160px, 220px) auto; gap: 0.75rem; padding: 1rem; border-bottom: 1px solid var(--line); }
.graph-toolbar input, .graph-toolbar select, .graph-toolbar button {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.055);
  color: var(--text); font: inherit; padding: 0.7rem 0.85rem; font-weight: 850;
}
.graph-toolbar option { background: #101827; color: var(--text); }
.graph-toolbar button { cursor: pointer; color: #04110d; background: var(--accent); border-color: transparent; }
.graph-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); min-height: 520px; }
.graph-canvas { width: 100%; height: 100%; min-height: 520px; background: radial-gradient(circle at 50% 50%, rgba(69, 240, 194, 0.08), transparent 22rem), #05070d; }
.graph-lines line { stroke: rgba(155, 197, 255, 0.22); stroke-width: 1.1; }
.graph-lines line.active { stroke: rgba(69, 240, 194, 0.74); stroke-width: 2.2; }
.graph-lines line.is-hidden, .graph-node.is-hidden { opacity: 0; pointer-events: none; }
.graph-node { cursor: pointer; transition: opacity 160ms ease; }
.graph-node circle { stroke: rgba(255, 255, 255, 0.65); stroke-width: 1.5; filter: drop-shadow(0 0 10px rgba(69, 240, 194, 0.16)); }
.graph-node.active circle { stroke: #fff; filter: drop-shadow(0 0 16px rgba(69, 240, 194, 0.55)); }
.graph-node.adjacent circle { stroke: var(--accent); stroke-width: 2; }
.graph-node text { fill: #d6e6f7; font: 12px Inter, system-ui, sans-serif; pointer-events: none; paint-order: stroke; stroke: rgba(5, 7, 13, 0.92); stroke-width: 4px; stroke-linejoin: round; }
.graph-detail { border-left: 1px solid var(--line); padding: 1rem; background: rgba(255, 255, 255, 0.035); overflow: auto; }
.graph-detail h3 { margin-bottom: 0.5rem; }
.graph-detail h4 { margin: 1rem 0 0.45rem; color: var(--accent); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; }
.graph-detail ul { display: grid; gap: 0.45rem; list-style: none; padding: 0; margin: 0; }
.graph-detail li, .reference-group li { display: grid; gap: 0.1rem; padding: 0.45rem 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.graph-detail li span, .reference-group li span, .empty-note { color: var(--soft); font-size: 0.78rem; }
.reference-groups { display: grid; gap: 0.75rem; margin-top: 0.75rem; }
.reference-group { border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 12px; background: rgba(255, 255, 255, 0.035); overflow: hidden; }
.reference-group summary { cursor: pointer; padding: 0.62rem 0.75rem; color: var(--text); font-weight: 900; }
.reference-group summary span { color: var(--accent); margin-left: 0.35rem; }
.reference-group ul { list-style: none; padding: 0 0.75rem 0.25rem; margin: 0; }
.unit-table { width: 100%; border-collapse: collapse; background: rgba(17, 26, 42, 0.72); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.unit-table th, .unit-table td { padding: 0.72rem 0.8rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); text-align: left; vertical-align: top; }
.unit-table th { color: var(--accent); font-size: 0.78rem; font-weight: 950; text-transform: uppercase; letter-spacing: 0.08em; }
.unit-table td { color: var(--muted); }
.unit-meta, .source-link, .result-count { color: var(--muted); font-size: 0.9rem; }
.search-controls { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(160px, 240px); gap: 0.75rem; margin-top: 1.1rem; }
.search-controls input, .search-controls select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.055);
  color: var(--text); font: inherit; padding: 0.78rem 0.9rem; font-weight: 800;
}
.search-controls option { background: #101827; color: var(--text); }
.search-list { display: grid; gap: 0.75rem; margin: 1rem 0 0; }
.search-item { padding: 0.9rem 1rem; }
.site-footer { border-top: 1px solid var(--line); background: rgba(7, 11, 18, 0.86); padding: 1rem; }
.site-footer nav { justify-content: center; }
@media (max-width: 1060px) {
  .site-frame { grid-template-columns: 1fr; }
  .sidebar { position: relative; top: auto; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-inner { max-width: 1180px; margin: 0 auto; }
  .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .intro { grid-template-columns: 1fr; }
  .graph-layout { grid-template-columns: 1fr; }
  .graph-detail { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .site-topbar { align-items: flex-start; flex-direction: column; padding: 0.85rem 1rem; }
  .top-nav { justify-content: flex-start; }
  .side-nav, .search-controls, .graph-toolbar { grid-template-columns: 1fr; }
  .content { padding: 1.1rem; }
  .stats { grid-template-columns: 1fr; }
  .graph-canvas { min-height: 430px; }
}
