:root {
  --bg: #f3f7f4;
  --surface: #ffffff;
  --surface-2: #e7efe9;
  --ink: #1f2822;
  --muted: #64736a;
  --line: #cad8cf;
  --accent: #1f766f;
  --accent-strong: #15534e;
  --danger: #9b2f45;
  --highlight: #b78a2f;
  --reader-size: 20px;
  --shadow: 0 14px 35px rgba(30, 50, 38, .12);
  --sticky-offset: 92px;
}

[data-theme="night"] {
  --bg: #101614;
  --surface: #1b2421;
  --surface-2: #25312d;
  --ink: #eef5ef;
  --muted: #a8b7ad;
  --line: #38463f;
  --accent: #64b8ae;
  --accent-strong: #8ad2ca;
  --highlight: #d2b45b;
  --shadow: none;
}

[data-theme="soft"] {
  --bg: #eef3e8;
  --surface: #fbfff6;
  --surface-2: #e1ead9;
  --ink: #243024;
  --muted: #64705d;
  --line: #cbd8c0;
  --accent: #477d6b;
  --accent-strong: #2f5d50;
  --highlight: #8d8c3a;
  --shadow: 0 12px 28px rgba(50, 71, 40, .10);
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--sticky-offset);
}
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 0 0, rgba(31, 118, 111, .12), transparent 34rem),
    linear-gradient(180deg, rgba(183, 138, 47, .08), transparent 28rem),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}
body.reader-mode { background: var(--bg); }
body.reader-mode .app { margin-bottom: 110px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 54%, transparent);
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px clamp(16px, 5vw, 56px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  overflow: visible;
}
.reader-header-toggle {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.reader-header-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.brand, .nav, .stat-row, .meta, .reader-actions, .filter-row {
  display: flex;
  align-items: center;
}
.brand { gap: 12px; min-width: 0; font-weight: 800; }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.nav-link {
  gap: 8px;
}

.nav-link-feature {
  position: relative;
  gap: 9px;
  padding-inline: 15px 16px;
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent),
    color-mix(in srgb, var(--surface) 84%, var(--surface-2));
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 12%, transparent);
  font-weight: 800;
}

.nav-link-feature .nav-link-icon {
  display: grid;
  place-items: center;
  width: 18px;
  color: var(--accent-strong);
  font-size: .98rem;
  line-height: 1;
}

.nav-link-feature:hover,
.nav-link-feature.is-current {
  border-color: color-mix(in srgb, var(--accent) 64%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 16%, transparent), transparent),
    color-mix(in srgb, var(--surface) 78%, var(--surface-2));
  box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 18%, transparent);
}

.nav-link-feature.is-current {
  color: var(--accent-strong);
}

.nav a, .nav button, .nav-user-trigger, .button, .control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.nav form { margin: 0; }
.nav a:hover, .nav button:hover, .nav-user-trigger:hover, .button:hover, .control:hover { border-color: var(--accent); color: var(--accent-strong); }
.nav-user {
  position: relative;
}
.nav-user::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  width: 100%;
  height: 10px;
}
.nav-user summary {
  list-style: none;
}
.nav-user summary::-webkit-details-marker {
  display: none;
}
.nav-user-trigger {
  gap: 10px;
  max-width: min(280px, 72vw);
  text-align: left;
  cursor: pointer;
}
.nav-user-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 999px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 28%, transparent), color-mix(in srgb, var(--highlight) 16%, transparent)),
    var(--surface-2);
  color: var(--accent-strong);
  font-weight: 800;
}
.nav-user-copy {
  display: grid;
  min-width: 0;
  line-height: 1.15;
}
.nav-user-copy strong,
.nav-user-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-user-copy small {
  color: var(--muted);
  font-size: .78rem;
}
.nav-user-caret {
  color: var(--muted);
  font-size: .82rem;
}
.nav-user[open] .nav-user-trigger,
.nav-user:hover .nav-user-trigger {
  border-color: var(--accent);
}
.nav-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: grid;
  gap: 6px;
  min-width: 210px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity .16s ease, transform .16s ease;
}
.nav-user-menu a,
.nav-user-menu button {
  width: 100%;
  justify-content: flex-start;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
}
.nav-user-menu a:hover,
.nav-user-menu button:hover {
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
}
.nav-user-menu form {
  margin: 0;
}
.nav-user[open] .nav-user-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button.secondary { background: var(--surface-2); }
.button.disabled { pointer-events: none; opacity: .55; }

