/* ==========================================================================
   Waidrn — app.css
   Design system for a fantasy-modern town square: warm ink, parchment and gold.
   Original work. No external fonts, images or URLs.

   Structure:
     01 tokens (dark default + light theme)
     02 reset & base elements
     03 typography & prose
     04 layout primitives (container / section / split / grids / hero / steps)
     05 site header, nav, footer
     06 buttons, links-as-buttons, icons
     07 badges, pills, chips, counts
     08 cards (generic, work, project, boards, tags, features)
     09 lists (threads, posts list, notifications, activity, chapters, index)
     10 threads & posts (post, quote, like, composer)
     11 power, notices, flash
     12 stats, progress, money
     13 forms & filters
     14 pagination, tabs, tables
     15 auth, errors, docs, reader
     16 profiles, settings, admin, studio, misc page shells
     17 utilities
     18 responsive (360 / 768 / 1280 / 1600) & motion & print
   ========================================================================== */

/* --------------------------------------------------------------------------
   01. DESIGN TOKENS
   Dark is the default (brief §6: default dark, toggle persisted per user+cookie).
   `data-theme` is rendered on <html> by the server and flipped by app.js.
   -------------------------------------------------------------------------- */

:root,
html[data-theme="dark"] {
  color-scheme: dark;

  /* surfaces — warm near-black ink */
  --bg: #12100c;
  --bg-deep: #0d0b08;
  --surface: #1a1611;
  --surface-2: #211c15;
  --surface-3: #2a241b;
  --surface-inset: #151209;
  --header-bg: rgba(18, 16, 12, 0.88);

  /* text */
  --ink: #f4ecdd;
  --ink-2: #d6c8b0;
  --ink-3: #b3a48c;
  --ink-inverse: #1a1409;

  /* gold — brand accent */
  --gold: #e8c987;
  --gold-bright: #f7e6b9;
  --gold-deep: #c49a55;
  --gold-ghost: rgba(232, 201, 135, 0.13);
  --gold-line: rgba(232, 201, 135, 0.42);

  /* supporting hues */
  --ember: #e08d61;
  --teal: #8fc9bf;
  --ok: #8fd39a;
  --ok-bg: rgba(143, 211, 154, 0.13);
  --info: #a9c7f0;
  --info-bg: rgba(169, 199, 240, 0.13);
  --warn: #ecc06a;
  --warn-bg: rgba(236, 192, 106, 0.14);
  --danger: #f0a094;
  --danger-bg: rgba(240, 160, 148, 0.14);

  /* lines & focus */
  --line: #362e23;
  --line-strong: #4c4030;
  --focus: #ffd98a;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.32);
  --glow: 0 0 0 1px var(--gold-line), 0 8px 30px rgba(232, 201, 135, 0.07);

  /* body backdrop — subtle gold embers at the top of the page */
  --page-glow: radial-gradient(1100px 460px at 18% -10%, rgba(232, 201, 135, 0.1), transparent 62%),
               radial-gradient(900px 420px at 100% 0%, rgba(143, 201, 191, 0.06), transparent 58%);
  --body-bg: var(--bg);
}

html[data-theme="light"] {
  color-scheme: light;

  --bg: #f8f2e6;
  --bg-deep: #efe6d3;
  --surface: #fffdf7;
  --surface-2: #f4ecdd;
  --surface-3: #e9dfca;
  --surface-inset: #f1e8d6;
  --header-bg: rgba(248, 242, 230, 0.92);

  --ink: #241d13;
  --ink-2: #4a3e2d;
  --ink-3: #6b5b45;
  --ink-inverse: #fff9ec;

  --gold: #8f5f16;
  --gold-bright: #a8731f;
  --gold-deep: #6d470e;
  --gold-ghost: rgba(143, 95, 22, 0.1);
  --gold-line: rgba(143, 95, 22, 0.4);

  --ember: #9c4a26;
  --teal: #1f6f66;
  --ok: #2f7a40;
  --ok-bg: rgba(47, 122, 64, 0.11);
  --info: #1f5f9e;
  --info-bg: rgba(31, 95, 158, 0.1);
  --warn: #8a5a07;
  --warn-bg: rgba(138, 90, 7, 0.12);
  --danger: #a33224;
  --danger-bg: rgba(163, 50, 36, 0.1);

  --line: #d9cbb2;
  --line-strong: #bfae90;
  --focus: #7a4d08;
  --shadow: 0 12px 30px rgba(58, 42, 18, 0.16);
  --shadow-soft: 0 4px 12px rgba(58, 42, 18, 0.1);
  --glow: 0 0 0 1px var(--gold-line), 0 8px 26px rgba(143, 95, 22, 0.1);

  --page-glow: radial-gradient(1100px 460px at 18% -10%, rgba(143, 95, 22, 0.09), transparent 62%),
               radial-gradient(900px 420px at 100% 0%, rgba(31, 111, 102, 0.05), transparent 58%);
  --body-bg: var(--bg);
}

/* Fallback if a document is rendered without data-theme (dark is the default). */
html:not([data-theme]) {
  color-scheme: dark;
  --bg: #12100c;
  --bg-deep: #0d0b08;
  --surface: #1a1611;
  --surface-2: #211c15;
  --surface-3: #2a241b;
  --surface-inset: #151209;
  --header-bg: rgba(18, 16, 12, 0.88);
  --ink: #f4ecdd;
  --ink-2: #d6c8b0;
  --ink-3: #b3a48c;
  --ink-inverse: #1a1409;
  --gold: #e8c987;
  --gold-bright: #f7e6b9;
  --gold-deep: #c49a55;
  --gold-ghost: rgba(232, 201, 135, 0.13);
  --gold-line: rgba(232, 201, 135, 0.42);
  --ember: #e08d61;
  --teal: #8fc9bf;
  --ok: #8fd39a;
  --ok-bg: rgba(143, 211, 154, 0.13);
  --info: #a9c7f0;
  --info-bg: rgba(169, 199, 240, 0.13);
  --warn: #ecc06a;
  --warn-bg: rgba(236, 192, 106, 0.14);
  --danger: #f0a094;
  --danger-bg: rgba(240, 160, 148, 0.14);
  --line: #362e23;
  --line-strong: #4c4030;
  --focus: #ffd98a;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.32);
  --glow: 0 0 0 1px var(--gold-line), 0 8px 30px rgba(232, 201, 135, 0.07);
  --page-glow: radial-gradient(1100px 460px at 18% -10%, rgba(232, 201, 135, 0.1), transparent 62%),
               radial-gradient(900px 420px at 100% 0%, rgba(143, 201, 191, 0.06), transparent 58%);
  --body-bg: var(--bg);
}

:root {
  /* spacing scale */
  --sp-0: 0;
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;

  /* radii */
  --r-xs: 5px;
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 20px;
  --r-pill: 999px;

  /* type */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
    Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --fs-xs: 0.78rem;
  --fs-sm: 0.9rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.22rem;
  --fs-xl: 1.45rem;
  --fs-2xl: clamp(1.65rem, 1.25rem + 1.4vw, 2.2rem);
  --fs-3xl: clamp(2rem, 1.35rem + 2.8vw, 3.1rem);
  --lh-tight: 1.18;
  --lh-body: 1.65;

  /* widths */
  --w-page: 1200px;
  --w-wide: 1400px;
  --w-read: 70ch;
  --w-form: 760px;

  /* motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 160ms;
}

/* --------------------------------------------------------------------------
   02. RESET & BASE
   -------------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem; /* sticky header offset for #anchors */
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--body-bg);
  background-image: var(--page-glow);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.plain {
  justify-content: center;
}

main#main {
  flex: 1 0 auto;
  width: 100%;
}

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

svg {
  vertical-align: middle;
}

/* element defaults for server-rendered markup from every lane */
h1,
h2,
h3,
h4 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: -0.012em;
  color: var(--ink);
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-2xl);
}

h2 {
  font-size: var(--fs-xl);
}

h3 {
  font-size: var(--fs-lg);
}

h4 {
  font-size: var(--fs-md);
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0;
}

p {
  margin: 0 0 var(--sp-4);
}

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

ul,
ol {
  margin: 0 0 var(--sp-4);
  padding-left: 1.35em;
}

li {
  margin-bottom: var(--sp-1);
}

li:last-child {
  margin-bottom: 0;
}

a {
  color: var(--gold);
  text-decoration: none;
  text-underline-offset: 0.18em;
  transition: color var(--dur) var(--ease);
}

a:hover {
  color: var(--gold-bright);
  text-decoration: underline;
}

strong,
b {
  font-weight: 700;
  color: var(--ink);
}

small {
  font-size: var(--fs-sm);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--sp-5) 0;
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  padding: 0.12em 0.38em;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

pre {
  overflow-x: auto;
  padding: var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  border: 1px solid var(--line);
  line-height: 1.55;
}

pre code {
  padding: 0;
  border: 0;
  background: none;
}

blockquote {
  margin: var(--sp-4) 0;
  padding: var(--sp-2) var(--sp-4);
  border-left: 3px solid var(--gold-deep);
  background: var(--gold-ghost);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--ink-2);
}

::selection {
  background: var(--gold);
  color: var(--ink-inverse);
}

/* visible keyboard focus everywhere */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* --------------------------------------------------------------------------
   03. TYPOGRAPHY HELPERS & PROSE
   -------------------------------------------------------------------------- */

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

.small {
  font-size: var(--fs-sm);
}

.lede {
  font-size: var(--fs-lg);
  line-height: 1.55;
  color: var(--ink-2);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

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

/* long-form pages: docs, rules, faq, manifesto */
.prose {
  max-width: var(--w-read);
  color: var(--ink-2);
  line-height: 1.75;
}

.prose > h2 {
  margin-top: var(--sp-7);
  color: var(--ink);
}

.prose > h3,
.prose > h4 {
  margin-top: var(--sp-6);
  color: var(--ink);
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre,
.prose table {
  margin-bottom: var(--sp-4);
}

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

.prose-narrow {
  max-width: 58ch;
}

/* headings inside cards/panels stay friendly */
.card > h2,
.card > h3 {
  margin-top: 0;
}

.card > :last-child,
.section > :last-child,
.split-main > :last-child,
.split-side > :last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   04. LAYOUT PRIMITIVES
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--w-page);
  margin-inline: auto;
  padding-inline: clamp(1rem, 0.55rem + 1.6vw, 2rem);
}

main#main.container {
  padding-block: clamp(1.25rem, 0.7rem + 2vw, 2.5rem) var(--sp-8);
}

.section {
  margin-bottom: clamp(2rem, 1.2rem + 3vw, 3.5rem);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--sp-2);
}

.section-header h2,
.section-header h1 {
  margin: 0;
  font-size: var(--fs-xl);
}

.section-action {
  flex: 0 0 auto;
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: clamp(1.25rem, 1rem + 2vw, 2.5rem);
  align-items: start;
}

.split-main,
.split-side {
  min-width: 0;
}

.split-side {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.card-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

.card-grid.two {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
}

.card-grid.three {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  align-items: center;
}

/* hero ------------------------------------------------------------------ */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr);
  gap: clamp(1.5rem, 1rem + 3vw, 3.25rem);
  align-items: center;
  margin-bottom: clamp(2rem, 1.2rem + 3vw, 3.5rem);
  padding-top: var(--sp-3);
}

