:root {
  --felt: #0f0b16;
  --felt-2: #171122;
  --felt-3: #20182e;
  --thread: #c8b6ff;
  --thread-dim: rgba(200, 182, 255, .42);
  --bone: #ece6f6;
  --dust: #9d93b6;
  --blood: #c0334d;
  --ok: #8fd6a6;
  --head: "Michroma", "Segoe UI", system-ui, sans-serif;
  --body: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--felt);
  color: var(--bone);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

a { color: var(--thread); text-underline-offset: 3px; }
a:hover { color: #fff; }
:focus-visible { outline: 2px solid var(--thread); outline-offset: 3px; border-radius: 3px; }

h1, h2, h3 { font-family: var(--head); font-weight: 400; line-height: 1.25; margin: 0 0 .6em; letter-spacing: .01em; }
h1 { font-size: clamp(1.8rem, 4.2vw, 2.8rem); }
h2 { font-size: 1.35rem; margin-top: 2.2em; }
h3 { font-size: 1rem; color: var(--thread); }
p { margin: 0 0 1em; max-width: 68ch; }
ul { padding-left: 1.2em; }
li { margin-bottom: .4em; max-width: 68ch; }
.muted { color: var(--dust); }
.small { font-size: .9rem; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 28px 22px;
  background: var(--felt-2);
  border-right: 2px dashed var(--thread-dim);
  display: flex; flex-direction: column; gap: 26px;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--bone); }
.brand img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: #000; }
.brand span { font-family: var(--head); font-size: .95rem; line-height: 1.2; }
.brand small { display: block; font-family: var(--body); color: var(--dust); font-size: .8rem; margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 4px;
  color: var(--bone); text-decoration: none; font-size: 1rem;
}
.nav a::before {
  content: ""; width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 2px solid var(--thread-dim);
  background: radial-gradient(circle, var(--felt-2) 0 2px, transparent 3px);
}
.nav a:hover { background: var(--felt-3); }
.nav a[aria-current="page"] { background: var(--felt-3); color: #fff; }
.nav a[aria-current="page"]::before { border-color: var(--thread); background: var(--thread); box-shadow: inset 0 0 0 3px var(--felt-3); }
.nav .sep { height: 0; border-top: 2px dashed var(--thread-dim); margin: 10px 0; opacity: .6; }

.side-foot { margin-top: auto; color: var(--dust); font-size: .85rem; }

.topbar { display: none; }

main { padding: clamp(24px, 5vw, 64px); max-width: 1080px; width: 100%; }

@media (max-width: 860px) {
  .shell { display: block; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20;
    padding: 10px 16px; background: var(--felt-2);
    border-bottom: 2px dashed var(--thread-dim);
  }
  .topbar .brand img { width: 38px; height: 38px; }
  .menu-btn { background: none; border: 2px solid var(--thread-dim); color: var(--bone); padding: 8px 14px; border-radius: 999px; font: inherit; cursor: pointer; }
  .side {
    position: fixed; inset: 56px 0 0 0; height: auto; z-index: 19;
    transform: translateX(-100%); transition: transform .2s ease; border-right: 0;
  }
  .side.open { transform: none; }
  .side .brand { display: none; }
}

/* ---------- patches (stitched cards) ---------- */
.patch {
  background: var(--felt-2);
  border: 2px dashed var(--thread-dim);
  border-radius: 6px;
  padding: 20px 22px;
}
.patch.warn { border-color: rgba(192, 51, 77, .6); }
.patch.solid { border-style: solid; }
.patch h3 { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }

.tick li, .cross li { list-style: none; position: relative; padding-left: 26px; }
.tick, .cross { padding-left: 0; margin: 0; }
.tick li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); }
.cross li::before { content: "✕"; position: absolute; left: 0; color: var(--blood); }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 40px; align-items: center; padding: 8px 0 10px; }
.hero h1 { margin-bottom: .4em; }
.hero p.lead { font-size: 1.25rem; color: var(--bone); }
.hero-art { display: grid; place-items: center; }
.hero-art img { width: min(100%, 320px); aspect-ratio: 1; border-radius: 50%; object-fit: cover; background: #000; border: 3px solid var(--thread); box-shadow: 0 0 0 10px var(--felt), 0 0 0 12px var(--thread-dim); }
.thread-line {
  height: 0; border-top: 3px dashed var(--thread); margin: 26px 0 30px; max-width: 420px;
  animation: sew 1.4s ease-out both;
}
@keyframes sew { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } .hero-art { order: -1; } .hero-art img { width: 200px; } }