.app { width: min(1240px, calc(100% - 32px)); margin: 28px auto 72px; }
.site-footer {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto 28px;
  padding: 22px 0 0;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
}
.site-footer strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}
.site-footer p { margin: 0; line-height: 1.6; }
.footer-credit {
  color: var(--muted);
  font-size: .95rem;
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}
.site-footer a {
  color: var(--ink);
  font-weight: 700;
}
.site-footer a:hover { color: var(--accent-strong); }
.library-shell { display: grid; gap: 24px; }
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 20px;
  align-items: stretch;
}
.intro-copy, .continue-box, .panel, .story-card, .story-summary, .chapter-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.intro-copy { padding: clamp(24px, 5vw, 48px); }
.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.intro h1, .story-title, .chapter-title { margin: 0; line-height: 1.12; }
.intro h1 { max-width: 740px; font-size: clamp(2rem, 5vw, 4rem); }
.intro-copy p {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.06rem;
  line-height: 1.7;
}
.continue-box {
  display: grid;
  align-content: space-between;
  gap: 18px;
  padding: 22px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 14%, transparent), transparent), var(--surface);
}
.continue-box h2, .panel h2, .chapter-panel h2 { margin: 0; font-size: 1.2rem; }
.stat-row { flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.stat {
  min-width: 120px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 72%, var(--surface-2));
}
.stat strong { display: block; font-size: 1.35rem; }
.stat span, .muted { color: var(--muted); }
.panel { padding: 18px; }
.panel > h2,
.chapter-panel > h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel > h2::before,
.chapter-panel > h2::before {
  content: "";
  width: 4px;
  height: 1.15em;
  border-radius: 999px;
  background: var(--accent);
}
.filter-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, auto) auto; gap: 12px; margin-top: 14px; }
.highlight-filter {
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
}
.search, .filter-row input, .control {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
}
.story-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  min-height: 100%;
  padding: 12px;
  overflow: hidden;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, transparent), var(--surface)),
    var(--surface);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.story-card:hover {
  border-color: var(--accent);
  box-shadow: 0 18px 38px color-mix(in srgb, var(--accent) 14%, transparent);
  transform: translateY(-2px);
}
.cover {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(31, 118, 111, .24), rgba(192, 139, 44, .20)), var(--surface-2);
  color: var(--ink);
  text-align: center;
  padding: 18px;
}
.cover img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cover-tags {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
}
.cover-tags span {
  max-width: 100%;
  padding: 4px 7px;
  border: 1px solid color-mix(in srgb, var(--surface) 70%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--ink);
  font-size: .76rem;
  font-weight: 800;
  line-height: 1.1;
  backdrop-filter: blur(10px);
}
.cover-fallback {
  position: relative;
  z-index: 1;
  font-weight: 800;
  line-height: 1.3;
}
.story-card h2 {
  display: -webkit-box;
  min-height: 2.7em;
  overflow: hidden;
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.meta { flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: .92rem; }
.story-card .meta {
  align-self: end;
  gap: 6px;
}
.story-card .meta span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 7px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  color: var(--muted);
  line-height: 1.2;
}
.chapter-panel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
}
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  color: var(--ink);
}

