/*
  Faux-chan thread reader — Applejack / SOVL / Comfy corkboard edition.
  Reads like 4chan, dresses like a saloon bulletin board.
*/

:root {
  --aj-green: #5d7e1c;
  --aj-green-deep: #466014;
  --aj-quote: #9f321f;
  --aj-quote-deep: #6c1c0d;
  --aj-stamp: #b13322;
  --aj-twine: #b07a3d;
}

.app-view--thread-reader[hidden] { display: none; }

/* ── Corkboard backdrop ─────────────────────────────────────────── */
.thread-reader {
  position: relative;
  margin: 6px 0 12px;
  padding: 22px 26px 30px;
  background:
    radial-gradient(rgba(0, 0, 0, .18) 1px, transparent 1.4px) 0 0/14px 14px,
    radial-gradient(rgba(255, 255, 255, .08) 1px, transparent 1.4px) 7px 7px/14px 14px,
    repeating-linear-gradient(118deg, rgba(0, 0, 0, .04) 0 1px, transparent 1px 7px),
    linear-gradient(#c4895c, #a5734a);
  border: 4px solid #4d2f15;
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, .18),
    inset 0 4px 14px rgba(0, 0, 0, .28),
    inset 0 -6px 14px rgba(255, 228, 180, .12),
    0 6px 16px rgba(36, 20, 8, .35);
  color: var(--ink);
  overflow: hidden;
}

/* twine running down both gutters */
.thread-reader::before,
.thread-reader::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  background:
    repeating-linear-gradient(30deg, #6e431d 0 4px, #aa7036 4px 8px, #6e431d 8px 12px);
  border-left: 1px solid rgba(0, 0, 0, .35);
  border-right: 1px solid rgba(255, 230, 180, .25);
  box-shadow: 0 0 6px rgba(0, 0, 0, .35);
  pointer-events: none;
}
.thread-reader::before { left: 4px; }
.thread-reader::after  { right: 4px; }

