* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: #121019;
  color: #f6f0e8;
  font: 18px/1.72 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
  padding: 76px 22px 64px;
  background: radial-gradient(circle at top, #3a274c 0, #17131f 58%, #121019 100%);
  border-bottom: 1px solid #3b3346;
}

.wrap,
main {
  max-width: 800px;
  margin: auto;
}

small {
  letter-spacing: 0.18em;
  color: #d8b8ff;
  font-weight: 850;
}

h1 {
  font-size: clamp(2.8rem, 8vw, 5.6rem);
  line-height: 0.94;
  margin: 0.25em 0;
}

h1 em {
  color: #f3ca60;
  font-style: normal;
}

.dek {
  font-size: 1.2rem;
  color: #c8bfce;
}

.hint {
  margin-top: 28px;
  color: #aaa0b3;
  font-size: 0.95rem;
  max-width: 650px;
}

nav {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  gap: 7px;
  overflow: auto;
  padding: 10px 14px;
  background: #121019ee;
  border-bottom: 1px solid #302938;
  backdrop-filter: blur(10px);
}

nav span {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: #786f82;
  padding: 7px;
}

nav a {
  color: #cdb8dc;
  text-decoration: none;
  background: #211b2b;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
}

section {
  padding: 58px 24px;
  border-bottom: 1px solid #302938;
}

.num {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: #6f6579;
  margin-bottom: 8px;
}

h2 {
  font-size: clamp(1.7rem, 5vw, 2.65rem);
  line-height: 1.05;
  margin: 0 0 32px;
  color: #f3ca60;
}

p {
  margin: 0 0 1.15em;
}

.chapter-art {
  margin: 0 0 30px;
}

.chapter-art img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #3b3346;
  border-radius: 8px;
  box-shadow: 0 18px 55px #0007;
}

.chapter-art figcaption {
  margin-top: 8px;
  color: #9c93a6;
  font-size: 0.82rem;
  line-height: 1.45;
}

.cut {
  margin: 0 0 1.4em;
  padding: 22px 24px;
  background: #191423;
  border: 1px solid #3b3346;
  border-radius: 8px;
}

.cut h3 {
  margin: 0 0 16px;
  color: #d7a9ff;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cut p:last-child {
  margin-bottom: 0;
}

blockquote {
  margin: 28px 0;
  padding: 20px 24px;
  background: #1e1928;
  border-left: 4px solid #d7a9ff;
  border-radius: 0 14px 14px 0;
}