.story-page {
  display: grid;
  grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.story-page-reflow {
  grid-template-columns: 1fr;
}
.story-hero {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: clamp(16px, 4vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 48%),
    var(--surface);
  box-shadow: var(--shadow);
}
.story-hero .cover {
  box-shadow: 0 18px 34px color-mix(in srgb, var(--ink) 14%, transparent);
}
.story-overview {
  display: grid;
  gap: 14px;
}
.story-summary { position: sticky; top: 96px; padding: 14px; }
.story-summary .cover { margin-bottom: 16px; }
.story-title { margin-bottom: 12px; font-size: clamp(1.65rem, 4vw, 2.7rem); }
.story-description { margin: 14px 0 0; color: var(--muted); line-height: 1.65; }
.story-overview .story-description {
  max-width: 78ch;
  margin-top: 0;
}
.story-rating {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 2px 0;
}
.rating-stars {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.rating-stars button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--muted) 62%, transparent);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.rating-stars button:hover,
.rating-stars button.is-active {
  color: var(--highlight);
}
.rating-stars:has(button[data-rating="1"]:hover) button[data-rating="1"],
.rating-stars:has(button[data-rating="2"]:hover) button:nth-child(-n + 2),
.rating-stars:has(button[data-rating="3"]:hover) button:nth-child(-n + 3),
.rating-stars:has(button[data-rating="4"]:hover) button:nth-child(-n + 4),
.rating-stars:has(button[data-rating="5"]:hover) button:nth-child(-n + 5) {
  color: var(--highlight);
}
.rating-stars button:disabled {
  cursor: default;
}
.rating-summary {
  color: var(--muted);
  font-size: .94rem;
}
.reader-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 156px));
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}
.reader-actions .button { white-space: nowrap; }
.nav-label-short { display: none; }
.chapter-panel { padding: clamp(18px, 4vw, 30px); }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: .95rem; margin-bottom: 14px; }

.chapter-items {
  display: grid;
  gap: 0;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
}
.chapter-items li {
  border-bottom: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
}
.chapter-items a {
  display: grid;
  grid-template-columns: minmax(0, 132px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 14px 6px 14px 4px;
  background: transparent;
  transition: color .16s ease, background-color .16s ease, padding-left .16s ease;
}
.chapter-items span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  width: fit-content;
  max-width: 100%;
  padding: 4px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.2;
  justify-self: start;
}
.chapter-items span:empty {
  visibility: hidden;
}
.chapter-items strong {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  line-height: 1.36;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.chapter-items strong.title-fit-sm {
  font-size: .92rem;
  line-height: 1.32;
  -webkit-line-clamp: 2;
}
.chapter-items strong.title-fit-xs {
  font-size: .86rem;
  line-height: 1.28;
  -webkit-line-clamp: 3;
}
.chapter-items strong.title-fit-xxs {
  font-size: .8rem;
  line-height: 1.24;
  -webkit-line-clamp: 3;
}
.chapter-items a:hover {
  background: color-mix(in srgb, var(--surface-2) 46%, transparent);
  color: var(--accent-strong);
  padding-left: 10px;
}
.chapter-items a.is-resume::after {
  content: "Đọc tiếp";
  grid-column: 3;
  align-self: center;
  justify-self: end;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent-strong);
  font-size: .78rem;
  font-weight: 800;
  white-space: nowrap;
}
.chapter-list-note {
  margin: 10px 0 0;
}

.reading-items {
  display: grid;
  gap: 0;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
}

.reading-items li {
  border-bottom: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
}

.reading-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 14px 6px 14px 0;
  transition: color .16s ease, background-color .16s ease, padding-left .16s ease;
}

.reading-item:hover {
  background: color-mix(in srgb, var(--surface-2) 46%, transparent);
  color: var(--accent-strong);
  padding-left: 10px;
}

.reading-item-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.reading-item-copy small {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
  line-height: 1.3;
}

.reading-item-copy strong {
  line-height: 1.35;
}

.reading-item-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent-strong);
  font-size: .8rem;
  font-weight: 800;
  white-space: nowrap;
}

