/* Reader-facing story pages: story overview + chapter reader. Mobile-first. */
.story-page { max-width: 760px; margin: 0 auto; padding: 0 0 40px; }
.story-page a { text-underline-offset: 3px; }

/* Buttons used on story pages */
.sp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 18px; border: 1px solid var(--link-color); border-radius: 999px; background: transparent; color: var(--link-color); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.sp-btn:hover { background: var(--header-bg); color: var(--header-color); }
.sp-btn.primary { background: var(--button-bg); color: var(--button-text); }
.sp-btn.primary:hover { background: var(--button-hover); color: var(--button-hover-text); }
.sp-btn.danger { color: var(--danger-text); border-color: var(--danger-border); }
.sp-btn.small { min-height: 36px; padding: 6px 14px; font-size: .9rem; }

/* ---------- Story overview ---------- */
.story-hero { background: var(--container-bg); border-radius: var(--border-radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px; }
.story-cover { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: 320px; object-fit: cover; }
.story-hero-body { padding: 20px 20px 24px; }
.story-draft-badge { display: inline-block; padding: 2px 10px; margin-bottom: 8px; border-radius: 999px; background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); font-size: .8rem; font-weight: 600; }
.story-title { margin: 0 0 6px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.75rem, 6vw, 2.6rem); line-height: 1.15; overflow-wrap: break-word; }
.story-byline { margin: 0 0 16px; color: var(--text-secondary); }
.story-byline a { color: var(--link-color); font-weight: 600; }
.story-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 16px; padding: 12px 0; border-block: 1px solid var(--border-color); text-align: center; }
.story-stats div + div { border-left: 1px solid var(--border-color); }
.story-stats dt { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); }
.story-stats dd { margin: 2px 0 0; font-size: 1.15rem; font-weight: 700; }
.story-tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.story-tag-list a { display: inline-flex; align-items: center; min-height: 32px; padding: 2px 12px; border: 1px solid var(--border-color); border-radius: 999px; background: var(--form-bg); color: var(--text-color); font-size: .85rem; text-decoration: none; }
.story-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.story-description { margin: 20px 0 0; font-family: Georgia, serif; line-height: 1.7; color: var(--text-color); }
.story-description p { margin: 0 0 1em; }
.story-description p:last-child { margin-bottom: 0; }

.toc { background: var(--container-bg); border-radius: var(--border-radius); box-shadow: var(--shadow); overflow: hidden; }
.toc-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0; padding: 16px 20px; border-bottom: 1px solid var(--border-color); font-size: 1.1rem; }
.toc-heading span { font-size: .85rem; font-weight: 400; color: var(--text-secondary); }
.toc-list { margin: 0; padding: 0; list-style: none; }
.toc-item { position: relative; display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border-color); }
.toc-item:last-child { border-bottom: 0; }
.toc-item:hover { background: var(--form-bg); }
.toc-number { flex: 0 0 2.25rem; height: 2.25rem; display: grid; place-items: center; border-radius: 50%; background: var(--header-bg); color: var(--header-color); font-weight: 700; font-size: .9rem; }
.toc-text { flex: 1; min-width: 0; }
.toc-title { display: block; font-weight: 700; color: var(--text-color); text-decoration: none; }
.toc-title::after { content: ""; position: absolute; inset: 0; }   /* whole row is the link */
.toc-snippet { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 2px 0 0; font-size: .9rem; color: var(--text-secondary); }
.toc-words { flex: none; font-size: .8rem; color: var(--text-secondary); white-space: nowrap; }
.toc-edit { position: relative; z-index: 1; }
.toc-empty { padding: 32px 20px; text-align: center; color: var(--text-secondary); }
.story-footer-nav { margin-top: 24px; text-align: center; }

/* ---------- Chapter reader ---------- */
.reader-crumbs { margin: 0 0 8px; font-size: .9rem; color: var(--text-secondary); }
.reader-crumbs a { color: var(--link-color); font-weight: 600; }
.reader-meta { margin: 0 0 16px; font-size: .9rem; color: var(--text-secondary); }
.reader-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

/* The reading sheet. Colours, fonts and spacing come from the author's page look (formatting.css)
   or the reader's own choices in the display bar. */
.reader-sheet { border-radius: var(--border-radius); box-shadow: var(--shadow); padding: clamp(18px, 5vw, 48px); }
.reader-sheet .chapter-content { padding: 0; margin: 0 auto; max-width: var(--pg-max, 65ch); hyphens: auto; }
.pg-width-narrow { --pg-max: 52ch; } .pg-width-normal { --pg-max: 65ch; } .pg-width-wide { --pg-max: 82ch; }

