/* Dark violet look, modeled on zeron.sh: near-black ground, Geist type,
   hairline borders, a violet glyph field behind the page. */
:root {
  --bg: #06040a;
  --bg-raise: #0c0913;
  --ink: #ece7f7;
  --dim: #9c92b5;
  --faint: #5d5178;
  --line: #241c36;
  --line-soft: #1a1428;
  --purple: #8b5cf6;
  --purple-hi: #b79df9;
  --purple-deep: #5b34b8;

  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Instrument Serif", Georgia, serif;

  --topbar-h: 64px;
  --gutter: 32px;
  --radius: 9px;

  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  background: var(--bg);
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #2a2140 transparent;
}

::-webkit-scrollbar { width: 10px; background: transparent; }
::-webkit-scrollbar-thumb {
  background: #2a2140;
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font: 15px/1.6 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--purple-deep); color: #fff; }

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--purple); outline-offset: 4px; border-radius: 4px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 6px;
}
.skip-link:focus { left: 8px; }

.wrap {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}

/* ── background ───────────────────────────────────────── */
.glyphs {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* violet wash from the top and a faint one from the bottom */
.beam {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 45% at 50% -5%, rgba(139, 92, 246, 0.22), transparent 70%),
    radial-gradient(40% 30% at 50% 110%, rgba(91, 52, 184, 0.14), transparent 70%);
}

/* ── top bar ──────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(6, 4, 10, 0.6);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  backdrop-filter: blur(12px) saturate(1.4);
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--topbar-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font: 600 17px/1 var(--mono);
  color: #fff;
  background: linear-gradient(140deg, var(--purple-hi), var(--purple) 45%, var(--purple-deep));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 0 24px rgba(139, 92, 246, 0.35);
}

.links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.navlink {
  padding: 6px 10px;
  color: var(--dim);
  transition: color 0.15s;
}
.navlink:hover, .navlink.is-active { color: var(--ink); }

/* ── buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  font: 500 14px/1 var(--sans);
  white-space: nowrap;
  color: #fff;
  background: var(--purple);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.btn:hover { background: var(--purple-hi); }
.btn:active { transform: scale(0.97); }

.btn--light { background: #f7f4ee; color: #17141d; }
.btn--light:hover { background: #ddd6ea; }

.btn--ghost {
  background: rgba(12, 9, 19, 0.6);
  color: var(--dim);
  box-shadow: inset 0 0 0 1px var(--line);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.btn--ghost:hover { background: rgba(12, 9, 19, 0.8); color: var(--ink); box-shadow: inset 0 0 0 1px var(--faint); }

.btn--small { height: 30px; padding: 0 13px; font-size: 12px; margin-left: 6px; }

.btn__arrow { font-size: 0.95em; opacity: 0.7; transition: transform 0.15s; }
.btn:hover .btn__arrow { transform: translate(2px, -2px); }

/* ── content ──────────────────────────────────────────── */
.content {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.doc {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 56px var(--gutter) 80px;
}

.doc--center {
  flex: 1;
  max-width: 1140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── hero ─────────────────────────────────────────────── */
.hero {
  max-width: 660px;
  padding-bottom: 6vh;
  text-align: center;
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  padding: 5px 12px 5px 10px;
  font: 500 12px/1.4 var(--mono);
  letter-spacing: 0.02em;
  color: var(--dim);
  background: rgba(31, 24, 46, 0.44);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 15px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.chip__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--purple-hi);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25), 0 0 12px var(--purple);
  animation: pulse 2.4s ease-in-out infinite;
}

.hero__title {
  font-size: clamp(64px, 12vw, 132px);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.055em;
  background: linear-gradient(180deg, #fff 20%, var(--purple-hi) 80%, var(--purple) 110%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 40px rgba(139, 92, 246, 0.3));
}

.hero__lede {
  margin-top: 26px;
  font-size: clamp(18px, 2.1vw, 22px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.5;
  color: var(--dim);
  text-wrap: balance;
}

.hero__lede b { display: block; font-weight: 600; color: var(--ink); }

.hero__lede em {
  font: italic 400 1.18em/1 var(--serif);
  letter-spacing: 0;
  color: var(--purple-hi);
}

.cta-row {
  margin-top: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.12), 0 0 18px var(--purple); }
}

