/* ==========================================================================
   QuillCraft — main stylesheet
   Plain CSS, no build step. Custom properties for theming, light/dark aware.
   ========================================================================== */

:root {
  --ink:            #1d2126;
  --ink-soft:       #5b636d;
  --ink-faint:      #8b929b;
  --paper:          #ffffff;
  --paper-sunk:     #f5f6f8;
  --paper-raised:   #ffffff;
  --line:           #e3e6ea;
  --line-strong:    #cdd3da;

  --accent:         #3f5f8f;
  --accent-hover:   #34527d;
  --accent-soft:    #eef2f8;
  --accent-ink:     #ffffff;

  --good:           #2f7d5b;
  --good-soft:      #e9f5ef;
  --warn:           #9a6b1f;
  --warn-soft:      #fdf3e2;
  --bad:            #a33a3a;
  --bad-soft:       #fbeded;

  --radius:         8px;
  --radius-lg:      12px;
  --shadow:         0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lift:    0 4px 12px rgba(16, 24, 40, .08);

  --wrap:           1140px;
  --gap:            20px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:          #e8eaed;
    --ink-soft:     #a8b0ba;
    --ink-faint:    #79818c;
    --paper:        #16191d;
    --paper-sunk:   #1c2026;
    --paper-raised: #21262d;
    --line:         #2c323a;
    --line-strong:  #3d444d;

    --accent:       #7ea3d8;
    --accent-hover: #96b6e4;
    --accent-soft:  #1e2733;
    --accent-ink:   #10141a;

    --good:         #6dbd96;
    --good-soft:    #16261f;
    --warn:         #d8ac68;
    --warn-soft:    #2a2114;
    --bad:          #e08585;
    --bad-soft:     #2b1919;

    --shadow:       0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lift:  0 4px 14px rgba(0, 0, 0, .5);
  }
}

/* --------------------------------------------------------------- base ---- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper-sunk);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; }
h1 { font-size: 1.9rem; letter-spacing: -.02em; }
h2 { font-size: 1.4rem; letter-spacing: -.01em; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

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

code, pre { font-family: var(--font-mono); font-size: .9em; }
code { background: var(--paper-sunk); padding: .15em .4em; border-radius: 4px; }
pre { background: var(--paper-sunk); padding: 14px; border-radius: var(--radius); overflow-x: auto; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

/* ------------------------------------------------------------- header ---- */

.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}

.site-header__inner {
  display: flex; align-items: center; gap: 24px;
  min-height: 62px;
}

.site-logo { display: flex; align-items: center; gap: 10px; color: var(--ink); flex-shrink: 0; }
.site-logo:hover { text-decoration: none; }

.site-logo__mark {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 700;
  flex-shrink: 0;
}

.site-logo__name { font-weight: 650; font-size: 1.05rem; letter-spacing: -.01em; }

.site-nav { margin-right: auto; }
.site-nav ul { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: 8px 12px; border-radius: var(--radius);
  color: var(--ink-soft); font-size: .94rem; font-weight: 500;
}
.site-nav a:hover { background: var(--paper-sunk); color: var(--ink); text-decoration: none; }
.site-nav a.is-active { background: var(--accent-soft); color: var(--accent); }

.site-account { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.account-chip {
  width: 34px; height: 34px; border-radius: 50%; overflow: hidden;
  background: var(--accent-soft); display: grid; place-items: center;
  border: 1px solid var(--line);
}
.account-chip img { width: 100%; height: 100%; object-fit: cover; }
.account-chip__initials { font-size: .8rem; font-weight: 650; color: var(--accent); }

.nav-toggle { display: none; }

@media (max-width: 800px) {
  .site-header__inner { flex-wrap: wrap; gap: 12px; }
  .nav-toggle {
    display: block; order: 3; margin-left: auto;
    background: none; border: 1px solid var(--line);
    border-radius: var(--radius); padding: 8px 10px; cursor: pointer;
  }
  .nav-toggle__bars, .nav-toggle__bars::before, .nav-toggle__bars::after {
    display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px;
  }
  .nav-toggle__bars { position: relative; }
  .nav-toggle__bars::before, .nav-toggle__bars::after { content: ""; position: absolute; }
  .nav-toggle__bars::before { top: -6px; }
  .nav-toggle__bars::after  { top: 6px; }

  .site-nav {
    order: 5; flex-basis: 100%; margin-right: 0;
    display: none; padding-bottom: 12px;
  }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; }
  .site-account { order: 4; }
}

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

.site-main { padding: 28px 0 56px; min-height: 60vh; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 24px;
}
.page-head__text { min-width: 0; }
.page-head h1 { margin-bottom: 4px; }
.page-head__sub { color: var(--ink-soft); margin: 0; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: var(--gap);
}
.panel > :last-child { margin-bottom: 0; }
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.panel__head h2, .panel__head h3 { margin: 0; }

.panel--upgrade { max-width: 620px; margin: 40px auto; text-align: center; }
.upgrade-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.grid { display: grid; gap: var(--gap); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }

@media (max-width: 900px) {
  .grid--3, .grid--4, .grid--sidebar { grid-template-columns: repeat(2, 1fr); }
  .grid--sidebar { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
}

.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row--between { justify-content: space-between; }
.muted { color: var(--ink-soft); }
.small { font-size: .88rem; }
.tiny  { font-size: .8rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ------------------------------------------------------------ buttons ---- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--paper-sunk); color: var(--ink);
  font: inherit; font-size: .93rem; font-weight: 550; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn:hover { text-decoration: none; background: var(--line); }
.btn:disabled, .btn.is-disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); color: var(--accent-ink); }

.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover { background: var(--paper-sunk); }

.btn--danger { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn--danger:hover { background: var(--bad); color: #fff; }

.btn--small { padding: 6px 11px; font-size: .86rem; }
.btn--block { display: flex; width: 100%; }

.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* -------------------------------------------------------------- forms ---- */

.form { max-width: 620px; }
.form--wide { max-width: none; }

.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }

.field > label, .field__label {
  display: block; font-weight: 550; font-size: .92rem; margin-bottom: 6px;
}

.field__hint { display: block; color: var(--ink-soft); font-size: .85rem; margin-top: 5px; }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  font: inherit; font-size: .95rem;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }

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

input[type=file] { font-size: .9rem; }