.hero-copy {
  min-width: 0;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.hero-eyebrow .rune {
  color: var(--gold);
}

.hero h1 {
  font-size: var(--fs-3xl);
  margin-bottom: var(--sp-4);
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--ink) 30%, var(--gold) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-lede {
  max-width: 54ch;
  margin-bottom: var(--sp-5);
  font-size: var(--fs-lg);
  line-height: 1.55;
  color: var(--ink-2);
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  align-items: center;
}

.hero-stats {
  padding: clamp(1.1rem, 0.9rem + 1vw, 1.6rem);
  border-color: var(--gold-line);
  box-shadow: var(--glow);
}

.hero-stats .card-title {
  font-size: var(--fs-md);
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--sp-3);
}

/* new-arrivals banner ---------------------------------------------------- */
.banner {
  border-color: var(--gold-line);
  background: linear-gradient(135deg, var(--gold-ghost), transparent 55%), var(--surface);
}

.banner h2 {
  font-size: var(--fs-xl);
}

.banner-new-arrivals {
  padding: clamp(1.25rem, 1rem + 1.5vw, 2rem);
  margin-bottom: clamp(2rem, 1.2rem + 3vw, 3.5rem);
  border-inline-start: 3px solid var(--gold);
}

.banner-new-arrivals .button-row {
  margin-top: var(--sp-4);
}

/* three-step explainer --------------------------------------------------- */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--sp-4);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps > li {
  position: relative;
  margin: 0;
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-soft);
  counter-increment: step;
}

.steps > li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  top: -0.85rem;
  left: var(--sp-4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  height: 2.1rem;
  padding-inline: 0.35rem;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--gold-line);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
}

.steps > li > h3 {
  margin-top: var(--sp-2);
  font-size: var(--fs-lg);
}

.steps > li > p {
  color: var(--ink-2);
  font-size: var(--fs-sm);
  margin-bottom: 0;
}

.feature-card {
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-soft);
}

.feature-card h3 {
  font-size: var(--fs-lg);
}

/* --------------------------------------------------------------------------
   05. SITE HEADER, NAV & FOOTER
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-3) var(--sp-4);
  min-height: 3.9rem;
  padding-block: var(--sp-2);
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.brand:hover {
  color: var(--gold);
  text-decoration: none;
}

.brand-name {
  line-height: 1;
}

.logo-mark {
  flex: 0 0 auto;
  filter: drop-shadow(0 0 6px var(--gold-ghost));
}

.main-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0.42rem 0.7rem;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.nav-link:hover {
  color: var(--ink);
  background: var(--surface-2);
  text-decoration: none;
}

.nav-link.active {
  color: var(--gold);
  background: var(--gold-ghost);
  border-color: var(--gold-line);
}

.admin-link {
  color: var(--teal);
}

.header-search {
  display: flex;
  align-items: center;
  flex: 1 1 12rem;
  max-width: 20rem;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-inset);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.header-search:focus-within {
  border-color: var(--gold-line);
  box-shadow: 0 0 0 3px var(--gold-ghost);
}

.header-search input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.42rem 0.3rem 0.42rem 0.85rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-sm);
}

.header-search input[type="search"]::placeholder {
  color: var(--ink-3);
}

.header-search input[type="search"]:focus {
  outline: none;
}

.header-search button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  margin-right: 0.12rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  font-size: 1.05rem;
  cursor: pointer;
}

.header-search button:hover {
  color: var(--gold);
  background: var(--surface-2);
}

.header-user {
  display: flex;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
  margin-left: auto;
  flex-wrap: wrap;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--gold);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.theme-toggle:hover {
  border-color: var(--gold-line);
  background: var(--surface-3);
  transform: rotate(12deg);
}

.icon-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid transparent;
  color: var(--ink-2);
  font-size: 1.05rem;
}

.icon-link:hover {
  color: var(--gold);
  background: var(--surface-2);
  border-color: var(--line);
  text-decoration: none;
}

.badge-count {
  position: absolute;
  top: -0.15rem;
  right: -0.15rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding-inline: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  background: var(--gold);
  color: var(--ink-inverse);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--header-bg);
}

.user-menu {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0.22rem 0.65rem 0.22rem 0.22rem;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  max-width: 13rem;
}

.user-menu:hover {
  color: var(--ink);
  border-color: var(--gold-line);
  text-decoration: none;
}

.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identicon {
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  flex: 0 0 auto;
  background: var(--surface-inset);
}

.linklike {
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  padding: 0.42rem 0.7rem;
  border-radius: var(--r-pill);
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
}

/* skip link */
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -4rem;
  z-index: 110;
  padding: 0.7rem 1.1rem;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  background: var(--gold);
  color: var(--ink-inverse);
  font-weight: 700;
  transition: top var(--dur) var(--ease);
}

.skip-link:focus {
  top: 0;
  text-decoration: none;
}

/* footer ---------------------------------------------------------------- */
.site-footer {
  margin-top: var(--sp-8);
  padding-block: var(--sp-7) var(--sp-5);
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, transparent, var(--surface-inset));
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));
  gap: var(--sp-5) var(--sp-6);
}

.footer-brand p {
  margin: var(--sp-2) 0 0;
  max-width: 34ch;
}

.footer-brand .logo-mark {
  margin-bottom: var(--sp-2);
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.footer-col h3 {
  margin: 0 0 var(--sp-2);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.footer-col a {
  color: var(--ink-3);
  font-size: var(--fs-sm);
  padding-block: 0.1rem;
}

.footer-col a:hover {
  color: var(--gold);
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: space-between;
  align-items: center;
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.footer-legal a {
  color: var(--ink-2);
  margin-left: var(--sp-4);
}

/* --------------------------------------------------------------------------
   06. BUTTONS
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0.55rem 1.05rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease),
    background var(--dur) var(--ease), color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.btn:hover {
  background: var(--surface-3);
  border-color: var(--gold-line);
  color: var(--ink);
  text-decoration: none;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: var(--ink-inverse);
  box-shadow: 0 2px 0 var(--gold-deep), var(--shadow-soft);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold-bright));
  border-color: var(--gold-bright);
  color: var(--ink-inverse);
}

.btn-small {
  padding: 0.32rem 0.72rem;
  font-size: var(--fs-xs);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--bg-deep);
}

html[data-theme="light"] .btn-danger {
  color: var(--ink-inverse);
}

.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--bg-deep);
  filter: brightness(1.06);
}

html[data-theme="light"] .btn-danger:hover {
  color: var(--ink-inverse);
}

.btn-disabled,
.btn:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-kudos {
  border-color: var(--gold-line);
  background: var(--gold-ghost);
  color: var(--gold);
}

.btn-kudos:hover {
  background: var(--gold-ghost);
  color: var(--gold-bright);
}

.btn-kudos[aria-pressed="true"],
.btn-kudos.is-kudosed {
  background: var(--gold);
  color: var(--ink-inverse);
}

/* text-link styled buttons (logout etc.) */
.linkish,
button.linklike {
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 600;
}

button.linklike:hover,
.linkish:hover {
  color: var(--gold);
  background: var(--surface-2);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   07. BADGES, PILLS, CHIPS, COUNTS
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.14rem 0.52rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
}

.badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  align-items: center;
}

.badge-ok {
  border-color: var(--ok);
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-info {
  border-color: var(--info);
  background: var(--info-bg);
  color: var(--info);
}

.badge-warn {
  border-color: var(--warn);
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-danger {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-muted {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-3);
}

.badge-pinned {
  border-color: var(--gold);
  background: var(--gold-ghost);
  color: var(--gold);
}

.badge-locked {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-story {
  border-color: var(--teal);
  background: rgba(143, 201, 191, 0.12);
  color: var(--teal);
}

.badge-rating {
  border-color: var(--gold-line);
  background: var(--gold-ghost);
  color: var(--gold);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  padding: 0.16rem 0.62rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.6;
  text-decoration: none;
  white-space: nowrap;
}

.pill:hover {
  border-color: var(--gold-line);
  color: var(--gold);
  text-decoration: none;
}

.pill-fandom {
  border-color: var(--gold-line);
  background: var(--gold-ghost);
  color: var(--gold);
}

.prefs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-2);
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

.prefs-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.1rem 0.5rem;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: var(--fs-xs);
}

.prefs-off {
  color: var(--warn);
  font-weight: 700;
}

/* power chips (⌁) -------------------------------------------------------- */
.power-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.12rem 0.55rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--gold-line);
  background: var(--gold-ghost);
  color: var(--gold);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.power-chip a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.power-chip.power-pruned {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.power-chip.power-none {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-3);
}

.power-inline {
  display: inline-flex;
}

/* --------------------------------------------------------------------------
   08. CARDS
   -------------------------------------------------------------------------- */

.card {
  position: relative;
  padding: clamp(1rem, 0.85rem + 0.7vw, 1.5rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-soft);
  min-width: 0;
}

.card + .card {
  margin-top: var(--sp-4);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-3);
}

.card-link {
  color: inherit;
  text-decoration: none;
  display: block;
}

.card-link:hover {
  text-decoration: none;
}

/* whole-card link hover affordance */
.card:has(> .card-link),
.card.has-link {
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.card:has(> .card-link):hover,
.card.has-link:hover {
  border-color: var(--gold-line);
  transform: translateY(-2px);
  box-shadow: var(--shadow), var(--glow);
}

.card:has(> .card-link):hover .card-title,
.card:has(> .card-link):hover .work-title,
.card:has(> .card-link):hover .project-title {
  color: var(--gold);
}

/* work cards ------------------------------------------------------------ */
.work-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: clamp(1rem, 0.85rem + 0.7vw, 1.4rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-soft);
  min-width: 0;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.work-card:hover {
  border-color: var(--gold-line);
  transform: translateY(-2px);
  box-shadow: var(--shadow), var(--glow);
}

.work-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
}

.work-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  line-height: 1.25;
}

.work-title a,
.work-card .card-link {
  color: inherit;
  text-decoration: none;
}

.work-title a:hover,
.work-card .card-link:hover .work-title {
  color: var(--gold);
}

.work-summary {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.work-byline {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.work-byline a,
.work-author a {
  color: var(--ink-2);
}

.work-fandoms,
.work-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.work-tags-block {
  margin-top: var(--sp-3);
}

.work-tags-block h3 {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--sp-2);
}

.work-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  margin-top: auto;
  padding-top: var(--sp-2);
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.work-stats span {
  display: inline-flex;
  align-items: center;
  gap: 0.28em;
}

.work-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.work-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* project cards --------------------------------------------------------- */
.project-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: clamp(1rem, 0.85rem + 0.7vw, 1.4rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-soft);
  min-width: 0;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.project-card:hover {
  border-color: var(--gold-line);
  transform: translateY(-2px);
  box-shadow: var(--shadow), var(--glow);
}

.project-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.project-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  line-height: 1.25;
}

.project-title a {
  color: inherit;
  text-decoration: none;
}

.project-title a:hover {
  color: var(--gold);
}

.project-summary {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

/* board cards ----------------------------------------------------------- */
.board-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-3);
}

.board-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-3) var(--sp-4);
  align-items: center;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-soft);
}

