:root {
  --paper: #f6efe2;
  --paper-deep: #eee3d2;
  --paper-light: #fffaf0;
  --card: #fffaf2;
  --ink: #211c18;
  --ink-soft: #5c5047;
  --ink-faint: #75675c;
  --line: #cfc0ad;
  --line-soft: #e4d9c9;
  --cinnabar: #8b3026;
  --cinnabar-dark: #69241d;
  --cinnabar-wash: rgba(139, 48, 38, 0.1);
  --focus: #135e96;
  --reader-width: 700px;
  --header-height: 66px;
  --bottom-height: calc(67px + env(safe-area-inset-bottom));
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --latin: Georgia, "Times New Roman", serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -15%, rgba(255, 252, 242, 0.95), transparent 42rem),
    linear-gradient(90deg, #e8dece 0, #efe6d8 15%, #efe6d8 85%, #e8dece 100%);
  font-family: var(--serif);
  line-height: 1.78;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: var(--cinnabar-dark);
  text-underline-offset: 0.16em;
}

img {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  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: fixed;
  z-index: 200;
  top: 8px;
  left: 8px;
  padding: 9px 14px;
  color: white;
  background: var(--ink);
  border-radius: 5px;
  transform: translateY(-150%);
}

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

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

.site-frame {
  width: min(100%, var(--reader-width));
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: var(--bottom-height);
  background: var(--paper);
  border-inline: 1px solid rgba(105, 85, 63, 0.12);
  box-shadow: 0 0 42px rgba(60, 44, 29, 0.09);
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px clamp(12px, 3.4vw, 22px);
  background: rgba(246, 239, 226, 0.94);
  border-bottom: 1px solid rgba(207, 192, 173, 0.7);
  backdrop-filter: blur(14px) saturate(105%);
}

.brand-button,
.icon-button,
.bottom-nav button,
.chapter-card,
.text-button,
.heart-button,
.secondary-button,
.primary-button,
.sort-button,
.rank-open,
.comment-action,
.drawer-link {
  appearance: none;
  border: 0;
  cursor: pointer;
}

.brand-button {
  min-width: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  padding: 4px 3px;
  background: transparent;
  line-height: 1.1;
  text-align: left;
}