.reader {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: clamp(12px, 3vw, 28px) 0 clamp(48px, 8vw, 88px);
}
.reader-header {
  padding: clamp(18px, 4vw, 34px) clamp(16px, 5vw, 54px) clamp(20px, 4vw, 34px);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 7%, transparent), transparent 72%),
    color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow);
  text-align: center;
}
.reader .breadcrumb {
  justify-content: center;
  margin-bottom: 18px;
}
.reader-header .story-rating {
  justify-content: center;
  margin-bottom: 14px;
}
.reader-kicker {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-weight: 800;
}
.reader-completion-note {
  margin: 0 auto 14px;
  color: var(--accent-strong);
  font-size: .95rem;
  font-weight: 700;
}
.chapter-title {
  max-width: 760px;
  margin: 0 auto 18px;
  font-size: clamp(1.75rem, 4vw, 3rem);
  text-wrap: balance;
}
.reader-content {
  max-width: 74ch;
  margin: clamp(28px, 5vw, 52px) auto 0;
  padding: 0 clamp(10px, 3vw, 24px);
  font-family: "Times New Roman", "Noto Serif", "Liberation Serif", serif;
  font-size: var(--reader-size) !important;
  line-height: 1.9;
  hyphens: auto;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
}
.reader-content * { font-size: inherit !important; }
.reader-content p { margin: 0 0 1.15em; text-align: justify; }
.reader-content a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.reader-highlight {
  position: relative;
  border-radius: 4px;
  background: color-mix(in srgb, var(--highlight) 42%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--highlight) 20%, transparent);
  cursor: pointer;
}
.reader-highlight:hover {
  background: color-mix(in srgb, var(--highlight) 58%, transparent);
}
.reader-highlight.is-target {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.reader-highlight[data-note]:hover::after {
  content: attr(data-note);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 85;
  width: max-content;
  max-width: min(280px, 82vw);
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: .86rem !important;
  line-height: 1.35;
  text-align: left;
  transform: translateX(-50%);
}
.highlight-popover {
  position: fixed;
  z-index: 80;
  display: none;
  max-width: calc(100vw - 20px);
  flex-wrap: wrap;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.highlight-popover.is-visible { display: inline-flex; }
.highlight-popover {
  gap: 8px;
}
.highlight-popover.is-manage {
  width: min(300px, calc(100vw - 20px));
  align-items: stretch;
}
.highlight-popover-note {
  display: grid;
  flex: 1 1 100%;
  gap: 3px;
  min-width: 0;
  padding-bottom: 2px;
}
.highlight-popover-note strong {
  overflow: hidden;
  color: var(--ink);
  font-size: .95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.highlight-popover-note span {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.35;
}
.highlight-popover button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: inherit;
  font-weight: 800;
  padding: 6px 8px;
  cursor: pointer;
}
.highlight-popover button[data-action="delete-inline-highlight"] {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  color: var(--danger);
}
.highlight-dialog {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .34);
}
.highlight-dialog.is-open { display: grid; }
.highlight-card {
  width: min(480px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.highlight-card h2 { margin: 0 0 10px; font-size: 1.2rem; }
.highlight-preview {
  max-height: 150px;
  overflow: auto;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  line-height: 1.6;
}
.highlight-card label { display: grid; gap: 6px; color: var(--muted); }
.highlight-card input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.highlight-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.highlight-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.highlight-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 78%, var(--surface-2));
}
.highlight-item h2 { margin: 0; font-size: 1.05rem; }
.highlight-item blockquote {
  margin: 0;
  color: var(--ink);
  line-height: 1.65;
}
.highlight-meta {
  color: var(--muted);
  font-size: .92rem;
}
.reader-footer {
  max-width: 780px;
  margin: clamp(34px, 6vw, 64px) auto 0;
  padding: 0 clamp(10px, 3vw, 24px);
}
.reader-end {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  color: var(--muted);
  font-size: .92rem;
  text-align: center;
}
.reader-end::before,
.reader-end::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}
.reader-actions-bottom { margin-top: 22px; }
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 100%;
  height: 4px;
  background: color-mix(in srgb, var(--line) 70%, transparent);
}
.reading-progress span { display: block; width: 0; height: 100%; background: var(--accent); }