.board-card-main {
  min-width: 0;
}

.board-card-main h3 {
  margin: 0 0 0.25rem;
  font-size: var(--fs-lg);
}

.board-card-main h3 a {
  color: var(--ink);
}

.board-card-main h3 a:hover {
  color: var(--gold);
  text-decoration: none;
}

.board-card-main p {
  margin: 0;
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

.board-card-stats {
  display: flex;
  gap: var(--sp-4);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.board-card-last {
  grid-column: 1 / -1;
  padding-top: var(--sp-2);
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.board-toolbar,
.directory-search {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-4);
}

.tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
  gap: var(--sp-3);
}

.tag-card {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.tag-header,
.tag-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

/* --------------------------------------------------------------------------
   09. LISTS — threads, posts, notifications, activity, chapters, index
   -------------------------------------------------------------------------- */

.thread-list {
  list-style: none;
  margin: 0 0 var(--sp-4);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.thread-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-1) var(--sp-4);
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  margin: 0;
}

.thread-row:last-child {
  border-bottom: 0;
}

.thread-row:hover {
  background: var(--surface-2);
}

.thread-row.pinned {
  background: linear-gradient(90deg, var(--gold-ghost), transparent 45%);
  border-left: 3px solid var(--gold);
}

.thread-list.compact .thread-row {
  padding: var(--sp-2) var(--sp-3);
}

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

.thread-title {
  display: inline;
  color: var(--ink);
  font-weight: 600;
  font-size: var(--fs-md);
  line-height: 1.4;
}

.thread-title:hover {
  color: var(--gold);
  text-decoration: none;
}

.thread-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  margin-top: 0.15rem;
  color: var(--ink-3);
  font-size: var(--fs-xs);
  align-items: center;
}

.thread-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  align-items: center;
}

.thread-stats {
  display: flex;
  gap: var(--sp-3);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.thread-last {
  grid-column: 1 / -1;
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.thread-last-link {
  color: var(--ink-2);
}

.thread-jump {
  font-size: var(--fs-sm);
}

.thread-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

.thread-header {
  margin-bottom: var(--sp-4);
}

.thread-header h1 {
  margin-bottom: var(--sp-2);
}

.thread-headings {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

/* posts list ------------------------------------------------------------ */
.post-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.post {
  padding: clamp(0.9rem, 0.8rem + 0.5vw, 1.35rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-soft);
  min-width: 0;
}

.post.post-op {
  border-color: var(--gold-line);
  box-shadow: var(--shadow-soft), inset 3px 0 0 var(--gold);
}

.post-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--line);
}

.post-identity {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.post-author {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
}

.post-author a {
  color: var(--ink);
}

.post-author a:hover {
  color: var(--gold);
}

.post-head .muted,
.post-head time {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.post-body {
  color: var(--ink-2);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

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

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

.post-body h1,
.post-body h2,
.post-body h3 {
  margin-top: var(--sp-5);
  color: var(--ink);
}

.post-body img {
  border-radius: var(--r-sm);
}

.post-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--line);
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.post-action {
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.post-action:hover {
  color: var(--gold);
}

.post-deleted-note {
  padding: var(--sp-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink-3);
  font-style: italic;
  font-size: var(--fs-sm);
}

.post-threadmark {
  font-size: var(--fs-xs);
}

.post-editor {
  margin: var(--sp-3) 0;
}

/* likes ------------------------------------------------------------------ */
.like-form {
  display: inline-flex;
  margin: 0;
}

.like {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-3);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    background var(--dur) var(--ease);
}

.like:hover {
  color: var(--ember);
  border-color: var(--ember);
  background: var(--surface-3);
}

.like.liked,
.like[aria-pressed="true"] {
  color: var(--ember);
  border-color: var(--ember);
  background: rgba(224, 141, 97, 0.13);
}

.like-anon {
  cursor: default;
  opacity: 0.8;
}

/* quotes ---------------------------------------------------------------- */
.quote-block {
  margin: 0 0 var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid var(--gold-deep);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surface-inset);
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

.quote-block header {
  margin-bottom: var(--sp-2);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.quote-block blockquote,
.quote-block p {
  margin: 0;
}

.reply-context {
  color: var(--ink-3);
  font-size: var(--fs-xs);
  margin-bottom: var(--sp-2);
}

/* comment / reply threads ----------------------------------------------- */
.comments,
.comment-list {
  list-style: none;
  margin: var(--sp-4) 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.comment {
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.comment-reply {
  margin-left: clamp(0.75rem, 0.4rem + 1.6vw, 2rem);
  border-left: 2px solid var(--gold-line);
}

.comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.comment-head strong,
.comment-head a {
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

.comment-body {
  color: var(--ink-2);
  font-size: var(--fs-sm);
  line-height: 1.65;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.comment-form.compact textarea {
  min-height: 3.2rem;
}

/* composer / editor shells ---------------------------------------------- */
.composer,
.thread-editor,
.reply-box,
.inline-editor {
  padding: clamp(1rem, 0.85rem + 0.6vw, 1.4rem);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  margin-block: var(--sp-4);
}

.reply-box,
.inline-editor {
  background: var(--surface-2);
  box-shadow: none;
}

/* notifications --------------------------------------------------------- */
.notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.notification {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.notification.unread {
  border-color: var(--gold-line);
  background: var(--gold-ghost);
}

.notification-main {
  min-width: 0;
  flex: 1 1 auto;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

/* activity (admin audit / dashboards) ----------------------------------- */
.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--sp-1) var(--sp-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-title {
  color: var(--ink-2);
}

/* chapter lists --------------------------------------------------------- */
.chapter-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.chapter-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line);
}

.chapter-row:last-child {
  border-bottom: 0;
}

.chapter-row:hover {
  background: var(--surface-2);
}

.chapter-num {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

.chapter-title {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  font-weight: 600;
}

.chapter-title a {
  color: inherit;
}

.chapter-title a:hover {
  color: var(--gold);
  text-decoration: none;
}

.chapter-notes,
.chapter-chip {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

/* threadmark index ------------------------------------------------------ */
.index-list {
  list-style: none;
  margin: 0 0 var(--sp-4);
  padding: 0;
}

.index-item {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
  border-bottom: 1px dotted var(--line);
  font-size: var(--fs-sm);
}

.index-label {
  flex: 1 1 auto;
  min-width: 0;
}

.index-group {
  margin-bottom: var(--sp-4);
}

.index-group > h2,
.index-group > h3 {
  font-size: var(--fs-md);
  font-family: var(--font-body);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--sp-2);
}

/* threadmark badges + category colours --------------------------------- */
.threadmark-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28em;
  padding: 0.1rem 0.5rem;
  border-radius: var(--r-xs);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}

.tm-chapter {
  border-color: var(--gold-line);
  background: var(--gold-ghost);
  color: var(--gold);
}

.tm-sidestory {
  border-color: var(--teal);
  background: rgba(143, 201, 191, 0.12);
  color: var(--teal);
}

.tm-apocrypha {
  border-color: var(--warn);
  background: var(--warn-bg);
  color: var(--warn);
}

.tm-media {
  border-color: var(--info);
  background: var(--info-bg);
  color: var(--info);
}

.tm-informational {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-2);
}

.tm-staff {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.threadmark-list,
.threadmark-manager,
.threadmark-tools,
.threadmark-form,
.threadmark-row {
  margin-block: var(--sp-2);
}

.threadmark-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

/* --------------------------------------------------------------------------
   10. NOTICES & FLASH
   -------------------------------------------------------------------------- */

.notice {
  position: relative;
  margin: var(--sp-4) 0;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line-strong);
  border-inline-start: 3px solid var(--ink-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

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

.notice-grace {
  border-inline-start-color: var(--warn);
  background: var(--warn-bg);
  color: var(--ink-2);
}

.notice-warn {
  border-inline-start-color: var(--warn);
  background: var(--warn-bg);
  color: var(--warn);
}

.notice-danger,
.notice-pruned {
  border-inline-start-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.notice-info {
  border-inline-start-color: var(--info);
  background: var(--info-bg);
  color: var(--info);
}

.notice-locked {
  border-inline-start-color: var(--line-strong);
  background: var(--surface-inset);
  color: var(--ink-3);
}

.notice-draft {
  border-inline-start-color: var(--teal);
  background: rgba(143, 201, 191, 0.1);
  color: var(--teal);
}

/* flash banners --------------------------------------------------------- */
.flash {
  position: relative;
  z-index: 40;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.flash .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.flash-success {
  background: var(--ok-bg);
  border-bottom-color: var(--ok);
  color: var(--ok);
}

.flash-error {
  background: var(--danger-bg);
  border-bottom-color: var(--danger);
  color: var(--danger);
}

.flash-info {
  background: var(--info-bg);
  border-bottom-color: var(--info);
  color: var(--info);
}

.flash-inline {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid currentColor;
  border-radius: var(--r-sm);
}

.flash-dismiss {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.8;
}

.flash-dismiss:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.12);
}

/* --------------------------------------------------------------------------
   11. STATS, PROGRESS & MONEY
   -------------------------------------------------------------------------- */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: var(--sp-3) var(--sp-4);
  margin: 0;
}

.stat {
  min-width: 0;
}

.stat dt {
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.stat dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  color: var(--ink);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.big-number,
.supply-total,
.wallet-balance,
.balance {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  color: var(--gold);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.supply-total {
  font-size: var(--fs-xl);
}

.card-stat {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.waid-amount {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  white-space: nowrap;
}

.waid-amount.pos {
  color: var(--ok);
}

.waid-amount.neg {
  color: var(--danger);
}

/* progress -------------------------------------------------------------- */
.progress {
  position: relative;
  display: flex;
  align-items: center;
  height: 1.5rem;
  margin: var(--sp-2) 0;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--line);
  overflow: hidden;
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
}

/* CSP-safe progress widths: the server emits
   class="progress-fill pct-<rounded-to-5>" and renders no inline style=
   (inline styles are blocked by the strict `style-src 'self'` CSP).
   .progress-fill.pct-N has higher specificity than `.progress-fill { width: 0 }`,
   so the class always wins; app.js still re-applies the width through the CSSOM
   from aria-valuenow as a belt-and-braces fallback. */
.progress-fill.pct-0 { width: 0%; }
.progress-fill.pct-5 { width: 5%; }
.progress-fill.pct-10 { width: 10%; }
.progress-fill.pct-15 { width: 15%; }
.progress-fill.pct-20 { width: 20%; }
.progress-fill.pct-25 { width: 25%; }
.progress-fill.pct-30 { width: 30%; }
.progress-fill.pct-35 { width: 35%; }
.progress-fill.pct-40 { width: 40%; }
.progress-fill.pct-45 { width: 45%; }
.progress-fill.pct-50 { width: 50%; }
.progress-fill.pct-55 { width: 55%; }
.progress-fill.pct-60 { width: 60%; }
.progress-fill.pct-65 { width: 65%; }
.progress-fill.pct-70 { width: 70%; }
.progress-fill.pct-75 { width: 75%; }
.progress-fill.pct-80 { width: 80%; }
.progress-fill.pct-85 { width: 85%; }
.progress-fill.pct-90 { width: 90%; }
.progress-fill.pct-95 { width: 95%; }
.progress-fill.pct-100 { width: 100%; }

.progress-label {
  position: relative;
  z-index: 1;
  padding-inline: 0.7rem;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-inverse);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

html[data-theme="dark"] .progress-label {
  color: var(--ink-inverse);
}

/* economy page shells --------------------------------------------------- */
.economy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: var(--sp-4);
}

.economy-hero {
  margin-bottom: var(--sp-5);
}

.wallet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: var(--sp-4);
}

.wallet-forms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--sp-4);
}

.wallet-history {
  margin-top: var(--sp-4);
}

.invariant-card {
  border-color: var(--line-strong);
}

.invariant-ok {
  border-color: var(--ok);
  box-shadow: 0 0 0 1px var(--ok-bg), var(--shadow-soft);
}

/* mint widget ----------------------------------------------------------- */
.mint-widget {
  border-color: var(--gold-line);
  background:
    radial-gradient(420px 160px at 12% 0%, var(--gold-ghost), transparent 70%),
    var(--surface);
}

.mint-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
}

#mint-status {
  color: var(--ink-3);
  font-size: var(--fs-sm);
  min-height: 1.2em;
}

/* --------------------------------------------------------------------------
   12. FORMS & FILTERS
   -------------------------------------------------------------------------- */

form {
  margin: 0;
}

fieldset {
  min-width: 0;
  margin: 0 0 var(--sp-4);
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}

legend {
  padding-inline: 0.4rem;
  color: var(--ink);
  font-weight: 700;
  font-size: var(--fs-sm);
}

label {
  display: block;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 600;
}

input,
select,
textarea,
button,
output {
  font-family: inherit;
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.58rem 0.72rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  color: var(--ink);
  font-size: var(--fs-md);
  line-height: 1.35;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-3);
  opacity: 1;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-ghost);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--danger);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--gold);
  vertical-align: text-bottom;
}