.brand-button strong {
  overflow: hidden;
  max-width: 100%;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-button span {
  overflow: hidden;
  max-width: 100%;
  margin-top: 4px;
  color: var(--ink-faint);
  font-family: var(--latin);
  font-size: 10px;
  font-style: italic;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--cinnabar-dark);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.shelf-link,
.login-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 11px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.login-link.is-authenticated {
  color: var(--cinnabar-dark);
  border-color: rgba(139, 48, 38, 0.45);
}

main {
  min-height: calc(100vh - var(--header-height) - var(--bottom-height));
  padding: 0 clamp(17px, 5vw, 34px) 40px;
}

.view {
  animation: view-enter 260ms ease both;
}

.view[hidden] {
  animation: none;
}

@keyframes view-enter {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.cover-stage {
  padding: clamp(24px, 6vw, 44px) 0 8px;
  text-align: center;
}

.cover-image-wrap {
  width: min(70vw, 286px);
  margin: 0 auto 26px;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 3px 12px 12px 3px;
  box-shadow: -7px 8px 0 #dfd2bf, 0 20px 38px rgba(60, 42, 26, 0.17);
  overflow: hidden;
  animation: cover-enter 560ms cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

.cover-image-wrap img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

@keyframes cover-enter {
  from {
    opacity: 0;
    transform: translateY(15px) rotate(-1deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

.kicker,
.section-label,
.dialog-heading > span,
.drawer-header span,
.chapter-source,
.page-label {
  color: var(--cinnabar-dark);
  font-family: var(--latin);
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.cover-stage h1 {
  margin: 0.25em 0 0.12em;
  font-size: clamp(36px, 9vw, 52px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: 0.08em;
}

.cover-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--latin);
  font-size: 15px;
  font-style: italic;
}

.cover-byline,
.cover-summary {
  color: var(--ink-soft);
  font-size: 14px;
}

.cover-byline {
  margin: 14px 0 0;
}

.cover-summary {
  max-width: 34em;
  margin: 20px auto 0;
}

.book-rule {
  height: 1px;
  margin: 28px 0;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.reading-guide {
  margin-bottom: 30px;
  padding: 16px 18px;
  color: var(--ink-soft);
  background: rgba(255, 250, 242, 0.72);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--cinnabar);
  border-radius: 3px 11px 11px 3px;
  font-size: 14px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 34px 0 13px;
}

.section-label::after {
  height: 1px;
  flex: 1;
  content: "";
  background: var(--line-soft);
}

.chapter-list,
.drawer-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chapter-card {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 15px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  box-shadow: 0 5px 13px rgba(67, 48, 28, 0.045);
  text-align: left;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.chapter-card:hover {
  border-color: var(--line);
  box-shadow: 0 8px 18px rgba(67, 48, 28, 0.075);
  transform: translateY(-1px);
}

.chapter-number {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--cinnabar-dark);
  border: 1.5px solid var(--cinnabar);
  border-radius: 50%;
  font-family: var(--latin);
  font-size: 13px;
  line-height: 1;
  text-align: center;
}

.chapter-card-copy {
  min-width: 0;
}

.chapter-card-copy strong {
  display: block;
  overflow: hidden;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-card-copy small {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--ink-faint);
  font-family: var(--latin);
  font-size: 11px;
  font-style: italic;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-arrow {
  color: var(--ink-faint);
  font-size: 20px;
}

.chapter-heading {
  padding: 32px 0 16px;
}

.back-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 0;
  color: var(--cinnabar-dark);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
}

.chapter-heading h1 {
  margin: 19px 0 4px;
  font-size: clamp(27px, 7vw, 36px);
  line-height: 1.35;
  letter-spacing: 0.04em;
}

.chapter-heading p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.chapter-source {
  margin-top: 8px;
  color: var(--ink-faint);
}

.loading-state,
.empty-state,
.error-state {
  padding: 64px 18px;
  color: var(--ink-soft);
  text-align: center;
}

.loading-mark {
  width: 30px;
  height: 30px;
  margin: 0 auto 16px;
  border: 2px solid var(--line);
  border-top-color: var(--cinnabar);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.page-break {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 33px 0 6px;
  color: var(--ink-faint);
}

.page-break::before,
.page-break::after {
  height: 1px;
  flex: 1;
  content: "";
  background: var(--line-soft);
}

.page-label {
  flex: none;
  color: var(--ink-faint);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.text-segment {
  position: relative;
  padding: 23px 2px 17px;
  border-bottom: 1px solid var(--line-soft);
  scroll-margin-top: calc(var(--header-height) + 18px);
}

.text-segment::before {
  position: absolute;
  top: 23px;
  bottom: 17px;
  left: -15px;
  width: 3px;
  content: "";
  background: var(--cinnabar);
  border-radius: 3px;
  opacity: var(--heat-opacity, 0);
  transition: opacity 240ms ease;
}

.text-segment.is-targeted {
  background: linear-gradient(90deg, var(--cinnabar-wash), transparent 72%);
}

.segment-text {
  margin: 0;
  font-size: clamp(17.5px, 4.5vw, 19.5px);
  line-height: 1.98;
  letter-spacing: 0.016em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.segment-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 13px;
}

.heart-group {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 1px;
  border-radius: 999px;
}

.heart-button {
  width: 38px;
  height: 40px;
  padding: 0;
  color: var(--cinnabar);
  background: transparent;
  border-radius: 50%;
  font-family: var(--latin);
  font-size: 24px;
  line-height: 1;
  transition: transform 120ms ease, color 120ms ease;
}

.heart-button:hover,
.heart-button[aria-pressed="true"] {
  color: var(--cinnabar-dark);
  transform: translateY(-1px);
}

.heart-button[aria-pressed="true"] {
  text-shadow: 0 2px 6px rgba(139, 48, 38, 0.24);
}

.reaction-summary {
  min-width: 5em;
  color: var(--ink-faint);
  font-size: 12px;
}

.reaction-summary strong {
  color: var(--cinnabar-dark);
}

.text-button,
.comment-action {
  min-height: 38px;
  padding: 6px 11px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}

.text-button.has-note,
.comment-action.has-comments {
  color: var(--cinnabar-dark);
  border-color: rgba(139, 48, 38, 0.48);
}

.book-figure {
  margin: 30px auto;
  text-align: center;
}

.book-figure img {
  display: block;
  width: auto;
  max-height: 70vh;
  margin: 0 auto;
  background: var(--paper-light);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
}

.book-figure figcaption {
  max-width: 38em;
  margin: 9px auto 0;
  color: var(--ink-faint);
  font-size: 12px;
}

.chapter-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 31px 0 8px;
}

.chapter-navigation button {
  min-height: 66px;
  padding: 11px 13px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.chapter-navigation button span {
  display: block;
  color: var(--ink-faint);
  font-family: var(--latin);
  font-size: 10px;
  font-style: italic;
}

.chapter-navigation button strong {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
}

.chapter-navigation button:disabled {
  cursor: default;
  opacity: 0.42;
}

.rankings-header,
.about-header {
  padding: 38px 0 13px;
  text-align: center;
}

.rankings-header h1,
.about-header h1 {
  margin: 0.2em 0 0.1em;
  font-size: clamp(30px, 8vw, 42px);
  letter-spacing: 0.08em;
}

.rankings-header p,
.about-header p {
  max-width: 34em;
  margin: 10px auto 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.sort-bar {
  display: flex;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
  margin: 18px 0 24px;
}

.sort-button {
  min-height: 40px;
  padding: 6px 14px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}

.sort-button[aria-pressed="true"] {
  color: white;
  background: var(--cinnabar-dark);
  border-color: var(--cinnabar-dark);
}

.ranking-list {
  display: grid;
  gap: 13px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-card {
  position: relative;
  overflow: hidden;
  padding: 17px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  box-shadow: 0 6px 15px rgba(67, 48, 28, 0.05);
}

.ranking-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--rank-width, 0%);
  content: "";
  pointer-events: none;
  background: linear-gradient(90deg, var(--cinnabar-wash), transparent);
}

.ranking-card > * {
  position: relative;
}

.rank-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-number {
  width: 32px;
  height: 32px;
  display: grid;
  flex: none;
  place-items: center;
  color: white;
  background: var(--ink-faint);
  border-radius: 8px;
  font-family: var(--latin);
  font-weight: 700;
  transform: rotate(-2deg);
}

.ranking-card:nth-child(1) .rank-number {
  background: #9b741f;
}

.ranking-card:nth-child(2) .rank-number {
  background: #6e6a65;
}

.ranking-card:nth-child(3) .rank-number {
  background: #985f36;
}

.rank-chapter {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  color: var(--cinnabar-dark);
  font-family: var(--latin);
  font-size: 13px;
}

.rank-score strong {
  font-size: 21px;
}

.rank-excerpt {
  margin: 13px 0 10px;
  font-size: 16px;
  line-height: 1.72;
}

.rank-stats {
  display: flex;
  gap: 12px;
  color: var(--ink-faint);
  font-size: 11px;
}

.rank-open {
  min-height: 40px;
  margin-top: 13px;
  padding: 6px 13px;
  color: var(--cinnabar-dark);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}

.hot-comment {
  margin: 13px 0 0;
  padding: 11px 0 0;
  border-top: 1px dashed var(--line);
}

.hot-comment blockquote {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.about-copy {
  font-size: 15px;
}

.about-copy p {
  color: var(--ink-soft);
}

.about-copy h2 {
  margin: 34px 0 8px;
  font-size: 21px;
}

.about-list {
  margin: 10px 0;
  padding-left: 1.4em;
  color: var(--ink-soft);
}

.note-tools {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.secondary-button,
.primary-button {
  min-height: 44px;
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13px;
}

.secondary-button {
  color: var(--ink-soft);
  background: var(--paper-light);
  border: 1px solid var(--line);
}

.primary-button {
  color: white;
  background: var(--cinnabar-dark);
  border: 1px solid var(--cinnabar-dark);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: default;
  opacity: 0.48;
}

.bottom-nav {
  position: fixed;
  z-index: 40;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: var(--bottom-height);
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  background: rgba(246, 239, 226, 0.95);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(105%);
}

.bottom-nav button {
  width: min(31vw, 138px);
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 3px 8px;
  color: var(--ink-faint);
  background: transparent;
  border-radius: 10px;
  font-size: 12px;
}

.bottom-nav button[aria-current="page"] {
  color: var(--cinnabar-dark);
  background: var(--cinnabar-wash);
}

.nav-symbol {
  font-family: var(--latin);
  font-size: 19px;
  line-height: 1.2;
}

.drawer-layer {
  position: fixed;
  z-index: 80;
  inset: 0;
}

.drawer-scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: rgba(31, 25, 20, 0.55);
  border: 0;
  cursor: pointer;
  animation: scrim-in 180ms ease both;
}

.chapter-drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(88vw, 410px);
  overflow-y: auto;
  padding: 18px 16px calc(30px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-right: 1px solid var(--line);
  box-shadow: 18px 0 50px rgba(31, 25, 20, 0.2);
  animation: drawer-in 220ms cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

@keyframes scrim-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes drawer-in {
  from { transform: translateX(-102%); }
  to { transform: none; }
}

.drawer-header {
  position: sticky;
  z-index: 2;
  top: -18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: -18px -16px 16px;
  padding: 18px 16px 13px;
  background: rgba(246, 239, 226, 0.96);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(12px);
}

.drawer-header h2 {
  margin: 1px 0 0;
  font-size: 24px;
}

.drawer-section {
  margin: 23px 5px 8px;
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.drawer-search {
  display: grid;
  gap: 5px;
  margin: 3px 4px 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.drawer-search input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.drawer-search-status {
  min-height: 1.5em;
  margin: 5px 5px 0;
  color: var(--ink-faint);
  font-size: 11px;
}

body.drawer-open #bdfz-unified-widget {
  visibility: hidden !important;
  pointer-events: none !important;
}

.drawer-link {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  color: var(--ink);
  background: transparent;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

.drawer-link span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-link span:last-child {
  color: var(--ink-faint);
  font-family: var(--latin);
  font-size: 11px;
}

.drawer-link[aria-current="true"] {
  color: var(--cinnabar-dark);
  background: var(--cinnabar-wash);
}

body.drawer-open {
  overflow: hidden;
}

.reader-dialog {
  width: min(92vw, 620px);
  max-height: min(88vh, 820px);
  margin: auto;
  padding: 0 21px 22px;
  overflow: auto;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(31, 25, 20, 0.32);
}

.reader-dialog::backdrop {
  background: rgba(31, 25, 20, 0.58);
  backdrop-filter: blur(2px);
}

.dialog-close-row {
  position: sticky;
  z-index: 4;
  top: 0;
  display: flex;
  justify-content: flex-end;
  margin: 0 -21px;
  padding: 11px 12px 2px;
  background: linear-gradient(var(--paper) 70%, transparent);
}

.dialog-heading {
  margin: -31px 48px 18px 0;
}

.dialog-heading h2 {
  margin: 0.12em 0;
  font-size: 27px;
}

.dialog-heading p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.dialog-quote {
  max-height: 8.7em;
  overflow: auto;
  margin: 15px 0 18px;
  padding: 10px 13px;
  color: var(--ink-soft);
  background: var(--cinnabar-wash);
  border-left: 3px solid var(--cinnabar);
  font-size: 13px;
  white-space: pre-wrap;
}

.field-label {
  display: block;
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 112px;
  padding: 12px 13px;
  color: var(--ink);
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.72;
  resize: vertical;
}

.field-status {
  min-height: 1.5em;
  flex: 1;
  margin: 7px 0 0;
  color: var(--ink-faint);
  font-size: 12px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.comment-thread {
  display: grid;
  gap: 12px;
  margin: 17px 0;
  padding: 14px 0;
  border-block: 1px solid var(--line-soft);
}

.comment-item {
  padding-bottom: 11px;
  border-bottom: 1px dashed var(--line-soft);
}

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

.comment-item.is-reply {
  margin-left: 18px;
  padding-left: 12px;
  border-left: 2px solid var(--line-soft);
}

.comment-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--ink-faint);
  font-size: 11px;
}

.comment-meta strong {
  color: var(--ink);
  font-size: 12px;
}

.comment-quote {
  margin: 6px 0;
  padding-left: 9px;
  color: var(--ink-soft);
  border-left: 2px solid var(--cinnabar);
  font-size: 12px;
}

.comment-body {
  margin: 5px 0;
  font-size: 14px;
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-actions {
  display: flex;
  gap: 9px;
  margin-top: 5px;
}

.comment-actions button {
  min-height: 36px;
  padding: 4px 8px;
  color: var(--ink-faint);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 11px;
}

.comment-actions button[aria-pressed="true"] {
  color: var(--cinnabar-dark);
}

.reply-banner,
.quote-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding: 7px 9px;
  color: var(--ink-soft);
  background: var(--cinnabar-wash);
  border-left: 2px solid var(--cinnabar);
  font-size: 12px;
}

.reply-banner button,
.quote-banner button {
  flex: none;
  padding: 4px;
  color: var(--cinnabar-dark);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.login-notice {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 120;
  right: 18px;
  bottom: calc(var(--bottom-height) + 14px);
  left: 18px;
  width: max-content;
  max-width: min(90vw, 520px);
  margin: 0 auto;
  padding: 9px 15px;
  color: white;
  background: var(--ink);
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(31, 25, 20, 0.24);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: none;
}

noscript {
  position: fixed;
  z-index: 300;
  inset: 0 auto auto 0;
  width: 100%;
  padding: 12px;
  color: white;
  background: var(--cinnabar-dark);
  text-align: center;
}

@media (max-width: 560px) {
  :root {
    --header-height: 62px;
  }

  .site-frame {
    border: 0;
    box-shadow: none;
  }

  .topbar {
    gap: 7px;
    padding-inline: 9px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .brand-button strong {
    font-size: 15px;
  }

  .brand-button span,
  .shelf-link {
    display: none;
  }

  .login-link {
    min-height: 36px;
    padding-inline: 9px;
  }

  main {
    padding-inline: 18px;
  }

  .cover-image-wrap {
    width: min(62vw, 248px);
  }

  .text-segment::before {
    left: -10px;
  }

  .segment-actions {
    gap: 5px;
  }

  .heart-button {
    width: 36px;
  }

  .reaction-summary {
    order: 3;
    width: 100%;
    min-height: 1.5em;
    padding-left: 4px;
  }

  .text-button,
  .comment-action {
    margin-left: 0;
  }

  .chapter-navigation {
    grid-template-columns: 1fr;
  }

  .reader-dialog {
    width: calc(100vw - 18px);
    max-height: calc(100dvh - 18px);
    padding-inline: 16px;
    border-radius: 13px;
  }

  .dialog-close-row {
    margin-inline: -16px;
  }

  .dialog-actions {
    align-items: stretch;
  }

  .dialog-actions .secondary-button,
  .dialog-actions .primary-button {
    flex: 1 1 auto;
  }
}

@media (min-width: 860px) {
  .menu-button {
    margin-left: -2px;
  }

  .site-frame {
    margin-block: 0;
  }
}

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

@media print {
  body,
  .site-frame {
    background: white;
  }

  .site-frame {
    width: 100%;
    max-width: none;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .topbar,
  .bottom-nav,
  .segment-actions,
  .chapter-navigation,
  .drawer-layer,
  .toast {
    display: none !important;
  }

  main {
    padding: 0;
  }

  .text-segment {
    break-inside: avoid;
  }
}