.reader-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: grid;
  justify-items: end;
  max-width: calc(100vw - 28px);
}
.reader-fab::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 48px;
  display: none;
  width: min(260px, calc(100vw - 28px));
  height: 18px;
}
.reader-fab-main, .reader-fab-control, .reader-fab-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.reader-fab-main, .reader-fab-control {
  cursor: pointer;
}
.reader-fab-main {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
  text-align: center;
  appearance: none;
  -webkit-appearance: none;
}
.reader-fab-panel {
  position: absolute;
  right: 0;
  bottom: 60px;
  display: grid;
  gap: 10px;
  width: min(260px, calc(100vw - 28px));
  padding: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(.98);
  transform-origin: bottom right;
  transition: opacity .16s ease, transform .16s ease;
  cursor: default;
}
.reader-fab.is-open .reader-fab-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.reader-fab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
}
.reader-fab-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
.reader-fab-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.reader-fab:not(.is-reader) .reader-fab-actions {
  grid-template-columns: 1fr;
}
.reader-fab-control {
  display: grid;
  place-items: center;
  gap: 3px;
  min-width: 60px;
  min-height: 54px;
  padding: 6px 8px;
}
.reader-fab-control span { font-size: 1.05rem; line-height: 1; }
.reader-fab-control small { color: var(--muted); font-size: .76rem; }
.reader-fab-menu label { color: var(--muted); font-size: .92rem; }
.reader-fab-menu input[type="range"] { width: 100%; accent-color: var(--accent); }
.reader-fab-main:hover, .reader-fab-control:hover { border-color: var(--accent); color: var(--accent-strong); }
@media (hover: hover) and (pointer: fine) {
  .nav-user:hover .nav-user-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
  .reader-fab:hover::before {
    display: block;
  }
  .reader-fab:hover .reader-fab-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.account-shell {
  width: min(920px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}
.account-shell-wide {
  width: min(1120px, 100%);
}
.account-hero-card h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.15;
}
.account-hero-card p:last-child {
  margin: 14px 0 0;
  line-height: 1.7;
}
.account-card {
  display: grid;
  gap: 14px;
}
.account-card h2 {
  margin: 0;
  font-size: 1.2rem;
}
.account-form {
  display: grid;
  gap: 14px;
}
.account-form label {
  display: grid;
  gap: 6px;
  font-weight: 650;
}
.account-form label input {
  font-weight: 400;
}
.account-note {
  margin: 0;
  color: var(--muted);
}
.account-note a {
  color: var(--accent-strong);
  font-weight: 700;
}
.account-summary {
  display: grid;
  gap: 18px;
}
.account-profile-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 20px;
  align-items: stretch;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 11%, transparent), transparent 52%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 95%, transparent), var(--surface));
}
.account-profile-lead {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}
.account-avatar {
  display: grid;
  place-items: center;
  width: 84px;
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 999px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 26%, transparent), color-mix(in srgb, var(--highlight) 18%, transparent)),
    var(--surface-2);
  color: var(--accent-strong);
  font-size: 2rem;
  font-weight: 800;
}
.account-identity {
  display: grid;
  gap: 10px;
}
.account-identity h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.06;
}
.account-identity .muted {
  margin: 0;
  max-width: 56ch;
  line-height: 1.7;
}
.account-identity-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.account-profile-side {
  display: grid;
  align-content: space-between;
  gap: 16px;
}
.account-stat-grid {
  display: grid;
  gap: 10px;
  margin: 0;
}
.account-stat-grid-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.account-stat-grid div {
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-2));
}
.account-stat-grid dt {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
}
.account-stat-grid dd {
  margin: 0;
  line-height: 1.45;
}
.account-quick-links,
.account-shortcuts,
.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.account-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}
.account-meta div {
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 68%, transparent);
}
.account-meta dt {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
}
.account-meta dd {
  margin: 0;
  line-height: 1.45;
}
.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.account-profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .8fr);
  gap: 18px;
  align-items: start;
}
.account-panel-stack,
.account-side-stack {
  display: grid;
  gap: 18px;
}
.account-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.account-helper {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.account-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.account-field-grid > label:first-child {
  grid-column: 1 / -1;
}
.account-note-panel h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.35;
}
.account-complete-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}
.account-complete-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}
.account-complete-item:first-child {
  border-top: 0;
  padding-top: 0;
}
.account-complete-item strong,
.account-complete-item span,
.account-complete-item small {
  display: block;
}
.account-complete-item span,
.account-complete-item small {
  color: var(--muted);
  font-size: .88rem;
}
.leaderboard-shell {
  display: grid;
  gap: 18px;
}
.leaderboard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.leaderboard-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}
.leaderboard-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}
.leaderboard-rank span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
  color: var(--accent-strong);
  font-weight: 800;
}
.leaderboard-copy,
.leaderboard-score {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.leaderboard-copy strong,
.leaderboard-copy small,
.leaderboard-score strong,
.leaderboard-score small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaderboard-copy small,
.leaderboard-score small {
  color: var(--muted);
}
.leaderboard-score {
  text-align: right;
}
.account-note-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}
.flash-message {
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  color: var(--ink);
}
.flash-message.error {
  border-color: color-mix(in srgb, var(--danger) 48%, var(--line));
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}