input[type="color"],
input[type="file"] {
  max-width: 100%;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 1.7rem;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--gold);
  cursor: pointer;
  --pct: 50%; /* static default; app.js sets the live value per slider */
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--gold) var(--pct, 50%), var(--surface-3) var(--pct, 50%));
  border: 1px solid var(--line);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--line);
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--gold);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: -0.32rem;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg-deep);
  box-shadow: var(--shadow-soft);
}

input[type="range"]::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg-deep);
  box-shadow: var(--shadow-soft);
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.field {
  margin-bottom: var(--sp-4);
}

.field > label,
.form-field > label {
  margin-bottom: var(--sp-1);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  align-items: flex-end;
  margin-bottom: var(--sp-4);
}

.form-row > .field,
.form-row > label {
  flex: 1 1 12rem;
  margin-bottom: 0;
}

.field-row {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
}

.field-hint {
  margin: var(--sp-1) 0 0;
  color: var(--ink-3);
  font-size: var(--fs-xs);
  line-height: 1.5;
}

.form-error {
  margin: var(--sp-1) 0 0;
  color: var(--danger);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.form-actions,
.primary-actions,
.editor-actions,
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  align-items: center;
  margin-top: var(--sp-4);
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-width: var(--w-form);
}

.stack-form > label,
.stack-form > .field {
  margin-bottom: 0;
}

.stack-form input,
.stack-form select,
.stack-form textarea {
  margin-top: var(--sp-1);
}

.editor-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.editor-section,
.inline-editor {
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}

.radio,
.checkbox,
.check {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-weight: 500;
  cursor: pointer;
  margin-bottom: var(--sp-1);
}

.radio input,
.checkbox input,
.check input {
  flex: 0 0 auto;
  margin-top: 0.25rem;
}

.power-fields {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.power-choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.power-choice {
  flex: 1 1 9rem;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.power-choice:has(input:checked) {
  border-color: var(--gold);
  background: var(--gold-ghost);
  color: var(--gold);
}

.power-choice input {
  accent-color: var(--gold);
}

.split-control {
  margin-top: var(--sp-4);
}

.split-control label {
  display: block;
  margin-bottom: var(--sp-1);
}

.split-control output {
  display: block;
  margin-top: var(--sp-1);
}

.range-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.range-row input[type="number"] {
  flex: 1 1 0;
  min-width: 0;
}

.range-row span {
  color: var(--ink-3);
}

.rights-check {
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
}

.save-preset {
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
}

.save-preset summary {
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 600;
}

.save-preset summary:hover {
  color: var(--gold);
}

details {
  margin-block: var(--sp-2);
}

summary {
  cursor: pointer;
  font-weight: 600;
}

/* filter sidebar -------------------------------------------------------- */
.filter-sidebar,
.stories-sidebar {
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-soft);
}

.filter-sidebar {
  position: sticky;
  top: 5.2rem;
  max-height: calc(100vh - 6.5rem);
  overflow-y: auto;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--sp-3) var(--sp-4);
  align-items: start;
}

.filter-group {
  margin-bottom: var(--sp-3);
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
}

.filter-legend {
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.filter-sidebar label {
  font-weight: 500;
  margin-bottom: var(--sp-1);
}

.stories-layout,
.work-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 19rem);
  gap: clamp(1.25rem, 1rem + 2vw, 2.5rem);
  align-items: start;
}

.stories-main,
.work-main {
  min-width: 0;
}

.stories-sidebar,
.work-aside {
  min-width: 0;
}

/* --------------------------------------------------------------------------
   13. PAGINATION, TABS, TABLES
   -------------------------------------------------------------------------- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
  margin: var(--sp-5) 0;
}

.pagination .page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 2.2rem;
  padding-inline: 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
}

.pagination .page:hover {
  border-color: var(--gold-line);
  color: var(--gold);
  text-decoration: none;
}

.pagination .page.current {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--ink-inverse);
}

.pagination .prev,
.pagination .next {
  padding-inline: 0.8rem;
}

.page-meta {
  margin-left: var(--sp-2);
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

/* tabs ------------------------------------------------------------------ */
.tabs,
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--line);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--ink-3);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.tab:hover {
  color: var(--ink);
  text-decoration: none;
}

.tab.active,
.tab[aria-selected="true"] {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* tables ---------------------------------------------------------------- */
.table,
.studio-table,
.table-compact {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table th,
.studio-table th,
.table-compact th {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

.table td,
.studio-table td,
.table-compact td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.table tbody tr:hover,
.studio-table tbody tr:hover {
  background: var(--surface-2);
}

.table tr:last-child td,
.studio-table tr:last-child td {
  border-bottom: 0;
}

.table .num,
.studio-table .num,
.table-compact .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table-total td,
.table-total th {
  border-top: 2px solid var(--line-strong);
  font-weight: 800;
  color: var(--ink);
}

.table-compact th,
.table-compact td {
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--fs-xs);
}

.card:has(.table),
.card:has(.studio-table) {
  overflow-x: auto;
}

/* --------------------------------------------------------------------------
   14. AUTH, ERRORS, DOCS
   -------------------------------------------------------------------------- */

.auth-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-5) var(--sp-4);
  width: 100%;
}

.auth-card {
  width: 100%;
  max-width: 27rem;
  padding: clamp(1.5rem, 1.2rem + 1.6vw, 2.4rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow), var(--glow);
}

.auth-card h1 {
  margin-bottom: var(--sp-2);
  font-size: var(--fs-2xl);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
}

.auth-brand:hover {
  color: var(--gold);
  text-decoration: none;
}

.auth-alt {
  margin-top: var(--sp-4);
  color: var(--ink-3);
  font-size: var(--fs-sm);
  text-align: center;
}

.auth-card .stack-form {
  max-width: none;
}

.login-prompt {
  padding: var(--sp-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink-2);
  text-align: center;
}

/* error pages ----------------------------------------------------------- */
.error-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-5) var(--sp-4);
  width: 100%;
}

.error-card {
  width: 100%;
  max-width: 34rem;
  padding: clamp(1.5rem, 1.2rem + 1.6vw, 2.5rem);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow), var(--glow);
}

.error-code {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 2.5rem + 6vw, 6rem);
  line-height: 1;
  color: var(--gold);
  opacity: 0.85;
}

.error-card h1 {
  font-size: var(--fs-xl);
}

.error-card p {
  color: var(--ink-2);
}

/* docs ------------------------------------------------------------------ */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: var(--sp-4);
}

.doc-card {
  display: block;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: inherit;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.doc-card:hover {
  border-color: var(--gold-line);
  transform: translateY(-2px);
  text-decoration: none;
}

.doc-card h2,
.doc-card h3 {
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-2);
}

.doc-card p {
  color: var(--ink-3);
  font-size: var(--fs-sm);
  margin: 0;
}

.doc-page {
  padding-top: var(--sp-2);
}

.doc-page h1 {
  margin-bottom: var(--sp-2);
}

.doc-page .lede {
  margin-bottom: var(--sp-5);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: var(--sp-3);
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.breadcrumb a {
  color: var(--ink-3);
}

/* --------------------------------------------------------------------------
   15. READER MODE
   -------------------------------------------------------------------------- */

.reader {
  max-width: var(--w-read);
  margin-inline: auto;
}

.reader-header,
.reader-head {
  text-align: center;
  margin-bottom: var(--sp-5);
}

.reader-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}

.reader-header h1,
.reader-title-row h1 {
  font-size: var(--fs-2xl);
  margin-bottom: var(--sp-2);
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
  margin-block: var(--sp-3);
}

.reader-chapter {
  margin-bottom: var(--sp-6);
}

.reader-chapter-head {
  text-align: center;
  margin-bottom: var(--sp-4);
}

.reader-chapter-head h2 {
  font-size: var(--fs-xl);
  margin-bottom: var(--sp-1);
}

.reader-chapter-foot,
.reader-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}

.reader-body,
.chapter-body,
.reader-single .prose {
  font-size: 1.08rem;
  line-height: 1.85;
  color: var(--ink-2);
}

.reader-body > p:first-child::first-letter,
.chapter-body > p:first-child::first-letter {
  float: left;
  padding-right: 0.08em;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 3.1em;
  line-height: 0.85;
}

.reader-body h1,
.reader-body h2,
.reader-body h3,
.chapter-body h1,
.chapter-body h2,
.chapter-body h3 {
  margin-top: var(--sp-6);
  color: var(--ink);
}

.reader-nav,
.reader-pager,
.chapter-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-block: var(--sp-5);
  padding-block: var(--sp-3);
  border-block: 1px solid var(--line);
}

.reader-pager a,
.reader-nav a {
  font-weight: 600;
}

.entire-work,
.entire-chapter {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
}

.work-header {
  margin-bottom: var(--sp-4);
}

.work-header h1 {
  font-size: var(--fs-2xl);
  margin-bottom: var(--sp-2);
}

.work-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  align-items: center;
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

.work-author {
  font-weight: 600;
}

.work-page h1 {
  margin-bottom: var(--sp-2);
}

/* --------------------------------------------------------------------------
   16. PROFILES, SETTINGS, ADMIN, STUDIO, MISC SHELLS
   -------------------------------------------------------------------------- */

.profile-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.profile-id {
  min-width: 0;
}

.profile-id h1 {
  margin-bottom: var(--sp-1);
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

.profile-bio {
  max-width: var(--w-read);
  color: var(--ink-2);
}

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plain-list li {
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line);
}