.field--error input, .field--error select, .field--error textarea { border-color: var(--bad); }
.field-error { display: block; color: var(--bad); font-size: .85rem; margin-top: 5px; }

.field--check { display: flex; align-items: flex-start; gap: 9px; }
.field--check input { width: auto; margin-top: 3px; flex-shrink: 0; }
.field--check label { font-weight: 450; margin: 0; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.form-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line);
}

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 20px;
}
.filters .field { margin-bottom: 0; }
.filters select, .filters input { min-width: 150px; width: auto; }

/* -------------------------------------------------------------- flash ---- */

.flash-stack { margin-bottom: 20px; }
.flash {
  padding: 11px 15px; border-radius: var(--radius);
  border-left: 3px solid; margin-bottom: 8px; font-size: .94rem;
}
.flash--success { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.flash--error   { background: var(--bad-soft);  border-color: var(--bad);  color: var(--bad); }
.flash--warning { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.flash--info    { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.notice {
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--paper-sunk); border: 1px solid var(--line);
  font-size: .93rem;
}
.notice--warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

/* ------------------------------------------------------------- badges ---- */

.tag, .pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  font-size: .78rem; font-weight: 550; line-height: 1.5;
  background: var(--paper-sunk); color: var(--ink-soft);
}
.pill--good    { background: var(--good-soft); color: var(--good); }
.pill--warn    { background: var(--warn-soft); color: var(--warn); }
.pill--bad     { background: var(--bad-soft);  color: var(--bad); }
.pill--accent  { background: var(--accent-soft); color: var(--accent); }

.verified-mark { color: var(--accent); font-size: .8em; }

/* -------------------------------------------------------------- cards ---- */

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: var(--gap); }

.book-card { display: block; color: inherit; }
.book-card:hover { text-decoration: none; }
.book-card:hover .book-card__title { color: var(--accent); }

.book-card__cover {
  aspect-ratio: 2 / 3; width: 100%;
  background: var(--paper-sunk); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 9px;
  box-shadow: var(--shadow);
  transition: box-shadow .15s ease, transform .15s ease;
}
.book-card:hover .book-card__cover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.book-card__cover img { width: 100%; height: 100%; object-fit: cover; }

.book-card__placeholder {
  width: 100%; height: 100%; display: grid; place-items: center; padding: 14px;
  text-align: center; font-family: var(--font-display); font-size: .9rem;
  color: var(--ink-faint); line-height: 1.3;
}

.book-card__title { font-weight: 600; font-size: .95rem; line-height: 1.35; margin: 0 0 2px; }
.book-card__author { color: var(--ink-soft); font-size: .86rem; margin: 0; }

.author-card {
  display: flex; gap: 13px; align-items: center;
  padding: 14px; border: 1px solid var(--line);
  border-radius: var(--radius-lg); background: var(--paper-raised);
  color: inherit;
}
.author-card:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow); }

.avatar {
  width: 48px; height: 48px; border-radius: 50%; overflow: hidden;
  background: var(--accent-soft); flex-shrink: 0;
  display: grid; place-items: center;
  font-weight: 650; color: var(--accent);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 96px; height: 96px; font-size: 1.7rem; }
.avatar--sm { width: 32px; height: 32px; font-size: .75rem; }

/* ------------------------------------------------------------- tables ---- */

.table-wrap { overflow-x: auto; margin: 0 -2px; }

table.data {
  width: 100%; border-collapse: collapse; font-size: .92rem;
  min-width: 560px;
}
table.data th, table.data td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--line); vertical-align: middle;
}
table.data th {
  font-weight: 600; font-size: .82rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-soft);
  background: var(--paper-sunk); white-space: nowrap;
}
table.data tbody tr:hover { background: var(--paper-sunk); }
table.data td.numeric, table.data th.numeric { text-align: right; font-variant-numeric: tabular-nums; }
table.data .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------------------------------------------------------- pagination --- */

.pagination {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 28px; flex-wrap: wrap;
}
.pagination__pages { display: flex; gap: 3px; align-items: center; }
.pagination__pages a, .pagination__current {
  min-width: 32px; height: 32px; padding: 0 8px;
  display: inline-grid; place-items: center;
  border-radius: var(--radius); font-size: .9rem;
}
.pagination__pages a { color: var(--ink-soft); }
.pagination__pages a:hover { background: var(--paper-sunk); text-decoration: none; }
.pagination__current { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pagination__gap { color: var(--ink-faint); padding: 0 4px; }
.pagination__step { font-size: .9rem; font-weight: 550; }
.pagination__step.is-disabled { color: var(--ink-faint); }

/* -------------------------------------------------------------- empty ---- */

.empty {
  text-align: center; padding: 48px 24px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-lg);
  color: var(--ink-soft); background: var(--paper);
}
.empty h3 { color: var(--ink); margin-bottom: 6px; }

/* -------------------------------------------------------------- stats ---- */

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat {
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 16px;
}
.stat__value { font-size: 1.7rem; font-weight: 650; line-height: 1.1; letter-spacing: -.02em; }
.stat__label { color: var(--ink-soft); font-size: .85rem; margin-top: 3px; }
.stat__note  { color: var(--ink-faint); font-size: .78rem; margin-top: 6px; }

.progress {
  height: 7px; background: var(--paper-sunk); border-radius: 99px; overflow: hidden;
}
.progress__bar { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s ease; }

/* ------------------------------------------------------------ banners ---- */

.banner-slot {
  position: relative; text-align: center;
  padding: 10px 20px; background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.banner-slot__link { display: inline-block; max-width: 100%; }
.banner-slot img { margin: 0 auto; border-radius: 4px; }
.banner-slot__label {
  position: absolute; top: 4px; right: 10px;
  font-size: .62rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint);
}

/* --------------------------------------------------------------- hero ---- */

.hero {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 44px 32px;
  text-align: center; margin-bottom: 32px;
}
.hero h1 { font-family: var(--font-display); font-size: 2.4rem; margin-bottom: 12px; }
.hero p { color: var(--ink-soft); font-size: 1.08rem; max-width: 620px; margin: 0 auto 22px; }
.hero__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 560px) {
  .hero { padding: 32px 20px; }
  .hero h1 { font-size: 1.8rem; }
}

/* ------------------------------------------------------------ profile ---- */

