/*
 * Blacktooth Grin: Recovered Chronicles
 * A dependency-free, offline-friendly reading theme.
 */

/* ---------- Design tokens ---------- */

:root {
  color-scheme: dark;
  --ink: #eee7d6;
  --ink-muted: #bdb4a2;
  --ink-faint: #8f8779;
  --canvas: #151311;
  --canvas-deep: #0d0c0b;
  --surface: #211e1a;
  --surface-raised: #2a2520;
  --surface-inset: #181512;
  --parchment: #d8c8a5;
  --parchment-ink: #282018;
  --rule: #514638;
  --rule-soft: rgb(185 157 111 / 20%);
  --crimson: #b8403b;
  --crimson-strong: #d45149;
  --crimson-deep: #661f1f;
  --brass: #c9a45f;
  --brass-bright: #edc87d;
  --brass-dim: #846a3d;
  --blue: #86b6c3;
  --speech: #e1e9e7;
  --green: #8fb78b;
  --warning: #efbd65;
  --danger: #ef756e;
  --focus: #f4cf83;
  --shadow-color: rgb(0 0 0 / 42%);
  --shadow-sm: 0 2px 7px var(--shadow-color);
  --shadow-md: 0 12px 32px var(--shadow-color);
  --radius-sm: 0.3rem;
  --radius: 0.55rem;
  --radius-lg: 0.9rem;
  --font-display: Georgia, "Times New Roman", serif;
  --font-prose: Georgia, Cambria, "Times New Roman", serif;
  --font-ui: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
  --reader-font-size: 19px;
  --reader-line-height: 1.72;
  --reader-width: 48rem;
  --page-width: 76rem;
  --header-height: 4rem;
  --motion-fast: 140ms;
  --motion: 240ms;
  --author-1: #e0a862;
  --author-2: #d87871;
  --author-3: #82b7c2;
  --author-4: #96bb81;
  --author-5: #c898d4;
  --author-6: #dfbe72;
  --author-7: #8ca8dc;
  --author-8: #d59368;
  --author-9: #75b9a4;
  --author-10: #c5a6a0;
  --author-11: #abc36f;
  --author-12: #cf8da8;
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink: #2e261e;
  --ink-muted: #65594b;
  --ink-faint: #817362;
  --canvas: #e8deca;
  --canvas-deep: #d7c8ac;
  --surface: #f4ead7;
  --surface-raised: #fff8e9;
  --surface-inset: #dfd1b9;
  --parchment: #f2e4c7;
  --parchment-ink: #2b2119;
  --rule: #9f8767;
  --rule-soft: rgb(93 64 35 / 18%);
  --crimson: #8e2e2c;
  --crimson-strong: #a73632;
  --crimson-deep: #5b1c1b;
  --brass: #73551e;
  --brass-bright: #8c6925;
  --brass-dim: #9b7c45;
  --blue: #28687a;
  --speech: #263a3a;
  --green: #3e7146;
  --warning: #85570c;
  --danger: #9e2f2c;
  --focus: #8e2e2c;
  --shadow-color: rgb(55 37 18 / 22%);
  --author-1: #825211;
  --author-2: #9b3d38;
  --author-3: #246679;
  --author-4: #47732f;
  --author-5: #79438a;
  --author-6: #745916;
  --author-7: #3c5e9a;
  --author-8: #8d461f;
  --author-9: #276c58;
  --author-10: #7b4d44;
  --author-11: #55701f;
  --author-12: #8b3c61;
}

/* ---------- Reset and foundations ---------- */

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

html {
  min-width: 18rem;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1.5rem);
  background: var(--canvas-deep);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.5;
  background-color: var(--canvas);
  background-image:
    linear-gradient(90deg, rgb(255 255 255 / 1.2%) 1px, transparent 1px),
    linear-gradient(rgb(255 255 255 / 0.8%) 1px, transparent 1px),
    radial-gradient(circle at 12% 5%, rgb(184 64 59 / 11%), transparent 27rem),
    radial-gradient(circle at 88% 26%, rgb(201 164 95 / 7%), transparent 30rem),
    linear-gradient(145deg, transparent 0 42%, rgb(0 0 0 / 4%) 42% 43%, transparent 43% 100%);
  background-size: 19px 19px, 23px 23px, auto, auto, auto;
  accent-color: var(--crimson-strong);
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(to bottom, rgb(0 0 0 / 22%), transparent 8rem),
    repeating-linear-gradient(108deg, transparent 0 55px, rgb(201 164 95 / 1.8%) 56px, transparent 57px 89px);
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  max-width: 100%;
  color: inherit;
  font: inherit;
}

button,
select,
label[for],
input[type="checkbox"],
input[type="range"] {
  cursor: pointer;
}

a {
  color: var(--brass-bright);
  text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

::selection {
  color: #fff8e9;
  background: var(--crimson-deep);
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  color: #231a11;
  font-weight: 800;
  text-decoration: none;
  background: var(--brass-bright);
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
  transition: transform var(--motion-fast) ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.container,
.page-shell {
  width: min(calc(100% - 2rem), var(--page-width));
  margin-inline: auto;
}

.flow > * + * {
  margin-block-start: var(--flow-space, 1rem);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cluster-gap, 0.65rem);
  align-items: center;
}

/* ---------- Header, navigation, and footer ---------- */

.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  min-height: var(--header-height);
  background:
    linear-gradient(to bottom, rgb(255 255 255 / 3%), transparent),
    color-mix(in srgb, var(--canvas-deep) 93%, transparent);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 5px 24px rgb(0 0 0 / 25%);
  backdrop-filter: blur(12px);
}

.site-header__inner {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  width: min(calc(100% - 2rem), var(--page-width));
  min-height: var(--header-height);
  margin-inline: auto;
}

.site-brand {
  display: inline-flex;
  flex: 0 1 auto;
  gap: 0.7rem;
  align-items: center;
  min-width: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1rem, 3vw, 1.35rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.015em;
  text-decoration: none;
}

.site-brand::before {
  display: grid;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  color: var(--brass-bright);
  font-family: var(--font-ui);
  font-size: 1rem;
  content: "BTG";
  place-items: center;
  background: var(--crimson-deep);
  border: 1px solid var(--brass-dim);
  border-radius: 50% 44% 50% 43%;
  box-shadow: inset 0 0 0 3px rgb(0 0 0 / 24%);
  transform: rotate(-3deg);
}

.site-brand:hover {
  color: var(--brass-bright);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  align-items: center;
  justify-content: flex-end;
}

.site-nav a,
.site-nav button {
  display: inline-flex;
  min-height: 2.5rem;
  padding: 0.48rem 0.7rem;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
}

.site-nav a:hover,
.site-nav a[aria-current="page"],
.site-nav button:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--rule-soft);
}