.plain-list li:last-child {
  border-bottom: 0;
}

/* settings -------------------------------------------------------------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: var(--sp-4);
  align-items: start;
}

.pref-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line);
}

.pref-row:last-child {
  border-bottom: 0;
}

.pref-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pref-name {
  flex: 1 1 12rem;
  min-width: 0;
  font-weight: 600;
  color: var(--ink);
}

.pref-choice {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  font-size: var(--fs-sm);
}

.pref-choice:has(input:checked) {
  border-color: var(--gold);
  background: var(--gold-ghost);
}

.danger-zone {
  border-color: var(--danger);
}

.danger-zone h2 {
  color: var(--danger);
}

/* admin ----------------------------------------------------------------- */
.admin-section {
  margin-bottom: var(--sp-5);
}

.admin-forms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: var(--sp-4);
}

.admin-search {
  flex: 1 1 16rem;
  max-width: 26rem;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  align-items: center;
}

.admin-users,
.admin-audit {
  margin-top: var(--sp-4);
}

/* studio ---------------------------------------------------------------- */
.studio-works {
  margin-top: var(--sp-4);
}

.studio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr));
  gap: var(--sp-4);
  align-items: start;
}

.studio-table {
  margin-top: var(--sp-3);
}

/* chapter editor / threadmark manager extras ---------------------------- */
.chapter-editor,
.threadmark-manager {
  margin-block: var(--sp-4);
}

.editor-actions {
  position: sticky;
  bottom: 0;
  padding: var(--sp-3);
  background: var(--header-bg);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  z-index: 20;
}

/* misc shells ----------------------------------------------------------- */
.page-head,
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.page-head h1,
.page-header h1 {
  margin-bottom: var(--sp-1);
}

.page-head .muted,
.page-header .muted {
  margin: 0;
}

.page-meta {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.breadcrumb + .page-header {
  margin-top: calc(-1 * var(--sp-2));
}

.tombstone {
  padding: var(--sp-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink-3);
  font-style: italic;
  text-align: center;
}

.adult-gate {
  max-width: 34rem;
  margin: var(--sp-6) auto;
  padding: var(--sp-5);
  border: 1px solid var(--warn);
  border-radius: var(--r-md);
  background: var(--warn-bg);
  text-align: center;
}

.adult-gate h1,
.adult-gate h2 {
  color: var(--warn);
}

.discuss-link {
  font-size: var(--fs-sm);
}

.share-box,
.bookmark-box {
  margin-block: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  font-size: var(--fs-sm);
}

.owner-tools,
.mod-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-block: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  font-size: var(--fs-xs);
}

.work-aside .card,
.work-aside > section {
  margin-bottom: var(--sp-4);
}

.stats-row + .progress {
  margin-top: var(--sp-3);
}

/* rune decorations ------------------------------------------------------ */
.rune {
  color: var(--gold);
  opacity: 0.9;
  flex: 0 0 auto;
}

/* --------------------------------------------------------------------------
   17. LANE COMPONENTS & PROGRESSIVE-ENHANCEMENT HOOKS
   Classes contributed by the feature lanes (projects/claims/receipts, search,
   moderation, milestones, studio) plus nodes created by app.js. These mostly
   compose the primitives above; rules here give them a deliberate look.
   -------------------------------------------------------------------------- */

/* empty states (components::empty_state) — must look intentional, not broken */
.empty-state {
  padding: clamp(1.5rem, 1.2rem + 1.6vw, 2.5rem);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-inset);
  text-align: center;
}

.empty-title {
  margin: 0 0 var(--sp-1);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  color: var(--ink);
}

