/* Insanity Creations :: Writings
   Bookshelf, flipbook reader, and the admin writing desk. */

@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;0,700;1,500&family=Source+Sans+3:wght@400;500;600;700&display=swap");

:root {
  --ink: #1b1b1b;
  --paper: #f3e8d0;
  --paper-edge: #e0d3b6;
  --room: #0c0b0a;
  --room-soft: #161311;
  --line: #2e2a24;
  --text: #eee6d8;
  --muted: #9a9184;
  --gold: #c9a227;
  --gold-soft: #e0c15a;
  --wood: #3a2616;
  --wood-deep: #24170e;
}

/* Library default is pan-y, which fights page turns on phones */
.stf__parent {
  -ms-touch-action: none !important;
  touch-action: none !important;
}

* { box-sizing: border-box; }

body.books-body,
body.admin-body {
  margin: 0;
  background:
    radial-gradient(ellipse at 50% -10%, #2a2218 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, #1a120c 0%, transparent 40%),
    var(--room);
  color: var(--text);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.18);
  background: rgba(8, 7, 6, 0.72);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.topbar .brand {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 15px;
  text-decoration: none;
}

.topbar nav {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.topbar nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  transition: color 0.2s;
}

.topbar nav a:hover,
.topbar nav a.active { color: var(--gold-soft); }

/* ---------- Page heading ---------- */

.page-head {
  text-align: center;
  padding: 72px 20px 36px;
}

.page-head .eyebrow {
  display: inline-block;
  margin: 0 0 14px;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}

.page-head h1 {
  margin: 0 0 12px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.05;
}

.page-head p {
  margin: 0 auto;
  max-width: 520px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 16px;
}

.rule {
  width: 72px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 26px auto 0;
}

/* ---------- Shelf ---------- */

.shelf {
  padding: 20px 0 90px;
}

.shelf-preview {
  --preview-accent: var(--gold);
  max-width: 720px;
  margin: 0 auto 36px;
  padding: 8px 18px 4px;
  text-align: center;
  min-height: 7.5rem;
}

.shelf-preview.has-media {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 22px 28px;
  align-items: center;
  text-align: left;
  max-width: 760px;
}

.shelf-preview-media {
  margin: 0;
}

.shelf-preview-media img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 3px;
  box-shadow:
    0 18px 34px -18px rgba(0, 0, 0, 0.9),
    inset 0 0 0 1px rgba(255, 220, 160, 0.12);
  background: #1a1510;
}

.shelf-preview-caption {
  margin: 10px 0 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--preview-accent, var(--gold-soft));
  text-align: center;
}

.shelf-preview-copy {
  min-width: 0;
}

.shelf-preview-eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--preview-accent, var(--gold-soft));
}

.shelf-preview-title {
  margin: 0 0 12px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.15;
  color: var(--text);
}

.shelf-preview-about {
  margin: 0 auto;
  max-width: 34em;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

.shelf-preview.has-media .shelf-preview-about {
  margin: 0;
}

.shelf-preview-hint {
  margin: 16px 0 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: rgba(154, 145, 132, 0.72);
}

.shelf-preview-hint-touch {
  display: none;
}

.shelf-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 50px;
  justify-content: center;
  align-items: flex-end;
  padding: 56px 28px 34px;
  margin-bottom: 58px;
  border-radius: 6px 6px 2px 2px;
  background:
    linear-gradient(180deg, rgba(255, 220, 160, 0.04), transparent 38%),
    linear-gradient(180deg, #1c1611 0%, #120e0a 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 170, 0.08),
    0 30px 50px -34px #000;
}

.shelf-row::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18px;
  border-radius: 0 0 2px 2px;
  background:
    linear-gradient(180deg, #5a3a22 0%, var(--wood) 40%, var(--wood-deep) 100%);
  box-shadow:
    0 10px 18px -8px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 200, 120, 0.25);
}

.shelf-row::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  height: 10px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.55), transparent 70%);
  filter: blur(4px);
}

/* ---------- A book ---------- */

.book {
  --cover: #2b2b2b;
  --accent: var(--gold);
  display: block;
  width: 178px;
  height: 260px;
  position: relative;
  text-decoration: none;
  perspective: 1400px;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
  z-index: 1;
}