.site-main {
  min-height: calc(100vh - 12rem);
  padding-block: clamp(1.5rem, 4vw, 3.5rem) 5rem;
}

.site-footer {
  padding-block: 2rem 3rem;
  color: var(--ink-muted);
  font-size: 0.88rem;
  text-align: center;
  background: color-mix(in srgb, var(--canvas-deep) 85%, transparent);
  border-top: 1px solid var(--rule-soft);
}

.site-footer a {
  color: var(--brass-bright);
}

.reading-progress {
  position: fixed;
  z-index: 80;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  pointer-events: none;
  background: linear-gradient(90deg, var(--crimson-strong), var(--brass-bright));
  box-shadow: 0 0 10px rgb(201 164 95 / 50%);
  transition: width 60ms linear;
}

/* ---------- Page headings and hero ---------- */

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--brass-bright);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.page-title,
.thread-title,
.hero__title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.08;
  text-wrap: balance;
}

.page-title {
  font-size: clamp(2rem, 7vw, 4rem);
}

.thread-title {
  max-width: 20ch;
  font-size: clamp(2rem, 6vw, 4.25rem);
}

.hero {
  position: relative;
  display: grid;
  min-height: min(35rem, 72vh);
  padding: clamp(2rem, 7vw, 5.5rem);
  overflow: hidden;
  place-items: center start;
  background:
    linear-gradient(105deg, color-mix(in srgb, var(--surface) 96%, transparent), color-mix(in srgb, var(--surface) 56%, transparent)),
    repeating-linear-gradient(116deg, transparent 0 28px, var(--rule-soft) 29px, transparent 30px 61px);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 0 7rem rgb(0 0 0 / 24%);
}

.hero::before,
.hero::after {
  position: absolute;
  pointer-events: none;
  content: "";
}

.hero::before {
  top: -5rem;
  right: -5rem;
  width: min(45vw, 28rem);
  aspect-ratio: 1;
  opacity: 0.45;
  background:
    radial-gradient(circle, transparent 29%, var(--crimson-deep) 30% 32%, transparent 33%),
    conic-gradient(from 10deg, transparent 0 10%, var(--crimson-deep) 10% 14%, transparent 14% 24%, var(--crimson-deep) 24% 28%, transparent 28% 100%);
  border: 2px solid var(--crimson-deep);
  border-radius: 49% 47% 45% 52%;
  transform: rotate(-17deg);
}

.hero::after {
  inset: 0;
  border: 0.45rem double rgb(201 164 95 / 13%);
  border-radius: inherit;
}

.hero__content {
  position: relative;
  z-index: 1;
  max-width: 48rem;
}

.hero__title {
  max-width: 13ch;
  font-size: clamp(2.5rem, 8vw, 6rem);
  text-shadow: 0 3px 0 var(--canvas-deep);
}

.hero__lede,
.page-lede,
.thread-summary {
  max-width: 66ch;
  color: var(--ink-muted);
  font-family: var(--font-prose);
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  line-height: 1.65;
}

.section-heading {
  display: flex;
  gap: 1rem;
  align-items: end;
  justify-content: space-between;
  margin-block: 3rem 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--rule);
}

.section-heading h2,
.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.35rem);
  line-height: 1.15;
}

/* ---------- Buttons, form controls, and chips ---------- */

.button,
.icon-button,
.filter-button,
.reader-tools button,
.disclosure-button {
  display: inline-flex;
  min-height: 2.6rem;
  gap: 0.45rem;
  padding: 0.52rem 0.85rem;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.1;
  text-decoration: none;
  background: linear-gradient(to bottom, var(--surface-raised), var(--surface));
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 rgb(255 255 255 / 5%);
  transition:
    color var(--motion-fast) ease,
    border-color var(--motion-fast) ease,
    transform var(--motion-fast) ease;
}

.button:hover,
.icon-button:hover,
.filter-button:hover,
.reader-tools button:hover,
.disclosure-button:hover {
  color: var(--brass-bright);
  border-color: var(--brass-dim);
  transform: translateY(-1px);
}

.button--primary {
  color: #fff7e5;
  background: linear-gradient(to bottom, var(--crimson-strong), var(--crimson-deep));
  border-color: color-mix(in srgb, var(--crimson-strong) 60%, var(--brass));
}