.empty-hint {
  margin: 0 auto var(--sp-4);
  max-width: 52ch;
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

.empty-hint:last-child {
  margin-bottom: 0;
}

/* small inline bits used across lanes */
.actions,
.aside-actions,
.result-actions,
.primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

.aside-actions {
  margin-top: var(--sp-3);
}

.meta,
.stat-label {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.stat-label {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.08rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  margin-block: var(--sp-2);
}

.new-link {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--gold);
}

.less-like {
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

.given {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.details {
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.threadmark-label {
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 700;
}

/* power banners/boxes rendered on post + composer pages */
.power,
.power-banner,
.power-box {
  margin-block: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--gold-line);
  border-radius: var(--r-sm);
  background: var(--gold-ghost);
  font-size: var(--fs-sm);
}

.power-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
}

.power-box {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

/* --- search ------------------------------------------------------------- */
.search-hero,
.search-landing {
  margin-bottom: var(--sp-5);
}

.search-hero h1,
.search-landing h1 {
  font-size: var(--fs-2xl);
}

.search-anchor {
  color: inherit;
}

.search-summary,
.search-head {
  color: var(--ink-3);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-3);
}

.search-groups {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.search-group {
  min-width: 0;
}

.search-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--line);
}

.search-group-head h2 {
  margin: 0;
  font-size: var(--fs-lg);
}

.search-empty,
.search-suggestions,
.suggestion-list {
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

.suggestion-list {
  padding-left: 1.2em;
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.result-item {
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.result-item:hover {
  border-color: var(--gold-line);
}

.result-title {
  margin: 0 0 0.2rem;
  font-family: var(--font-display);
  font-size: var(--fs-md);
}

.result-title a {
  color: var(--ink);
}

.result-title a:hover {
  color: var(--gold);
}

.result-meta {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.result-excerpt {
  margin: 0.2rem 0 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-post,
.result-project,
.result-thread,
.result-work,
.result-user,
.user-hit,
.user-hit-body {
  min-width: 0;
}

.user-hit {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.user-hit-body {
  flex: 1 1 auto;
}

/* --- projects: layout, claims, milestones, receipts --------------------- */
.project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 21rem);
  gap: clamp(1.25rem, 1rem + 2vw, 2.5rem);
  align-items: start;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
  gap: var(--sp-4);
}

.project-main,
.project-side {
  min-width: 0;
}

.project-side {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.project-head {
  margin-bottom: var(--sp-3);
}

.project-card-summary {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card-stats,
.project-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.project-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.contract-card,
.claim-card,
.pool-card,
.receipt-card {
  border-color: var(--gold-line);
}

.contract-summary,
.settlement-preview {
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  font-size: var(--fs-sm);
}

.contract-table,
.small-table,
.settlement-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.contract-table th,
.contract-table td,
.small-table th,
.small-table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.contract-table th,
.small-table th {
  color: var(--ink-3);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.terms-plain {
  color: var(--ink-2);
  font-size: var(--fs-sm);
  line-height: 1.7;
}

.milestone-list,
.patron-row,
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.milestone-card,
.milestone-editor,
.milestone-vote,
.milestone-head {
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.milestone-vote {
  border-color: var(--gold-line);
  background: var(--gold-ghost);
}

.milestone-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
}

.milestone-head h3,
.milestone-head h4 {
  margin: 0;
}

.deliver-form,
.resolve-form,
.mod-hide-form,
.report-form,
.report-details {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-block: var(--sp-3);
}

.deliverable {
  color: var(--ink-2);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.acceptance,
.check-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

.acceptance ul,
.acceptance ol {
  margin: 0;
}

.timeline {
  margin-block: var(--sp-3);
  padding-left: var(--sp-4);
  border-left: 2px solid var(--line-strong);
}

.timeline-event {
  position: relative;
  padding: var(--sp-1) 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

.timeline-event::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--sp-4) - 5px);
  top: 0.7em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-deep);
}

.settled-line {
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
}

.hash-block {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

/* --- moderation / reports ---------------------------------------------- */
.report-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.report-card {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.report-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.report-reason {
  color: var(--warn);
  font-weight: 700;
  font-size: var(--fs-sm);
}

.report-subject,
.report-subject-meta,
.report-subject-title {
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

.report-subject-title {
  font-weight: 700;
}

.report-excerpt,
.report-note,
.report-resolution {
  margin-block: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

.report-resolution {
  border-inline-start: 3px solid var(--ok);
}

.report-link {
  font-size: var(--fs-xs);
}

.mod-hide {
  color: var(--danger);
  font-weight: 700;
}

/* --- studio / boards / work extras ------------------------------------- */
.studio-card,
.studio-overview {
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}

.board-search,
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-3);
}

.work-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.work-series,
.work-notes {
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

.story-header,
.story-description {
  color: var(--ink-2);
}

.chapter,
.chapter-index,
.chapter-link {
  color: inherit;
}

.markdown-body {
  color: var(--ink-2);
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.user-link {
  color: var(--ink-2);
  font-weight: 600;
}

.user-link:hover {
  color: var(--gold);
}

/* --- wallet balance cards & admin role form ----------------------------- */
.wallet-balance {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  border-top: 3px solid var(--line-strong);
}

.wallet-balance h2,
.wallet-balance .card-title {
  margin-bottom: 0;
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.wallet-usd {
  border-top-color: var(--teal);
}

.wallet-account {
  border-top-color: var(--gold);
}

.wallet-loaned {
  border-top-color: var(--info);
}

.wallet-balance .waid-amount,
.wallet-balance .big-number {
  font-size: var(--fs-2xl);
  color: var(--ink);
}

.role-form {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}

.role-form select {
  width: auto;
  min-width: 6.5rem;
  padding: 0.3rem 0.5rem;
  font-size: var(--fs-xs);
}

/* --- progressive-enhancement hooks created by app.js -------------------- */
.char-counter {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.char-counter.warn {
  color: var(--warn);
}

.char-counter.over {
  color: var(--danger);
  font-weight: 700;
}

.flash-dismiss:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* mobile nav toggle support: only collapses when the app renders a
   button[data-nav-toggle]; without it the nav stays visible/scrollable. */
@media (max-width: 900px) {
  .site-header.nav-collapsible:not(.nav-open) .main-nav {
    display: none;
  }

  .site-header.nav-collapsible .main-nav {
    overflow-x: auto;
  }
}

/* ==========================================================================
   17b. RESPONSIVE
   -------------------------------------------------------------------------- */

/* wide desktop breathing room */
@media (min-width: 1600px) {
  .container {
    max-width: var(--w-wide);
  }

  .hero {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 0.8fr);
  }
}

/* laptop / small desktop */
@media (max-width: 1080px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-stats {
    order: 2;
  }

  .stories-layout,
  .work-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-sidebar {
    position: static;
    max-height: none;
  }

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

/* tablet */
@media (max-width: 900px) {
  .header-inner {
    min-height: 3.4rem;
  }

  .main-nav {
    order: 3;
    flex: 1 0 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.15rem;
    scrollbar-width: thin;
  }

  .header-search {
    order: 2;
    flex: 1 1 10rem;
    max-width: none;
  }

  .header-user {
    order: 1;
    margin-left: auto;
    flex-wrap: nowrap;
  }

  .user-name {
    display: none;
  }

  .split {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .footer-brand {
    grid-column: 1 / -1;
  }

  body {
    font-size: 1rem;
  }

  .editor-actions {
    position: static;
  }
}

/* phone */
@media (max-width: 640px) {
  .container {
    padding-inline: 0.9rem;
  }

  .header-inner {
    gap: var(--sp-2);
  }

  .brand {
    font-size: 1.12rem;
  }

  .nav-link {
    padding: 0.34rem 0.55rem;
  }

  .hero h1 {
    font-size: clamp(1.75rem, 1.2rem + 3vw, 2.4rem);
  }

  .hero-lede {
    font-size: var(--fs-md);
  }

  .hero-ctas .btn {
    flex: 1 1 auto;
  }

  .card,
  .work-card,
  .project-card,
  .post {
    box-shadow: none;
  }

  .thread-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .thread-stats,
  .board-card-stats {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: var(--sp-2);
  }

  .board-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .footer-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-4);
  }

  .footer-legal {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-legal a {
    margin-left: 0;
  }

  .pagination .page {
    min-width: 2rem;
    height: 2rem;
  }

  .page-meta {
    display: block;
    width: 100%;
    margin-left: 0;
  }

  .reader-body,
  .chapter-body {
    font-size: 1.02rem;
    line-height: 1.78;
  }

  .auth-shell,
  .error-shell {
    align-items: flex-start;
    padding-top: var(--sp-6);
  }

  .settings-grid,
  .economy-grid,
  .wallet-grid,
  .admin-forms {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* tiny phones (360px) — never overflow horizontally */
@media (max-width: 400px) {
  .container {
    padding-inline: 0.72rem;
  }

  .header-inner {
    min-height: 3rem;
  }

  .header-search {
    order: 4;
    flex: 1 0 100%;
  }

  .header-user {
    gap: var(--sp-1);
  }

  .theme-toggle,
  .icon-link {
    width: 2rem;
    height: 2rem;
  }

  .hero-ctas .btn,
  .button-row .btn {
    flex: 1 1 100%;
  }

  .table,
  .studio-table,
  .table-compact {
    font-size: var(--fs-xs);
  }

  .table th,
  .table td,
  .studio-table th,
  .studio-table td {
    padding: var(--sp-1) var(--sp-2);
  }
}

/* --------------------------------------------------------------------------
   18. MOTION & PRINT
   -------------------------------------------------------------------------- */

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

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .btn:hover,
  .work-card:hover,
  .project-card:hover,
  .card:has(> .card-link):hover,
  .theme-toggle:hover {
    transform: none;
  }
}

@media (prefers-contrast: more) {
  :root,
  html[data-theme="dark"] {
    --ink-3: #cdbda1;
    --line: #574a37;
    --line-strong: #6d5c44;
  }

  html[data-theme="light"] {
    --ink-3: #4f402c;
    --line: #b8a482;
    --line-strong: #9c8866;
  }

  .btn,
  .card,
  .post,
  .work-card,
  .project-card {
    border-width: 2px;
  }
}

/* print: reader mode and documents only */
@media print {
  :root,
  html[data-theme="dark"],
  html[data-theme="light"] {
    --bg: #ffffff;
    --ink: #111111;
    --ink-2: #222222;
    --ink-3: #444444;
    --line: #cccccc;
    --line-strong: #999999;
    --gold: #6d470e;
  }

  body {
    background: #ffffff !important;
    color: #111111;
    font-size: 11.5pt;
  }

  .site-header,
  .site-footer,
  .flash,
  .skip-link,
  .btn,
  .button-row,
  .reader-actions,
  .reader-nav,
  .reader-pager,
  .pagination,
  .editor-actions,
  .owner-tools,
  .mod-controls,
  .theme-toggle,
  .header-search,
  .main-nav,
  .header-user,
  .tabs,
  .admin-tabs,
  .quote-block,
  .post-footer,
  script {
    display: none !important;
  }

  .container,
  .reader,
  .reader-body,
  .chapter-body,
  .prose,
  .doc-page {
    max-width: none !important;
    width: auto !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  main#main.container {
    padding: 0 !important;
  }

  a {
    color: #111111 !important;
    text-decoration: underline;
  }

  .post,
  .card,
  .reader-chapter {
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: transparent !important;
  }

  .reader-body > p:first-child::first-letter,
  .chapter-body > p:first-child::first-letter {
    float: none;
    font-size: inherit;
    color: inherit;
  }

  h1,
  h2,
  h3 {
    color: #111111 !important;
    break-after: avoid;
  }

  p,
  li {
    orphans: 3;
    widows: 3;
  }
}

/* ==== v1.1 additions: onboarding, import, library, discovery, admin ==== */

/* hidden honeypot must look like a real field to naive bots but be off-screen */
.hp-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* onboarding wizard */
.onboarding-head { margin-bottom: 0.5rem; }
.onboarding-steps { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 1.25rem; }
.onboarding-step { padding: 0.5rem 0.9rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.onboarding-step.active { border-color: var(--gold); color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, transparent); }
.onboarding-card { max-width: 52rem; }
.onboarding-skip { margin-top: 1rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 1rem; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.chip-check { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-size: 0.9rem; }
.chip-check input { accent-color: var(--gold); }
.chip-check:has(input:checked) { border-color: var(--gold); color: var(--gold); }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.8rem; margin: 0.75rem 0; }
.choice-card { display: block; text-decoration: none; color: inherit; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; transition: border-color 120ms ease, transform 120ms ease; }
.choice-card:hover, .choice-card:focus-visible { border-color: var(--gold); transform: translateY(-1px); }
.choice-card h3 { margin: 0 0 0.35rem; }
.plain-list { list-style: none; padding: 0; margin: 0.75rem 0; display: grid; gap: 0.4rem; }
.banner-onboarding { border-left: 3px solid var(--gold); }

/* import flow */
.import-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1rem; margin: 1rem 0; }
.import-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.9rem; }
.import-meta-grid .field-wide { grid-column: 1 / -1; }
.import-chapter-list { margin: 0.75rem 0 0; padding-left: 1.4rem; display: grid; gap: 0.5rem; }
.import-chapter-peek { color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0 0; }
.hidden-textarea { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.checkbox-field { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-field input { width: auto; }
.field-hint { color: var(--muted); font-size: 0.82rem; }

/* small helpers used by new pages */
.page-head .lede { max-width: 60rem; }
.muted.small, .small.muted { font-size: 0.85rem; }
.hidden { display: none !important; }
.notice-ok { border-left: 3px solid var(--ok, #6fbf73); }
.notice-error { border-left: 3px solid var(--err, #d46767); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.8rem; }
.stat-card { border: 1px solid var(--line); border-radius: 12px; padding: 0.9rem 1rem; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 600; color: var(--gold); }
.stat-card .stat-label { color: var(--muted); font-size: 0.85rem; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.work-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag-chip { display: inline-block; padding: 0.2rem 0.6rem; border: 1px solid var(--line); border-radius: 999px; font-size: 0.85rem; text-decoration: none; }
.tag-chip:hover { border-color: var(--gold); color: var(--gold); }
.status-pill { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.78rem; border: 1px solid var(--line); }
.status-pill.ok { color: var(--ok, #6fbf73); border-color: currentColor; }
.status-pill.bad { color: var(--err, #d46767); border-color: currentColor; }

@media (max-width: 480px) {
  .import-columns { grid-template-columns: 1fr; }
  .onboarding-steps { gap: 0.35rem; }
  .onboarding-step { padding: 0.4rem 0.6rem; font-size: 0.82rem; }
}

/* --- v1.2 reader polish: comment sorting, staff comments, keyboard hint, nudge --- */
.comments-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.75rem; }
.comments-head h2 { margin: 0; }
.comment-sort { margin-left: auto; }
.comment-staff { border-left: 3px solid var(--border-strong, #5b6b83); background: color-mix(in srgb, var(--surface, #17202c) 88%, #4863a0 12%); }
.comment-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.35rem; }
.comment-like, .comment-delete {
  background: none; border: 1px solid var(--border, #2c3a4d); border-radius: 999px;
  color: var(--muted, #9fb0c6); cursor: pointer; font: inherit; font-size: 0.8rem; padding: 0.1rem 0.55rem;
}
.comment-like:hover, .comment-delete:hover { color: var(--fg, #e8eef7); border-color: var(--border-strong, #5b6b83); }
.comment-like.liked { color: #ef7d9b; border-color: #ef7d9b; }
.reader-shortcuts kbd {
  background: var(--surface-2, #1d2836); border: 1px solid var(--border, #2c3a4d);
  border-radius: 4px; font-size: 0.75rem; padding: 0 0.3rem;
}
.reader-nudge { margin-top: 1rem; }
.reader-nudge-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.badge-staff { background: #4863a0; color: #eef2ff; }

/* --- v1.2 notification center filters --- */
.notification-filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin: 0.5rem 0 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.chip {
  border: 1px solid var(--border, #2c3a4d); border-radius: 999px; padding: 0.12rem 0.6rem;
  font-size: 0.8rem; color: var(--muted, #9fb0c6); text-decoration: none;
}
.chip:hover { color: var(--fg, #e8eef7); border-color: var(--border-strong, #5b6b83); }
.chip.active { background: var(--surface-2, #1d2836); color: var(--fg, #e8eef7); border-color: var(--border-strong, #5b6b83); }
.kind-tag {
  border-radius: 4px; background: var(--surface-2, #1d2836); padding: 0 0.3rem;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.02em;
}

/* --- v1.3 hub global bar: realms/filters entry on every classic page --- */
.hub-global-bar {
  border-bottom: 1px solid var(--line, #362e23);
  background: var(--surface, #1a1611);
  font-size: 0.82rem;
}
.hub-global-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  padding: 0.3rem 1rem;
  min-height: 34px;
}
.hub-global-label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3, #b3a48c);
}
.hub-bar-link {
  color: var(--ink-2, #d6c8b0);
  text-decoration: none;
  padding: 0.15rem 0.1rem;
  border-bottom: 1px solid transparent;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
}
.hub-bar-link:hover { color: var(--gold-bright, #f7e6b9); border-bottom-color: var(--gold-line, rgba(232,201,135,.42)); }
.hub-bar-link.active { color: var(--gold-bright, #f7e6b9); border-bottom-color: var(--gold-line, rgba(232,201,135,.42)); }
.hub-bar-more { margin-left: auto; color: var(--ink-3, #b3a48c); }

/* ---------------------------------------------------------------------------
   v1.4 Research realm (RES lane) — preprint archive: moderated, not peer
   reviewed. Plain system surfaces reuse the existing tokens/classes.
--------------------------------------------------------------------------- */
.research-page-head { max-width: 70ch; }
.research-page-head h1 { margin-bottom: 0.3rem; }
.research-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.6rem; }
.research-actions .btn { min-height: 44px; }
.research-notice {
  border: 1px solid var(--gold-line, rgba(232,201,135,.42));
  background: var(--gold-ghost, rgba(232,201,135,.06));
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  max-width: 90ch;
}
.research-notice p { margin: 0; }
.research-search { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; margin: 1rem 0; }
.research-search .field { min-width: 240px; flex: 1 1 320px; }
.research-search input { min-height: 44px; }
.research-field-grid { list-style: none; padding: 0; margin: 0.6rem 0 1.2rem; display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.research-field-tile {
  display: flex; flex-direction: column; gap: 0.25rem; padding: 0.6rem 0.7rem;
  border: 1px solid var(--line, rgba(255,255,255,.12)); border-radius: 10px; min-height: 44px;
  text-decoration: none; color: inherit;
}
.research-field-tile:hover { border-color: var(--gold-line, rgba(232,201,135,.42)); }
.research-list { list-style: none; padding: 0; margin: 0.8rem 0; display: grid; gap: 0.8rem; }
.research-card { border: 1px solid var(--line, rgba(255,255,255,.12)); border-radius: 12px; padding: 0.9rem 1rem; }
.research-card-head { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.35rem; }
.research-card-title { margin: 0.1rem 0 0.3rem; font-size: 1.08rem; }
.research-card-title a { text-decoration: none; }
.research-card-meta { margin: 0.1rem 0; }
.research-fields { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.25rem 0; }
.research-field-chip { text-decoration: none; }
.research-labels { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
.research-paper { max-width: 80ch; }
.research-paper-head h1 { margin: 0.4rem 0 0.3rem; }
.research-authors { font-size: 1.05rem; margin: 0.2rem 0; }
.research-paper-meta { margin: 0.2rem 0; }
.research-dl { display: grid; grid-template-columns: minmax(130px, max-content) 1fr; gap: 0.35rem 0.9rem; margin: 0; }
.research-dl dt { color: var(--ink-3, #b3a48c); }
.research-dl dd { margin: 0; }
.research-version-list, .research-citation-list, .research-review-list { margin: 0.4rem 0; padding-left: 1.2rem; }
.research-version-list li, .research-citation-list li, .research-review-list li { margin: 0.35rem 0; }
.research-review { border-top: 1px solid var(--line, rgba(255,255,255,.1)); padding-top: 0.5rem; }
.research-review-head { margin: 0 0 0.25rem; }
.research-form { max-width: 80ch; }
.research-form input[type="text"], .research-form textarea, .research-form select { min-height: 44px; }
.research-pdf input[type="file"] { min-height: 44px; }
.textarea[readonly], textarea[readonly] { opacity: 0.92; }
.research-mod-card { border-color: var(--gold-line, rgba(232,201,135,.3)); }
.research-reject { border: 1px solid var(--danger, #c0504d); border-radius: 10px; padding: 0.7rem 0.9rem; margin: 0.8rem 0; }
.research-pending { border: 1px solid var(--gold-line, rgba(232,201,135,.42)); border-radius: 10px; padding: 0.7rem 0.9rem; margin: 0.8rem 0; }
.research-cite .field textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86rem; }
@media (max-width: 640px) {
  .research-dl { grid-template-columns: 1fr; }
  .research-actions .btn { width: 100%; justify-content: center; }
}

/* ---------------------------------------------------------------------------
   v1.4 Mega-projects realm (MEGA lane) — planet scene hook + division accents
--------------------------------------------------------------------------- */
.mega-realm { position: relative; }
.mega-realm::before {
  content: "";
  position: absolute; inset: -2rem -2rem auto -2rem; height: 22rem;
  background: radial-gradient(60% 80% at 20% 0%, rgba(120, 180, 255, 0.12), transparent 70%),
              radial-gradient(50% 70% at 85% 10%, rgba(232, 201, 135, 0.10), transparent 70%);
  pointer-events: none; z-index: -1;
}
[data-scene="planet"] .mega-hero h1 { text-wrap: balance; }
.mega-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.mega-actions .btn { min-height: 44px; }
.mega-notice { border: 1px solid var(--gold-line, rgba(232,201,135,.42)); background: var(--gold-ghost, rgba(232,201,135,.06)); border-radius: 10px; padding: 0.8rem 1rem; margin: 1rem 0; max-width: 100ch; }
.mega-notice p { margin: 0; }
.mega-division-grid { list-style: none; padding: 0; margin: 0.7rem 0 1.4rem; display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.mega-division-tile { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.8rem 0.9rem; border: 1px solid var(--line, rgba(255,255,255,.12)); border-radius: 12px; text-decoration: none; color: inherit; min-height: 44px; }
.mega-division-tile:hover { border-color: var(--gold-line, rgba(232,201,135,.42)); }
.mega-division-glyph { font-size: 1.2rem; color: var(--gold); }
.mega-list { list-style: none; padding: 0; margin: 0.8rem 0; display: grid; gap: 0.9rem; }
.mega-card { border: 1px solid var(--line, rgba(255,255,255,.12)); border-radius: 12px; padding: 0.9rem 1rem; }
.mega-card-head { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-bottom: 0.3rem; }
.mega-card-title { margin: 0.1rem 0 0.3rem; font-size: 1.1rem; }
.mega-card-summary { margin: 0.1rem 0 0.4rem; }
.mega-card-facts { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; margin: 0.4rem 0; }
.mega-card-facts div { display: flex; gap: 0.35rem; align-items: baseline; }
.mega-card-facts dt { color: var(--ink-3, #b3a48c); }
.mega-card-facts dd { margin: 0; }
.mega-card-actions .btn { min-height: 44px; }
.mega-project-panels { margin: 1.5rem 0; display: grid; gap: 0.9rem; }
.mega-project-panels .card { padding: 0.9rem 1rem; }
.mega-rights-block { border: 1px solid var(--danger, #c0504d); border-radius: 10px; padding: 0.7rem 0.9rem; }
.mega-jump { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.mega-tree-list, .mega-phase-list, .mega-team-list, .mega-links-list { list-style: none; padding: 0; margin: 0.4rem 0; }
.mega-tree-list li, .mega-phase-list li, .mega-team-list li, .mega-links-list li { padding: 0.45rem 0; border-top: 1px solid var(--line, rgba(255,255,255,.1)); }
.mega-phase-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; }
.mega-phase-pos { min-width: 4.5rem; }
.mega-engine-note { max-width: 100ch; }
@media (max-width: 640px) {
  .mega-actions .btn { width: 100%; justify-content: center; }
  .mega-card-facts { flex-direction: column; gap: 0.2rem; }
}

/* ==========================================================================
   Private messaging (R-11, #308) — inbox + 1:1 thread.
   Additive surface styles only; the shared card/btn/empty-state vocabulary
   does the rest. Mobile-first: one column at 360, form beside inbox at 768+.
   ========================================================================== */
.pm-layout { display: grid; gap: 1rem; margin: 1rem 0 2rem; }
@media (min-width: 768px) {
  .pm-layout { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: start; }
}
.pm-new { padding: 1rem 1.1rem; }
.pm-new h2 { margin-top: 0; font-size: 1.05rem; }
.pm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.pm-row { border: 1px solid var(--line, rgba(255,255,255,.12)); border-radius: 12px; }
.pm-row.is-unread { border-color: var(--gold-line, rgba(232,201,135,.5)); }
.pm-row-link { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.75rem 0.85rem; color: inherit; text-decoration: none; min-height: 44px; }
.pm-row-link:hover, .pm-row-link:focus-visible { background: rgba(255,255,255,.03); border-radius: 12px; }
.pm-row-main { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; flex: 1; }
.pm-row-head { display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; align-items: baseline; }
.pm-row-handle { font-size: 0.85em; }
.pm-row-time { margin-left: auto; white-space: nowrap; }
.pm-row-preview { display: block; color: var(--ink-2, #d8cdbb); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-unread { flex: none; min-width: 1.6rem; height: 1.6rem; padding: 0 0.4rem; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; background: var(--gold, #e8c987); color: #1a1712; font-weight: 700; font-size: 0.85rem; }
.pm-thread { padding: 1rem 1.1rem; margin: 1rem 0; }
.pm-thread-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.pm-msg { max-width: 46rem; border: 1px solid var(--line, rgba(255,255,255,.12)); border-radius: 12px; padding: 0.6rem 0.85rem; }
.pm-msg.is-mine { margin-left: auto; border-color: var(--gold-line, rgba(232,201,135,.42)); background: var(--gold-ghost, rgba(232,201,135,.06)); }
.pm-msg.is-deleted { opacity: .75; border-style: dashed; }
.pm-msg-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; margin-bottom: 0.2rem; }
.pm-msg-who { font-weight: 600; }
.pm-msg-time { margin-left: auto; white-space: nowrap; }
.pm-msg-body { margin: 0.15rem 0 0.35rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.pm-msg-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.pm-report summary { cursor: pointer; color: var(--ink-3, #b3a48c); font-size: 0.9rem; min-height: 24px; }
.pm-report form { margin-top: 0.5rem; }
.pm-msg.is-deleted .pm-msg-time, .pm-deleted .pm-msg-time { margin-left: 0.6rem; }
.pm-older { display: flex; justify-content: center; margin-bottom: 0.8rem; }
.pm-composer { margin-top: 1rem; padding: 1rem 1.1rem; }
.pm-composer textarea { width: 100%; min-height: 6rem; }
.pm-composer-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between; }
.pm-thread-head h1 { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .pm-layout { grid-template-columns: 1fr; }
  .pm-msg { max-width: 100%; }
  .pm-composer-actions .btn { width: 100%; }
  .pm-row-time { margin-left: 0; }
}

/* #313 ACC-02 — header account/profile switcher (native <details>, no JS). */
.account-switcher { position: relative; }
.account-switcher > summary { list-style: none; cursor: pointer; }
.account-switcher > summary::-webkit-details-marker { display: none; }
.switcher-caret { margin-left: .3rem; opacity: .7; font-size: .8em; }
.account-popover {
  position: absolute; right: 0; top: calc(100% + .45rem); z-index: 60;
  min-width: 17rem; max-width: min(22rem, calc(100vw - 1.5rem));
  padding: .6rem; display: grid; gap: .35rem;
  background: var(--panel, #14171c); border: 1px solid var(--line, #2b3038);
  border-radius: 12px; box-shadow: 0 18px 48px rgba(0,0,0,.45);
}
.popover-kicker {
  margin: .1rem .35rem .2rem; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; opacity: .7;
}
.switch-form { margin: 0; }
.switch-profile {
  width: 100%; display: flex; align-items: center; gap: .5rem;
  padding: .45rem .5rem; min-height: 44px; text-align: left;
  background: transparent; color: inherit; border: 1px solid transparent;
  border-radius: 9px; cursor: pointer;
}
.switch-profile:hover, .switch-profile:focus-visible {
  background: rgba(232,201,135,.09); border-color: rgba(232,201,135,.28);
}
.switch-profile[aria-current="true"] { border-color: rgba(232,201,135,.45); background: rgba(232,201,135,.12); }
.switch-name { font-weight: 600; }
.switch-handle { font-size: .8rem; margin-left: auto; }
.popover-links { display: grid; gap: .15rem; padding: .3rem; border-top: 1px solid var(--line, #2b3038); }
.popover-links a { padding: .4rem .5rem; min-height: 36px; border-radius: 8px; display: flex; align-items: center; }
.popover-links a:hover { background: rgba(232,201,135,.09); }
.account-switcher[open] .switcher-caret { transform: rotate(180deg); }
@media (max-width: 720px) {
  .account-popover {
    position: fixed; left: .5rem; right: .5rem; bottom: .5rem; top: auto;
    max-height: 72vh; overflow-y: auto; border-radius: 16px;
  }
}

/* ==========================================================================
   R-08 (#305) — post permalinks and one-level replies.
   Flat is the default view; the nested toggle indents one reply level only.
   ========================================================================== */
.post-reply-chip { margin: 0.15rem 0 0; color: var(--ink-3, #b3a48c); }
.post-reply-chip a { text-decoration: underline; }
.post-permalink { font-variant-numeric: tabular-nums; }
.post-list-nested .post-reply {
  margin-left: 2.25rem;
  border-left: 2px solid var(--line, #3a3328);
  padding-left: 0.85rem;
}
.post-focus { box-shadow: inset 3px 0 0 var(--gold, #e8c987); }
.thread-view-toggle { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; margin: 0.6rem 0; }
.thread-view-toggle .btn { min-height: 28px; }
@media (max-width: 480px) {
  .post-list-nested .post-reply { margin-left: 0.75rem; padding-left: 0.55rem; }
  .thread-view-toggle { gap: 0.35rem; }
}

/* ==========================================================================
   Chats and rooms (R-10 / #307) — public, unencrypted, buffered.
   Additive surface styles; reuses the shared card/btn/badge/empty-state
   vocabulary. Mobile-first: one column everywhere, room log is fluid.
   ========================================================================== */
.chat-disclosure { border: 1px solid var(--gold-line, rgba(232,201,135,.42)); background: var(--gold-ghost, rgba(232,201,135,.06)); border-radius: 12px; padding: .8rem 1rem; margin: 1rem 0; max-width: 100ch; }
.chat-disclosure p { margin: 0 0 .35rem; }
.chat-disclosure p:last-child { margin-bottom: 0; }
.chat-head h1 { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.chat-head-actions, .room-mod { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.chat-slow-input { width: 5.5rem; min-height: 36px; }
.chat-create { padding: 1rem 1.1rem; margin: 1rem 0; }
.chat-create h2 { margin-top: 0; font-size: 1.05rem; }
.chat-list-section { margin: 1.4rem 0; }
.chat-index-list, .chat-room-grid { list-style: none; margin: .8rem 0; padding: 0; display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.chat-index-card, .chat-room-card { padding: .85rem 1rem; }
.chat-index-title, .chat-room-card-link { display: inline-flex; gap: .5rem; align-items: center; min-height: 44px; color: inherit; text-decoration: none; }
.chat-index-title:hover, .chat-room-card-link:hover { text-decoration: underline; }
.chat-room { padding: 1rem 1.05rem; margin: 1rem 0; }
.chat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.chat-msg { border: 1px solid var(--line, rgba(255,255,255,.12)); border-radius: 10px; padding: .5rem .75rem; max-width: 60rem; }
.chat-msg.is-mine { border-color: var(--gold-line, rgba(232,201,135,.42)); background: var(--gold-ghost, rgba(232,201,135,.05)); }
.chat-msg.is-deleted { opacity: .7; border-style: dashed; }
.chat-msg-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.chat-msg-who { font-weight: 600; }
.chat-msg-time { margin-left: auto; white-space: nowrap; }
.chat-msg-body { margin: .15rem 0 .3rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg-deleted { margin: .2rem 0; font-style: italic; }
.chat-msg-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.chat-msg-actions .report-link { font-size: .85rem; color: var(--ink-3, #b3a48c); }
.chat-older { display: flex; justify-content: center; margin-bottom: .8rem; }
.chat-composer { margin: 1rem 0 2rem; padding: 1rem 1.05rem; }
.chat-composer textarea { width: 100%; min-height: 5rem; }
.chat-composer-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.chat-archived-note, .chat-join { padding: .9rem 1.05rem; margin: 1rem 0; }
@media (max-width: 480px) {
  .chat-index-list, .chat-room-grid { grid-template-columns: 1fr; }
  .chat-msg { max-width: 100%; }
  .chat-composer-actions .btn { width: 100%; }
  .chat-msg-time { margin-left: 0; }
}

/* ==========================================================================
   /j jobs bridge (R-13 / #310) — directory, detail, post form, submission card.
   Additive; reuses shared card/btn/chip/badge/empty-state vocabulary.
   ========================================================================== */
.jobs-banner { border: 1px solid var(--gold-line, rgba(232,201,135,.42)); background: var(--gold-ghost, rgba(232,201,135,.06)); border-radius: 10px; padding: .7rem 1rem; margin: 1rem 0; max-width: 100ch; }
.jobs-banner-offline { border-color: var(--warning, #d8a657); }
.jobs-banner-stale { border-style: dashed; }
.jobs-filters { padding: 1rem 1.1rem; margin: 1rem 0; }
.jobs-list { list-style: none; margin: 1rem 0 2rem; padding: 0; display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.jobs-card { padding: .9rem 1rem; display: flex; flex-direction: column; gap: .4rem; }
.jobs-card-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; justify-content: space-between; }
.jobs-card-title { font-weight: 650; font-size: 1.05rem; color: inherit; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.jobs-card-title:hover { text-decoration: underline; }
.jobs-card-summary { margin: 0; }
.jobs-card-meta { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: baseline; }
.jobs-budget { font-weight: 600; color: var(--gold, #e8c987); }
.jobs-provenance { margin: .3rem 0 0; }
.jobs-detail { padding: 1.1rem 1.2rem; margin: 1rem 0; }
.jobs-description { white-space: pre-wrap; overflow-wrap: anywhere; }
.jobs-submission { padding: 1rem 1.1rem; margin: 1rem 0; border-left: 3px solid var(--gold, #e8c987); }
.jobs-submission.is-failed { border-left-color: var(--danger, #c0504d); }
.jobs-submission.is-sent { border-left-color: var(--ok, #6aa06a); }
.jobs-submission h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.jobs-form { padding: 1rem 1.1rem; margin: 1rem 0; max-width: 70ch; }
.jobs-form textarea { width: 100%; }
.jobs-detail-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (max-width: 480px) {
  .jobs-list { grid-template-columns: 1fr; }
  .jobs-detail-actions .btn { width: 100%; }
}

/* ===================================================================

   Thread navigator (LY-09 / #104): one navigator for every thread kind.
   Desktop: sticky rail beside the thread. Mobile: native <details> collapse,
   no JavaScript dependency.
   ========================================================================== */
.thread-nav-rail { margin: 0 0 1rem; }
.thread-nav-details { border: 1px solid var(--line, rgba(255,255,255,.12)); border-radius: 10px; padding: .4rem .7rem; background: var(--surface-2, rgba(255,255,255,.03)); }
.thread-nav-summary { cursor: pointer; font-weight: 600; padding: .35rem 0; list-style-position: inside; }
.thread-nav-summary:focus-visible { outline: 2px solid var(--gold, #e8c987); outline-offset: 2px; }
.thread-nav-body { padding: .25rem 0 .6rem; }
.thread-nav-title { margin: 0 0 .15rem; font-weight: 600; }
.thread-nav-quick { display: flex; flex-wrap: wrap; gap: .25rem .5rem; font-size: .9rem; padding: .3rem 0 .5rem; }
.thread-nav-quick a { min-height: 32px; display: inline-flex; align-items: center; }
.nav-section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; margin: .6rem 0 .25rem; color: var(--muted, #a9a291); }
.thread-nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; max-height: 340px; overflow: auto; }
.thread-nav-list a { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; padding: .4rem .45rem; border-radius: 6px; text-decoration: none; min-height: 40px; align-items: center; }
.thread-nav-list a:hover { background: rgba(255,255,255,.06); }
.thread-nav-list a[aria-current="page"] { background: rgba(232,201,135,.12); border-left: 3px solid var(--gold, #e8c987); font-weight: 600; }
.thread-nav-pages { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.thread-nav-pages a { justify-content: center; }
@media (min-width: 1024px) {
  .thread-nav-rail { float: right; width: 300px; margin: 0 0 1rem 1.2rem; position: sticky; top: 80px; z-index: 2; }
  .thread-nav-details > summary { display: none; }
  .thread-nav-details:not([open]) > .thread-nav-body { display: block; } /* always open on desktop */
  .thread-nav-body { padding-top: 0; }
  .thread-nav-list { max-height: 52vh; }
}
@media (max-width: 1023px) {
  .thread-nav-rail { position: static; width: auto; float: none; }
}
=======
/* table mode (MK-05 / #153) ------------------------------------------------ */
.table-scroll{width:100%;overflow-x:auto;border:1px solid var(--line, #2a2f3a);border-radius:10px;background:var(--panel, #141820)}
.works-table{width:100%;border-collapse:collapse;font-size:.86rem}
.works-table caption{text-align:left}
.works-table th,.works-table td{padding:.55rem .7rem;border-bottom:1px solid var(--line, #2a2f3a);vertical-align:top;white-space:nowrap}
.works-table thead th{position:sticky;top:0;background:var(--panel, #141820);font-weight:600;text-align:left}
.works-table thead th a{color:inherit;text-decoration:none}
.works-table thead th a:hover,.works-table thead th a:focus-visible{text-decoration:underline}
.works-table .num{text-align:right;font-variant-numeric:tabular-nums}
.works-table tbody tr:hover{background:rgba(255,255,255,.03)}
.works-table-title{font-weight:600}
.sort-arrow,.sort-chip{margin-left:.25rem;font-size:.72em;opacity:.85}
.sort-chip{border:1px solid currentColor;border-radius:999px;padding:0 .2rem}
.table-note{color:var(--muted, #8a93a5);font-size:.78rem;margin:.5rem 0 0}
.table-mobile-fallback{display:none}
@media (max-width:767px){
  .table-scroll, .works-table{display:none}
  .table-mobile-fallback{display:block}
}
/* v2 shell: table mode reuses its dense table; the numbered chain + note are shared */
html[data-design="v2"] .works-table th a{color:inherit;text-decoration:none}

/* #41 creator analytics: aggregate-only studio charts (server-rendered SVG). */
.studio-chart { margin: 0; padding: 0; }
.studio-chart-svg { width: 100%; height: auto; display: block; background: var(--surface-2, #1b1712); border-radius: 8px; }
.studio-chart .chart-axis { stroke: var(--line, #3a332a); stroke-width: 1; }
.studio-chart .chart-bar { fill: var(--gold, #e8c987); opacity: 0.85; }
.studio-chart .chart-line { fill: none; stroke-width: 2; }
.studio-chart .chart-line-kudos { stroke: var(--gold, #e8c987); }
.studio-chart .chart-line-comments { stroke: var(--teal, #8fc9bf); }
.studio-analytics-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.analytics-works .num { text-align: right; white-space: nowrap; }
.analytics-top-list li { margin-bottom: .35rem; }
@media (max-width: 820px) {
  .studio-analytics-grid { grid-template-columns: 1fr; }
  .analytics-works th:nth-child(3), .analytics-works td:nth-child(3),
  .analytics-works th:nth-child(4), .analytics-works td:nth-child(4),
  .analytics-works th:nth-child(5), .analytics-works td:nth-child(5) { display: none; }
}

/* #31 edit-history diff ------------------------------------------------ */
.diff-block h2{text-transform:capitalize}
pre.diff{overflow-x:auto;background:var(--panel,#141820);border:1px solid var(--line,#2a2f3a);border-radius:8px;padding:.6rem .8rem;font-size:.82rem;line-height:1.45}
.diff-line{display:block;white-space:pre-wrap}
.diff-add{color:#7fd18b;background:rgba(60,160,90,.12)}
.diff-del{color:#e08585;background:rgba(190,60,60,.12)}
.diff-same{color:var(--muted,#8a93a5)}
.draft-tools textarea{width:100%}