.book:hover,
.book:focus-visible,
.book.is-active {
  transform: translateY(-18px) rotate(-1.5deg);
  outline: none;
  z-index: 2;
}

.book-inner {
  position: absolute;
  inset: 0;
  border-radius: 2px 8px 8px 2px;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.28)),
    radial-gradient(circle at 30% 20%, rgba(255, 220, 150, 0.12), transparent 45%),
    var(--cover);
  box-shadow:
    inset 0 0 0 1px rgba(255, 220, 160, 0.12),
    inset -1px 0 0 rgba(255, 255, 255, 0.08),
    0 18px 28px -14px rgba(0, 0, 0, 0.95);
  transform-origin: left center;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.3, 1), box-shadow 0.35s;
  padding: 28px 20px 22px 28px;
  display: flex;
  flex-direction: column;
  color: #fff;
  overflow: hidden;
}

.book-inner::after {
  content: "";
  position: absolute;
  inset: 10px 10px 10px 18px;
  border: 1px solid rgba(201, 162, 39, 0.55);
  border-radius: 1px;
  opacity: 0.65;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.book-inner::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 16px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.15)),
    repeating-linear-gradient(
      180deg,
      transparent 0 10px,
      rgba(255, 220, 150, 0.08) 10px 11px
    );
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px 0 0 2px;
}

.book::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  right: -7px;
  width: 9px;
  border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(
    180deg,
    var(--paper) 0 2px,
    var(--paper-edge) 2px 4px
  );
  box-shadow: 2px 0 8px -1px rgba(0, 0, 0, 0.75);
  z-index: -1;
}

.book::before {
  content: "";
  position: absolute;
  left: 10%;
  right: 4%;
  bottom: -14px;
  height: 16px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.55), transparent 70%);
  filter: blur(3px);
  z-index: -2;
  transition: transform 0.35s, opacity 0.35s;
}

.book:hover::before,
.book:focus-visible::before,
.book.is-active::before {
  transform: translateY(8px) scaleX(0.9);
  opacity: 0.7;
}

.book:hover .book-inner,
.book:focus-visible .book-inner,
.book.is-active .book-inner {
  transform: rotateY(-26deg);
  box-shadow:
    inset 0 0 0 1px rgba(255, 220, 160, 0.16),
    inset -1px 0 0 rgba(255, 255, 255, 0.08),
    28px 24px 40px -16px rgba(0, 0, 0, 0.95);
}

.book-title {
  position: relative;
  z-index: 1;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 22px;
  line-height: 1.2;
  margin: 0 0 10px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.book-subtitle {
  position: relative;
  z-index: 1;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.72);
  margin: 0;
}

.book-author {
  position: relative;
  z-index: 1;
  margin-top: auto;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  border-top: 1px solid var(--accent);
  padding-top: 10px;
}

.book-flag {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #14110c;
  padding: 4px 8px;
  border-radius: 2px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.book.is-opening {
  transform: translateY(-30px) scale(1.05);
  transition: transform 0.45s ease, opacity 0.45s ease;
  opacity: 0;
}

.shelf-empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  line-height: 1.8;
}

/* ---------- Reader ---------- */

.reader-body {
  background:
    radial-gradient(ellipse at 50% 12%, rgba(201, 162, 39, 0.16), transparent 38%),
    radial-gradient(ellipse at 50% 100%, rgba(90, 58, 34, 0.35), transparent 45%),
    radial-gradient(circle at 50% 0%, #2f261c 0%, var(--room) 58%);
  min-height: 100vh;
}

.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.16);
  background: rgba(8, 7, 6, 0.45);
}

.reader-eyebrow {
  margin: 0 0 4px;
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
}

.reader-head h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 26px;
  margin: 0;
  font-weight: 600;
}

.reader-head .by {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.reader-back {
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.reader-back:hover {
  color: var(--gold-soft);
  border-color: rgba(201, 162, 39, 0.45);
}

.reader-scene {
  position: relative;
  padding-bottom: 20px;
}

.reader-glow {
  position: absolute;
  left: 50%;
  top: 8%;
  width: min(720px, 80vw);
  height: 280px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(255, 214, 140, 0.18), transparent 68%);
  pointer-events: none;
  filter: blur(8px);
}

.reader-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px 0;
  z-index: 1;
}