blockquote.chat {
  max-width: 88%;
  border: 1px solid color-mix(in srgb, var(--speaker-color, #d7a9ff) 42%, #302938);
  background: color-mix(in srgb, var(--speaker-color, #d7a9ff) 13%, #1e1928);
  box-shadow: inset 5px 0 0 var(--speaker-color, #d7a9ff);
  border-radius: 20px 20px 20px 6px;
}

blockquote.chat--right {
  margin-left: auto;
  box-shadow: inset -5px 0 0 var(--speaker-color, #d7a9ff);
  border-radius: 20px 20px 6px 20px;
}

blockquote.chat b:first-child {
  color: #fff;
  font-weight: 900;
}

blockquote.chat .name {
  border-bottom-color: var(--speaker-color, #d7a9ff);
}

blockquote br {
  display: block;
  content: "";
  margin-top: 7px;
}

.boom {
  text-align: center;
  font-size: clamp(1.75rem, 6vw, 3.1rem);
  font-weight: 900;
  line-height: 1.08;
  padding: 30px 5px;
  color: #d7a9ff;
}

.name {
  font: inherit;
  color: #f6f0e8;
  background: none;
  border: 0;
  border-bottom: 2px dotted #d7a9ff;
  padding: 0;
  cursor: pointer;
  font-weight: 780;
}

.name:hover,
.name:focus-visible {
  color: #f3ca60;
}

.name:focus-visible {
  outline: 2px solid #f3ca60;
  outline-offset: 3px;
  border-radius: 4px;
}

ul {
  margin: 0 0 1.4em;
}

dialog {
  max-width: 500px;
  width: calc(100% - 32px);
  border: 1px solid #584968;
  border-radius: 20px;
  background: #211b2b;
  color: #f6f0e8;
  padding: 28px;
  box-shadow: 0 25px 90px #000;
}

dialog::backdrop {
  background: #09070dcc;
  backdrop-filter: blur(4px);
}

#x {
  position: absolute;
  right: 14px;
  top: 8px;
  border: 0;
  background: none;
  color: #aaa0b3;
  font-size: 2rem;
  cursor: pointer;
}

#x:focus-visible {
  outline: 2px solid #f3ca60;
  outline-offset: 2px;
  border-radius: 6px;
}

#info h3 {
  font-size: 1.7rem;
  margin: 0;
  color: #f3ca60;
}

#info .real {
  font-size: 1.2rem;
  margin: 2px 0 14px;
  color: #d7a9ff;
  font-weight: 800;
}

#info .race {
  display: inline-block;
  background: #332942;
  border-radius: 999px;
  padding: 4px 10px;
  margin: 0 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

#info p {
  margin-top: 0;
}

footer {
  max-width: 800px;
  margin: auto;
  padding: 60px 24px 90px;
  color: #8f8797;
  text-align: center;
}

@media (max-width: 600px) {
  body {
    font-size: 17px;
  }

  section {
    padding: 46px 20px;
  }

  header {
    padding-top: 58px;
  }

  .cut {
    padding: 18px;
  }

  blockquote.chat {
    max-width: 95%;
    padding: 17px 20px;
  }
}

/* ---------------------------------------------------------------- threads */

.thread {
  margin: 30px 0;
  padding: 16px 14px 18px;
  background: #171322;
  border: 1px solid #3b3346;
  border-radius: 16px;
}

.thread-head {
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8f85a0;
  padding: 0 6px 12px;
  border-bottom: 1px solid #2b2437;
  margin-bottom: 14px;
}

.thread-msgs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 18px 18px 18px 6px;
  background: color-mix(in srgb, var(--speaker-color, #d7a9ff) 13%, #1e1928);
  border: 1px solid color-mix(in srgb, var(--speaker-color, #d7a9ff) 40%, #302938);
  position: relative;
}

.msg--right {
  margin-left: auto;
  border-radius: 18px 18px 6px 18px;
}

.msg-speaker {
  display: block;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: var(--speaker-color, #d7a9ff);
  margin-bottom: 3px;
}

.msg-text {
  display: block;
  line-height: 1.5;
}

.msg-reacts {
  position: absolute;
  bottom: -9px;
  right: 10px;
  background: #241d31;
  border: 1px solid #3b3346;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.8rem;
  line-height: 1.5;
}

.msg--system {
  max-width: 100%;
  margin: 2px auto;
  background: none;
  border: 0;
  padding: 2px 0;
  text-align: center;
  color: #8f85a0;
  font-size: 0.82rem;
  font-style: italic;
}

/* The speaker label is a real text node, so app.js turns it into a popup button. */
.msg .msg-speaker .name {
  color: var(--speaker-color, #d7a9ff);
  border-bottom-color: color-mix(in srgb, var(--speaker-color, #d7a9ff) 60%, transparent);
  font-weight: 900;
}

.thread[data-platform="tweets"] .msg,
.thread[data-platform="comments"] .msg {
  max-width: 100%;
  margin-left: 0;
  border-radius: 12px;
}

.thread[data-platform="dms"] {
  background: #14111d;
}

/* ------------------------------------------------------------------ memes */

.meme {
  margin: 30px 0;
}

.meme-frame {
  position: relative;
  container-type: inline-size;
  aspect-ratio: var(--aspect, 1 / 1);
  background: #1e1928;
  border: 1px solid #3b3346;
  border-radius: 10px;
  overflow: hidden;
}

.meme-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Text sits over the template image as positioned DOM rather than being baked into
   the pixels, so name popups, selection and screen readers all still work. */
.meme-slot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Percentage padding resolves against the CONTAINING BLOCK's width - the frame -
     not the slot, so 2% cost a small box ~30px of vertical room regardless of its
     own size. Em padding scales with the type instead. */
  padding: 0.15em 0.25em;
  text-align: center;
  /* A long word cannot wrap, so without this it overflows the box sideways however
     small the type gets. */
  overflow-wrap: anywhere;
  color: var(--ink, #000);
  /* Meme text lands on artwork, not a clean background. A contrasting outline keeps
     it readable wherever a slot box overlaps a button, a face or a shadow. */
  -webkit-text-stroke: 0.06em var(--ink-edge, #fff);
  paint-order: stroke fill;
  font-weight: 800;
  line-height: 1.18;
  text-wrap: balance;
  overflow: hidden;
  /* --fs is solved per slot from its box area and text length (see fitFontSize in
     lib/blocks.mjs). cqw resolves against .meme-frame, so type scales with the
     template rather than the viewport; the clamp keeps it legible on phones and
     stops a roomy box from rendering absurdly large type. */
  font-size: clamp(0.5rem, var(--fs, 3cqw), 1.45rem);
}

.meme-cap {
  margin-top: 8px;
  color: #9c93a6;
  font-size: 0.82rem;
  line-height: 1.45;
}

.meme-slot[style*="--ink:#fff"] {
  --ink-edge: #000;
}

.meme-slot .name {
  color: inherit;
  font-weight: 900;
  border-bottom-color: #0006;
}

@media (max-width: 600px) {
  .msg {
    max-width: 92%;
  }

  .thread {
    padding: 14px 10px 16px;
  }
}