.reader-heading { max-width: var(--pg-max, 65ch); margin: 0 auto 2rem; }
.reader-label { margin: 0 0 6px; font-size: .85rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--pg-fg); opacity: .65; }
.reader-title { margin: 0 0 6px; font-family: var(--rd-font, var(--pg-heading-font, var(--pg-font, Georgia, serif))); font-size: clamp(1.6rem, 5.5vw, 2.4rem); line-height: 1.2; overflow-wrap: break-word; color: var(--pg-fg); }
.reader-subtitle { margin: 0; font-style: italic; opacity: .8; }
.pg-heading-align-center .reader-heading { text-align: center; }
.pg-heading-style-caps .reader-title { text-transform: uppercase; letter-spacing: .08em; font-size: clamp(1.35rem, 4.6vw, 2rem); }
.pg-heading-style-ornate .reader-heading::after { content: "\2766"; display: block; margin-top: 1rem; font-size: 1.5rem; opacity: .7; text-align: center; }
.pg-heading-style-ornate .reader-title { font-variant: small-caps; letter-spacing: .04em; }

.author-note { max-width: var(--pg-max, 65ch); margin: 0 auto 1.75rem; padding: .8rem 1rem; border-left: 4px solid var(--border-color); border-radius: 0 8px 8px 0; background: color-mix(in srgb, currentColor 6%, transparent); font-family: system-ui, sans-serif; font-size: .95rem; line-height: 1.55; }
.author-note h2 { margin: 0 0 .3rem; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; opacity: .7; }
.author-note p { margin: 0 0 .6em; } .author-note p:last-child { margin-bottom: 0; }
.author-note.after { margin: 2rem auto 0; }

/* Reader display bar */
.reader-display { position: relative; margin-bottom: 12px; }
.reader-display summary { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; border: 1px solid var(--link-color); border-radius: 999px; font-weight: 600; cursor: pointer; list-style: none; }
.reader-display summary::-webkit-details-marker { display: none; }
.reader-display-panel { display: grid; gap: 12px; margin-top: 8px; padding: 14px; background: var(--container-bg); border: 1px solid var(--border-color); border-radius: var(--border-radius); box-shadow: var(--shadow); }
.reader-display-panel label { display: grid; gap: 4px; font-size: .85rem; font-weight: 600; }
.reader-display-panel select { min-height: 40px; padding: 6px 10px; border-radius: 8px; }
.reader-display-panel .row { display: flex; gap: 8px; align-items: center; }
.reader-display-panel button { min-height: 40px; padding: 6px 14px; border: 1px solid var(--link-color); border-radius: 999px; background: transparent; color: var(--link-color); font: inherit; font-weight: 700; cursor: pointer; }
@media (min-width: 700px) { .reader-display-panel { grid-template-columns: repeat(2, 1fr); } }
.reader-sheet .chapter-thumbnail { display: block; max-width: 100%; margin: 0 auto 1.5rem; }
.reader-sheet .page-navigation { justify-content: space-between; margin-top: 2rem; font-family: system-ui, sans-serif; }
.reader-sheet .page-navigation a { display: inline-flex; align-items: center; min-height: 44px; }

.chapter-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 24px 0 8px; }
.chapter-pager a { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 64px; padding: 10px 16px; border: 1px solid var(--border-color); border-radius: var(--border-radius); background: var(--container-bg); color: var(--text-color); text-decoration: none; }
.chapter-pager a:hover { background: var(--form-bg); }
.chapter-pager small { color: var(--text-secondary); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; }
.chapter-pager strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-pager .next { grid-column: 2; text-align: right; }
.chapter-pager .prev { grid-column: 1; }
.chapter-all { text-align: center; margin: 12px 0 0; }

/* Comments */
.comments-card { margin-top: 32px; background: var(--container-bg); border-radius: var(--border-radius); box-shadow: var(--shadow); padding: 20px; }
.comments-card h2 { margin: 0 0 16px; font-size: 1.15rem; }