#flipbook {
  margin: 0 auto;
  display: block;
  position: relative;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  -ms-touch-action: none;
  touch-action: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

#flipbook.stf__parent,
.stf__parent {
  overflow: visible !important;
  -ms-touch-action: none !important;
  touch-action: none !important;
}

#flipbook canvas,
#flipbook .stf__block,
#flipbook .stf__item {
  -ms-touch-action: none !important;
  touch-action: none !important;
}

.flipbook-shell {
  width: 100%;
  max-width: 1000px;
  min-height: 220px;
  display: flex;
  justify-content: center;
  animation: book-arrive 0.95s cubic-bezier(0.2, 0.8, 0.3, 1) both;
  filter: drop-shadow(0 34px 46px rgba(0, 0, 0, 0.62));
  z-index: 2;
}

.flipbook-shell.is-ready {
  animation: none !important;
  opacity: 1 !important;
  visibility: visible !important;
}

#flipbook,
#flipbook.stf__parent {
  opacity: 1 !important;
  visibility: visible !important;
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  .flipbook-shell {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

@keyframes book-arrive {
  0%   { opacity: 0; transform: perspective(1600px) translateY(28px) rotateY(-34deg) scale(0.86); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: perspective(1600px) translateY(0) rotateY(0deg) scale(1); }
}

.reader-desk {
  width: min(920px, 92vw);
  height: 42px;
  margin-top: -6px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.18) 42%, transparent 72%);
  filter: blur(2px);
  z-index: 1;
}

.page {
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

.page .page-inner {
  height: 100%;
  padding: 52px 48px 58px;
  display: flex;
  flex-direction: column;
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  position: relative;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.09), rgba(0, 0, 0, 0) 11%),
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.4), transparent 55%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(120, 90, 40, 0.015) 3px,
      rgba(120, 90, 40, 0.015) 4px
    ),
    var(--paper);
}

.page[data-side="left"] .page-inner {
  background:
    linear-gradient(270deg, rgba(0, 0, 0, 0.09), rgba(0, 0, 0, 0) 11%),
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.4), transparent 55%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(120, 90, 40, 0.015) 3px,
      rgba(120, 90, 40, 0.015) 4px
    ),
    var(--paper);
}

.page h2,
.page-heading {
  font-size: 28px;
  margin: 0 0 8px;
  letter-spacing: 0.01em;
  line-height: 1.2;
  font-weight: 600;
  color: #1a1510;
}

.page-ornament {
  width: 54px;
  height: 10px;
  margin: 0 0 18px;
  background:
    linear-gradient(90deg, transparent, var(--accent, var(--gold)), transparent);
  position: relative;
  opacity: 0.75;
  flex: none;
}

.page-ornament::before,
.page-ornament::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 5px;
  height: 5px;
  border: 1px solid var(--accent, var(--gold));
  transform: translateY(-50%) rotate(45deg);
}

.page-ornament::before { left: -2px; }
.page-ornament::after { right: -2px; }

.page-text {
  font-size: 19px;
  line-height: 1.85;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
  color: #241e16;
}

.page-text p {
  margin: 0 0 1.1em;
  overflow-wrap: break-word;
}

.page-text p:last-child {
  margin-bottom: 0;
}

.page-measure-host {
  position: absolute;
  left: -10000px;
  top: 0;
  visibility: hidden;
  pointer-events: none;
}

.page-num {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: "Source Sans 3", sans-serif;
  font-size: 11px;
  color: #8a7f68;
  letter-spacing: 0.14em;
}

.page-cover {
  color: #fff;
  background: var(--cover, #2b2b2b);
}

.page-cover .page-inner {
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.28)),
    radial-gradient(circle at 30% 18%, rgba(255, 220, 150, 0.16), transparent 42%),
    var(--cover, #2b2b2b);
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  font-family: "Cormorant Garamond", Georgia, serif;
  padding: 36px;
}

.cover-plate {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  border: 1px solid rgba(201, 162, 39, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.25),
    inset 0 0 40px rgba(0, 0, 0, 0.18);
}

