:root {
  --bg: #020617;
  --raised: #0b1220;
  --line: #1e293b;
  --line-strong: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --faint: #cbd5e1;
  --rose: #f43f5e;
  --rose-soft: #fda4af;
  --amber: #fbbf24;
  --purple: #d8b4fe;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(244, 63, 94, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 17px/1.6 "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  min-height: 100vh;
}

img { display: block; }

a { color: var(--rose-soft); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: white; }

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: white;
  color: var(--bg);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  z-index: 5;
}
.skip:focus { top: 0.75rem; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(2, 6, 23, 0.92);
  backdrop-filter: blur(10px);
  z-index: 4;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: inherit;
  text-decoration: none;
  flex: 0 0 auto;
}

.word {
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--rose);
  font-size: 1.05rem;
}
.word span { color: white; }

.wiki-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 28rem;
  margin-left: auto;
}

.search input {
  width: 100%;
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
}
.search input:focus {
  outline: 2px solid rgba(244, 63, 94, 0.55);
  border-color: var(--rose);
}

#results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  background: #0f172a;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  max-height: 22rem;
  overflow: auto;
}
#results a, #results .hit-empty {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}
#results a:hover, #results a[aria-selected="true"] { background: #1e293b; }
.hit-page {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hit-empty { color: var(--muted); margin: 0; }

.app-link, .nav-toggle {
  flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--raised);
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 650;
  padding: 0.4rem 0.7rem;
}
.app-link:hover, .nav-toggle:hover { border-color: var(--rose); color: white; }
.nav-toggle { display: none; cursor: pointer; font: inherit; }

.shell {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  gap: 1.75rem 2rem;
  max-width: 78rem;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
  align-items: start;
}
.shell.no-toc { grid-template-columns: 16rem minmax(0, 42rem); }

#site-nav { position: sticky; top: 5rem; }
#content { min-width: 0; }

.shell:not(.no-toc) #content {
  display: grid;
  grid-template-columns: minmax(0, 42rem) 14rem;
  column-gap: 1.75rem;
  align-items: start;
}
.shell:not(.no-toc) #content > * { grid-column: 1; }
.shell:not(.no-toc) #content > .toc {
  grid-column: 2;
  grid-row: 1 / span 200;
  position: sticky;
  top: 5rem;
  align-self: start;
  max-height: calc(100vh - 6.5rem);
  overflow: auto;
}

.nav-label {
  margin: 1.1rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
#site-nav .nav-label:first-child { margin-top: 0; }
#site-nav a {
  display: block;
  color: var(--faint);
  text-decoration: none;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  border-left: 2px solid transparent;
}
#site-nav a:hover { color: white; background: rgba(15, 23, 42, 0.8); }
#site-nav a[aria-current="page"] {
  color: white;
  border-left-color: var(--rose);
  background: rgba(244, 63, 94, 0.08);
}

.toc summary {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}
.toc summary::-webkit-details-marker { display: none; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.86rem;
  line-height: 1.35;
  padding: 0.22rem 0;
}
.toc a:hover { color: white; }
.toc-sub a { padding-left: 0.75rem; }

h1 {
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.8rem;
}
h2 {
  font-size: 1.35rem;
  line-height: 1.25;
  margin: 2.2rem 0 0.6rem;
  scroll-margin-top: 5rem;
}
h3 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.4rem;
  scroll-margin-top: 5rem;
  color: white;
}
p { margin: 0.75rem 0; }
strong { color: white; }

.lede {
  font-size: 1.12rem;
  color: var(--faint);
}
.muted { color: var(--muted); }

.note, .limit {
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.72);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  margin: 1.1rem 0;
}
.note { border-left: 3px solid var(--rose); }
.limit { border-left: 3px solid var(--amber); }
.note p:first-child, .limit p:first-child { margin-top: 0; }
.note p:last-child, .limit p:last-child { margin-bottom: 0; }

.doors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0 0.25rem;
}
.door {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-decoration: none;
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem 1rem;
  min-height: 7.5rem;
}
.door:hover { border-color: var(--rose); color: white; }
.door span:last-child { color: var(--muted); font-size: 0.92rem; }
.kicker {
  color: var(--rose-soft);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

ul, ol { padding-left: 1.2rem; }
li { margin: 0.35rem 0; }
li p { margin: 0.3rem 0; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 1rem 0;
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
tr:last-child td { border-bottom: 0; }
th {
  color: var(--rose-soft);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #0f172a;
}
caption {
  caption-side: bottom;
  text-align: left;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.55rem 0.75rem 0.7rem;
}

code, kbd {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.86em;
}
code {
  background: #0f172a;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.05rem 0.3rem;
}
kbd {
  background: #0f172a;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0.02rem 0.35rem;
}

.colophon {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.25rem;
  text-align: center;
}
.colophon p { margin: 0.3rem 0; }
.colophon a { margin: 0 0.45rem; }

:focus-visible {
  outline: 2px solid rgba(244, 63, 94, 0.8);
  outline-offset: 2px;
}

@media (max-width: 1100px) {
  .shell, .shell.no-toc { grid-template-columns: 15rem minmax(0, 1fr); }
  .shell:not(.no-toc) #content { display: block; }
  .toc { position: static; max-height: none; margin: 0.25rem 0 1.25rem; }
}

@media (max-width: 800px) {
  .nav-toggle { display: inline-flex; }
  .app-link { display: none; }
  .wiki-tag { display: none; }
  .search { min-width: 0; max-width: none; }
  .shell, .shell.no-toc {
    grid-template-columns: 1fr;
    padding-top: 1rem;
  }
  #site-nav { display: none; position: static; }
  body.nav-open #site-nav {
    display: block;
    background: var(--raised);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.75rem;
  }
  .doors { grid-template-columns: 1fr; }
  h1 { font-size: 1.7rem; }
  .top { padding-inline: 0.8rem; }
}