/* ── plain pages (anything that isn't the hero) ───────── */
.doc h1, .doc h2, .doc h3 { letter-spacing: -0.03em; line-height: 1.2; }
.doc:not(.doc--center) h1 { font-size: 40px; margin-bottom: 20px; }
.doc h2 { font-size: 24px; margin: 40px 0 12px; }
.doc h3 { font-size: 18px; margin: 28px 0 8px; }
.doc:not(.doc--center) p, .doc ul, .doc ol { margin-bottom: 14px; color: var(--dim); }
.doc ul, .doc ol { padding-left: 22px; }
.doc strong { color: var(--ink); }
.doc:not(.doc--center) a:not([class]) { color: var(--purple-hi); }
.doc:not(.doc--center) a:not([class]):hover { text-decoration: underline; }
.doc code { font: 0.9em var(--mono); padding: 1px 5px; background: var(--bg-raise); border: 1px solid var(--line-soft); border-radius: 5px; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }

.code { position: relative; margin-bottom: 16px; }
.code pre { overflow-x: auto; padding: 14px 16px; background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); }
.code pre code { padding: 0; background: none; border: 0; font-size: 13px; }
.code__copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 9px;
  font: 500 11px var(--mono);
  color: var(--dim);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.code__copy:hover, .code__copy.is-done { color: var(--ink); border-color: var(--faint); }