.cover-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(224, 193, 90, 0.75);
}

.cover-corner-tl { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.cover-corner-tr { top: 8px; right: 8px; border-left: 0; border-bottom: 0; }
.cover-corner-bl { bottom: 8px; left: 8px; border-right: 0; border-top: 0; }
.cover-corner-br { bottom: 8px; right: 8px; border-left: 0; border-top: 0; }

.cover-crest {
  width: 28px;
  height: 28px;
  margin-bottom: 18px;
  border: 1px solid rgba(224, 193, 90, 0.8);
  transform: rotate(45deg);
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.15);
  background: linear-gradient(135deg, rgba(255, 220, 150, 0.2), transparent 60%);
}

.page-cover h2 {
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.15;
  margin: 0 0 14px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  max-width: 12ch;
}

.page-cover .cover-sub {
  color: rgba(255, 255, 255, 0.8);
  font-size: 15px;
  margin: 0 0 18px;
  max-width: 28ch;
  line-height: 1.5;
  font-family: "Source Sans 3", sans-serif;
}

.cover-sub-quiet {
  font-style: italic;
  opacity: 0.85;
}

.cover-rule {
  width: 64px;
  height: 1px;
  margin: 0 0 16px;
  background: linear-gradient(90deg, transparent, var(--accent, var(--gold)), transparent);
}

.page-cover .cover-by {
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
  font-family: "Source Sans 3", sans-serif;
}

.page-cover.page-back .page-inner { justify-content: center; }

.page-end {
  text-align: center;
  margin: auto 0;
  font-style: italic;
  color: #6f6553;
  font-size: 20px;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px 28px;
  flex-wrap: wrap;
  padding: 4px 20px 6px;
  position: relative;
  z-index: 2;
}

.reader-chapters {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.reader-chapters-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.reader-chapters select {
  appearance: none;
  -webkit-appearance: none;
  min-width: min(280px, 72vw);
  max-width: 360px;
  padding: 9px 34px 9px 14px;
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 3px;
  background:
    linear-gradient(45deg, transparent 50%, var(--gold-soft) 50%) calc(100% - 16px) calc(50% - 3px) / 6px 6px no-repeat,
    linear-gradient(135deg, var(--gold-soft) 50%, transparent 50%) calc(100% - 11px) calc(50% - 3px) / 6px 6px no-repeat,
    rgba(20, 16, 12, 0.92);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.reader-chapters select:focus {
  outline: none;
  border-color: rgba(201, 162, 39, 0.65);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15);
}

.reader-chapters select:disabled {
  opacity: 0.45;
  cursor: default;
}

.reader-bookmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-reader-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--muted);
  min-width: 0;
  padding-left: 12px;
  padding-right: 12px;
}

.btn-reader-ghost:hover {
  color: var(--text);
  border-color: rgba(201, 162, 39, 0.35);
  background: rgba(20, 16, 12, 0.85);
}

#saveBookmark.is-active {
  border-color: rgba(201, 162, 39, 0.7);
  color: var(--gold-soft);
  background: rgba(201, 162, 39, 0.08);
}

.bookmark-status {
  color: var(--gold-soft);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  min-height: 1.2em;
}

.reader-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 20px 18px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}

.reader-controls .counter {
  color: var(--muted);
  font-size: 13px;
  min-width: 130px;
  text-align: center;
  letter-spacing: 0.06em;
}

.btn-reader {
  min-width: 120px;
  border-color: rgba(201, 162, 39, 0.28);
  background: rgba(20, 16, 12, 0.85);
}

.btn-reader:hover {
  border-color: rgba(201, 162, 39, 0.55);
  background: #24201b;
}

.btn-reader-next {
  background: linear-gradient(180deg, rgba(224, 193, 90, 0.95), rgba(201, 162, 39, 0.95));
  border-color: var(--gold);
  color: #14110c;
  font-weight: 600;
}