/* Reviews stay scoped to either a whole story or one chapter. */
.reviews-section { margin-top: 32px; padding: 20px; border: 1px solid var(--border-color); border-radius: var(--border-radius); background: var(--container-bg); box-shadow: var(--shadow); }
.reviews-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.reviews-heading h2 { margin: 3px 0 0; font-size: 1.25rem; }
.review-kicker { margin: 0; color: var(--text-secondary); font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.review-average { margin: 0; color: var(--text-secondary); }
.review-average strong, .review-rating { color: var(--text-color); }
.review-progress, .review-meta, .review-guidance { color: var(--text-secondary); font-size: .9rem; }
.review-form { padding: 14px; border-radius: 10px; background: var(--form-bg); }
.review-form p { display: grid; gap: 5px; margin: 0 0 12px; }
.review-form p:has(input[type=checkbox]) { display: flex; align-items: center; gap: 9px; }
.review-form input[type=checkbox] { margin: 0; }
.review-form textarea { width: 100%; box-sizing: border-box; }
.review-delete-form { margin: 10px 0 18px; }
.review-list { display: grid; gap: 12px; margin-top: 16px; }
.review-card { min-width: 0; padding: 14px; border: 1px solid var(--border-color); border-radius: 10px; }
.review-card-heading { display: flex; justify-content: space-between; gap: 12px; }
.review-meta { margin: 4px 0 10px; font-size: .8rem; }
.review-body > :last-child { margin-bottom: 0; }
.review-spoiler { padding: 10px 12px; border-radius: 8px; background: var(--form-bg); }
.review-spoiler summary { min-height: 36px; cursor: pointer; font-weight: 700; }
.review-report-form { display: flex; align-items: center; justify-content: end; gap: 8px; margin-top: 12px; }
.review-report-form label { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: .8rem; }
.review-report-form select, .review-report-button { min-height: 36px; }
.review-pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.comments-list { display: grid; gap: 12px; }
.comment-item { display: flex; gap: 12px; padding: 12px; background: var(--form-bg); border-radius: 10px; }
.comment-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; }
.comment-content { flex: 1; min-width: 0; }
.comment-author { font-weight: 700; font-size: .95rem; }
.comment-author a { color: var(--link-color); text-decoration: none; }
.comment-text { margin: 2px 0 6px; font-size: 1rem; line-height: 1.5; color: var(--text-color); }
.comment-text p { margin: 0 0 .5em; }
.comment-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.comment-date, .like-display { font-size: .8rem; color: var(--text-secondary); }
.like-button { min-height: 36px; padding: 4px 10px; border: 1px solid var(--border-color); border-radius: 999px; background: transparent; color: var(--text-secondary); font-size: .85rem; cursor: pointer; }
.like-button.liked { color: var(--danger-text); border-color: var(--danger-border); font-weight: 700; }
.comment-form-container { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-color); }
.comment-form-container h3 { margin: 0 0 10px; font-size: 1rem; }
.comment-form { display: grid; gap: 12px; }
.comment-form textarea { width: 100%; min-height: 96px; padding: 12px; border: 1px solid var(--border-color); border-radius: 10px; font: inherit; }
.comment-form .sp-btn { justify-self: start; }
.comments-login { margin: 16px 0 0; text-align: center; color: var(--text-secondary); }

@media (max-width: 600px) {
    .story-hero-body { padding: 16px; }
    .story-actions .sp-btn { flex: 1 1 100%; }
    .toc-item { padding: 12px 16px; gap: 12px; align-items: flex-start; }
    .toc-words { display: none; }
    .toc-heading { padding: 14px 16px; }
    .reader-sheet { border-radius: 0; margin-inline: -12px; box-shadow: none; }
    .qq-block-epigraph { max-width: 100%; }
    .chapter-pager { grid-template-columns: 1fr; }
    .chapter-pager .next, .chapter-pager .prev { grid-column: 1; text-align: left; }
    .chapter-pager .next { grid-row: 1; }
    .comments-card { padding: 16px; }
    .comment-form .sp-btn { justify-self: stretch; }
}
@media print { .reader-toolbar, .chapter-pager, .comments-card, .story-actions { display: none; } }

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

.toc-label { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-secondary); }
.story-kind { margin: -8px 0 14px; font-size: .9rem; }
.kind-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border-color); background: var(--form-bg); font-size: .78rem; font-weight: 700; letter-spacing: .04em; }
.kind-fanfiction { border-color: var(--info-border); background: var(--info-bg); color: var(--info-text); }
.kind-original { border-color: var(--success-border); background: var(--success-bg); color: var(--success-text); }
.story-tag-list li { margin: 0; padding: 0; border: 0; font-size: inherit; }
.story-hero-body, .reader-top { text-align: left; }
.pg-label-style-plain .reader-label { text-transform: none; letter-spacing: 0; font-size: 1.05rem; font-weight: 600; }
.pg-label-style-large .reader-label { text-transform: none; letter-spacing: .04em; font-size: 1.5rem; font-weight: 400; font-family: var(--rd-font, var(--pg-heading-font, var(--pg-font, Georgia, serif))); opacity: .8; }