.table-scroll { overflow-x: auto; margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.table th { color: var(--ink); font-weight: 600; }
.table td { color: var(--dim); }

/* ── app pages (Posts, Resources) ─────────────────────── */
.doc--wide { max-width: 960px; }
.app { min-height: 40vh; }
.dim { color: var(--faint); }
.app-loading { color: var(--faint); }
.app-error {
  margin: 0 0 16px;
  padding: 12px 14px;
  color: #ffc9d2;
  background: rgba(190, 40, 70, 0.12);
  border: 1px solid rgba(220, 70, 100, 0.35);
  border-radius: var(--radius);
}

.app-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.doc .app-head h1 { margin-bottom: 4px; }
.app-head__actions { display: flex; gap: 8px; }
.whoami { font-size: 13px; color: var(--faint); }
.badge {
  margin-left: 8px;
  padding: 1px 7px;
  font: 500 11px/1.5 var(--mono);
  color: var(--purple-hi);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.linkish {
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--dim);
  background: none;
  border: 0;
  cursor: pointer;
}
.linkish:hover { color: var(--ink); }
.linkish--danger:hover { color: #ff8fa3; }
button:disabled { opacity: 0.55; cursor: progress; }
.btn--small.btn--ghost { margin-left: 0; }

.back { display: inline-block; margin-bottom: 18px; font-size: 14px; color: var(--dim); }
.back:hover { color: var(--ink); }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; font-size: 13px; color: var(--faint); }
.meta strong { color: var(--dim); font-weight: 600; }
.meta__link { display: inline-flex; align-items: center; gap: 4px; color: var(--faint); }
.meta__link:hover { color: var(--ink); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* sort tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.doc .tab { padding: 8px 14px; margin-bottom: -1px; font-size: 14px; color: var(--dim); border-bottom: 2px solid transparent; }
.doc .tab:hover { color: var(--ink); text-decoration: none; }
.doc .tab.is-active { color: var(--ink); border-bottom-color: var(--purple); }

/* votes */
.vote { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 40px; }
.vote--row { flex-direction: row; gap: 4px; min-width: 0; }
.vote__btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--faint);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.vote--row .vote__btn { width: 24px; height: 24px; }
.vote__btn:hover { color: var(--ink); background: rgba(139, 92, 246, 0.12); }
.vote__btn--up[aria-pressed="true"] { color: #ff8b5c; }
.vote__btn--down[aria-pressed="true"] { color: #8fa8ff; }
.vote__score { font: 600 13px/1 var(--mono); color: var(--dim); min-width: 2ch; text-align: center; }
.vote.is-up .vote__score { color: #ff8b5c; }
.vote.is-down .vote__score { color: #8fa8ff; }

.flair {
  display: inline-block;
  padding: 1px 8px;
  font: 500 11px/1.6 var(--mono);
  color: var(--dim);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}
.flair--announcement { color: #ffd88a; background: rgba(255, 190, 70, 0.12); }
.flair--question { color: #8fd3ff; background: rgba(80, 170, 255, 0.12); }
.flair--resource { color: #9ef0c0; background: rgba(70, 210, 140, 0.12); }
.flair--practice { color: var(--purple-hi); background: rgba(139, 92, 246, 0.14); }
.pinned { display: inline-flex; align-items: center; gap: 4px; font: 500 11px/1.6 var(--mono); color: #9ef0c0; }

/* feed */
.doc ul.feed { list-style: none; padding: 0; display: grid; gap: 10px; }
.feed__item {
  display: flex;
  gap: 12px;
  padding: 12px 16px 12px 8px;
  background: rgba(12, 9, 19, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}
.feed__item:hover { border-color: var(--faint); }
.feed__item.is-pinned { border-color: rgba(70, 210, 140, 0.35); }
.feed__main { flex: 1; min-width: 0; }
.feed__top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.doc a.feed__title { display: block; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); overflow-wrap: anywhere; }
.doc a.feed__title:hover { color: var(--purple-hi); text-decoration: none; }
.doc p.feed__excerpt {
  margin: 4px 0 6px;
  font-size: 14px;
  color: var(--dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.empty { padding: 48px 16px; text-align: center; color: var(--dim); border: 1px dashed var(--line); border-radius: var(--radius); }
.doc .empty p { margin-bottom: 16px; }

/* single post */
.post { display: flex; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.post__main { flex: 1; min-width: 0; }
.doc h1.post__title { font-size: 30px; margin: 4px 0 8px; overflow-wrap: anywhere; }
.post__body { margin-top: 18px; }
.actions { display: flex; gap: 16px; margin-top: 16px; }

/* comments */
.comments { margin-top: 24px; }
.doc h2.comments__title { margin: 0 0 14px; font-size: 18px; }
.comment-form { margin-bottom: 18px; }
.comment-list { display: grid; gap: 16px; }
.comment { min-width: 0; }
.comment .md { margin: 4px 0 2px; }
.comment__actions { display: flex; align-items: center; gap: 14px; }
.comment__slot .comment-form { margin: 10px 0 6px; }
.comment__children { display: grid; gap: 14px; margin: 10px 0 0 10px; padding-left: 16px; border-left: 2px solid var(--line); }
.comment__children:hover { border-left-color: var(--faint); }

/* rendered Markdown */
.md { color: var(--dim); overflow-wrap: anywhere; }
.doc .md p, .doc .md ul, .doc .md ol { margin: 0 0 10px; }
.doc .md > :last-child { margin-bottom: 0; }
.doc .md h2, .doc .md h3, .doc .md h4, .doc .md h5, .doc .md h6 { margin: 18px 0 8px; color: var(--ink); }
.doc .md h2 { font-size: 22px; }
.doc .md h3 { font-size: 18px; }
.doc .md h4, .doc .md h5, .doc .md h6 { font-size: 15px; }
.doc .md > :first-child { margin-top: 0; }
.md a { color: var(--purple-hi); }
.md a:hover { text-decoration: underline; }
.md pre { margin: 0 0 10px; padding: 12px 14px; overflow-x: auto; background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); }
.doc .md pre code { padding: 0; background: none; border: 0; font-size: 13px; }
.md blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--line); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* forms */
.doc h1.form__title { font-size: 30px; }
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field__hint { font-size: 12px; color: var(--faint); }
.field__input {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.field__input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2); }
select.field__input { max-width: 260px; }
.field__input--area { min-height: 90px; resize: vertical; font: 14px/1.55 var(--mono); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--dim); }
.check input { accent-color: var(--purple); width: 16px; height: 16px; }
.form__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.form .app-error { margin: 0; }

.editor__tabs { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.editor__tab { padding: 4px 10px; font: inherit; font-size: 13px; color: var(--faint); background: none; border: 0; border-radius: 6px; cursor: pointer; }
.editor__tab:hover { color: var(--ink); }
.editor__tab.is-active { color: var(--ink); background: var(--bg-raise); box-shadow: inset 0 0 0 1px var(--line); }
.editor__hint { margin-left: auto; font-size: 12px; color: var(--faint); }
.md--preview { min-height: 90px; padding: 10px 12px; background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); }

/* resources: GitHub-style folder browser */
.repo-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.repo-bar__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 18px; }
.doc .crumbs a { color: var(--purple-hi); }
.doc .crumbs a:hover { text-decoration: underline; }
.crumbs strong { color: var(--ink); }
.crumbs__sep { color: var(--faint); }

.panel { display: grid; gap: 12px; margin-bottom: 14px; padding: 16px; background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); }
.doc h2.panel__title { margin: 0; font-size: 16px; }

.repo { overflow: hidden; background: rgba(12, 9, 19, 0.72); border: 1px solid var(--line); border-radius: var(--radius); }
.repo__head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 11px 16px; font-size: 13px; background: rgba(31, 24, 46, 0.45); border-bottom: 1px solid var(--line); }
.repo__head strong { color: var(--ink); }
.repo__head-right { margin-left: auto; color: var(--faint); }
.repo > .repo__head:last-child { border-bottom: 0; }
.doc ul.repo__list { list-style: none; padding: 0; margin: 0; }
.repo__row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) minmax(0, 120px) 92px auto;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  font-size: 14px;
  border-top: 1px solid var(--line-soft);
}
.repo__row:first-child { border-top: 0; }
.repo__row:hover { background: rgba(139, 92, 246, 0.05); }
.repo__row--up { display: block; }
.repo__icon { display: grid; place-items: center; color: var(--faint); }
.repo__icon--folder { color: var(--purple-hi); }
.repo__cell { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.doc a.repo__name { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc a.repo__name:hover { color: var(--purple-hi); text-decoration: underline; }
.repo__desc { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.repo__by { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.repo__when { color: var(--faint); text-align: right; white-space: nowrap; }
.repo__tools { display: flex; gap: 10px; opacity: 0; transition: opacity 0.15s; }
.repo__row:hover .repo__tools, .repo__tools:focus-within { opacity: 1; }

.readme, .file { margin-top: 16px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); }
.readme__head, .file__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 14px;
  background: rgba(31, 24, 46, 0.45);
  border-bottom: 1px solid var(--line);
}
.readme__head span { display: grid; color: var(--faint); }
.doc .readme__head a { color: var(--ink); }
.readme__edit { margin-left: auto; }
.readme__body, .file__body { padding: 20px 24px; background: rgba(12, 9, 19, 0.72); }
.file__head strong { color: var(--ink); }
.file__by { font-size: 13px; }
.file__tools { display: flex; gap: 8px; margin-left: auto; }
.doc p.file__body { margin: 0; }

@media (max-width: 480px) {
  /* five nav items don't fit beside the name; the mark alone still links home */
  .brand { font-size: 0; gap: 0; }
  .btn--small { margin-left: 2px; }
}

@media (max-width: 640px) {
  .repo__row { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .repo__by, .repo__when { display: none; }
  .repo__tools { opacity: 1; }
  .repo__desc { display: none; }
  .feed__item { padding-right: 12px; }
  .doc h1.post__title { font-size: 24px; }
  .readme__body, .file__body { padding: 16px; }
}

@media (max-width: 640px) {
  :root { --gutter: 16px; --topbar-h: 56px; }
  .topbar__inner { gap: 12px; }
  .links { gap: 2px; }
  .navlink { padding: 6px 8px; }
  .doc { padding-top: 40px; }
  .cta-row .btn { flex: 1 1 140px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero, .chip__dot { animation: none; }
  .btn, .btn__arrow { transition: none; }
}