.btn-reader-next:hover {
  background: linear-gradient(180deg, #edd06a, #d4ad2f);
}

.btn-reader:disabled,
.btn-reader-next:disabled {
  opacity: 0.35;
  background: rgba(20, 16, 12, 0.85);
  color: var(--text);
  border-color: var(--line);
}

.reader-hint {
  text-align: center;
  color: #6f6a62;
  font-size: 12.5px;
  padding-bottom: 28px;
}

.reader-hint-mobile {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .reader-hint-desktop { display: none; }
  .reader-hint-mobile { display: inline; }
}

/* ---------- Tip jar ---------- */

.reader-tip {
  color: var(--gold-soft) !important;
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 999px;
  padding: 6px 14px;
}

.reader-tip:hover {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.1);
}

.donate-card {
  max-width: 620px;
  margin: 0 auto 56px;
  padding: 30px 32px 28px;
  text-align: center;
  border: 1px solid rgba(201, 162, 39, 0.22);
  border-radius: 4px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(201, 162, 39, 0.09), transparent 65%),
    rgba(20, 16, 12, 0.72);
  position: relative;
  z-index: 2;
}

.donate-eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 11.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.donate-card h2 {
  margin: 0 0 12px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 27px;
  font-weight: 600;
  color: #f4efe6;
}

