:root {
  --bg: #12120e;
  --bg-elev: #1c1c16;
  --ink: #e8e4d4;
  --muted: #9a957f;
  --accent: #c4b37a;
  --accent-dim: #8a7d4f;
  --danger: #e07a6a;
  --line: #2e2e24;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --pad: max(0.9rem, env(safe-area-inset-left));
  --pad-r: max(0.9rem, env(safe-area-inset-right));
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, #2a2818 0%, transparent 55%),
    linear-gradient(180deg, #12120e 0%, #0e0e0b 100%);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  color: #e0d4a0;
}

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

.top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: max(0.55rem, env(safe-area-inset-top)) var(--pad-r) 0.55rem var(--pad);
  background: rgba(18, 18, 14, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
}

.top-go {
  flex: 1;
  display: flex;
  min-width: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.top-go input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0.55rem 0.85rem;
  font-size: 0.95rem;
}

.top-go button {
  border: 0;
  background: var(--accent-dim);
  color: #111;
  font-weight: 700;
  padding: 0 0.9rem;
  font-size: 1.1rem;
}

.hubs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.55rem var(--pad) 0.65rem;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.hubs::-webkit-scrollbar {
  display: none;
}

.nav-link {
  flex: 0 0 auto;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--ink);
  border-color: var(--accent-dim);
}

.main {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1rem var(--pad) 3rem var(--pad-r);
}

.page-title {
  font-size: 1.45rem;
  line-height: 1.25;
  margin: 0.2rem 0 0.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.source {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 1rem;
  word-break: break-all;
}

.hero {
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: 1.75rem;
  margin: 0 0 0.4rem;
}

.lede {
  color: var(--muted);
  margin: 0 0 1rem;
}

.go-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.go-form input {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 1rem;
}

.go-form button {
  padding: 0.85rem 1rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #1a180c;
  font-weight: 700;
  font-size: 1rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: #252518;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.88rem;
}

.error {
  background: #3a1e1a;
  border: 1px solid var(--danger);
  color: #f0c8c0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.article {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.article img,
.article video,
.article iframe {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 6px;
}

.article table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 0.75rem 0;
}

.article pre,
.article code {
  max-width: 100%;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.88em;
}

.article pre {
  padding: 0.75rem;
  background: #0a0a08;
  border-radius: 8px;
  border: 1px solid var(--line);
  white-space: pre-wrap;
}

.article p {
  margin: 0.7em 0;
}

.article h1,
.article h2,
.article h3,
.article h4 {
  line-height: 1.25;
  margin: 1.25em 0 0.5em;
}

.article ul,
.article ol {
  padding-left: 1.25rem;
}

.article .collapsible-label {
  font-weight: 700;
  color: var(--accent);
  margin: 0.75rem 0 0.25rem;
}

.article .scp-image-block,
.article .image-container {
  max-width: 100%;
  margin: 0.75rem auto;
}

.article hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.25rem 0;
}

/* Wikidot rate/theme leftovers */
.article .page-rate-widget-box,
.article .creditRate {
  display: none !important;
}

.foot {
  padding: 1rem var(--pad) max(1.5rem, env(safe-area-inset-bottom));
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--line);
}

.foot p {
  margin: 0;
}

@media (min-width: 640px) {
  .go-form {
    flex-direction: row;
  }
  .go-form button {
    flex: 0 0 auto;
    min-width: 6rem;
  }
}