/* ── Header plank ───────────────────────────────────────────────── */
.thread-reader__plank {
  position: relative;
  margin: 0 14px 22px;
  padding: 14px 22px 16px 22px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px 18px;
  align-items: center;
  background:
    repeating-linear-gradient(0deg, rgba(67, 31, 10, .12) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(90deg, rgba(255, 219, 145, .08) 0 2px, transparent 2px 10px),
    linear-gradient(#9d6530 0%, #7c481f 50%, #6b3a17 100%);
  border: 3px solid #4d2f15;
  border-top-color: #b77b3c;
  border-radius: 5px;
  color: #fff4d4;
  box-shadow:
    inset 0 0 0 2px rgba(255, 230, 178, .14),
    inset 0 -8px 16px rgba(0, 0, 0, .28),
    0 5px 0 rgba(0, 0, 0, .22),
    0 8px 14px rgba(0, 0, 0, .35);
}

/* twine knots at corners of the plank */
.thread-reader__plank::before,
.thread-reader__plank::after {
  content: "";
  position: absolute;
  top: -6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffd99a, #b97c39 65%, #5c3613);
  box-shadow:
    0 2px 3px rgba(0, 0, 0, .45),
    inset 0 0 0 1px rgba(0, 0, 0, .35);
}
.thread-reader__plank::before { left: -6px; }
.thread-reader__plank::after  { right: -6px; }

.thread-reader__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 7px;
  color: #fff4d4;
  font-family: "Rye", "IM Fell English SC", Georgia, serif;
  font-size: 13px;
  letter-spacing: .04em;
  background: linear-gradient(#d96d35, #a13018);
  border: 2px solid #5b210f;
  border-radius: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 220, .35),
    0 3px 0 rgba(0, 0, 0, .35);
  cursor: pointer;
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  transition: transform .12s ease, filter .12s ease;
}
.thread-reader__back:hover,
.thread-reader__back:focus-visible {
  filter: brightness(1.1);
  transform: translateY(-1px);
  outline: none;
  background: linear-gradient(#d96d35, #a13018);
  color: #fff4d4;
}
.thread-reader__back::before {
  content: "↩";
  font-family: Georgia, serif;
  font-size: 16px;
  line-height: 1;
}

.thread-reader__title-block {
  display: grid;
  gap: 4px;
  min-width: 0;
  text-align: center;
}
.thread-reader__title-block .kicker {
  font-family: "IM Fell English SC", Georgia, serif;
  font-size: 11px;
  letter-spacing: .28em;
  color: #ffe5a7;
  opacity: .85;
}
.thread-reader__title-block h2 {
  font-family: "Rye", "IM Fell English SC", Georgia, serif;
  font-size: 26px;
  line-height: 1.05;
  color: #fff4d4;
  text-shadow:
    0 1px 0 rgba(0, 0, 0, .5),
    0 0 16px rgba(255, 196, 90, .22);
  word-break: break-word;
}
.thread-reader__title-block .subtitle {
  font-family: "Kalam", "Special Elite", Georgia, cursive;
  font-size: 13px;
  color: #ffeec1;
  opacity: .9;
}

.thread-reader__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.thread-reader__meta-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px 4px;
  background: linear-gradient(#fff4d4, #ecc878);
  color: #5a3013;
  border: 1.5px solid #6b3a17;
  border-radius: 999px;
  font-family: "IM Fell English SC", Georgia, serif;
  font-size: 12px;
  letter-spacing: .04em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 230, .55),
    0 2px 0 rgba(0, 0, 0, .3);
  white-space: nowrap;
}
.thread-reader__meta-pill strong {
  font-family: "Rye", Georgia, serif;
  font-size: 13px;
  color: var(--apple);
}

/* source-archive luggage tag — small ticket dangling from the plank's
   upper-right with a punched hole and a stretch of twine. Non-intrusive
   secondary action for readers who want the original on desuarchive. */
.thread-reader__source-tag {
  position: absolute;
  top: -16px;
  right: 70px;
  display: grid;
  gap: 0;
  padding: 6px 12px 7px 22px;
  text-align: left;
  text-decoration: none;
  color: #4b2c16;
  background:
    repeating-linear-gradient(0deg, rgba(120, 70, 30, .06) 0 1px, transparent 1px 6px),
    linear-gradient(#fff6d7, #ecc878);
  border: 1.5px solid #8a4f1c;
  border-radius: 3px 3px 8px 3px;
  transform: rotate(-4deg);
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 218, .6),
    0 3px 4px rgba(0, 0, 0, .35);
  z-index: 4;
  transition: transform .15s ease, filter .15s ease;
}
.thread-reader__source-tag[hidden] { display: none; }

.thread-reader__source-tag::before {
  /* punched hole */
  content: "";
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4d2f15;
  box-shadow:
    inset 0 1px 1px rgba(0, 0, 0, .55),
    0 0 0 1px rgba(255, 248, 218, .45);
}

.thread-reader__source-tag::after {
  /* twine string up to the plank */
  content: "";
  position: absolute;
  left: 10px;
  top: -12px;
  width: 1px;
  height: 16px;
  background: repeating-linear-gradient(0deg, #6e431d 0 2px, transparent 2px 4px);
  transform: rotate(10deg);
  transform-origin: bottom center;
}

.thread-reader__source-tag-line {
  font-family: "Kalam", "Special Elite", Georgia, cursive;
  font-size: 10.5px;
  letter-spacing: .02em;
  color: #6f4818;
  line-height: 1;
}

.thread-reader__source-tag-host {
  font-family: "Rye", "IM Fell English SC", Georgia, serif;
  font-size: 11.5px;
  letter-spacing: .04em;
  color: #9f321f;
  line-height: 1.1;
}

.thread-reader__source-tag:hover,
.thread-reader__source-tag:focus-visible {
  filter: brightness(1.08);
  transform: rotate(-2deg) translateY(-1px);
  outline: none;
}
.thread-reader__source-tag:hover .thread-reader__source-tag-host,
.thread-reader__source-tag:focus-visible .thread-reader__source-tag-host {
  color: #c24a27;
}

/* tiny twine label dangling below the plank */
.thread-reader__pulltag {
  position: absolute;
  left: 50%;
  bottom: -22px;
  transform: translateX(-50%) rotate(-2deg);
  padding: 4px 12px 6px;
  background: linear-gradient(#fff6d7, #e7c989);
  border: 1.5px dashed #8a4f1c;
  border-radius: 3px;
  color: #4b2c16;
  font-family: "Kalam", "Special Elite", Georgia, cursive;
  font-size: 12.5px;
  white-space: nowrap;
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 218, .55),
    0 3px 4px rgba(0, 0, 0, .35);
  z-index: 3;
}
.thread-reader__pulltag::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -18px;
  width: 1px;
  height: 18px;
  background: repeating-linear-gradient(0deg, #6e431d 0 3px, transparent 3px 5px);
}

/* ── Loading / error states ─────────────────────────────────────── */
.thread-reader__status {
  margin: 8px 14px;
  padding: 32px 24px;
  background: linear-gradient(#fff5d9, #f0d496);
  border: 2px dashed var(--paper-edge);
  border-radius: 5px;
  font-family: "Kalam", "Special Elite", Georgia, cursive;
  font-size: 16px;
  text-align: center;
  color: #4b2c16;
}
.thread-reader__status .spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-right: 10px;
  vertical-align: middle;
  border-radius: 50%;
  border: 3px solid rgba(155, 88, 36, .25);
  border-top-color: var(--apple);
  animation: aj-spin 1s linear infinite;
}
@keyframes aj-spin { to { transform: rotate(360deg); } }

/* ── Post stream ────────────────────────────────────────────────── */
.thread-reader__stream {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 0 14px 12px;
  position: relative;
}

/* tiny apple bullet between posts */
.thread-reader__stream::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: repeating-linear-gradient(0deg, rgba(255, 232, 178, .14) 0 4px, transparent 4px 10px);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Post card ──────────────────────────────────────────────────── */
.aj-post {
  --tilt: 0deg;
  position: relative;
  z-index: 1;
  align-self: flex-start;
  width: min(820px, 100%);
  padding: 14px 18px 16px;
  background:
    radial-gradient(circle at 12% 18%, rgba(127, 80, 31, .07) 0 1.5px, transparent 2px),
    radial-gradient(circle at 86% 76%, rgba(127, 80, 31, .07) 0 1.5px, transparent 2px),
    linear-gradient(#fff5d9, #f7e7bd);
  border: 2px solid var(--paper-edge);
  border-radius: 4px;
  box-shadow:
    inset 0 0 0 2px rgba(255, 248, 222, .72),
    inset 0 0 0 4px rgba(182, 112, 43, .15),
    0 3px 0 rgba(73, 42, 13, .2),
    0 6px 14px rgba(36, 20, 8, .32);
  scroll-margin-top: 24px;
  transition: box-shadow .25s ease;
}

.aj-post::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px dashed rgba(165, 99, 37, .55);
  border-radius: 2px;
  pointer-events: none;
}

.aj-post + .aj-post { margin-top: 0; }

.aj-post:nth-of-type(even) { --tilt: .35deg; align-self: flex-end; }
.aj-post:nth-of-type(odd)  { --tilt: -.35deg; }

.aj-post:hover {
  box-shadow:
    inset 0 0 0 2px rgba(255, 248, 222, .82),
    inset 0 0 0 4px rgba(182, 112, 43, .22),
    0 4px 0 rgba(73, 42, 13, .22),
    0 12px 22px rgba(36, 20, 8, .42);
}

/* highlighted via quotelink jump */
.aj-post.is-jumped {
  animation: aj-post-flash 1.6s ease-out 1;
}
@keyframes aj-post-flash {
  0%   { box-shadow: 0 0 0 0 rgba(217, 109, 53, 0), inset 0 0 0 2px rgba(255, 248, 222, .72), 0 6px 14px rgba(36, 20, 8, .32); }
  20%  { box-shadow: 0 0 0 6px rgba(217, 109, 53, .55), inset 0 0 0 2px rgba(255, 248, 222, .9), 0 0 22px rgba(255, 178, 90, .65); }
  100% { box-shadow: 0 0 0 0 rgba(217, 109, 53, 0), inset 0 0 0 2px rgba(255, 248, 222, .72), 0 6px 14px rgba(36, 20, 8, .32); }
}

/* tack at top of each post — colour rotates by hash for variety */
.aj-post__tack {
  position: absolute;
  top: -8px;
  left: 22px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, var(--tack-glint, #ff8a6c) 0 26%, var(--tack-head, #c83434) 72%);
  border: 1px solid rgba(0, 0, 0, .45);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .4);
  z-index: 3;
}
.aj-post__tack::after {
  content: "";
  position: absolute;
  top: 60%;
  left: 50%;
  width: 2px;
  height: 5px;
  background: rgba(0, 0, 0, .55);
  transform: translateX(-50%);
  border-radius: 1px;
}

/* OP variant ── wider, brassier, "wanted poster" vibe */
.aj-post--op {
  --tilt: 0deg;
  width: min(960px, 100%);
  align-self: center;
  padding: 22px 26px 22px;
  background:
    radial-gradient(circle at 8% 6%, rgba(167, 54, 32, .08) 0 4px, transparent 5px),
    radial-gradient(circle at 92% 92%, rgba(113, 137, 61, .08) 0 4px, transparent 5px),
    linear-gradient(#fff7df, #f0d28e);
  border: 3px solid #7c481f;
  border-top-color: #d19a4e;
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 2px rgba(255, 250, 226, .8),
    inset 0 0 0 5px rgba(165, 99, 37, .28),
    0 4px 0 rgba(73, 42, 13, .25),
    0 14px 28px rgba(36, 20, 8, .42);
}
.aj-post--op::after { inset: 8px; border-color: rgba(165, 99, 37, .65); }

.aj-post--op:hover {
  box-shadow:
    inset 0 0 0 2px rgba(255, 250, 226, .9),
    inset 0 0 0 5px rgba(165, 99, 37, .34),
    0 5px 0 rgba(73, 42, 13, .25),
    0 16px 32px rgba(36, 20, 8, .46);
}

.aj-post--media-only {
  width: min(420px, 100%);
  max-width: min(420px, 100%);
}

.aj-post--media-only .aj-post__body {
  display: block;
}

.aj-post--media-only .aj-media-frame {
  float: none;
  margin: 0;
  width: min(var(--media-w, 320px), 320px, 100%);
}

/* OP plaque */
.aj-post__op-plaque {
  position: absolute;
  top: -18px;
  right: 18px;
  padding: 6px 14px 5px;
  color: #fff4d4;
  font-family: "Rye", Georgia, serif;
  font-size: 13px;
  letter-spacing: .14em;
  background: linear-gradient(#d96d35, #a13018);
  border: 2px solid #5b210f;
  border-radius: 4px;
  transform: rotate(4deg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 220, .35),
    0 3px 0 rgba(0, 0, 0, .32),
    0 0 16px rgba(255, 130, 60, .35);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  z-index: 3;
}

/* ── Post header ───────────────────────────────────────────────── */
.aj-post__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px dashed rgba(133, 84, 33, .55);
  font-family: "IM Fell English SC", Georgia, serif;
  font-size: 13px;
}

.aj-post__name {
  font-family: "IM Fell English SC", Georgia, serif;
  color: var(--leaf-dark);
  font-weight: 700;
  letter-spacing: .04em;
}
.aj-post__name--op { color: var(--apple); }

.aj-post__trip {
  font-family: "Special Elite", monospace;
  font-size: 12px;
  color: #6f4818;
  background: rgba(255, 235, 178, .55);
  padding: 1px 6px;
  border-radius: 2px;
  border: 1px dotted rgba(133, 84, 33, .35);
}

.aj-post__title {
  color: var(--apple);
  font-family: "Rye", Georgia, serif;
  font-size: 14px;
}

.aj-post__date {
  font-family: "Special Elite", Georgia, monospace;
  font-size: 12px;
  color: #6c4318;
}

/* the wax seal / stamp number */
.aj-post__num {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px 2px;
  color: var(--apple-bright);
  font-family: "Rye", Georgia, serif;
  font-size: 12px;
  letter-spacing: .04em;
  background:
    radial-gradient(ellipse at 30% 25%, rgba(255, 255, 255, .42), transparent 65%),
    linear-gradient(#fff4d4, #f2d486);
  border: 1.5px solid var(--apple);
  border-radius: 3px;
  transform: rotate(-3deg);
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 222, .65),
    0 2px 0 rgba(0, 0, 0, .12);
  text-decoration: none;
  text-shadow: 0 1px 0 #fff2c7;
  cursor: copy;
}
.aj-post__num:hover {
  background: linear-gradient(#fff8e0, #f4d68a);
  color: var(--aj-quote-deep);
}
.aj-post__num--op {
  background: linear-gradient(#fff4d4, #ffd07b);
  border-color: #a13018;
  color: #a13018;
  font-size: 13px;
  transform: rotate(-5deg);
}

.aj-post__country {
  font-size: 12px;
  color: #6c4318;
}

/* ── Post body ─────────────────────────────────────────────────── */
.aj-post__body {
  font-family: "Caudex", "IM Fell English", Georgia, serif;
  font-size: 15.5px;
  line-height: 1.48;
  color: var(--ink);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.aj-post__body::after {
  content: "";
  display: block;
  clear: both;
}

.aj-post__body p { margin: 0; }

.aj-greentext {
  color: var(--aj-green);
  font-family: "Special Elite", "Caudex", Georgia, monospace;
  font-style: italic;
  text-shadow: 0 1px 0 rgba(255, 250, 226, .65);
}

.aj-link {
  color: var(--aj-quote);
  text-decoration: underline dotted rgba(159, 50, 31, .55);
  text-underline-offset: 2px;
  word-break: break-all;
}
.aj-link:hover { color: var(--aj-quote-deep); background: rgba(217, 109, 53, .08); }

/* Quotelinks — small inked stamps */
.aj-quotelink {
  display: inline-block;
  padding: 0 5px 1px;
  margin: 0 1px;
  color: var(--aj-quote);
  font-family: "Special Elite", monospace;
  font-size: .92em;
  letter-spacing: .02em;
  text-decoration: none;
  border: 1px dashed rgba(159, 50, 31, .55);
  border-radius: 2px;
  background: rgba(255, 244, 212, .5);
  transition: background .12s ease, color .12s ease, transform .12s ease;
  cursor: pointer;
}
.aj-quotelink:hover {
  color: #fff4d4;
  background: var(--aj-quote);
  border-color: var(--aj-quote-deep);
  transform: translateY(-1px);
}
.aj-quotelink--dead {
  opacity: .8;
  color: #7b4f1a;
  border-style: dotted;
  background: repeating-linear-gradient(45deg, rgba(133, 84, 33, .08) 0 4px, transparent 4px 8px);
}
.aj-quotelink--cross { color: var(--leaf-dark); border-color: var(--leaf-dark); }
.aj-quotelink--cross:hover { background: var(--leaf-dark); color: #fff4d4; }

/* OP backlink (a quotelink in the OP referencing nothing or pointing back) */
.aj-quotelink--op-marker::after {
  content: " (OP)";
  font-size: .82em;
  color: var(--apple);
}

/* ── Media ─────────────────────────────────────────────────────── */
.aj-media-frame {
  display: block;
  position: relative;
  float: left;
  box-sizing: border-box;
  width: min(var(--media-w, 320px), 320px, 100%);
  margin: 4px 16px 10px 0;
  padding: 8px 8px 30px;
  background: #fffaf0;
  border: 1px solid #bda36d;
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, .08),
    0 8px 12px rgba(0, 0, 0, .28),
    inset 0 0 0 1px rgba(0, 0, 0, .04);
  transform: rotate(-1.5deg);
  text-decoration: none;
  color: inherit;
  transition: transform .2s ease, box-shadow .2s ease;
  cursor: zoom-in;
  max-width: 100%;
}

.aj-post:nth-of-type(odd) .aj-media-frame { transform: rotate(1deg); }
.aj-post:nth-of-type(3n) .aj-media-frame  { transform: rotate(-.5deg); }

.aj-media-frame:hover {
  transform: rotate(0deg) translateY(-2px);
  box-shadow:
    0 2px 0 rgba(0, 0, 0, .1),
    0 14px 22px rgba(0, 0, 0, .32);
}

.aj-media-frame::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 26px;
  height: 11px;
  background: linear-gradient(rgba(255, 243, 180, .8), rgba(255, 222, 140, .55));
  border-left: 1px dashed rgba(0, 0, 0, .06);
  border-right: 1px dashed rgba(0, 0, 0, .06);
  transform: translateX(-50%) rotate(-3deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
  pointer-events: none;
}

.aj-media-frame img,
.aj-media-frame video {
  display: block;
  width: 100%;
  height: auto;
  background: #f0e2c4;
  border-radius: 1px;
}

.aj-media-frame.is-expanded {
  cursor: zoom-out;
  float: none;
  width: auto;
  max-width: 100%;
}
.aj-media-frame.is-expanded img {
  width: auto;
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.aj-media-frame__caption {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 7px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  font-family: "Kalam", "Special Elite", Georgia, cursive;
  font-size: 11px;
  color: #5b3f15;
  pointer-events: none;
}
.aj-media-frame__caption .dims { color: #9e6329; font-size: 10.5px; }

/* OP cert stamp on the OP image */
.aj-media-frame--op::after {
  content: "Sweet Apple Acres ★ Certified";
  position: absolute;
  top: 14px;
  right: -18px;
  padding: 4px 10px 3px;
  color: #fff4d4;
  font-family: "Rye", Georgia, serif;
  font-size: 9.5px;
  letter-spacing: .12em;
  background: linear-gradient(#d96d35, #a13018);
  border: 1.5px solid #5b210f;
  border-radius: 2px;
  transform: rotate(12deg);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .35);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  pointer-events: none;
  z-index: 2;
}

/* Spoiler covering */
.aj-media-frame--spoiler:not(.is-revealed) img {
  filter: blur(18px) saturate(.7);
  transform: scale(1.04);
}
.aj-media-frame--spoiler:not(.is-revealed)::before {
  content: "Spoiler — click to reveal";
  position: absolute;
  inset: 8px 8px 30px;
  display: grid;
  place-items: center;
  font-family: "Rye", Georgia, serif;
  font-size: 13px;
  letter-spacing: .12em;
  color: #fff4d4;
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .35) 0 6px, rgba(0, 0, 0, .55) 6px 12px),
    linear-gradient(rgba(64, 38, 16, .85), rgba(43, 25, 11, .9));
  text-shadow: 0 1px 0 rgba(0, 0, 0, .5);
  z-index: 1;
  border-radius: 1px;
  pointer-events: none;
}

/* ── Backlinks footer ──────────────────────────────────────────── */
.aj-post__backlinks {
  clear: both;
  margin-top: 14px;
  padding: 6px 0 0;
  border-top: 1px dashed rgba(133, 84, 33, .35);
  font-family: "IM Fell English SC", Georgia, serif;
  font-size: 12.5px;
  color: #6c4318;
}
.aj-post__backlinks-label {
  color: var(--leaf-dark);
  font-family: "Rye", Georgia, serif;
  font-size: 11px;
  letter-spacing: .08em;
  margin-right: 6px;
}
.aj-post__backlinks .aj-quotelink {
  margin-right: 4px;
  margin-top: 4px;
}

/* ── Quote preview tooltip ─────────────────────────────────────── */
.aj-quote-preview {
  position: fixed;
  z-index: 220;
  width: min(540px, 70vw);
  max-height: min(70vh, 560px);
  overflow: auto;
  padding: 10px 14px 10px;
  background: linear-gradient(#fff5d9, #f5dca0);
  border: 2px solid var(--paper-edge);
  border-radius: 4px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 222, .75),
    0 8px 22px rgba(36, 20, 8, .5);
  font-family: "Caudex", Georgia, serif;
  font-size: 14px;
  color: var(--ink);
  pointer-events: none;
  transform-origin: top left;
  animation: aj-preview-pop .14s ease-out;
  scrollbar-width: thin;
  scrollbar-color: #b0703d #f5dca0;
}
@keyframes aj-preview-pop {
  from { opacity: 0; transform: scale(.96) translateY(-3px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.aj-quote-preview .aj-post__head {
  margin-bottom: 6px;
  padding-bottom: 4px;
  font-size: 11.5px;
}
.aj-quote-preview .aj-post__body { font-size: 13.5px; line-height: 1.42; }
.aj-quote-preview .aj-media-frame { max-width: 110px; transform: rotate(-2deg); }

/* ── Float-back saddle ─────────────────────────────────────────── */
.thread-reader__saddle {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}
.thread-reader__saddle button {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #5b210f;
  background:
    radial-gradient(circle at 35% 28%, #ffd99a 0 18%, transparent 38%),
    linear-gradient(#d96d35, #a13018);
  color: #fff4d4;
  font-family: "Rye", Georgia, serif;
  font-size: 18px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 230, .35),
    0 4px 0 rgba(0, 0, 0, .35),
    0 8px 18px rgba(36, 20, 8, .4);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  transition: transform .15s ease, filter .15s ease;
}
.thread-reader__saddle button:hover,
.thread-reader__saddle button:focus-visible {
  filter: brightness(1.08);
  transform: translateY(-2px);
  outline: none;
}
.thread-reader__saddle button[hidden] { display: none; }

/* ── Stream end card ───────────────────────────────────────────── */
.thread-reader__end {
  align-self: center;
  margin-top: 18px;
  padding: 12px 22px;
  color: #5b3f15;
  font-family: "Kalam", "Special Elite", Georgia, cursive;
  font-size: 14px;
  background: linear-gradient(#fff5d9, #ecc878);
  border: 2px dashed #8a4f1c;
  border-radius: 4px;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255, 248, 222, .6);
}
.thread-reader__end::before { content: "🍎  "; }
.thread-reader__end::after { content: "  🍎"; }

/* ── Floating "scroll origin" ribbon — appears when scrolled ───── */
.thread-reader__ribbon {
  position: sticky;
  top: 4px;
  z-index: 5;
  display: flex;
  justify-content: center;
  margin: -10px 0 14px;
  font-family: "Rye", Georgia, serif;
  font-size: 11px;
  letter-spacing: .12em;
  pointer-events: none;
}
.thread-reader__ribbon span {
  padding: 4px 14px 4px;
  background: linear-gradient(#fff4d4, #ecc878);
  border: 1.5px solid #6b3a17;
  border-radius: 3px;
  color: #5a3013;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  pointer-events: auto;
}

/* ── Hide the archive list when reader is open ─────────────────── */
.app-view--threads.reader-open .archive-shell__board > :not(.thread-reader),
.app-view--threads.reader-open .archive-shell__head,
.app-view--threads.reader-open .archive-stats,
.app-view--threads.reader-open .archive-banner {
  display: none;
}

/* When reader is open, browser title bar gets a slim breadcrumb */
.app-view--threads.reader-open .archive-shell__board {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

/* ── Reduced motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .aj-post,
  .aj-media-frame,
  .thread-reader__back,
  .thread-reader__saddle button {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
}

/* ── Narrow fallback (still ≥1220 due to body min-width) ────────── */
@media (max-width: 1100px) {
  .thread-reader { padding: 16px 14px 22px; }
  .aj-post { width: 100%; }
  .aj-post--op { width: 100%; }
  .aj-media-frame {
    float: none;
    margin: 0 0 12px;
    max-width: 260px;
  }
}