.donate-copy {
  margin: 0 auto 22px;
  max-width: 44ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.btn-donate {
  background: linear-gradient(180deg, rgba(224, 193, 90, 0.95), rgba(201, 162, 39, 0.95));
  border-color: var(--gold);
  color: #14110c;
  font-weight: 600;
  padding: 11px 26px;
}

.btn-donate:hover {
  background: linear-gradient(180deg, #edd06a, #d4ad2f);
  border-color: #edd06a;
  color: #14110c;
}

.donate-fine {
  margin: 16px 0 0;
  color: #6f6a62;
  font-size: 12px;
  line-height: 1.6;
}

.page-cover .cover-tip {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.6);
  font-family: "Source Sans 3", sans-serif;
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.6;
}

.shelf-donate {
  margin: 18px auto 0;
  max-width: 40rem;
  color: var(--muted);
  font-size: 14px;
}

.shelf-donate a {
  color: var(--gold-soft);
  text-decoration: none;
  border-bottom: 1px solid rgba(201, 162, 39, 0.45);
}

.shelf-donate a:hover {
  color: #edd06a;
  border-color: #edd06a;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: #191613;
  color: var(--text);
  padding: 9px 18px;
  border-radius: 3px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  font-family: inherit;
}

.btn:hover { background: #24201b; border-color: #4a4338; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn-primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: var(--gold);
  color: #14110c;
  font-weight: 600;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #edd06a, #d4ad2f);
  border-color: #d4ad2f;
}

.btn-danger { color: #ff8a80; border-color: #4a2b2b; }
.btn-danger:hover { background: #2a1717; border-color: #6b3b3b; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Admin ---------- */

.auth-card {
  max-width: 420px;
  margin: 90px auto;
  background: #171411;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 34px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 28px;
}

.admin-main { padding: 34px 0 80px; }

.admin-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.admin-head h1 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 32px;
}

.card {
  background: #171411;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 22px;
}

.card h2 {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 600;
}

label {
  display: block;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  margin-top: 6px;
  background: #100e0c;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
}

textarea {
  resize: vertical;
  line-height: 1.7;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 17px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
}

input[type="color"] {
  margin-top: 6px;
  width: 62px;
  height: 38px;
  background: #100e0c;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px;
  cursor: pointer;
}

.field-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.field-row > label { flex: 1 1 220px; }

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 6px;
}

.feature-upload {
  margin: 8px 0 22px;
  padding: 18px 18px 8px;
  border: 1px solid rgba(201, 162, 39, 0.18);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.feature-upload h2 {
  margin: 0 0 8px;
}

.feature-upload .hint {
  margin: 0 0 16px;
}

.feature-upload-current {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.feature-upload-current img {
  width: 120px;
  height: 160px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: #100e0c;
}

.feature-remove {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  cursor: pointer;
}

.feature-remove input {
  width: auto;
  margin: 0;
}

input[type="file"] {
  width: 100%;
  margin-top: 6px;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
}

.message-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.3fr);
  gap: 16px;
  align-items: start;
}

.message-list {
  padding: 0;
  overflow: hidden;
}

.message-row {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.message-row:last-child {
  border-bottom: 0;
}

.message-row strong {
  color: var(--text);
}

.message-row span,
.message-row time {
  color: var(--muted);
  font-size: 13px;
}

.message-row.is-unread strong {
  color: var(--gold-soft);
}

.message-row.is-open {
  background: rgba(201, 162, 39, 0.08);
}

.message-meta {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.message-body {
  color: var(--text);
  line-height: 1.7;
  white-space: normal;
}

@media (max-width: 800px) {
  .message-layout {
    grid-template-columns: 1fr;
  }
}

.book-list { display: grid; gap: 12px; }

.book-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: #171411;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
}

.book-swatch {
  width: 26px;
  height: 38px;
  border-radius: 2px 4px 4px 2px;
  border-left: 4px solid rgba(0, 0, 0, 0.5);
  flex: none;
}

.book-row .meta { flex: 1 1 240px; min-width: 0; }
.book-row .meta strong { display: block; font-size: 16px; }
.book-row .meta span { color: var(--muted); font-size: 13px; }
.book-row .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tag {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.tag-published { color: #101010; background: var(--gold); border-color: var(--gold); }

.page-list { display: grid; gap: 10px; }

.page-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: #100e0c;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 14px;
}

.page-row .num {
  font-size: 13px;
  color: var(--muted);
  width: 58px;
  flex: none;
}

.page-row .snippet {
  flex: 1 1 220px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #c7c2b9;
  font-size: 14px;
}

.notice {
  padding: 11px 14px;
  border-radius: 5px;
  font-size: 14px;
  margin: 0 0 16px;
  border: 1px solid var(--line);
}

.notice-ok { border-color: #2f5233; background: #14210f; color: #b6e2a1; }
.notice-bad { border-color: #5a2b2b; background: #200f0f; color: #f0b1ab; }

.hint { color: var(--muted); font-size: 13px; line-height: 1.65; }

.char-count { color: var(--muted); font-size: 12px; }
.char-count.over { color: #f0b1ab; }

@media (max-width: 640px) {
  .page-head { padding-top: 48px; }
  .shelf-row { gap: 32px; padding: 40px 16px 28px; }
  .book { width: 140px; height: 208px; }
  .book-title { font-size: 18px; }
  .shelf-preview {
    margin-bottom: 24px;
    padding: 0 8px;
    min-height: 0;
  }
  .shelf-preview.has-media {
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 14px 16px;
  }
  .shelf-preview-title { font-size: 26px; }
  .shelf-preview-about { font-size: 14.5px; -webkit-line-clamp: 5; }
  .shelf-preview-hint-mouse { display: none; }
  .shelf-preview-hint-touch { display: block; }
  .page .page-inner { padding: 40px 32px 52px; }
  .page-text { font-size: 17.5px; line-height: 1.75; }
  .page h2 { font-size: 24px; }
  .reader-toolbar { gap: 12px; padding-top: 8px; }
  .reader-chapters { width: 100%; justify-content: center; }
  .reader-chapters select { min-width: 0; width: min(320px, 88vw); }
  .reader-bookmark { justify-content: center; }
  .reader-stage { padding: 28px 8px 0; }
  .reader-head { padding: 14px 16px; }
  .reader-head h1 { font-size: 22px; }
}

/* Portrait phone reader: maximize book, shrink chrome */
body.reader-phone-portrait .reader-eyebrow,
body.reader-phone-portrait .reader-glow,
body.reader-phone-portrait .reader-desk,
body.reader-phone-portrait .reader-hint,
body.reader-phone-portrait .donate-card {
  display: none !important;
}

body.reader-phone-portrait .reader-head {
  padding: 8px 12px;
  gap: 8px;
}

body.reader-phone-portrait .reader-head h1 {
  font-size: 17px;
  line-height: 1.25;
  margin: 0;
}

body.reader-phone-portrait .reader-head .by {
  font-size: 12px;
  margin: 2px 0 0;
}

body.reader-phone-portrait .reader-tip {
  display: none;
}

body.reader-phone-portrait .reader-stage {
  padding: 6px 4px 0;
  min-height: 0 !important;
}

body.reader-phone-portrait .reader-toolbar {
  padding: 4px 8px;
  gap: 8px;
}

body.reader-phone-portrait .reader-chapters-label {
  display: none;
}

body.reader-phone-portrait .reader-chapters select {
  padding: 7px 30px 7px 10px;
  font-size: 13px;
  min-width: 0;
  width: min(260px, 70vw);
}

body.reader-phone-portrait .btn-reader {
  padding: 8px 12px;
  font-size: 13px;
}

body.reader-phone-portrait .reader-controls {
  padding: 6px 10px 14px;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent, rgba(12, 11, 10, 0.92) 28%);
}

body.reader-phone-portrait .btn-reader {
  min-width: 0;
  flex: 1 1 38%;
  padding: 14px 12px;
  font-size: 15px;
}

body.reader-phone-portrait .reader-controls .counter {
  order: -1;
  flex: 1 1 100%;
  min-width: 0;
  margin-bottom: 2px;
}

body.reader-phone-portrait .page .page-inner {
  padding: 22px 18px 34px;
}

body.reader-phone-portrait .page-text {
  font-size: 16.5px;
  line-height: 1.58;
}

body.reader-phone-portrait .page-text p {
  margin: 0 0 0.85em;
}

body.reader-phone-portrait .page h2 {
  font-size: 20px;
  margin: 0 0 4px;
}

body.reader-phone-portrait .page-ornament {
  margin-bottom: 10px;
  width: 42px;
  height: 8px;
}

body.reader-phone-portrait .page-num {
  bottom: 12px;
  font-size: 11px;
}

body.reader-phone-portrait .flipbook-shell {
  filter: drop-shadow(0 16px 22px rgba(0, 0, 0, 0.55));
}

/* Landscape phone reader — same compact chrome as CSS orientation query */
body.reader-phone-landscape .reader-eyebrow,
body.reader-phone-landscape .reader-head .by,
body.reader-phone-landscape .reader-glow,
body.reader-phone-landscape .reader-desk,
body.reader-phone-landscape .reader-hint,
body.reader-phone-landscape .donate-card,
body.reader-phone-landscape .reader-tip {
  display: none !important;
}

body.reader-phone-landscape .reader-head {
  padding: 6px 12px;
}

body.reader-phone-landscape .reader-head h1 {
  font-size: 16px;
  margin: 0;
}

body.reader-phone-landscape .reader-stage {
  padding: 4px 6px 0;
  min-height: 0 !important;
}

body.reader-phone-landscape .reader-toolbar {
  padding: 2px 8px;
  gap: 8px;
}

body.reader-phone-landscape .reader-chapters-label {
  display: none;
}

body.reader-phone-landscape .reader-controls {
  padding: 2px 8px 6px;
}

body.reader-phone-landscape .page .page-inner {
  padding: 16px 18px 28px;
}

body.reader-phone-landscape .page-text {
  font-size: 15px;
  line-height: 1.48;
}

body.reader-phone-landscape .page h2 {
  font-size: 17px;
  margin: 0 0 4px;
}

body.reader-phone-landscape .page-ornament {
  margin-bottom: 6px;
}

body.reader-phone-landscape .flipbook-shell {
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.5));
}

/* Phone sideways only — keep portrait mobile large */
@media (orientation: landscape) and (max-height: 520px) {
  .reader-body {
    min-height: 100dvh;
  }

  .reader-head {
    padding: 6px 12px;
  }

  .reader-head h1 {
    font-size: 16px;
  }

  .reader-eyebrow,
  .reader-head .by,
  .reader-glow,
  .reader-desk,
  .reader-hint,
  .donate-card {
    display: none !important;
  }

  .reader-stage {
    padding: 8px 8px 0;
    min-height: 0 !important;
  }

  .reader-toolbar {
    padding: 2px 10px;
    gap: 8px;
  }

  .reader-controls {
    padding: 4px 10px 8px;
  }

  .reader-chapters-label {
    display: none;
  }

  .page .page-inner {
    padding: 18px 20px 30px;
  }

  .page-text {
    font-size: 15px;
    line-height: 1.5;
  }

  .page h2 {
    font-size: 18px;
    margin-bottom: 4px;
  }

  .page-ornament {
    margin-bottom: 8px;
  }

  .page-num {
    font-size: 11px;
  }

  .flipbook-shell {
    filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.5));
  }
}
