/* infra wiki — violet/blue, dark-first */
* { box-sizing: border-box; }

:root {
  --violet: #8b5cf6;
  --violet-soft: #a78bfa;
  --blue: #60a5fa;
  --grad: linear-gradient(120deg, #a78bfa 0%, #818cf8 45%, #60a5fa 100%);

  --bg: #fbfbfe;
  --bg2: #f4f4fb;
  --bg3: #ecedf8;
  --fg: #2a2d3d;
  --fg2: #5b5f79;
  --title: #191b28;
  --line: #e2e3f0;
  --link: #7c3aed;
  --code-bg: #eeeefa;
  --code-fg: #6d28d9;
  --glow: rgba(139, 92, 246, 0.10);
}

html.dark {
  --bg: #0b0d16;
  --bg2: #10131f;
  --bg3: #171b2c;
  --fg: #d9dbe8;
  --fg2: #9aa1bc;
  --title: #f4f5fb;
  --line: #232842;
  --link: #a78bfa;
  --code-bg: #1a1e33;
  --code-fg: #c4b5fd;
  --glow: rgba(139, 92, 246, 0.16);
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

html.dark body {
  background:
    radial-gradient(1100px 520px at 85% -5%, var(--glow), transparent 60%),
    radial-gradient(900px 460px at -10% 25%, rgba(96, 165, 250, 0.07), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

.layout { display: flex; min-height: 100vh; }

/* ── sidebar ── */
.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: 250px; flex-shrink: 0; height: 100vh; overflow-y: auto;
  padding: 1.4rem 1.1rem;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg2) 72%, transparent);
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 1rem;
}

.logo {
  display: flex; align-items: center; gap: 0.55rem;
  font-size: 1.12rem; font-weight: 800; letter-spacing: -0.02em;
  color: var(--title); text-decoration: none;
}
.logo-text b {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.searchbtn {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 0.45rem 0.7rem;
  font: inherit; font-size: 0.85rem; color: var(--fg2);
  background: var(--bg3); border: 1px solid var(--line); border-radius: 9px;
  cursor: pointer;
}
.searchbtn:hover { border-color: var(--violet); color: var(--fg); }
kbd {
  font-family: "JetBrains Mono", monospace; font-size: 0.7rem;
  padding: 0.05rem 0.35rem; border: 1px solid var(--line);
  border-radius: 5px; background: var(--bg);
}

.nav { list-style: none; margin: 0; padding: 0; font-size: 0.92rem; }
.nav > li { margin: 0.15rem 0; }
.nav a {
  display: block; padding: 0.28rem 0.6rem; border-radius: 7px;
  color: var(--fg); text-decoration: none; font-weight: 600;
}
.nav ul { list-style: none; margin: 0; padding-left: 0.9rem; border-left: 1px solid var(--line); margin-left: 0.7rem; }
.nav ul a { font-weight: 400; color: var(--fg2); font-size: 0.87rem; padding: 0.2rem 0.55rem; }
.nav a:hover { background: var(--bg3); color: var(--link); }
.nav a[aria-current] {
  background: linear-gradient(120deg, rgba(139,92,246,.16), rgba(96,165,250,.12));
  color: var(--link);
}

.side-foot {
  margin-top: auto; display: flex; align-items: center; gap: 0.7rem;
  font-size: 0.85rem;
}
.side-foot a { color: var(--fg2); }
.themebtn {
  font-size: 1rem; line-height: 1; padding: 0.3rem 0.5rem;
  background: var(--bg3); color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer;
}
.themebtn:hover { border-color: var(--violet); }

/* ── main ── */
main { flex: 1; min-width: 0; padding: 2.6rem 3rem 3rem; }
article { max-width: 46rem; margin: 0 auto; }
.hamburger { display: none; }

.crumbs { max-width: 46rem; margin: 0 auto 0.4rem; font-size: 0.85rem; color: var(--fg2); }
.crumbs a { color: var(--fg2); text-decoration: none; }
.crumbs a:hover { color: var(--link); }
.crumbs .sep { margin: 0 0.4rem; opacity: 0.5; }

.ptitle {
  margin: 0.1rem 0 0.6rem; font-size: 2.1rem; font-weight: 800;
  letter-spacing: -0.03em; line-height: 1.15;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.picon { margin-right: 0.5rem; -webkit-text-fill-color: initial; }

.props { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1.3rem; }
.chip, .tag {
  display: inline-block; padding: 0.1rem 0.65rem;
  font-size: 0.74rem; font-weight: 600; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg3);
  color: var(--fg2); text-decoration: none;
}
.chip b { color: var(--blue); font-weight: 600; margin-right: 0.25rem; }
.tag {
  background: rgba(139,92,246,.1); border-color: rgba(139,92,246,.35);
  color: var(--violet-soft); text-transform: uppercase; letter-spacing: 0.02em;
}
html:not(.dark) .tag { color: #7c3aed; }
.tag:hover { background: rgba(139,92,246,.2); }
.chip.status-accepted { background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.4); color: #34d399; }
html:not(.dark) .chip.status-accepted { color: #059669; }
.chip.status-proposed { background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.4); color: #fbbf24; }
html:not(.dark) .chip.status-proposed { color: #b45309; }
.chip.status-superseded { opacity: 0.65; text-decoration: line-through; }

/* ── outline ── */
.outline { list-style: none; margin: 0; padding: 0; }
.outline .outline {
  padding-left: 1.15rem; margin-left: 0.32rem;
  border-left: 1px solid var(--line);
}
.block { position: relative; margin: 0.28rem 0; }
.outline .outline > .block:not(.hblock) > .bc { padding-left: 0.95rem; }
.outline .outline > .block:not(.hblock)::before {
  content: ""; position: absolute; left: 0; top: 0.62em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--violet); opacity: 0.55;
  box-shadow: 0 0 0 3px var(--glow);
}
.bc > p { margin: 0.15rem 0; }

h2, h3, h4, h5 { color: var(--title); letter-spacing: -0.02em; line-height: 1.3; }
h2 { font-size: 1.35rem; margin: 1.6rem 0 0.4rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--line); }
h3 { font-size: 1.12rem; margin: 1.1rem 0 0.25rem; }
h4 { font-size: 1rem; margin: 0.9rem 0 0.2rem; }
h2 .count { font-size: 0.8rem; color: var(--fg2); font-weight: 500; margin-left: 0.4rem; }

a { color: var(--link); }
.wl { font-weight: 550; text-decoration: none; border-bottom: 1px solid rgba(139,92,246,.4); }
.wl:hover { border-bottom-color: var(--link); background: var(--glow); border-radius: 3px; }
.wl.broken { color: var(--fg2); border-bottom: 1px dashed var(--line); cursor: help; }

strong { color: var(--title); }
mark { background: rgba(251,191,36,.3); color: inherit; border-radius: 3px; padding: 0 0.15em; }
img { max-width: 100%; border-radius: 10px; }
.dim { color: var(--fg2); }

/* ── code ── */
code, pre, .shiki {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.84em;
}
:not(pre) > code {
  background: var(--code-bg); color: var(--code-fg);
  padding: 0.1em 0.38em; border-radius: 5px;
}
pre.shiki {
  margin: 0.45rem 0; padding: 0.85rem 1rem;
  border: 1px solid var(--line); border-radius: 11px;
  overflow-x: auto; line-height: 1.55;
}
.shiki, .shiki span { color: var(--shiki-light); background-color: transparent !important; }
pre.shiki { background-color: var(--bg2) !important; }
html.dark .shiki, html.dark .shiki span { color: var(--shiki-dark); }
html.dark pre.shiki { background-color: #0d0f1c !important; }

/* ── tables ── */
.tablewrap { overflow-x: auto; margin: 0.5rem 0; border: 1px solid var(--line); border-radius: 11px; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th {
  text-align: left; background: var(--bg3);
  border-bottom: 2px solid var(--violet); font-weight: 700;
}
th, td { padding: 0.45rem 0.8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { white-space: normal; }
tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: var(--glow); }

/* ── panels: backlinks, sub-pages ── */
.panel {
  margin-top: 2.2rem; padding: 1rem 1.2rem;
  border: 1px solid var(--line); border-radius: 13px;
  background: color-mix(in srgb, var(--bg2) 65%, transparent);
}
.panel h2 { margin: 0 0 0.6rem; font-size: 1.05rem; border: 0; padding: 0; }
.reflist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.ref { padding: 0.55rem 0; border-top: 1px solid var(--line); }
.ref:first-of-type { border-top: 0; }
.ref-src { font-size: 0.78rem; font-weight: 700; color: var(--blue); text-decoration: none; text-transform: uppercase; letter-spacing: 0.04em; }
.ref-body { font-size: 0.9rem; color: var(--fg2); }
.ref-body p { margin: 0.15rem 0 0; }

.editlink { margin-top: 2rem; font-size: 0.83rem; }
.editlink a { color: var(--fg2); }
.editlink a:hover { color: var(--link); }

.journal { margin-bottom: 1.6rem; }
.journal h2 { border: 0; }

.foot {
  max-width: 46rem; margin: 3.5rem auto 0; padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem; color: var(--fg2);
}
.foot a { color: var(--fg2); }

/* ── graph ── */
.grapharticle { max-width: none; }
#graph {
  width: 100%; height: 72vh; display: block;
  border: 1px solid var(--line); border-radius: 14px;
  background: color-mix(in srgb, var(--bg2) 60%, transparent);
  cursor: grab;
}

/* ── search modal ── */
.search-modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 6, 12, 0.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.search-modal[hidden] { display: none; }
.search-box {
  width: min(620px, 92vw); border-radius: 14px; overflow: hidden;
  background: var(--bg2); border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0,0,0,0.45), 0 0 0 1px var(--glow);
}
.search-box input {
  width: 100%; padding: 0.9rem 1.1rem; font: inherit; font-size: 1rem;
  color: var(--fg); background: transparent; border: 0; outline: 0;
  border-bottom: 1px solid var(--line);
}
.search-results { list-style: none; margin: 0; padding: 0.35rem; max-height: 46vh; overflow-y: auto; }
.search-results li a {
  display: block; padding: 0.5rem 0.75rem; border-radius: 8px;
  color: var(--fg); text-decoration: none;
}
.search-results li a small { display: block; color: var(--fg2); font-size: 0.78rem; }
.search-results li.sel a, .search-results li a:hover {
  background: linear-gradient(120deg, rgba(139,92,246,.18), rgba(96,165,250,.14));
}

/* ── mobile ── */
@media (max-width: 860px) {
  .layout { display: block; }
  .sidebar {
    position: fixed; z-index: 40; height: 100vh; width: 260px;
    transform: translateX(-100%); transition: transform 0.2s ease;
    background: var(--bg2);
  }
  #menu:checked ~ .sidebar { transform: none; box-shadow: 0 0 60px rgba(0,0,0,0.5); }
  .hamburger {
    display: inline-block; font-size: 1.3rem; cursor: pointer;
    color: var(--fg); margin-bottom: 0.6rem; user-select: none;
  }
  main { padding: 1.2rem 1.1rem 2rem; }
  .ptitle { font-size: 1.6rem; }
  th, td { white-space: normal; }
}