.profile-head {
  display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap;
  margin-bottom: 28px;
}
.profile-head__body { flex: 1; min-width: 240px; }
.profile-head h1 { margin-bottom: 4px; }
.profile-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.profile-links a {
  font-size: .86rem; padding: 5px 11px; border-radius: 99px;
  background: var(--paper-sunk); color: var(--ink-soft);
}
.profile-links a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

/* --------------------------------------------------------- book detail --- */

.book-detail { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 32px; align-items: start; }
@media (max-width: 760px) { .book-detail { grid-template-columns: 1fr; } }

.book-detail__cover {
  border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow-lift);
  aspect-ratio: 2 / 3; background: var(--paper-sunk);
}
.book-detail__cover img { width: 100%; height: 100%; object-fit: cover; }

.meta-list { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.meta-list li {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 7px 0; border-bottom: 1px solid var(--line);
}
.meta-list li:last-child { border-bottom: 0; }
.meta-list dt, .meta-list__key { color: var(--ink-soft); }
.meta-list__value { text-align: right; font-weight: 500; }

/* --------------------------------------------------------- dashboard ----- */

.dash { display: grid; grid-template-columns: 218px minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 900px) { .dash { grid-template-columns: 1fr; } }

.dash-nav {
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 10px; position: sticky; top: 78px;
}
@media (max-width: 900px) { .dash-nav { position: static; } }

.dash-nav__group { margin-bottom: 6px; }
.dash-nav__group:last-child { margin-bottom: 0; }
.dash-nav__title {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); font-weight: 650; padding: 10px 10px 5px;
}
.dash-nav ul { list-style: none; margin: 0; padding: 0; }
.dash-nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius);
  color: var(--ink-soft); font-size: .9rem;
}
.dash-nav a:hover { background: var(--paper-sunk); color: var(--ink); text-decoration: none; }
.dash-nav a.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }

.lock-mark { font-size: .68rem; color: var(--ink-faint); }

/* ------------------------------------------------------------- misc ------ */

.cover-thumb {
  width: 40px; height: 60px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--line); background: var(--paper-sunk);
  flex-shrink: 0;
}

.inline-form { display: inline; }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-plain > li:last-child { border-bottom: 0; }

.prose { max-width: 68ch; }
.prose h2 { margin-top: 1.5em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose img { border-radius: var(--radius); margin: 1em 0; }
.prose blockquote {
  margin: 1em 0; padding: 4px 0 4px 16px;
  border-left: 3px solid var(--line-strong); color: var(--ink-soft);
}

.copy-field { display: flex; gap: 6px; }
.copy-field input { font-family: var(--font-mono); font-size: .84rem; }

.site-footer {
  background: var(--paper); border-top: 1px solid var(--line);
  padding: 32px 0; margin-top: auto; font-size: .9rem;
}
.site-footer__inner { display: grid; gap: 20px; }
.site-footer__brand { display: flex; gap: 12px; align-items: center; }
.site-footer__name { font-weight: 650; margin: 0; }
.site-footer__tagline { color: var(--ink-soft); margin: 0; font-size: .88rem; }
.site-footer__nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer__nav a { color: var(--ink-soft); }
.site-footer__legal { color: var(--ink-faint); margin: 0; font-size: .85rem; }

@media print {
  .site-header, .site-footer, .banner-slot, .page-head__actions, .dash-nav { display: none; }
}

/* ==========================================================================
   Wave 2 — discovery & reading layer
   ========================================================================== */

/* ---------------------------------------------------------------- stars --- */

.stars { white-space: nowrap; letter-spacing: .04em; }
.stars__full  { color: #d8a13a; }
.stars__empty { color: var(--line-strong); }

.star-input { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; }
.star-input__option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star-input__option span {
  font-size: 1.9rem; line-height: 1; color: var(--line-strong);
  cursor: pointer; transition: color .1s ease;
}
/* Reversed order means "this star and everything after it in the DOM" is
   everything to its left visually — which is how a star rating should light up. */
.star-input__option:hover span,
.star-input__option:hover ~ .star-input__option span,
.star-input__option input:checked ~ span,
.star-input__option:has(input:checked) ~ .star-input__option span { color: #d8a13a; }
.star-input__option input:focus-visible ~ span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----------------------------------------------------------------- tags --- */

.tag-group { margin-bottom: 14px; }
.tag-group:last-child { margin-bottom: 0; }
.tag-group__label {
  display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); font-weight: 650; margin-bottom: 6px;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

.tag__count { opacity: .6; font-size: .9em; }

a.tag:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.tag--author { background: var(--accent-soft); color: var(--accent); }
.tag--author::before { content: "✓ "; opacity: .7; }

.tag--active { background: var(--accent); color: var(--accent-ink); }
a.tag--active:hover { background: var(--accent-hover); color: var(--accent-ink); }

.tag-group--warning {
  background: var(--warn-soft); border-radius: var(--radius);
  padding: 10px 14px; margin-top: 14px;
}
.tag-group--warning summary { cursor: pointer; font-weight: 550; font-size: .9rem; color: var(--warn); }
.tag-group--warning .tag-row { margin-top: 10px; }

.tag-browser {
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 20px;
}
.tag-browser > summary { cursor: pointer; font-weight: 550; font-size: .93rem; }
.tag-browser[open] > summary { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }

.active-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.tag-fieldset { border: 0; padding: 0; margin: 0 0 16px; }
.tag-fieldset legend { font-weight: 600; font-size: .88rem; padding: 0; margin-bottom: 8px; }
.tag-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-choice { position: relative; }
.tag-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tag-choice span {
  display: inline-block; padding: 5px 11px; border-radius: 99px;
  background: var(--paper-sunk); color: var(--ink-soft);
  font-size: .84rem; cursor: pointer; border: 1px solid transparent;
}
.tag-choice input:checked + span { background: var(--accent); color: var(--accent-ink); }
.tag-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --------------------------------------------------------------- shelves -- */

.shelf-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); margin-bottom: 20px;
}
.shelf-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; color: var(--ink-soft); font-size: .92rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.shelf-tab:hover { color: var(--ink); text-decoration: none; }
.shelf-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 550; }
.shelf-tab__count {
  background: var(--paper-sunk); border-radius: 99px;
  padding: 1px 7px; font-size: .75rem; color: var(--ink-soft);
}
.shelf-tab.is-active .shelf-tab__count { background: var(--accent-soft); color: var(--accent); }