.comments-shell {
  width: min(980px, 100%);
  margin: 30px auto 0;
  padding: clamp(18px, 4vw, 28px);
  display: grid;
  gap: 18px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, transparent), transparent 140px),
    var(--surface);
}
.comments-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
}
.comments-head h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.18;
}
.comments-head .muted {
  margin: 10px 0 0;
  max-width: 62ch;
  line-height: 1.7;
}
.comments-stat {
  display: grid;
  justify-items: end;
  gap: 4px;
  min-width: 92px;
  padding: 4px 0 2px;
}
.comments-stat strong {
  font-size: 1.5rem;
  line-height: 1;
}
.comments-stat span {
  color: var(--muted);
  font-size: .88rem;
}
.comments-feedback {
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.comments-feedback.is-error {
  border-color: color-mix(in srgb, var(--danger) 48%, var(--line));
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}
.comments-composer {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 4%, transparent), transparent 160px),
    color-mix(in srgb, var(--surface) 90%, var(--surface-2));
}
.comments-composer-head,
.comments-auth-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.comments-auth-callout {
  align-items: flex-start;
}
.comments-auth-callout .muted {
  margin: 8px 0 0;
  line-height: 1.6;
}
.comments-auth-actions,
.comments-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.comments-user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.comments-user-chip strong,
.comment-meta strong {
  display: block;
}
.comments-user-chip span:last-child,
.comments-hint,
.comment-meta span,
.comment-action-muted,
.comment-reply-context,
.comments-counter {
  color: var(--muted);
  font-size: .9rem;
}
.comments-user-avatar,
.comment-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  border-radius: 999px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 26%, transparent), color-mix(in srgb, var(--highlight) 18%, transparent)),
    var(--surface-2);
  color: var(--accent-strong);
  font-weight: 800;
}
.comment-avatar.small {
  width: 34px;
}
.comments-form {
  display: grid;
  gap: 10px;
}
.comments-form textarea,
.comment-inline-reply textarea {
  width: 100%;
  min-height: 118px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.7;
  resize: vertical;
}
.comment-inline-reply textarea {
  min-height: 88px;
}
.comments-form-foot,
.comment-inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.comments-list {
  display: grid;
  gap: 14px;
}
.comments-empty {
  padding: 28px 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  color: var(--muted);
}
.comments-empty strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
}
.comments-empty p {
  margin: 0;
  line-height: 1.6;
}
.comment-card,
.comment-reply {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, transparent), color-mix(in srgb, var(--surface-2) 26%, transparent)),
    var(--surface);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--ink) 5%, transparent);
}
.comment-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.comment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}
.comment-meta time {
  color: var(--muted);
  font-size: .88rem;
}
.comment-content {
  display: grid;
  gap: 8px;
  line-height: 1.7;
}
.comment-content p {
  margin: 0;
}
.comment-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.comment-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 700;
  cursor: pointer;
}
.comment-reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.comment-reaction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 42px;
  min-height: 38px;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 86%, var(--surface-2));
  color: var(--ink);
  cursor: pointer;
}
.comment-reaction span {
  font-size: 1rem;
  line-height: 1;
}
.comment-reaction:hover,
.comment-reaction.is-active {
  border-color: var(--accent);
  color: var(--accent-strong);
}
.comment-reaction em {
  font-style: normal;
}
.comment-reaction em {
  color: var(--muted);
  font-size: .78rem;
  line-height: 1;
}
.comment-inline-reply {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.comment-replies {
  display: grid;
  gap: 10px;
  margin-top: 2px;
  padding-left: 18px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 20%, var(--line));
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.pagination-summary { color: var(--muted); }
.pagination-links {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pagination-links span {
  min-width: 112px;
  color: var(--muted);
  text-align: center;
}
.page-size-form label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.page-size-form select {
  width: auto;
  min-width: 84px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

@media (max-width: 820px) {
  :root { --sticky-offset: 132px; }
  .site-header, .intro, .story-page, .filter-row { grid-template-columns: 1fr; }
  .site-header {
    display: grid;
    gap: 12px;
    padding: 12px 14px;
  }
  .brand {
    gap: 10px;
    justify-content: flex-start;
  }
  .brand img {
    width: 38px;
    height: 38px;
  }
  .brand span {
    font-size: 1.08rem;
  }
  .nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    align-items: stretch;
    overflow: visible;
    padding-bottom: 0;
    row-gap: 10px;
    column-gap: 10px;
    width: 100%;
  }
  .nav a, .nav-user { min-width: 0; }
  .nav-link-feature {
    width: 100%;
    min-height: 50px;
    justify-content: flex-start;
    padding: 11px 14px;
  }
  .nav-link-feature span:last-child {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nav-user,
  .nav a:not(.nav-link-feature) {
    grid-column: 1 / -1;
  }
  .nav-user-trigger {
    width: 100%;
    min-height: 52px;
    justify-content: flex-start;
    padding: 10px 12px;
  }
  .nav-user-menu {
    left: 0;
    right: 0;
    min-width: 0;
  }
  body.reader-mode .site-header {
    position: fixed;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 66;
    display: grid;
    min-height: auto;
    gap: 10px;
    padding: 12px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-125%);
    transition: opacity .18s ease, transform .18s ease;
  }
  body.reader-mode.reader-nav-open .site-header {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
  body.reader-mode .reader-header-toggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 67;
    display: grid;
    place-content: center;
    gap: 4px;
    width: 42px;
    height: 42px;
  }
  body.reader-mode.reader-nav-open .reader-header-toggle {
    opacity: 0;
    pointer-events: none;
  }
  body.reader-mode .brand { gap: 8px; }
  body.reader-mode .brand img { width: 34px; height: 34px; }
  body.reader-mode .brand span { font-size: 1rem; }
  body.reader-mode .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  body.reader-mode .nav a {
    min-height: 44px;
    padding: 10px 12px;
    white-space: nowrap;
  }
  body.reader-mode .nav-user-trigger {
    min-height: 48px;
    padding: 10px 12px;
  }
  .story-summary { position: static; }
  .story-hero {
    grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
  }
  .app { width: min(100% - 24px, 1240px); margin-top: 18px; }
  body.reader-mode .app {
    width: min(100% - 20px, 920px);
    margin-top: 12px;
    margin-bottom: 96px;
  }
  .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reader-header {
    padding: 18px 14px 20px;
  }
  .rating-stars button {
    width: 38px;
    height: 38px;
  }
  .reader-content {
    line-height: 1.82;
  }
  .reader-fab { right: 12px; bottom: 12px; }
  .reader-fab-panel { width: min(260px, calc(100vw - 24px)); }
  .pagination-bar, .pagination-links, .page-size-form label {
    align-items: stretch;
    width: 100%;
  }
  .pagination-links .button { flex: 1; }
  .page-size-form, .page-size-form select { width: 100%; }
  .site-footer {
    display: grid;
    gap: 14px;
  }
  .account-grid,
  .account-meta,
  .account-field-grid,
  .account-profile-layout,
  .account-profile-hero,
  .comments-head {
    grid-template-columns: 1fr;
  }
  .account-profile-lead {
    grid-template-columns: 1fr;
  }
  .account-stat-grid-compact {
    grid-template-columns: 1fr;
  }
  .leaderboard-head,
  .leaderboard-item {
    grid-template-columns: 1fr;
  }
  .leaderboard-score {
    text-align: left;
  }
  .account-avatar {
    width: 72px;
  }
  .comments-composer-head,
  .comments-auth-callout,
  .comments-form-foot,
  .comment-inline-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .site-footer nav {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  :root { --sticky-offset: 142px; }
  .nav {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .nav-link-feature {
    padding-inline: 12px 13px;
  }
  .story-grid {
    grid-template-columns: 1fr;
  }
  .chapter-items a {
    grid-template-columns: minmax(0, 88px) minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 68px;
    padding-right: 4px;
  }
  .chapter-items a.is-resume::after {
    padding: 4px 8px;
    font-size: .74rem;
  }
  .chapter-items span {
    width: 100%;
    justify-content: center;
    font-size: .78rem;
  }
  .reading-item {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding-right: 0;
  }
  .reading-item-action {
    justify-self: start;
  }
  .comment-card,
  .comment-reply {
    grid-template-columns: 1fr;
  }
  .comment-avatar {
    width: 38px;
  }
  .comment-replies {
    padding-left: 12px;
  }
  .intro-copy,
  .continue-box,
  .panel,
  .chapter-panel {
    padding: 16px;
  }
  .story-card {
    grid-template-columns: 92px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
  }
  .story-card .cover {
    grid-row: 1 / span 2;
    width: 92px;
  }
  .story-card h2 {
    min-height: 0;
    -webkit-line-clamp: 3;
  }
  .story-card .meta {
    align-self: start;
  }
  .reader-fab {
    right: 10px;
    bottom: 10px;
  }
  .reader-fab-main {
    width: 48px;
    height: 48px;
  }
  .story-hero {
    grid-template-columns: 1fr;
  }
  .story-hero .cover {
    width: min(190px, 70vw);
    justify-self: center;
  }
  .reader {
    padding-bottom: 44px;
  }
  .reader-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .reader-actions .button {
    min-width: 0;
    min-height: 38px;
    padding: 7px 8px;
    font-size: .9rem;
  }
  .reader-content {
    padding-inline: 4px;
  }
  .reader-content p {
    text-align: left;
  }
  .reader-fab-panel {
    right: 56px;
    bottom: 0;
    width: min(244px, calc(100vw - 76px));
    padding: 8px;
    gap: 7px;
  }
  .reader-fab-actions {
    gap: 6px;
  }
  .reader-fab-control {
    min-width: 0;
    min-height: 44px;
    padding: 5px;
  }
  .reader-fab-control small {
    display: none;
  }
  .reader-fab-menu label {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: .82rem;
  }
  .nav-user-trigger {
    max-width: none;
    padding-inline: 10px;
  }
  .nav-user {
    margin-left: 0;
  }
  .nav-user-copy strong {
    max-width: none;
  }
  .nav-user-menu {
    left: 0;
    right: 0;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 380px) {
  .reader-actions .button {
    font-size: .86rem;
    padding-inline: 6px;
  }
  .nav-label-full { display: none; }
  .nav-label-short { display: inline; }
}