.button--quiet {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.icon-button {
  width: 2.65rem;
  padding: 0;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field > label,
.filter-label {
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input[type="search"],
input[type="text"],
select {
  width: 100%;
  min-height: 2.7rem;
  padding: 0.5rem 0.72rem;
  color: var(--ink);
  background: var(--surface-inset);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 5px rgb(0 0 0 / 16%);
}

input[type="search"]::placeholder,
input[type="text"]::placeholder {
  color: var(--ink-faint);
  opacity: 1;
}

input[type="search"]:focus,
input[type="text"]:focus,
select:focus {
  border-color: var(--brass-bright);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--crimson-strong);
}

.check-control {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  min-height: 2.4rem;
  color: var(--ink-muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.check-control input {
  width: 1.1rem;
  height: 1.1rem;
}

.badge,
.chip,
.tag,
.author-badge {
  display: inline-flex;
  width: fit-content;
  min-height: 1.65rem;
  gap: 0.32rem;
  padding: 0.2rem 0.55rem;
  align-items: center;
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.055em;
  text-decoration: none;
  text-transform: uppercase;
  background: var(--surface-inset);
  border: 1px solid var(--rule-soft);
  border-radius: 999px;
}

.badge--story,
[data-thread-type="story"] .type-badge {
  color: var(--brass-bright);
  border-color: var(--brass-dim);
}

.badge--mixed,
[data-thread-type="mixed"] .type-badge,
[data-thread-type="mixed-roleplay"] .type-badge {
  color: var(--green);
}

.badge--ooc,
[data-thread-type="planning"] .type-badge,
[data-thread-type="planning-ooc"] .type-badge {
  color: var(--blue);
}

.badge--reference,
[data-thread-type="reference"] .type-badge {
  color: var(--ink-muted);
}

.badge--chat,
[data-thread-type="chat"] .type-badge,
[data-thread-type="chat-transcript"] .type-badge {
  color: #c39ad6;
}

.badge--warning {
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 40%, transparent);
}

.author-badge {
  color: var(--author-color, var(--brass-bright));
  text-transform: none;
  background: color-mix(in srgb, var(--author-color, var(--brass)) 9%, var(--surface-inset));
  border-color: color-mix(in srgb, var(--author-color, var(--brass)) 42%, var(--rule));
}

/* ---------- Search and archive filters ---------- */

.search-panel,
.filter-panel,
.reader-tools {
  padding: 1rem;
  background:
    linear-gradient(to bottom right, rgb(255 255 255 / 2.5%), transparent 45%),
    var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.search-panel {
  position: relative;
  max-width: 52rem;
}

.search-field {
  position: relative;
}

.search-field input {
  min-height: 3.2rem;
  padding-inline: 1rem 3.5rem;
  font-size: 1rem;
}

.search-shortcut {
  position: absolute;
  top: 50%;
  right: 0.65rem;
  padding: 0.15rem 0.38rem;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: 0.25rem;
  transform: translateY(-50%);
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(12rem, 2fr) repeat(4, minmax(8rem, 1fr)) auto;
  gap: 0.8rem;
  align-items: end;
  margin-block: 1.5rem;
}

.filter-summary {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  min-height: 2rem;
  margin-block: 0.7rem;
  color: var(--ink-muted);
  font-size: 0.84rem;
}

.filter-summary strong {
  color: var(--ink);
}

.search-results {
  display: grid;
  gap: 0.55rem;
  margin: 0.7rem 0 0;
  padding: 0;
  list-style: none;
}

.search-results:empty {
  display: none;
}

.search-result {
  display: block;
  padding: 0.8rem 0.9rem;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface-inset);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.search-result:hover,
.search-result:focus-visible {
  color: var(--ink);
  border-color: var(--brass-dim);
}

.search-result__title {
  display: block;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.search-result__meta,
.search-result__excerpt {
  display: block;
  margin-top: 0.22rem;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.search-result__excerpt {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.empty-state {
  padding: clamp(1.5rem, 5vw, 3.5rem);
  color: var(--ink-muted);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
}

/* ---------- Thread and collection cards ---------- */

.thread-grid,
.collection-grid,
.author-grid,
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 1rem;
}

.thread-card,
.collection-card,
.author-card,
.stat-card {
  position: relative;
  min-width: 0;
  padding: 1.1rem;
  background:
    linear-gradient(145deg, rgb(255 255 255 / 2.5%), transparent 42%),
    var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease,
    transform var(--motion-fast) ease;
}

.thread-card::before,
.collection-card::before {
  position: absolute;
  top: -1px;
  right: 0.85rem;
  left: 0.85rem;
  height: 2px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--card-accent, var(--crimson)), transparent);
  opacity: 0.62;
}

.thread-card:hover,
.thread-card:focus-within,
.collection-card:hover,
.collection-card:focus-within,
.author-card:hover,
.author-card:focus-within {
  border-color: var(--brass-dim);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.thread-card__title,
.collection-card__title,
.author-card__title {
  margin: 0.65rem 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.2;
}

.thread-card__title a,
.collection-card__title a,
.author-card__title a {
  color: var(--ink);
  text-decoration: none;
}

.thread-card__title a::after,
.collection-card__title a::after,
.author-card__title a::after {
  position: absolute;
  inset: 0;
  content: "";
}

.thread-card__summary,
.collection-card__summary {
  display: -webkit-box;
  min-height: 4.25em;
  margin: 0;
  overflow: hidden;
  color: var(--ink-muted);
  font-family: var(--font-prose);
  font-size: 0.94rem;
  line-height: 1.48;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.thread-card__meta,
.collection-card__meta,
.author-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin-top: 0.9rem;
  color: var(--ink-faint);
  font-size: 0.72rem;
}

.thread-card__meta > span,
.collection-card__meta > span,
.author-card__meta > span {
  position: relative;
}

.thread-card__meta > span + span::before,
.collection-card__meta > span + span::before,
.author-card__meta > span + span::before {
  position: absolute;
  left: -0.47rem;
  color: var(--rule);
  content: "\2022";
}

.thread-card__tags {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.8rem;
  pointer-events: none;
}

.thread-card[data-thread-type="story"] {
  --card-accent: var(--brass);
}

.thread-card[data-thread-type="planning"],
.thread-card[data-thread-type="planning-ooc"] {
  --card-accent: var(--blue);
}

.thread-card[data-thread-type="chat"],
.thread-card[data-thread-type="chat-transcript"] {
  --card-accent: #9b6eb3;
}

.stat-card {
  text-align: center;
}

.stat-card__value {
  display: block;
  color: var(--brass-bright);
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 700;
}

.stat-card__label {
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Chronology ---------- */

.timeline {
  position: relative;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}

.timeline::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 6.7rem;
  width: 1px;
  content: "";
  background: var(--rule);
}

.timeline__item {
  display: grid;
  grid-template-columns: 5.8rem 1fr;
  gap: 1.8rem;
  padding-block: 0.65rem;
}

.timeline__date {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-align: right;
}

.timeline__content {
  position: relative;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.timeline__content::before {
  position: absolute;
  top: 1rem;
  left: -2.19rem;
  width: 0.72rem;
  height: 0.72rem;
  content: "";
  background: var(--crimson);
  border: 2px solid var(--canvas);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--brass-dim);
}

/* ---------- Thread header, layout, and reader tools ---------- */

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin: 0 0 1.2rem;
  padding: 0;
  color: var(--ink-faint);
  font-size: 0.77rem;
  list-style: none;
}

.breadcrumbs li + li::before {
  margin-right: 0.38rem;
  color: var(--rule);
  content: "/";
}

.breadcrumbs a {
  color: var(--ink-muted);
}

.thread-header {
  max-width: 62rem;
  padding-block: clamp(1rem, 3vw, 2.5rem) 2rem;
}

.thread-header__meta,
.thread-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  align-items: center;
  margin-block: 1rem;
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.thread-layout {
  display: grid;
  grid-template-columns: minmax(0, var(--reader-width)) minmax(12rem, 16rem);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: start;
  justify-content: center;
}

.thread-content {
  min-width: 0;
}

.thread-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 1rem);
  display: grid;
  gap: 1rem;
  max-height: calc(100vh - var(--header-height) - 2rem);
  overflow-y: auto;
  scrollbar-width: thin;
}

.thread-toc,
.archive-note {
  padding: 0.9rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.thread-toc h2,
.thread-toc h3,
.archive-note h2,
.archive-note h3 {
  margin: 0 0 0.65rem;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.thread-toc ol,
.thread-toc ul {
  display: grid;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.thread-toc a {
  display: block;
  padding: 0.28rem 0.4rem;
  overflow: hidden;
  color: var(--ink-muted);
  text-decoration: none;
  white-space: nowrap;
  text-overflow: ellipsis;
  border-left: 2px solid transparent;
}

.thread-toc a:hover,
.thread-toc a[aria-current="location"],
.thread-toc a.is-active {
  color: var(--brass-bright);
  background: var(--surface-inset);
  border-left-color: var(--crimson-strong);
}

.reader-tools {
  display: grid;
  gap: 0.75rem;
  font-size: 0.78rem;
}

.reader-tools__heading {
  margin: 0;
  color: var(--ink);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.reader-tools__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: center;
}

.reader-tools__row label {
  color: var(--ink-muted);
}

.reader-tools output {
  min-width: 3.2rem;
  color: var(--brass-bright);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-align: right;
}

.reader-tools select {
  min-height: 2.3rem;
  font-size: 0.78rem;
}

/* ---------- Posts and recovered prose ---------- */

.post-list {
  display: grid;
  gap: clamp(1.1rem, 3vw, 2rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.post {
  --post-accent: var(--author-color, var(--brass));
  position: relative;
  min-width: 0;
  overflow: clip;
  background:
    linear-gradient(125deg, color-mix(in srgb, var(--post-accent) 5%, transparent), transparent 30%),
    var(--surface);
  border: 1px solid var(--rule);
  border-top: 2px solid color-mix(in srgb, var(--post-accent) 72%, var(--rule));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.post:target {
  border-color: var(--brass-bright);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass-bright) 20%, transparent), var(--shadow-md);
}

.post__header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  justify-content: space-between;
  min-height: 3.3rem;
  padding: 0.72rem clamp(0.9rem, 3vw, 1.4rem);
  background: color-mix(in srgb, var(--surface-inset) 78%, transparent);
  border-bottom: 1px solid var(--rule-soft);
}

.post__identity {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.post__author {
  color: var(--post-accent);
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
}

.post__number,
.post__date,
.post__permalink {
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: 0.72rem;
}

.post__permalink {
  position: relative;
  z-index: 1;
  padding: 0.2rem 0.3rem;
  text-decoration: none;
  border-radius: 0.2rem;
}

.post__permalink:hover {
  color: var(--brass-bright);
  background: var(--surface);
}

.post__body {
  max-width: none;
  padding: clamp(1rem, 4vw, 2rem);
  color: var(--ink);
  font-family: var(--font-prose);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  overflow-wrap: anywhere;
}

.post__body > :first-child {
  margin-top: 0;
}

.post__body > :last-child {
  margin-bottom: 0;
}

.post__body p,
.post__body ul,
.post__body ol,
.post__body blockquote,
.post__body pre,
.post__body .ooc,
.post__body .missing-media,
.post__body .content-warning {
  margin-block: 0 1em;
}

.post__body hr {
  width: 60%;
  margin: 2em auto;
  border: 0;
  border-top: 1px solid var(--rule);
}

.post__body a {
  overflow-wrap: anywhere;
}

.post__body u {
  text-decoration-thickness: 1px;
  text-underline-offset: 0.14em;
}

.post__body code,
.post__body pre {
  font-family: var(--font-mono);
  font-size: 0.84em;
}

.post__body pre {
  padding: 1rem;
  overflow-x: auto;
  background: var(--surface-inset);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.post__body blockquote,
.bbcode-quote,
.quote {
  position: relative;
  padding: 1rem 1.1rem 1rem 1.35rem;
  color: var(--ink-muted);
  font-size: 0.94em;
  background: var(--surface-inset);
  border: 1px solid var(--rule-soft);
  border-left: 4px solid var(--brass-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.quote__attribution,
.bbcode-quote__author,
blockquote > cite:first-child {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--brass-bright);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bbcode-center,
.text-center {
  text-align: center;
}

.ooc,
.post--ooc .post__body {
  padding: 0.8rem 1rem;
  color: var(--blue);
  font-family: var(--font-ui);
  font-size: 0.86em;
  line-height: 1.55;
  background:
    repeating-linear-gradient(135deg, transparent 0 12px, color-mix(in srgb, var(--blue) 4%, transparent) 12px 13px),
    color-mix(in srgb, var(--blue) 6%, var(--surface-inset));
  border: 1px dashed color-mix(in srgb, var(--blue) 45%, var(--rule));
  border-radius: var(--radius-sm);
}

.ooc::before {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.67rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  content: "OUT OF CHARACTER";
}

.ooc-inline {
  padding: 0.08em 0.3em;
  color: var(--blue);
  font-family: var(--font-ui);
  font-size: 0.92em;
  background: color-mix(in srgb, var(--blue) 9%, var(--surface-inset));
  border: 1px dashed color-mix(in srgb, var(--blue) 45%, var(--rule));
  border-radius: 0.25em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.post--ooc .post__header {
  border-bottom-color: color-mix(in srgb, var(--blue) 35%, var(--rule));
}

:root[data-hide-ooc="true"] .ooc,
:root[data-hide-ooc="true"] .post--ooc,
:root[data-hide-ooc="true"] [data-ooc] {
  display: none !important;
}

.content-warning {
  padding: 0.85rem 1rem;
  color: var(--warning);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  background: color-mix(in srgb, var(--warning) 7%, var(--surface-inset));
  border: 1px solid color-mix(in srgb, var(--warning) 48%, var(--rule));
  border-radius: var(--radius-sm);
}

.content-warning strong:first-child {
  display: inline-block;
  margin-right: 0.3rem;
  letter-spacing: 0.04em;
}

.editorial-note {
  padding: 0.8rem 1rem;
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  background: color-mix(in srgb, var(--brass) 5%, var(--surface-inset));
  border-left: 3px solid var(--brass-dim);
}

.missing-media {
  display: grid;
  min-height: 9rem;
  padding: 1.2rem;
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  text-align: center;
  place-content: center;
  background:
    linear-gradient(45deg, transparent 48%, var(--rule-soft) 49% 51%, transparent 52%),
    linear-gradient(-45deg, transparent 48%, var(--rule-soft) 49% 51%, transparent 52%),
    var(--surface-inset);
  background-size: 30px 30px;
  border: 1px dashed var(--rule);
  border-radius: var(--radius-sm);
}

.missing-media::before {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--brass-bright);
  font-size: 1.4rem;
  content: "\25C7";
}

.missing-media a {
  position: relative;
  z-index: 1;
  margin-top: 0.35rem;
  font-size: 0.75rem;
}

.trivial-post,
.post--trivial {
  border-style: dashed;
  opacity: 0.86;
}

.trivial-post > summary,
.post--trivial > summary {
  padding: 0.75rem 1rem;
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

:root[data-hide-trivial="true"] .trivial-post,
:root[data-hide-trivial="true"] .post--trivial,
:root[data-hide-trivial="true"] [data-trivial] {
  display: none !important;
}

.chat-transcript {
  display: grid;
  gap: 0.35rem;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 0.84em;
  list-style: none;
}

.chat-line {
  display: grid;
  grid-template-columns: minmax(5rem, 9rem) 1fr;
  gap: 0.6rem;
  padding: 0.35rem 0.55rem;
  border-radius: 0.2rem;
}

.chat-line:nth-child(odd) {
  background: var(--surface-inset);
}

.chat-line__speaker {
  color: var(--author-color, var(--brass-bright));
  font-weight: 800;
  text-align: right;
}

/* ---------- Warning gates and navigation ---------- */

.warning-gate {
  padding: clamp(1rem, 4vw, 2rem);
  text-align: center;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--rule));
  border-radius: var(--radius);
}

.warning-gate__content[aria-hidden="true"] {
  display: none;
}

.thread-pagination {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2.5rem;
}

.thread-pagination a {
  display: grid;
  min-height: 5.5rem;
  padding: 1rem;
  align-content: center;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.thread-pagination a:hover {
  border-color: var(--brass-dim);
}

.thread-pagination__next {
  text-align: right;
}

.thread-pagination__label {
  color: var(--ink-faint);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.thread-pagination__title {
  margin-top: 0.25rem;
  font-family: var(--font-display);
  font-size: 1rem;
}

.back-to-top {
  position: fixed;
  z-index: 30;
  right: 1rem;
  bottom: 1rem;
  width: 2.8rem;
  height: 2.8rem;
  padding: 0;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--rule);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
  transition: opacity var(--motion-fast) ease, transform var(--motion-fast) ease;
}

.back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ---------- Utilities ---------- */

.text-muted {
  color: var(--ink-muted);
}

.text-small {
  font-size: 0.82rem;
}

.divider {
  margin-block: 2rem;
  border: 0;
  border-top: 1px solid var(--rule);
}

.no-results {
  grid-column: 1 / -1;
}

.js-only {
  display: none;
}

.js .js-only {
  display: revert;
}

.js .no-js-only {
  display: none !important;
}

/* ---------- Generated-site compatibility layer ---------- */

/* These selectors mirror the dependency-free renderer in grin_archive/site.py. */

.section-shell {
  width: min(calc(100% - 2rem), var(--page-width));
  margin-inline: auto;
}

.site-header {
  display: grid;
  grid-template-columns: auto minmax(22rem, 1fr) minmax(12rem, 18rem) auto;
  gap: clamp(0.55rem, 2vw, 1.25rem);
  align-items: center;
  min-height: var(--header-height);
  padding: 0.55rem max(1rem, calc((100vw - var(--page-width)) / 2));
}

.site-mark {
  display: inline-flex;
  gap: 0.65rem;
  align-items: center;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.84rem;
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.site-mark > span {
  display: grid;
  width: 2.3rem;
  height: 2.3rem;
  color: var(--brass-bright);
  font-family: var(--font-ui);
  font-size: 0.73rem;
  font-weight: 900;
  place-items: center;
  background: var(--crimson-deep);
  border: 1px solid var(--brass-dim);
  border-radius: 50% 42% 49% 45%;
  box-shadow: inset 0 0 0 3px rgb(0 0 0 / 22%);
  transform: rotate(-3deg);
}

.site-mark:hover {
  color: var(--brass-bright);
}

.site-search {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
}

.site-search label {
  min-width: 0;
}

.site-search input {
  min-height: 2.45rem;
  padding-right: 2.5rem;
  font-size: 0.82rem;
}

.site-search > button {
  width: 2.5rem;
  min-height: 2.45rem;
  margin-left: -2.5rem;
  color: var(--brass-bright);
  font-size: 1.25rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
}

.search-popover {
  position: absolute;
  z-index: 100;
  top: calc(100% + 0.5rem);
  right: 0;
  width: min(90vw, 30rem);
  max-height: min(70vh, 34rem);
  padding: 0.5rem;
  overflow-y: auto;
  background: var(--surface-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.search-popover .search-result + .search-result {
  margin-top: 0.45rem;
}

.search-empty {
  margin: 0;
  padding: 0.85rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
  text-align: center;
}

.theme-toggle {
  display: grid;
  width: 2.55rem;
  height: 2.55rem;
  padding: 0;
  color: var(--brass-bright);
  font-size: 1.25rem;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 50%;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--brass-dim);
}

main#main-content {
  min-height: calc(100vh - 13rem);
  padding-bottom: clamp(3.5rem, 8vw, 7rem);
}

.hero > h1 {
  position: relative;
  z-index: 1;
  max-width: 14ch;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(2.7rem, 8vw, 6rem);
  line-height: 0.96;
  text-wrap: balance;
  text-shadow: 0 3px 0 var(--canvas-deep);
}

.hero > h1 span {
  color: var(--brass-bright);
}

.hero-deck {
  position: relative;
  z-index: 1;
  max-width: 58ch;
  margin: 1.2rem 0 0;
  color: var(--ink-muted);
  font-family: var(--font-prose);
  font-size: clamp(1.04rem, 2.2vw, 1.3rem);
  line-height: 1.6;
}

.hero-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.5rem;
}

.button-primary {
  color: #fff7e5;
  background: linear-gradient(to bottom, var(--crimson-strong), var(--crimson-deep));
  border-color: color-mix(in srgb, var(--crimson-strong) 60%, var(--brass));
}

.button-quiet,
.text-button {
  background: transparent;
  box-shadow: none;
}

.archive-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(6.5rem, 1fr));
  gap: 0.65rem;
  width: min(100%, 42rem);
  margin: 2rem 0 0;
}

.archive-stats > div {
  padding: 0.7rem;
  background: color-mix(in srgb, var(--surface-inset) 72%, transparent);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.archive-stats dt {
  color: var(--brass-bright);
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 700;
}

.archive-stats dd {
  margin: 0.1rem 0 0;
  color: var(--ink-muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.shelf,
.archive-browser {
  padding-block: clamp(2.5rem, 7vw, 5.5rem) 0;
}

.section-heading > div {
  min-width: 0;
}

.section-heading > p {
  max-width: 52ch;
  margin: 0;
  color: var(--ink-muted);
  font-family: var(--font-prose);
  font-size: 0.92rem;
  line-height: 1.55;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 4vw, 2.45rem);
}

.filter-panel label {
  display: grid;
  min-width: 0;
  gap: 0.35rem;
  color: var(--ink-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.055em;
}

.filter-panel label > span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-transform: uppercase;
}

.filter-panel .wide-control {
  min-width: 15rem;
}

.filter-panel > button {
  white-space: nowrap;
}

.browser-status {
  margin: 0.8rem 0;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.browser-status strong {
  color: var(--brass-bright);
}

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.thread-card > .card-kicker {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-faint);
  font-size: 0.67rem;
  font-weight: 750;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.thread-card > h3 {
  margin: 0.72rem 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.27rem;
  line-height: 1.18;
}

.thread-card > h3 a {
  color: var(--ink);
  text-decoration: none;
}

.thread-card > h3 a::after {
  position: absolute;
  inset: 0;
  content: "";
}

.thread-card > p:not(.participant-line) {
  display: -webkit-box;
  min-height: 4.25em;
  margin: 0;
  overflow: hidden;
  color: var(--ink-muted);
  font-family: var(--font-prose);
  font-size: 0.93rem;
  line-height: 1.48;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.thread-card .participant-line {
  margin: 0.75rem 0 0;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 0.72rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.thread-card > footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.9rem;
  pointer-events: none;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.card-warning {
  color: var(--warning);
  font-size: 0.66rem;
  font-weight: 800;
}

.listing-hero,
.thread-hero {
  padding-block: clamp(2.5rem, 7vw, 6rem) clamp(1.8rem, 5vw, 4rem);
  border-bottom: 1px solid var(--rule);
}

.listing-hero h1,
.thread-hero h1 {
  max-width: 22ch;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(2.35rem, 7vw, 5rem);
  line-height: 1.02;
  text-wrap: balance;
}

.listing-hero > p:last-child,
.thread-hero > .thread-summary {
  max-width: 66ch;
  margin: 1rem 0 0;
  color: var(--ink-muted);
  font-family: var(--font-prose);
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  line-height: 1.62;
}

.thread-hero .breadcrumbs {
  margin-bottom: 1.6rem;
}

.thread-hero .breadcrumbs > span {
  color: var(--rule);
}

.thread-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0 0;
}

.thread-facts > div {
  padding: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.thread-facts dt {
  margin-bottom: 0.28rem;
  color: var(--ink-faint);
  font-size: 0.65rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.thread-facts dd {
  margin: 0;
  color: var(--ink-muted);
  font-family: var(--font-prose);
  font-size: 0.87rem;
}

.series-note,
.review-note {
  max-width: 62rem;
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
  background: var(--surface);
  border-left: 3px solid var(--brass-dim);
}

.series-note > span {
  margin-right: 0.35rem;
  color: var(--brass-bright);
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

details.content-warning {
  max-width: 42rem;
  margin-top: 1rem;
}

details.content-warning > summary,
.thread-contents > summary,
.thread-notes summary {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

details.content-warning > summary span,
.thread-contents > summary span {
  color: var(--ink-faint);
  font-size: 0.68rem;
  font-weight: 600;
}

.thread-contents {
  max-width: 42rem;
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.thread-contents ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.25rem;
  max-height: 22rem;
  margin: 0.8rem 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.thread-contents a {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) auto;
  gap: 0.35rem;
  padding: 0.32rem 0.4rem;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 0.72rem;
  text-decoration: none;
  border-left: 2px solid transparent;
}

.thread-contents a:hover,
.thread-contents a.is-active {
  color: var(--brass-bright);
  background: var(--surface-inset);
  border-left-color: var(--crimson-strong);
}

.thread-contents a > span {
  color: var(--ink-faint);
  font-family: var(--font-mono);
}

.thread-contents a > small {
  overflow: hidden;
  color: var(--ink-faint);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.thread-page > .reader-tools {
  position: sticky;
  z-index: 35;
  top: calc(var(--header-height) + 0.6rem);
  grid-template-columns: auto repeat(3, minmax(8rem, 1fr)) auto auto;
  width: min(calc(100% - 2rem), var(--page-width));
  margin: 1.2rem auto 0;
  padding: 0.7rem 0.9rem;
  align-items: center;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
}

.thread-page > .reader-tools > span {
  color: var(--brass-bright);
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.thread-page > .reader-tools label {
  display: grid;
  grid-template-columns: auto minmax(4rem, 1fr);
  gap: 0.45rem;
  align-items: center;
  color: var(--ink-muted);
}

.text-button {
  min-height: 2.2rem;
  padding: 0.35rem 0.5rem;
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 750;
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.text-button:hover {
  color: var(--brass-bright);
  border-color: var(--brass-dim);
}

.post-stream {
  display: grid;
  gap: clamp(1.1rem, 3vw, 2rem);
  width: min(calc(100% - 2rem), var(--reader-width));
  padding-top: clamp(1.3rem, 4vw, 3rem);
}

.post-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  justify-content: space-between;
  min-height: 3.5rem;
  padding: 0.7rem clamp(0.9rem, 3vw, 1.4rem);
  background: color-mix(in srgb, var(--surface-inset) 78%, transparent);
  border-bottom: 1px solid var(--rule-soft);
}

.author-badge[class*="tone-"] {
  --post-accent: var(--author-color);
  position: relative;
  z-index: 1;
  gap: 0.5rem;
  padding: 0;
  color: var(--author-color);
  background: transparent;
  border: 0;
}

.author-badge > span,
.author-monogram,
.large-monogram {
  display: grid;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  color: var(--surface-inset);
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 900;
  place-items: center;
  background: var(--author-color);
  border: 1px solid color-mix(in srgb, var(--author-color) 70%, var(--ink));
  border-radius: 50%;
}

.author-badge > strong {
  font-family: var(--font-display);
  font-size: 1rem;
}

.tone-0 { --author-color: var(--author-1); }
.tone-1 { --author-color: var(--author-2); }
.tone-2 { --author-color: var(--author-3); }
.tone-3 { --author-color: var(--author-4); }
.tone-4 { --author-color: var(--author-5); }
.tone-5 { --author-color: var(--author-6); }
.tone-6 { --author-color: var(--author-7); }
.tone-7 { --author-color: var(--author-8); }
.tone-8 { --author-color: var(--author-9); }
.tone-9 { --author-color: var(--author-10); }

.post-date {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  text-decoration: none;
}

.post-date:hover {
  color: var(--brass-bright);
}

.post-date > span {
  color: var(--brass-dim);
  font-family: var(--font-mono);
}

.post-body {
  max-width: none;
  padding: clamp(1rem, 4vw, 2rem);
  color: var(--ink);
  font-family: var(--font-prose);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  overflow-wrap: anywhere;
}

.post-body > :first-child {
  margin-top: 0;
}

.post-body > :last-child {
  margin-bottom: 0;
}

.post-body p,
.post-body ul,
.post-body ol,
.post-body blockquote,
.post-body pre,
.post-body .missing-media {
  margin-block: 0 1em;
}

.post-body a {
  overflow-wrap: anywhere;
}

.ooc-post {
  border-top-color: color-mix(in srgb, var(--blue) 70%, var(--rule));
}

.ooc-post .post-header::after {
  padding: 0.16rem 0.45rem;
  color: var(--blue);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  content: "OOC";
  border: 1px solid color-mix(in srgb, var(--blue) 40%, var(--rule));
  border-radius: 999px;
}

:root[data-hide-ooc="true"] .ooc-post,
:root[data-hide-ooc="true"] [data-ooc-post] {
  display: none !important;
}

.trivial-post > details > summary {
  padding: 0.8rem 1rem;
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}

:root[data-hide-trivial="true"] [data-trivial-post] {
  display: none !important;
}

.bb-quote {
  position: relative;
  padding: 1rem 1.1rem 1rem 1.35rem;
  color: var(--ink-muted);
  font-size: 0.94em;
  background: var(--surface-inset);
  border: 1px solid var(--rule-soft);
  border-left: 4px solid var(--brass-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.bb-quote > cite {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--brass-bright);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bb-center {
  text-align: center;
}

.bb-underline {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.14em;
}

.bb-color {
  font-weight: inherit;
}

.prose-dialogue {
  color: var(--speech);
  font-weight: 550;
  text-decoration: none;
}

.prose-dialogue::selection {
  color: #fff8e9;
  background: var(--crimson-deep);
}

.post-body em {
  color: color-mix(in srgb, var(--ink) 88%, var(--brass-bright));
  font-style: italic;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--brass-dim) 34%, transparent);
  text-decoration-thickness: 0.045em;
  text-underline-offset: 0.2em;
}

.scene-break {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin: 1.65em 0;
  color: var(--brass-dim);
  font-family: var(--font-display);
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-align: center;
}

.scene-break::before,
.scene-break::after {
  flex: 1 1 auto;
  height: 1px;
  content: "";
  background: linear-gradient(to var(--scene-direction, right), transparent, var(--rule));
}

.scene-break::after {
  --scene-direction: left;
}

.bb-image {
  margin: 1rem 0;
}

.bb-image img {
  width: auto;
  max-height: 70vh;
  margin-inline: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.legacy-link::after {
  display: inline-block;
  margin-left: 0.18em;
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: 0.65em;
  content: "\2197";
  vertical-align: super;
}

.thread-notes {
  width: min(calc(100% - 2rem), var(--reader-width));
  margin-top: 1.5rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.thread-notes > details {
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.thread-notes code {
  overflow-wrap: anywhere;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 0.78em;
}

.thread-notes dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 0.8rem;
}

.thread-notes dd {
  min-width: 0;
  margin: 0;
}

.thread-notes h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.chronicle-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: clamp(2rem, 5vw, 4rem);
}

.chronicle-nav-link {
  display: grid;
  min-height: 6rem;
  padding: 1rem;
  align-content: center;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

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

.chronicle-nav-link > span {
  color: var(--ink-faint);
  font-size: 0.65rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chronicle-nav-link > strong {
  margin-top: 0.2rem;
  font-family: var(--font-display);
}

.chronicle-nav-link > small {
  margin-top: 0.25rem;
  color: var(--ink-faint);
}

.reading-progress {
  width: 100%;
  background: transparent;
  box-shadow: none;
}

.reading-progress > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--crimson-strong), var(--brass-bright));
  box-shadow: 0 0 10px rgb(201 164 95 / 50%);
  transition: width 60ms linear;
}

.timeline.section-shell {
  margin-block: 0;
  padding: 0;
}

.timeline.section-shell::before {
  display: none;
}

.timeline-year {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr);
  gap: clamp(1rem, 4vw, 3rem);
  padding-block: 2rem;
  border-top: 1px solid var(--rule);
}

.year-marker {
  position: sticky;
  top: calc(var(--header-height) + 1rem);
  align-self: start;
}

.year-marker h2 {
  margin: 0;
  color: var(--brass-bright);
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.8rem);
}

.year-marker span {
  color: var(--ink-faint);
  font-size: 0.7rem;
}

.author-index {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 0.8rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.author-index-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 0.08rem 0.75rem;
  min-height: 5rem;
  padding: 0.85rem;
  align-content: center;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.author-index-card:hover {
  color: var(--author-color);
  border-color: var(--author-color);
}

.author-index-card .author-monogram {
  grid-row: 1 / 3;
  width: 2.6rem;
  height: 2.6rem;
}

.author-index-card small {
  overflow: hidden;
  color: var(--ink-faint);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.author-hero {
  position: relative;
  padding-left: clamp(6rem, 14vw, 10rem);
}

.large-monogram {
  position: absolute;
  bottom: clamp(2rem, 5vw, 4rem);
  left: 0;
  width: clamp(4.2rem, 10vw, 7rem);
  height: clamp(4.2rem, 10vw, 7rem);
  font-size: clamp(1.25rem, 3vw, 2.3rem);
  box-shadow: var(--shadow-md);
}

.link-manifest {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: links;
}

.link-manifest > li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.25rem 0.7rem;
  padding: 0.8rem 1rem;
  counter-increment: links;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.link-manifest > li > a {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.link-manifest > li > small {
  grid-column: 2;
  color: var(--ink-faint);
}

.prose-page {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding-top: clamp(1.5rem, 5vw, 3rem);
}

.prose-page > section {
  padding: clamp(1rem, 3vw, 1.5rem);
  color: var(--ink-muted);
  font-family: var(--font-prose);
  font-size: 1.02rem;
  line-height: 1.68;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
}

.prose-page h2 {
  margin-top: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.45rem;
}

.prose-page .archive-notice {
  grid-column: 1 / -1;
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 6%, var(--surface));
  border-color: color-mix(in srgb, var(--warning) 38%, var(--rule));
}

/* ---------- Responsive layout ---------- */

/* The generated shell nests every header control in .site-header__inner. */
.site-header {
  display: block;
  padding: 0;
}

.site-mark.site-brand::before {
  display: none;
  content: none;
}

.site-header__inner > .site-nav {
  flex: 1 1 auto;
}

.site-header__inner > .site-search {
  flex: 0 1 17rem;
}

#nav-toggle {
  display: none;
}

@media (max-width: 68rem) {
  .filter-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filter-panel .field:first-child {
    grid-column: span 2;
  }

  .thread-layout {
    grid-template-columns: minmax(0, var(--reader-width));
  }

  .thread-sidebar {
    position: static;
    grid-row: 1;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    width: min(100%, var(--reader-width));
    max-height: none;
    overflow: visible;
  }

  .thread-page > .reader-tools {
    grid-template-columns: auto repeat(3, minmax(7rem, 1fr));
  }

  .thread-page > .reader-tools > .text-button {
    grid-row: 2;
  }
}

@media (max-width: 48rem) {
  :root {
    --header-height: 3.6rem;
  }

  .site-header__inner {
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    padding-block: 0.45rem;
  }

  .site-header__inner > .site-mark {
    flex: 1 1 auto;
  }

  .site-header {
    display: block;
    padding: 0;
  }

  #nav-toggle {
    display: grid;
    flex: 0 0 auto;
    order: 1;
  }

  .site-header__inner > .theme-toggle {
    flex: 0 0 auto;
    order: 2;
  }

  .site-header__inner > .site-nav {
    display: none;
    flex: 1 0 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    order: 3;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .site-header__inner > .site-nav[data-expanded="true"] {
    display: flex;
  }

  .site-header__inner > .site-nav a,
  .site-header__inner > .site-nav a:not([aria-current="page"]) {
    display: inline-flex;
    flex: 0 0 auto;
    min-height: 2.15rem;
    padding: 0.35rem 0.55rem;
    font-size: 0.75rem;
  }

  .site-header__inner > .site-search {
    flex: 1 0 100%;
    order: 4;
  }

  .search-popover {
    right: auto;
    left: 0;
    width: 100%;
  }

  .site-brand span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .hero {
    min-height: 28rem;
    padding: 2rem 1.25rem;
  }

  .hero::before {
    opacity: 0.22;
  }

  .archive-stats {
    grid-template-columns: repeat(2, minmax(6rem, 1fr));
  }

  .section-heading {
    display: grid;
    align-items: start;
  }

  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-panel .field:first-child {
    grid-column: 1 / -1;
  }

  .thread-card__summary {
    min-height: auto;
  }

  .thread-card > p:not(.participant-line) {
    min-height: auto;
  }

  .thread-page > .reader-tools {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(calc(100% - 1rem), var(--page-width));
  }

  .thread-page > .reader-tools > span {
    grid-column: 1 / -1;
  }

  .thread-page > .reader-tools label {
    grid-template-columns: 3.5rem minmax(0, 1fr);
  }

  .timeline-year {
    grid-template-columns: 1fr;
  }

  .year-marker {
    position: static;
  }

  .prose-page {
    grid-template-columns: 1fr;
  }

  .author-hero {
    padding-left: clamp(5rem, 20vw, 7rem);
  }

  .timeline::before {
    left: 0.35rem;
  }

  .timeline__item {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.25rem;
    padding-left: 1.6rem;
  }

  .timeline__date {
    text-align: left;
  }

  .timeline__content::before {
    top: 1rem;
    left: -1.64rem;
  }

  .post__header {
    align-items: flex-start;
  }

  .post-header {
    align-items: flex-start;
  }

  .chat-line {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .chat-line__speaker {
    text-align: left;
  }
}

@media (max-width: 32rem) {
  .container,
  .page-shell,
  .site-header__inner {
    width: min(calc(100% - 1rem), var(--page-width));
  }

  .site-brand::before {
    width: 1.8rem;
    height: 1.8rem;
    font-size: 0.8rem;
  }

  .filter-panel {
    grid-template-columns: 1fr;
  }

  .filter-panel .field:first-child {
    grid-column: auto;
  }

  .filter-panel .wide-control {
    min-width: 0;
  }

  .thread-grid,
  .collection-grid,
  .author-grid {
    grid-template-columns: 1fr;
  }

  .thread-sidebar {
    grid-template-columns: 1fr;
  }

  .post__body {
    padding: 1rem;
  }

  .post-body {
    padding: 1rem;
  }

  .thread-page > .reader-tools {
    grid-template-columns: 1fr;
  }

  .thread-page > .reader-tools > span {
    grid-column: auto;
  }

  .chronicle-nav {
    grid-template-columns: 1fr;
  }

  .thread-notes dl,
  .link-manifest > li {
    grid-template-columns: 1fr;
  }

  .link-manifest > li > small {
    grid-column: auto;
  }

  .author-hero {
    padding-left: 5.2rem;
  }

  .large-monogram {
    width: 4rem;
    height: 4rem;
  }

  .thread-pagination {
    grid-template-columns: 1fr;
  }

  .thread-pagination__next {
    text-align: left;
  }
}

/* Collapse the full navigation before it can force the title bar to wrap. */
@media (max-width: 72rem) {
  .site-header__inner {
    flex-wrap: wrap;
    gap: 0.45rem;
    padding-block: 0.45rem;
  }

  .site-header__inner > .site-mark {
    flex: 1 1 auto;
    order: 0;
  }

  .site-header__inner > .site-search {
    flex: 0 1 15rem;
    order: 1;
  }

  #nav-toggle {
    display: grid;
    flex: 0 0 auto;
    order: 2;
  }

  .site-header__inner > .theme-toggle {
    flex: 0 0 auto;
    order: 3;
  }

  .site-header__inner > .site-nav {
    display: none;
    flex: 1 0 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    order: 4;
  }

  .site-header__inner > .site-nav[data-expanded="true"] {
    display: flex;
  }

  .site-header__inner > .site-nav a,
  .site-header__inner > .site-nav a:not([aria-current="page"]) {
    display: inline-flex;
  }
}

@media (max-width: 40rem) {
  .site-header__inner > .site-nav {
    order: 4;
  }

  .site-header__inner > .site-search {
    flex: 1 0 100%;
    order: 5;
  }
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ---------- Print ---------- */

@media print {
  :root {
    color-scheme: light;
    --ink: #1d1915;
    --ink-muted: #4d453b;
    --canvas: #fff;
    --surface: #fff;
    --surface-inset: #f5f2eb;
    --rule: #9b9387;
    --rule-soft: #d5d0c7;
    --brass-bright: #563d13;
    --reader-font-size: 11pt;
    --reader-line-height: 1.48;
    --reader-width: none;
    --page-width: none;
  }

  @page {
    margin: 0.7in;
  }

  html,
  body {
    min-width: 0;
    color: #1d1915;
    background: #fff !important;
  }

  body::before,
  .site-header,
  .site-footer,
  .thread-sidebar,
  .reading-progress,
  .back-to-top,
  .thread-pagination,
  .chronicle-nav,
  .reader-tools,
  .site-search,
  .filter-panel,
  .search-panel,
  .skip-link,
  .post__permalink,
  .no-print {
    display: none !important;
  }

  .page-shell,
  .container,
  .thread-layout,
  .thread-content,
  .section-shell,
  .post-stream,
  .thread-notes {
    display: block;
    width: 100%;
    max-width: none;
    padding: 0;
    margin: 0;
  }

  .thread-header {
    max-width: none;
    padding: 0 0 1.5rem;
  }

  .thread-title {
    max-width: none;
    font-size: 26pt;
  }

  .post-list {
    display: block;
  }

  .post {
    break-inside: auto;
    margin-bottom: 1.3rem;
    overflow: visible;
    background: #fff !important;
    border: 1px solid #aaa;
    box-shadow: none;
  }

  .post__header,
  .post-header {
    break-after: avoid;
    background: #f3f0e9;
  }

  .post__body p,
  .post-body p,
  .post__body blockquote,
  .post-body blockquote,
  .post__body li,
  .post-body li {
    orphans: 3;
    widows: 3;
  }

  a {
    color: inherit;
    text-decoration: underline;
  }

  .prose-dialogue,
  .post-body em {
    color: inherit;
    text-decoration: none;
  }

  .scene-break {
    color: #555;
  }

  .post__body a[href^="http"]::after,
  .post-body a[href^="http"]::after,
  .editorial-note a[href^="http"]::after {
    color: #555;
    font-family: var(--font-ui);
    font-size: 0.7em;
    content: " (" attr(href) ")";
  }

  :root[data-hide-ooc="true"] .ooc,
  :root[data-hide-ooc="true"] .post--ooc,
  :root[data-hide-ooc="true"] .ooc-post,
  :root[data-hide-ooc="true"] [data-ooc-post],
  :root[data-hide-trivial="true"] .trivial-post,
  :root[data-hide-trivial="true"] .post--trivial {
    display: block !important;
  }
}