.shelf-picker {
  margin-top: 18px; padding: 14px; background: var(--paper-sunk);
  border-radius: var(--radius-lg);
}
.shelf-picker__label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); font-weight: 650; margin: 0 0 8px;
}
.shelf-picker__buttons { display: flex; flex-direction: column; gap: 5px; }
.shelf-btn {
  width: 100%; text-align: left; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  font: inherit; font-size: .88rem; cursor: pointer;
}
.shelf-btn:hover { border-color: var(--accent); }
.shelf-btn.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 550; }
.shelf-btn.is-active::before { content: "✓ "; }

.shelf-row {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.shelf-row:last-child { border-bottom: 0; }

.shelf-entry { min-width: 0; }

/* --------------------------------------------------------------- ratings -- */

.book-rating { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 1.05rem; }

.rating-summary {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px;
  align-items: center; padding: 18px 0; border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
@media (max-width: 560px) { .rating-summary { grid-template-columns: 1fr; gap: 16px; } }

.rating-summary__score { text-align: center; }
.rating-summary__number {
  display: block; font-size: 2.6rem; font-weight: 700; line-height: 1; letter-spacing: -.03em;
}
.rating-summary__bars { display: grid; gap: 5px; }

.rating-bar { display: grid; grid-template-columns: 30px minmax(0, 1fr) 40px; gap: 10px; align-items: center; }
.rating-bar__label { font-size: .8rem; color: var(--ink-soft); text-align: right; }
.rating-bar__track { height: 8px; background: var(--paper-sunk); border-radius: 99px; overflow: hidden; }
.rating-bar__fill { display: block; height: 100%; background: #d8a13a; border-radius: 99px; }
.rating-bar__count { font-size: .8rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.review-form {
  background: var(--paper-sunk); border-radius: var(--radius-lg);
  padding: 20px; margin: 20px 0;
}
.review-form h3 { margin-bottom: 14px; }

.review-item { padding: 16px 0; border-bottom: 1px solid var(--line); }
.review-item:last-child { border-bottom: 0; }

.review-card { margin-bottom: var(--gap); }

.spoiler {
  background: var(--paper-sunk); border-radius: var(--radius);
  padding: 10px 14px; margin: 6px 0;
}
.spoiler summary { cursor: pointer; font-size: .87rem; color: var(--ink-soft); font-weight: 550; }
.spoiler[open] summary { margin-bottom: 8px; }

/* ------------------------------------------------------------ challenges -- */

.challenge-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.challenge-row:last-child { border-bottom: 0; }

.progress__bar--done { background: var(--good); }

.challenge-card {
  display: flex; gap: 18px; align-items: flex-start; justify-content: space-between;
  padding: 16px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.challenge-card:last-child { border-bottom: 0; }

/* ----------------------------------------------------------------- deals -- */

.deal-card {
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden;
  display: flex; flex-direction: column;
}
.deal-card__cover { position: relative; display: block; aspect-ratio: 3 / 2; background: var(--paper-sunk); }
.deal-card__cover img { width: 100%; height: 100%; object-fit: contain; padding: 12px; }

.deal-flag {
  position: absolute; top: 10px; left: 10px;
  background: var(--accent); color: var(--accent-ink);
  font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px;
}
.deal-flag--free { background: var(--good); }

.deal-card__body { padding: 14px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.deal-card__body h3 { font-size: .98rem; margin: 0; line-height: 1.3; }
.deal-card__body p { margin: 0; }
.deal-card__price { font-size: 1.05rem; margin-top: 4px !important; }
.deal-card__price s { font-size: .85rem; margin-left: 6px; }
.deal-card .btn { margin-top: auto; }

.book-deal {
  margin-top: 14px; padding: 12px; border-radius: var(--radius);
  background: var(--good-soft); color: var(--good); font-size: .9rem; text-align: center;
}

/* -------------------------------------------------------- universal link -- */

.universal-link-page .site-main { padding-top: 40px; }

.ulink { max-width: 520px; margin: 0 auto; }

.ulink__book { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.ulink__cover {
  width: 130px; flex-shrink: 0; aspect-ratio: 2 / 3;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow-lift); background: var(--paper-sunk);
}
.ulink__cover img { width: 100%; height: 100%; object-fit: cover; }
.ulink__meta { min-width: 0; }
.ulink__meta h1 { font-size: 1.5rem; margin-bottom: 4px; }
.ulink__subtitle { color: var(--ink-soft); font-size: .95rem; margin-bottom: 6px; }
.ulink__author { margin-bottom: 8px; }
.ulink__rating { display: flex; align-items: center; gap: 8px; margin: 0; }

.ulink__deal {
  background: var(--good-soft); color: var(--good);
  padding: 11px 15px; border-radius: var(--radius);
  text-align: center; font-size: .92rem; margin-bottom: 20px;
}

.ulink__links { display: flex; flex-direction: column; gap: 9px; }

.ulink__format {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); font-weight: 650; margin: 14px 0 2px;
}
.ulink__format:first-child { margin-top: 0; }

.retailer-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; border-radius: var(--radius);
  background: var(--paper-raised); border: 1px solid var(--line-strong);
  color: var(--ink); font-weight: 600; font-size: .98rem;
  transition: border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.retailer-btn:hover {
  text-decoration: none; border-color: var(--accent);
  transform: translateY(-1px); box-shadow: var(--shadow);
}
.retailer-btn__go { color: var(--accent); font-size: 1.1rem; }

.ulink__empty { text-align: center; padding: 24px 0; }

.ulink__blurb {
  margin-top: 24px; padding: 14px 16px;
  background: var(--paper-sunk); border-radius: var(--radius);
}
.ulink__blurb summary { cursor: pointer; font-weight: 550; font-size: .92rem; }
.ulink__blurb[open] summary { margin-bottom: 10px; }
.ulink__blurb p { font-size: .92rem; line-height: 1.6; margin: 0; }

.ulink__foot {
  margin-top: 28px; text-align: center; font-size: .86rem;
  color: var(--ink-faint); display: flex; gap: 10px; justify-content: center;
}

.ulink__owner {
  margin-top: 28px; padding: 16px; border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}

/* ------------------------------------------------------- year in review --- */

.wrapped { max-width: 760px; margin: 0 auto; }

.wrapped__head { text-align: center; margin-bottom: 32px; }
.wrapped__head .avatar { margin: 0 auto 14px; }
.wrapped__head h1 { font-family: var(--font-display); font-size: 2rem; }

.wrapped__years { display: flex; gap: 6px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.wrapped__years a {
  padding: 4px 12px; border-radius: 99px;
  background: var(--paper-sunk); color: var(--ink-soft); font-size: .88rem;
}
.wrapped__years a.is-active { background: var(--accent); color: var(--accent-ink); }
.wrapped__years a:hover { text-decoration: none; }

.wrapped__big {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px; margin-bottom: 28px; text-align: center;
}
.wrapped__stat {
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 22px 14px;
}
.wrapped__value {
  display: block; font-size: 2.4rem; font-weight: 700;
  line-height: 1; letter-spacing: -.03em; color: var(--accent);
}
.wrapped__label { display: block; color: var(--ink-soft); font-size: .86rem; margin-top: 6px; }

.wrapped__chart { width: 100%; height: auto; display: block; }
.wrapped__bar { fill: var(--accent); }
.wrapped__bar--empty { fill: var(--line); }
.wrapped__bar-label { fill: var(--ink-faint); font-size: 3.4px; font-family: var(--font); }

.wrapped__share {
  margin-top: 28px; padding: 18px;
  background: var(--paper-sunk); border-radius: var(--radius-lg);
}

@media print {
  .wrapped__share, .shelf-picker, .tag-browser, .review-form { display: none; }
}

/* ==========================================================================
   Wave 3 — community: feed, posts, comments, messages, forums, clubs
   Appended, never rewriting what earlier waves defined.
   ========================================================================== */

/* The dashboard's content column. The grid places it; this stops long tables
   and code from forcing the whole page wide. */
.dash-main { min-width: 0; }

/* --- shared bits that were admin-only until now ---------------------------
   report.php, critique.php and the dashboard all use these, and those pages
   load main.css only. admin.css keeps its own copies and still wins there. */

.review-row {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.review-row:last-child { border-bottom: 0; }

/* Wins over admin.css's three-column grid, for rows that are not
   avatar / body / actions. */
.review-row.review-row--plain {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start;
}

.diff-note {
  background: var(--paper-sunk); border-left: 3px solid var(--line-strong);
  padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .9rem; color: var(--ink-soft); margin: 10px 0;
}

.queue-count {
  display: inline-block;
  background: var(--bad); color: #fff;
  font-size: .68rem; font-weight: 700; line-height: 1;
  padding: 3px 6px; border-radius: 99px; min-width: 18px; text-align: center;
}

/* A button that reads as a link — used for destructive-but-minor actions
   that must be POSTed rather than followed. */
.link-btn {
  background: none; border: 0; padding: 0;
  font: inherit; font-size: .85rem; color: var(--ink-soft);
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--ink); }
.link-btn.small, .link-btn .small { font-size: .8rem; }

.report-link {
  font-size: .78rem; color: var(--ink-faint); text-decoration: none;
}
.report-link:hover { color: var(--bad); text-decoration: underline; }

/* --- header counters ----------------------------------------------------- */

.nav-count {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius);
  color: var(--ink-soft); text-decoration: none; font-size: 1rem;
}
.nav-count:hover { background: var(--paper-sunk); color: var(--ink); text-decoration: none; }
.nav-count__badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--bad); color: #fff;
  font-size: .6rem; font-weight: 700; line-height: 1;
  padding: 2px 4px; border-radius: 99px; min-width: 14px; text-align: center;
}

/* --- feed and posts ------------------------------------------------------ */

.feed-item { margin-bottom: 18px; }
.feed-item__head { display: flex; gap: 11px; align-items: center; margin-bottom: 8px; }

.post-card {
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.post-card__body { margin: 0 0 10px; line-height: 1.55; overflow-wrap: anywhere; }
.post-card__image {
  display: block; max-width: 100%; height: auto;
  border-radius: var(--radius); margin: 10px 0;
}
.post-card__book {
  display: flex; gap: 12px; align-items: center;
  background: var(--paper-sunk); border-radius: var(--radius);
  padding: 10px 12px; margin: 10px 0; text-decoration: none; color: inherit;
}
.post-card__book:hover { background: var(--accent-soft); text-decoration: none; }
.post-card__book .cover-thumb { width: 34px; height: 51px; }

.post-card__actions {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line);
}
.post-card__comments { margin-top: 12px; }

.react-btn {
  background: none; border: 1px solid var(--line); border-radius: 99px;
  padding: 3px 11px; font: inherit; font-size: .82rem; color: var(--ink-soft);
  cursor: pointer; line-height: 1.5;
}
.react-btn:hover { border-color: var(--accent); color: var(--accent); }
.react-btn.is-on { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.react-btn.is-static { cursor: default; }
.react-btn.is-static:hover { border-color: var(--line); color: var(--ink-soft); }

/* --- comments ------------------------------------------------------------ */

.comment { display: flex; gap: 10px; padding: 9px 0; }
.comment > div { min-width: 0; flex: 1; }
.comment p { overflow-wrap: anywhere; }
.comment--reply {
  margin-top: 8px; margin-left: 0;
  padding-left: 12px; border-left: 2px solid var(--line);
}

.comment-form { display: flex; gap: 8px; margin-top: 12px; }
.comment-form input[type="text"] { flex: 1; min-width: 0; }

/* --- composer ------------------------------------------------------------ */

.composer { padding: 14px 16px; margin-bottom: 20px; }
.composer textarea { width: 100%; resize: vertical; }
.composer__foot {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-top: 10px;
}
.composer__book { max-width: 220px; }

/* --- direct messages ----------------------------------------------------- */

.messages {
  display: grid; grid-template-columns: 250px minmax(0, 1fr);
  gap: 18px; align-items: start;
}
@media (max-width: 800px) { .messages { grid-template-columns: 1fr; } }

.messages__list {
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden; max-height: 70vh; overflow-y: auto;
}

.conversation {
  display: flex; gap: 10px; align-items: center;
  padding: 11px 13px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.conversation:last-child { border-bottom: 0; }
.conversation:hover { background: var(--paper-sunk); text-decoration: none; }
.conversation.is-active { background: var(--accent-soft); }

.messages__thread {
  display: flex; flex-direction: column;
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: var(--radius-lg); min-height: 420px;
}
.messages__head {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.messages__body {
  flex: 1; padding: 16px; overflow-y: auto; max-height: 55vh;
  display: flex; flex-direction: column; gap: 8px;
}

.bubble {
  align-self: flex-start; max-width: 78%;
  background: var(--paper-sunk); border-radius: var(--radius-lg);
  padding: 9px 13px;
}
.bubble p { margin: 0; font-size: .92rem; overflow-wrap: anywhere; }
.bubble--mine { align-self: flex-end; background: var(--accent-soft); }
.bubble__time { display: block; font-size: .7rem; color: var(--ink-faint); margin-top: 3px; }

.messages__composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.messages__composer textarea { flex: 1; min-width: 0; resize: vertical; }

/* --- notifications ------------------------------------------------------- */

.notification {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.notification:last-child { border-bottom: 0; }
.notification.is-unread {
  background: var(--accent-soft);
  margin: 0 -18px; padding-left: 18px; padding-right: 18px;
}

/* --- forums -------------------------------------------------------------- */

.forum-post {
  display: grid; grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--line);
}
.forum-post:last-child { border-bottom: 0; }
@media (max-width: 700px) { .forum-post { grid-template-columns: 1fr; gap: 10px; } }

.forum-post--op { background: var(--paper-sunk); border-radius: var(--radius-lg); padding: 16px; }
.forum-post__author { text-align: center; font-size: .85rem; color: var(--ink-soft); }
@media (max-width: 700px) {
  .forum-post__author { display: flex; gap: 10px; align-items: center; text-align: left; }
}
.forum-post__body { min-width: 0; line-height: 1.6; overflow-wrap: anywhere; }
.forum-post__actions {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-top: 12px; font-size: .84rem;
}

/* --- polls --------------------------------------------------------------- */

.poll-option { margin-bottom: 6px; }
.poll-btn {
  display: block; width: 100%; text-align: left;
  background: var(--paper-sunk); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 12px;
  font: inherit; font-size: .88rem; color: inherit; cursor: pointer;
}
.poll-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

.poll-result {
  position: relative; overflow: hidden;
  background: var(--paper-sunk); border-radius: var(--radius);
  padding: 8px 12px; margin-bottom: 6px;
}
.poll-result__bar {
  position: absolute; inset: 0 auto 0 0;
  background: var(--accent-soft); z-index: 0;
}
.poll-result.is-mine .poll-result__bar { background: var(--good-soft); }
.poll-result__label {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; gap: 10px; font-size: .88rem;
}

/* --- critique exchange --------------------------------------------------- */

.critique-block { margin-bottom: 14px; }
.critique-block h4 {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); margin-bottom: 4px;
}
.critique-block p { margin: 0; font-size: .92rem; line-height: 1.55; overflow-wrap: anywhere; }

/* A neutral bordered container for one-off blocks that are not full panels. */
.box {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px;
}

/* ==========================================================================
   Wave 4 — serialization, quote cards, press kits, Q&A, accessibility
   Appended, never rewriting what earlier waves defined.
   ========================================================================== */

/* --- accessibility preferences -------------------------------------------
   Driven by data-attributes on <html>, set server-side in a11y_html_attributes().
   No JavaScript is involved in applying them: the page has to be readable
   before any script runs, which is the entire point. */

:root[data-font-scale="90"]  { font-size: 90%; }
:root[data-font-scale="112"] { font-size: 112%; }
:root[data-font-scale="125"] { font-size: 125%; }
:root[data-font-scale="150"] { font-size: 150%; }

/* Not a licensed dyslexia face — those cannot be shipped without a build step
   or a webfont host. This is the set of adjustments that research attributes
   most of the benefit to: a heavier weight, wider letter and word spacing,
   more leading, and no italics. */
:root[data-dyslexic="1"] body,
:root[data-dyslexic="1"] input,
:root[data-dyslexic="1"] textarea,
:root[data-dyslexic="1"] select,
:root[data-dyslexic="1"] button {
  font-family: Verdana, Tahoma, "DejaVu Sans", sans-serif;
  letter-spacing: .035em;
  word-spacing: .12em;
  font-weight: 500;
}
:root[data-dyslexic="1"] p,
:root[data-dyslexic="1"] li { line-height: 1.85; }
:root[data-dyslexic="1"] em,
:root[data-dyslexic="1"] i { font-style: normal; font-weight: 700; }
:root[data-dyslexic="1"] .prose { max-width: 60ch; }

:root[data-contrast="high"] {
  --ink: #000000;
  --ink-soft: #26292e;
  --ink-faint: #444a52;
  --paper: #ffffff;
  --paper-sunk: #f2f3f5;
  --line: #7d848d;
  --line-strong: #4a5058;
  --accent: #14356e;
  --accent-hover: #0c2450;
}
@media (prefers-color-scheme: dark) {
  :root[data-contrast="high"] {
    --ink: #ffffff;
    --ink-soft: #e2e6ec;
    --ink-faint: #c2c8d0;
    --paper: #000000;
    --paper-sunk: #14171b;
    --paper-raised: #0b0d10;
    --line: #7d848d;
    --line-strong: #a8afb8;
    --accent: #9dc0f0;
  }
}
:root[data-contrast="high"] a { text-decoration: underline; }
:root[data-contrast="high"] .btn { border-width: 2px; }

:root[data-underline="1"] a { text-decoration: underline; text-underline-offset: 2px; }

:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}

/* Spoilers open by default: a screen reader announces the hidden text anyway,
   so making people click first is friction without protection for them. */
:root[data-spoilers="shown"] .spoiler > summary { display: none; }
:root[data-spoilers="shown"] .spoiler > *:not(summary) { display: block; }

:root[data-leading="relaxed"] p,
:root[data-leading="relaxed"] li { line-height: 1.8; }
:root[data-leading="loose"] p,
:root[data-leading="loose"] li { line-height: 2.05; }

:root[data-measure="narrow"] .prose,
:root[data-measure="narrow"] .reader__prose { max-width: 54ch; }
:root[data-measure="wide"] .prose,
:root[data-measure="wide"] .reader__prose { max-width: 82ch; }

.a11y-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding: 12px 0; margin-top: 10px;
  border-top: 1px solid var(--line);
  font-size: .82rem; color: var(--ink-soft);
}
.a11y-bar__label { font-weight: 600; }
.a11y-bar__check { display: inline-flex; gap: 6px; align-items: center; }
.a11y-bar select { font-size: .82rem; padding: 4px 8px; }

/* --- the serial reader ---------------------------------------------------- */

.reader { max-width: 760px; margin: 0 auto; }

.reader__bar {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
  align-items: center; padding-bottom: 12px; margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.reader__body h1 { font-size: 1.7rem; margin-bottom: 4px; }

.reader__prose {
  max-width: 68ch;
  margin: 26px auto 0;
  font-size: 1.06rem;
  line-height: 1.75;
}
.reader__para { position: relative; margin-bottom: 1.15em; overflow-wrap: break-word; }

/* The margin mark for an inline note. Sits outside the measure on a wide
   screen and folds back inline on a narrow one. */
.reader__note-mark {
  position: absolute; top: 2px; right: -34px;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 99px; font-size: .7rem; font-weight: 700;
  text-decoration: none; line-height: 1;
}
.reader__note-mark:hover { background: var(--accent); color: var(--accent-ink); text-decoration: none; }
@media (max-width: 900px) {
  .reader__note-mark { position: static; margin-left: 6px; vertical-align: super; }
}

.reader__note {
  background: var(--paper-sunk); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px; margin: 28px 0 0;
}
.reader__note h2 { font-size: .95rem; margin-bottom: 6px; }
.reader__note p { font-size: .94rem; margin: 0; }

.reader__nav {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  margin: 32px 0 18px; padding-top: 20px; border-top: 1px solid var(--line);
}
.reader__actions {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  margin-bottom: 26px;
}

/* A comfortable writing surface in the chapter editor. */
textarea.writing {
  font-family: var(--font-display);
  font-size: 1.02rem;
  line-height: 1.7;
  min-height: 420px;
}

/* --- chapter list --------------------------------------------------------- */

.chapter-list { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.chapter-list li {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: space-between; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.chapter-list li:last-child { border-bottom: 0; }
.chapter-list a { display: flex; gap: 12px; align-items: baseline; min-width: 0; text-decoration: none; }
.chapter-list a:hover .chapter-list__title { text-decoration: underline; }
.chapter-list__num {
  flex: 0 0 auto; min-width: 26px;
  color: var(--ink-faint); font-variant-numeric: tabular-nums; font-size: .85rem;
}
.chapter-list__title { color: var(--ink); font-weight: 500; }
.chapter-list__meta { flex: 0 0 auto; }

/* --- quote cards ---------------------------------------------------------- */

.quote-share {
  display: grid; grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px; align-items: start;
}
@media (max-width: 760px) { .quote-share { grid-template-columns: 1fr; } }

.quote-share__image {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
}
.quote-share__side { min-width: 0; }

.quote-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.quote-grid__item { margin: 0; min-width: 0; }
.quote-grid__item img {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.quote-grid__item figcaption { margin-top: 6px; }

/* --- press kit ------------------------------------------------------------ */

.press-head {
  display: flex; flex-wrap: wrap; gap: 24px; align-items: center;
  padding-bottom: 24px; margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.press-head h1 { font-size: 1.9rem; margin-bottom: 4px; }
.press-head__photo {
  width: 148px; height: 148px; object-fit: cover;
  border-radius: var(--radius-lg); border: 1px solid var(--line);
}

.press-book {
  display: flex; gap: 18px; align-items: flex-start;
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.press-book:last-child { border-bottom: 0; }
.press-book .cover-thumb { flex: 0 0 auto; }

/* --- ask the author ------------------------------------------------------- */

.qa-question {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.qa-question:last-child { border-bottom: 0; }
.qa-question p { overflow-wrap: anywhere; }

.qa-answer {
  background: var(--accent-soft); border-radius: var(--radius);
  padding: 12px 15px; margin-top: 12px;
}
.qa-answer p:last-child { margin-bottom: 0; }

/* =========================================================================
   WAVE 5 — audio, series, rights, widgets, communities, moderation
   ========================================================================= */

/* --- audio ---------------------------------------------------------------- */

.audio-player {
  display: block; width: 100%; max-width: 520px;
  margin: 12px 0; border-radius: var(--radius);
}
.audio-player--sm { max-width: 340px; margin: 8px 0; }

/* The audiobook strip on a book page. Tinted so it reads as a second edition
   of the same book rather than as another book entirely. */
.audio-strip { background: var(--accent-soft); border-color: transparent; }
.audio-strip .panel__head h2 { font-size: 1.05rem; }

.narrator-card { display: flex; flex-direction: column; }
.narrator-card .btn { margin-top: auto; align-self: flex-start; }

/* An audition script is prose the narrator will read aloud — give it room. */
.script-block {
  background: var(--paper-sunk); border-radius: var(--radius);
  padding: 14px 16px; font-size: .95rem; line-height: 1.7;
}

.promo-code {
  display: inline-block; background: var(--paper-sunk);
  border: 1px dashed var(--line-strong); border-radius: 5px;
  padding: 2px 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .9em; letter-spacing: .04em; user-select: all;
}

/* --- key/value blocks ----------------------------------------------------- */

/* Used by the narrator, casting, rights, and community sidebars. A <dl> rather
   than .meta-list because these values wrap onto several lines. */
.detail-list { margin: 0; }
.detail-list dt {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-faint); margin-top: 12px;
}
.detail-list dt:first-child { margin-top: 0; }
.detail-list dd { margin: 3px 0 0; overflow-wrap: anywhere; }

/* --- series --------------------------------------------------------------- */

.series-strip { background: var(--paper-sunk); }

.series-map { list-style: none; margin: 0; padding: 0; counter-reset: none; }

.series-map__item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.series-map__item:last-child { border-bottom: 0; }

/* Fixed width so decimal positions (2.5) line up with whole ones. */
.series-map__num {
  flex: 0 0 2.4em; text-align: right;
  font-variant-numeric: tabular-nums; font-weight: 650;
  color: var(--accent); font-size: 1.05rem; line-height: 1.5;
}
.series-map__body { min-width: 0; flex: 1; }
.series-map__body p { margin-bottom: 3px; }

/* --- widgets -------------------------------------------------------------- */

.widget-preview {
  display: inline-block; padding: 14px;
  background: var(--paper-sunk); border-radius: var(--radius-lg);
}
.widget-preview svg { display: block; max-width: 100%; height: auto; }

.copy-target {
  width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem; resize: vertical;
}

/* --- communities ---------------------------------------------------------- */

.announcement { border-left: 3px solid var(--accent); }

.lead { font-size: 1.05rem; color: var(--ink-soft); max-width: 62ch; }

/* --- responsive ----------------------------------------------------------- */

@media (max-width: 640px) {
  .series-map__item { gap: 10px; }
  .series-map__num { flex-basis: 1.9em; font-size: .95rem; }
  .detail-list dd { font-size: .95rem; }
}

/* =========================================================================
   WAVE 6 — plans and billing
   ========================================================================= */

.go-pro { border-color: var(--accent); color: var(--accent); }

.plan-grid { align-items: stretch; margin-bottom: var(--gap); }

.plan-card { display: flex; flex-direction: column; }
.plan-card__head { margin-bottom: 16px; }
.plan-card__head h2 { margin: 6px 0 4px; }

.plan-card__price {
  font-size: 2.1rem; font-weight: 650; letter-spacing: -.02em;
  line-height: 1.1; margin: 0 0 4px;
}
.plan-card__period { font-size: .9rem; font-weight: 400; color: var(--ink-soft); letter-spacing: 0; }

/* The paid card is marked with a border rather than a fill: a solid colour
   block reads as an advertisement, and this page is meant to read as a list of
   facts. */
.plan-card--featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.plan-list { list-style: none; margin: 0 0 20px; padding: 0; font-size: .93rem; }
.plan-list li {
  position: relative; padding: 6px 0 6px 22px; line-height: 1.5;
  border-bottom: 1px solid var(--line);
}
.plan-list li:last-child { border-bottom: 0; }
.plan-list li::before {
  content: "✓"; position: absolute; left: 0; top: 6px;
  color: var(--accent); font-weight: 700;
}

/* Sits where the button would, so the two cards stay the same height. */
.plan-card__current {
  margin-top: auto; text-align: center; font-weight: 600;
  color: var(--accent); padding: 10px 0;
}
.plan-card .btn--block { margin-top: auto; }

.plan-status .detail-list { margin-top: 14px; }

@media (max-width: 640px) {
  .plan-card__price { font-size: 1.7rem; }
  .go-pro { display: none; }   /* the header is tight enough on a phone */
}

.upgrade-notice { border-left: 3px solid var(--accent); margin-bottom: 22px; }

/* ---------------------------------------------------------------------------
   Wave 7 — the games

   Restrained on purpose. These are games on a books site, not a games site: the
   surfaces borrow the same panels, pills, and type as everything else, and the
   only real flourishes are the bingo grid and the boss's health bar, where the
   shape genuinely carries information.
   --------------------------------------------------------------------------- */

.games-season { align-items: center; gap: 10px; }

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--gap); }

.game-card {
  display: block;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--paper-raised);
  color: inherit;
  text-decoration: none;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.game-card:hover, .game-card:focus-visible { box-shadow: var(--shadow-lift); border-left-color: var(--accent); }
.game-card--quiz     { border-left-color: var(--accent); }
.game-card--versus   { border-left-color: var(--warn); }
.game-card--progress { border-left-color: var(--good); }

.game-card__title { margin: 0 0 6px; font-size: 1.05rem; }
.game-card__desc  { margin: 0 0 10px; color: var(--ink-soft); font-size: .9rem; }
.game-card__meta  { margin: 0; }

.game-main > .panel:first-child { margin-top: 0; }
.game-side .panel { margin-top: 0; margin-bottom: var(--gap); }

/* Quizzes ---------------------------------------------------------------- */

.game-question.is-answered { opacity: .78; }

.game-excerpt {
  margin: 0 0 14px;
  padding: 12px 16px;
  border-left: 3px solid var(--line-strong);
  background: var(--paper-sunk);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
}
.game-excerpt--large { font-size: 1.1rem; line-height: 1.7; }

.game-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.game-choice  { justify-content: flex-start; text-align: left; }

/* Head-to-head ----------------------------------------------------------- */

.versus { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: start; }
.versus__side { text-align: center; }
.versus__side .btn { margin-top: 12px; }
.versus__cover img { width: 100%; height: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.versus__blurb {
  text-align: left;
  padding: 16px;
  background: var(--paper-sunk);
  border-radius: var(--radius);
  font-size: .95rem;
  line-height: 1.65;
}

.battle { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; margin: 12px 0; }
.battle__side  { text-align: center; }
.battle__score { font-size: 2rem; font-weight: 600; line-height: 1.2; }
.battle__vs    { color: var(--ink-faint); text-transform: uppercase; font-size: .8rem; letter-spacing: .08em; }

/* Bingo ------------------------------------------------------------------ */

.bingo {
  display: grid;
  grid-template-columns: repeat(var(--bingo-grid, 5), 1fr);
  gap: 6px;
}
.bingo__cell {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 92px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-sunk);
  font-size: .78rem;
  line-height: 1.35;
  color: var(--ink-soft);
}
.bingo__cell.is-done {
  background: var(--good-soft);
  border-color: var(--good);
  color: var(--good);
  font-weight: 600;
}

/* Treasure hunt ---------------------------------------------------------- */

.hunt-clue { padding: 14px 0; border-bottom: 1px solid var(--line); }
.hunt-clue:last-child { border-bottom: 0; }
.hunt-clue.is-found { opacity: .7; }

.hunt-token {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  padding: 12px 16px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.hunt-token__label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.hunt-token__code  { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.15rem; letter-spacing: .12em; }

/* Boss ------------------------------------------------------------------- */

.boss-bar {
  height: 22px;
  border-radius: 11px;
  background: var(--paper-sunk);
  border: 1px solid var(--line);
  overflow: hidden;
}
.boss-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--warn), var(--bad));
  transition: width .4s ease;
}

/* Bits shared with other pages ------------------------------------------- */

.book-game-wins { color: var(--good); }
.book-grid--tight { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.stat-row--stacked { grid-template-columns: 1fr; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }

@media (max-width: 640px) {
  .versus { grid-template-columns: 1fr; }
  .battle { grid-template-columns: 1fr; }
  .bingo__cell { min-height: 74px; font-size: .68rem; }
}
