:root {
  --bg: #0b0811;
  --bg-elevated: #12101a;
  --bg-glass: rgba(18, 16, 26, 0.92);
  --border: rgba(255, 255, 255, 0.1);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-hover: #ff3095;
  --accent: #ff3095;
  --accent-muted: rgba(255, 48, 149, 0.12);
  --text: #f3f0f5;
  --text-muted: #a89aab;
  --radius: 6px;
  --radius-lg: 8px;
  --font: "Poppins", "Segoe UI", system-ui, sans-serif;
  --danger: #f87171;
  --success: #34d399;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

.page-glow {
  pointer-events: none;
  position: fixed;
  inset: 0 0 auto;
  height: 280px;
  background: radial-gradient(ellipse 70% 50% at 50% -20%, rgba(255, 48, 149, 0.08), transparent 65%);
  z-index: 0;
}

.main {
  position: relative;
  z-index: 1;
  width: min(1040px, calc(100% - 2.5rem));
  margin: 0 auto 3rem;
  padding-top: 1.25rem;
}

.main.narrow {
  width: min(720px, calc(100% - 2.5rem));
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem max(1.25rem, calc((100% - 1040px) / 2));
  background: rgba(11, 8, 17, 0.92);
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  font-size: 0.72rem;
  font-weight: 400;
}

.brand-text strong {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-text span {
  color: var(--text-muted);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.65rem;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.25rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: transparent;
}

.nav-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-pill {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: transparent;
}

.card-glass {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  margin-bottom: 0.85rem;
}

.hero {
  margin-top: 1.75rem;
  text-align: left;
  padding: 1.75rem 1.75rem;
  border-left: 3px solid var(--accent);
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--accent);
  letter-spacing: 0.16em;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 0.55rem;
  font-size: clamp(1.45rem, 2.8vw, 1.85rem);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.hero-lead {
  margin: 0;
  max-width: 38rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 400;
}

.section-label {
  margin: 0 0 0.85rem;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.search-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
}

@media (max-width: 800px) {
  .search-row {
    grid-template-columns: 1fr;
  }
  .topnav {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
  }
  .nav-user {
    width: 100%;
    margin-left: 0;
  }
}

input,
select,
textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 400;
}

input::placeholder {
  color: rgba(168, 154, 171, 0.7);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(255, 48, 149, 0.55);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.5rem 0.95rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: #e02886;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: rgba(255, 48, 149, 0.45);
  color: var(--text);
  background: var(--accent-muted);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.08);
}

.legend-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
}

.legend-group {
  margin-top: 0.85rem;
}

.legend-group:first-of-type {
  margin-top: 0.35rem;
}

.legend-group-title {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.legend-desc {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-right: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.12rem 0.45rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--badge-bd, transparent);
  color: var(--badge-fg, #fff);
  background: var(--badge-bg, var(--accent));
  vertical-align: middle;
}

.badge-outline {
  background: transparent !important;
  color: var(--badge-bd) !important;
}

.badge-soft {
  border-color: transparent;
}

.toc-section {
  transition: border-color 0.15s ease;
  padding: 0;
  overflow: hidden;
}

.toc-section:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.toc-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0.95rem 1.15rem;
}

.toc-toggle.sub {
  padding: 0.65rem 1rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
}

.toc-num {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  min-width: 2.25rem;
  font-variant-numeric: tabular-nums;
}

.toc-kind {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  flex-shrink: 0;
}

.toc-section.is-document .toc-title {
  font-weight: 600;
}

.code-row.is-document .code-name {
  font-weight: 600;
}

.toc-title {
  flex: 1;
  font-weight: 500;
  font-size: 0.95rem;
}

.chevron {
  color: var(--text-muted);
  font-size: 0.75rem;
  opacity: 0.7;
}

.toc-body {
  padding: 0 0.85rem 0.85rem;
  border-top: 1px solid var(--border-subtle);
}

.code-row {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  margin: 0.4rem 0;
  background: rgba(0, 0, 0, 0.22);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.code-row:hover,
.code-row.is-highlighted {
  border-color: rgba(255, 48, 149, 0.35);
  background: rgba(255, 48, 149, 0.04);
  box-shadow: none;
}

.code-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
}

.code-expand {
  flex: 1;
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 12rem;
}

.code-ref {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.code-sep {
  color: var(--text-muted);
  font-weight: 400;
  margin: 0 0.15rem;
}

.code-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.code-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.code-page .code-meta {
  align-items: flex-end;
  gap: 0.65rem 0.85rem;
  margin: 0.85rem 0 1.1rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  align-items: flex-start;
}

.meta-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1;
}

.meta-pill {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 0.12rem 0.4rem;
  background: rgba(255, 255, 255, 0.02);
}

.icon-btn {
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius);
  width: 1.85rem;
  height: 1.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.85rem;
}

.icon-btn:hover,
.icon-btn.is-active {
  color: var(--accent);
  border-color: rgba(255, 48, 149, 0.4);
  background: var(--accent-muted);
}

.code-detail {
  padding: 0.75rem 0.85rem 0.85rem;
  border-top: 1px solid var(--border-subtle);
}

.rich-text {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.rich-text h2,
.rich-text h3 {
  color: var(--text);
  font-weight: 600;
}

.see-also {
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.see-also a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.see-also a:hover {
  text-decoration: underline;
}

.search-results {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.35rem;
}

.search-hit {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  background: rgba(0, 0, 0, 0.15);
}

.search-hit:hover {
  border-color: rgba(255, 48, 149, 0.35);
  background: var(--accent-muted);
}

.flash {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.flash-error {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.28);
  color: #fecaca;
}

.empty {
  text-align: left;
  padding: 2rem 1.5rem;
}

.empty h2,
.empty h1 {
  margin-top: 0;
  font-weight: 600;
  font-size: 1.15rem;
}

.empty p {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.site-footer {
  position: relative;
  z-index: 1;
  width: min(1040px, calc(100% - 2.5rem));
  margin: 0 auto 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.linkish {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
}

.linkish:hover {
  text-decoration: underline;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  -webkit-overflow-scrolling: touch;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(520px, 100%);
  max-height: none;
  margin: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.4rem;
}

.modal-card.modal-card-wide {
  width: min(1100px, calc(100vw - 2rem));
}

.modal-card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-body {
  max-width: 100%;
}

.shortcuts-list {
  padding-left: 1.1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

kbd {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.08rem 0.3rem;
}

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

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.back-link:hover {
  color: var(--accent);
}

.code-page h1 {
  margin-top: 0;
  font-weight: 600;
  font-size: 1.5rem;
}

.muted {
  color: var(--text-muted);
}

.diff-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.diff-pane {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  background: rgba(0, 0, 0, 0.18);
  min-width: 0;
  max-height: min(420px, 50vh);
  overflow: auto;
}

.diff-label {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.revision-history {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.revision-entry {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  background: rgba(0, 0, 0, 0.12);
}

.revision-entry summary {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.9rem;
}

.revision-entry summary::-webkit-details-marker {
  display: none;
}

.revision-entry[open] summary {
  border-bottom: 1px solid var(--border-subtle);
}

.revision-entry .diff-split {
  padding: 0.75rem;
}

@media (max-width: 700px) {
  .diff-split {
    grid-template-columns: 1fr;
  }
}