.btn {
  display: inline-block; font: inherit; font-size: 1rem; cursor: pointer;
  padding: 10px 20px; border-radius: 999px; text-decoration: none;
  background: var(--thread); color: #12091f; border: 2px solid var(--thread);
}
.btn:hover { background: #fff; border-color: #fff; color: #12091f; }
.btn.ghost { background: transparent; color: var(--thread); }
.btn.ghost:hover { background: var(--felt-3); color: #fff; border-color: var(--thread); }
.btn.small { padding: 5px 14px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.pill { display: inline-block; padding: 2px 12px; border-radius: 999px; border: 1.5px solid var(--thread-dim); font-size: .85rem; color: var(--bone); }
.pill.on { border-color: var(--ok); color: var(--ok); }
.pill.off { border-color: var(--blood); color: #ff9aae; }

/* ---------- hierarchy ---------- */
.tier { margin-bottom: 26px; }
.tier-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 16px; margin-bottom: 10px; }
.tier-head h3 { margin: 0; font-size: 1.05rem; }
.rank-list { list-style: none; padding: 0; margin: 0; }
.rank-list li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1.5px dashed var(--thread-dim); max-width: none; margin: 0; }
.rank-list li:last-child { border-bottom: 0; }
.rank-list b { font-family: var(--head); font-weight: 400; font-size: .95rem; }
.rank-list span { color: var(--dust); text-align: right; }

/* ---------- gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; border-radius: 4px; display: block; background: #000; }
.gallery figcaption { padding-top: 10px; font-size: .95rem; color: var(--dust); }
.gallery .good img { outline: 3px solid var(--ok); outline-offset: 2px; }
.gallery .bad img { outline: 3px solid var(--blood); outline-offset: 2px; }

/* ---------- forms + code ---------- */
label { display: block; font-size: .95rem; color: var(--dust); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--bone);
  background: var(--felt); border: 2px solid var(--thread-dim); border-radius: 4px; padding: 9px 12px;
}
input:focus, select:focus, textarea:focus { border-color: var(--thread); outline: none; }
input[type="color"] { padding: 2px; height: 42px; }
input[type="checkbox"] { width: auto; margin-right: 8px; }
textarea { min-height: 120px; resize: vertical; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }

.code { position: relative; margin: 0 0 18px; }
.code .code-label { font-size: .9rem; color: var(--dust); margin-bottom: 6px; display: block; }
.code pre {
  margin: 0; padding: 14px 16px; padding-right: 90px;
  background: #07050b; border: 2px solid var(--thread-dim); border-radius: 4px;
  font-family: var(--mono); font-size: .85rem; line-height: 1.5; color: var(--bone);
  white-space: pre-wrap; word-break: break-word;
}
.code button { position: absolute; right: 8px; bottom: 8px; }

.notice { border-left: 4px solid var(--thread); background: var(--felt-2); padding: 14px 18px; border-radius: 0 4px 4px 0; margin: 20px 0; }
.notice.warn { border-color: var(--blood); }
.notice p:last-child { margin-bottom: 0; }

/* ---------- lore ---------- */
.lore-wrap { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 32px; }
@media (max-width: 760px) { .lore-wrap { grid-template-columns: 1fr; } }
.lore-list h3 { margin: 18px 0 6px; font-size: .9rem; }
.lore-list h3:first-child { margin-top: 0; }
.lore-list a { display: block; padding: 6px 10px; border-radius: 4px; text-decoration: none; color: var(--bone); }
.lore-list a:hover { background: var(--felt-3); }
.lore-list a[aria-current="true"] { background: var(--felt-3); color: var(--thread); }
.lore-body { background: var(--felt-2); border: 2px dashed var(--thread-dim); border-radius: 6px; padding: clamp(18px, 4vw, 40px); min-height: 300px; }
.lore-body h1 { font-size: 1.6rem; }
.lore-body h2 { font-size: 1.15rem; }
.lore-body blockquote { margin: 1em 0; padding: 4px 18px; border-left: 3px solid var(--thread-dim); color: var(--dust); }
.lore-body hr { border: 0; border-top: 2px dashed var(--thread-dim); margin: 2em 0; }
.lore-body code { font-family: var(--mono); background: #07050b; padding: 1px 6px; border-radius: 3px; }
.lore-body img { max-width: 100%; border-radius: 4px; }
.lore-body table { border-collapse: collapse; margin: 1em 0; }
.lore-body th, .lore-body td { border: 1.5px dashed var(--thread-dim); padding: 6px 12px; text-align: left; }
.redact { background: #000; color: #000; border-radius: 2px; padding: 0 6px; user-select: none; }
.redact:hover { color: var(--blood); }

/* ---------- terminal ---------- */
.gate { max-width: 460px; margin: 8vh auto; text-align: center; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tabs button { font: inherit; background: none; color: var(--bone); border: 2px solid var(--thread-dim); padding: 8px 18px; border-radius: 999px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--thread); color: #12091f; border-color: var(--thread); }
.log { list-style: none; padding: 0; margin: 12px 0 0; }
.log li { padding: 8px 0; border-bottom: 1.5px dashed var(--thread-dim); max-width: none; }
.embed-preview { background: #2b2d31; border-left: 4px solid var(--thread); border-radius: 4px; padding: 12px 16px; font-family: system-ui, sans-serif; color: #dbdee1; font-size: .95rem; }
.embed-preview .t { font-weight: 700; color: #fff; margin-bottom: 4px; }
.embed-preview .d { white-space: pre-wrap; }
.embed-preview .f { font-size: .78rem; color: #b5bac1; margin-top: 8px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--felt-3); border: 2px solid var(--thread); padding: 10px 20px; border-radius: 999px; z-index: 50; }

/* ---------- terminal extras ---------- */
.brand b { font-weight: 400; }
.chip { display: flex; align-items: center; gap: 10px; }
.chip img { width: 34px; height: 34px; border-radius: 50%; background: #000; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.pick button { font: inherit; font-size: .85rem; background: none; color: var(--bone); border: 1.5px solid var(--thread-dim); border-radius: 999px; padding: 3px 12px; cursor: pointer; }
.pick button[aria-pressed="true"] { background: var(--thread); color: #12091f; border-color: var(--thread); }
.sec { margin-top: 26px; }
.sec:first-child { margin-top: 0; }
.err { color: #ff9aae; }
.two { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
.list a { display: block; padding: 6px 10px; border-radius: 4px; color: var(--bone); text-decoration: none; cursor: pointer; }
.list a:hover, .list a[aria-current="true"] { background: var(--felt-3); }
textarea.tall { min-height: 260px; font-family: var(--mono); font-size: .85rem; }

/* ---------- ask the rules ---------- */
.ask-form { display: grid; gap: 12px; }
.ask-row { display: flex; gap: 10px; }
.ask-row input {
  flex: 1; min-width: 0; padding: 12px 14px; font: inherit; font-size: 1rem;
  color: var(--bone); background: var(--felt); border: 2px solid var(--thread-dim); border-radius: 10px;
}
.ask-row input:focus { outline: none; border-color: var(--thread); }
.ask-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: .88rem; color: var(--dust); background: transparent; cursor: pointer;
  border: 1px dashed var(--thread-dim); border-radius: 999px; padding: 6px 12px;
}
.chip:hover { color: var(--bone); border-color: var(--thread); }
.ask-out {
  padding: 14px 16px; border-left: 4px solid var(--thread); background: var(--felt-3);
  border-radius: 0 10px 10px 0; font-size: 1.05rem; line-height: 1.5; white-space: pre-wrap;
}
.ask-out.loading { color: var(--dust); font-style: italic; }
.ask-out.err { border-left-color: var(--blood); }
.btn:disabled { opacity: .6; cursor: wait; }
