:root {
  --page: #f6f3ed;
  --surface: #fffefa;
  --surface-soft: #f1eee6;

  --text: #282a25;
  --muted: #7c7d72;
  --border: #e6e0d5;

  --accent: #486b55;
  --accent-dark: #34533f;
  --accent-soft: #e9efe7;

  --gold: #c69c60;
  --shadow: 0 15px 45px rgba(65, 54, 34, 0.07);

  --reader-font-size: 18px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  transition: background 0.2s, color 0.2s;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid #a9c5a9;
  outline-offset: 3px;
}

a {
  color: inherit;
}

.topbar {
  height: 74px;
  padding: 0 clamp(18px, 5vw, 76px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.05em;
}

.brand-icon {
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  border-radius: 10px 10px 10px 3px;
  background: var(--accent);
  color: white;
  font-family: Georgia, serif;
  font-size: 1.3rem;
}

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

.tagline,
.muted {
  color: var(--muted);
}

.tagline {
  font-size: 0.82rem;
}

.icon-button {
  min-width: 39px;
  height: 39px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
}

.icon-button:hover {
  background: var(--surface-soft);
}

.container {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
}

.hero {
  min-height: 290px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  position: relative;
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.8rem, 5vw, 4.5rem);
  line-height: 1.04;
  letter-spacing: -0.075em;
  font-weight: 500;
}

.hero h1 em {
  color: var(--accent);
  font-family: "Literata", Georgia, serif;
  font-weight: 400;
}

.hero-description {
  max-width: 450px;
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.8;
  font-size: 0.95rem;
}

.hero-decoration {
  position: relative;
  width: 240px;
  height: 200px;
  flex: 0 0 auto;
}

.decoration-circle {
  position: absolute;
  width: 165px;
  height: 165px;
  top: 10px;
  right: 20px;
  border: 1px solid #d5c19e;
  border-radius: 50%;
  background: #e8e8d9;
  box-shadow: inset 0 0 0 15px var(--page);
}

.decoration-line {
  position: absolute;
  width: 210px;
  height: 1px;
  right: -5px;
  top: 110px;
  background: var(--gold);
  transform: rotate(-35deg);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 24px;
}

.section-heading .eyebrow {
  margin-bottom: 7px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: -0.055em;
}

.count-pill {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.library {
  padding-bottom: 65px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}

.book-card {
  min-width: 0;
  padding: 17px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--surface);
  transition: transform 0.2s, box-shadow 0.2s;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.book-card-main {
  display: grid;
  grid-template-columns: 105px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.book-cover {
  position: relative;
  min-height: 148px;
  padding: 13px;
  display: flex;
  align-items: end;
  overflow: hidden;
  isolation: isolate;
  border-radius: 9px;
  color: white;
  background: linear-gradient(145deg, #314b42, #8d9e7d);
  box-shadow: 0 8px 18px rgba(38, 45, 36, 0.12);
}

.book-cover::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 125px;
  height: 125px;
  top: -25px;
  right: -38px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  box-shadow:
    0 0 0 12px rgba(255, 255, 255, 0.07),
    0 0 0 24px rgba(255, 255, 255, 0.06);
}

.book-cover::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 6px;
  background: rgba(0, 0, 0, 0.13);
}

.book-cover[data-cover="blue"],
.mini-cover[data-cover="blue"] {
  background: linear-gradient(145deg, #253d5a, #839cb0);
}

.book-cover[data-cover="terracotta"],
.mini-cover[data-cover="terracotta"] {
  background: linear-gradient(145deg, #864c3b, #d1a078);
}

.book-cover[data-cover="plum"],
.mini-cover[data-cover="plum"] {
  background: linear-gradient(145deg, #4d3a55, #aa91a5);
}

.cover-initials {
  font-family: "Literata", Georgia, serif;
  font-size: 1.6rem;
  line-height: 1;
  letter-spacing: -0.08em;
}

.book-details {
  min-width: 0;
}

.book-category {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.book-details h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  letter-spacing: -0.03em;
}

.book-author {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.book-description {
  flex: 1;
  margin: 17px 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.7;
}

.book-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.book-progress-copy {
  color: var(--muted);
  font-size: 0.72rem;
}

.book-progress-copy strong {
  color: var(--text);
}

.open-book-button {
  padding: 8px 0 8px 8px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.open-book-button:hover {
  color: var(--accent-dark);
}

.empty-message,
.status-message {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Reader layout */

.reader-layout {
  display: grid;
  grid-template-columns: 265px minmax(0, 1fr);
  align-items: start;
  gap: 22px;
  padding: 18px 0 65px;
}

.sidebar,
.reader-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar {
  min-height: 650px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}

.back-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  text-align: left;
  font-size: 0.8rem;
}

.back-link:hover {
  color: var(--accent);
}

.current-book {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 21px 0;
  border-bottom: 1px solid var(--border);
}

.mini-cover {
  width: 52px;
  height: 68px;
  flex: 0 0 auto;
  border-radius: 5px;
  background: linear-gradient(145deg, #314b42, #8d9e7d);
}

.current-book .eyebrow {
  margin-bottom: 6px;
  font-size: 0.57rem;
}

.current-book h2 {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.current-book p:last-child {
  margin: 5px 0 0;
  font-size: 0.75rem;
}

.progress-section {
  padding: 19px 0;
  border-bottom: 1px solid var(--border);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.75rem;
}

.progress-label strong {
  color: var(--accent);
}

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-soft);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s;
}

.small {
  font-size: 0.72rem;
  line-height: 1.5;
}

.progress-section p {
  margin: 9px 0 0;
}

.search-form {
  padding: 18px 0 6px;
}

.search-form label {
  display: block;
  margin-bottom: 9px;
  font-size: 0.78rem;
  font-weight: 600;
}

.search-input-wrapper {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.search-input-wrapper input {
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 0;
  border-radius: inherit;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 0.76rem;
}

.search-input-wrapper button {
  padding: 0 11px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
}

.search-results {
  margin-top: 8px;
  padding: 10px;
  border-radius: 9px;
  background: var(--surface-soft);
}

.search-results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.search-results-heading p {
  color: var(--muted);
  font-size: 0.7rem;
}

.search-results-heading button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
}

.search-result-item {
  display: block;
  width: 100%;
  padding: 10px 0;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.search-result-item strong,
.search-result-item span {
  display: block;
}

.search-result-item strong {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.75rem;
}

.search-result-item span {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.5;
}

.contents-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 0 10px;
}

.contents-heading h3 {
  margin: 0;
  font-size: 0.87rem;
}

.contents-heading span {
  color: var(--muted);
  font-size: 0.68rem;
}

.toc-list {
  display: grid;
  gap: 4px;
}

.toc-button {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.toc-button:hover {
  background: var(--surface-soft);
}

.toc-button.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.toc-number {
  min-width: 18px;
  padding-top: 2px;
  font-size: 0.68rem;
  opacity: 0.7;
}

.toc-text {
  font-size: 0.77rem;
  line-height: 1.45;
}

.sidebar-bookmark {
  margin-top: auto;
  padding-top: 22px;
}

.sidebar-bookmark button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.77rem;
  font-weight: 700;
  text-align: left;
}

.sidebar-bookmark p {
  margin: 8px 0 0;
}

/* Main reading panel */

.reader-card {
  overflow: hidden;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 22px clamp(18px, 3vw, 40px);
}

.reader-toolbar .eyebrow {
  margin-bottom: 6px;
  font-size: 0.61rem;
}

.reader-toolbar h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.03em;
}

.reader-controls {
  display: flex;
  align-items: center;
  gap: 7px;
}

.font-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.font-controls button {
  width: 31px;
  height: 31px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 0.77rem;
}

.font-controls button:hover {
  background: var(--surface-soft);
}

.font-controls span {
  min-width: 35px;
  color: var(--muted);
  text-align: center;
  font-size: 0.69rem;
}

.bookmark-button {
  font-size: 1.2rem;
}

.reader-progress-line {
  height: 3px;
  background: var(--surface-soft);
}

#reading-progress-fill-top {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}

.chapter-content {
  max-width: 760px;
  min-height: 460px;
  margin: 0 auto;
  padding: clamp(40px, 6vw, 75px) clamp(22px, 6vw, 75px);
  font-family: "Literata", Georgia, serif;
  font-size: var(--reader-font-size);
  line-height: 1.95;
  overflow-wrap: anywhere;
}

.chapter-content h1 {
  margin: 0 0 1.3em;
  font-family: "DM Sans", sans-serif;
  font-size: 1.9em;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.06em;
}

.chapter-content h2 {
  margin: 1.7em 0 0.7em;
  font-family: "DM Sans", sans-serif;
  font-size: 1.3em;
  line-height: 1.4;
}

.chapter-content p {
  margin: 0 0 1.35em;
}

.chapter-content p:first-of-type:not(.no-dropcap)::first-letter {
  float: left;
  padding: 0.08em 0.12em 0 0;
  color: var(--accent);
  font-size: 3.2em;
  line-height: 0.85;
}

.chapter-content blockquote {
  margin: 1.8em 0;
  padding: 0.2em 0 0.2em 1.1em;
  border-left: 2px solid var(--gold);
  color: var(--muted);
  font-style: italic;
}

.reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px clamp(14px, 3vw, 40px);
  border-top: 1px solid var(--border);
}

.reader-footer > span {
  color: var(--muted);
  font-size: 0.75rem;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 600;
}

.nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.nav-button.secondary {
  background: var(--surface);
  color: var(--text);
}

.nav-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.site-footer {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 28px;
  display: flex;
  justify-content: space-between;
  gap: 15px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
}

.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;
}

/* Dark theme */

body.dark-theme {
  color-scheme: dark;

  --page: #171b19;
  --surface: #202622;
  --surface-soft: #2a332d;

  --text: #eceee8;
  --muted: #a7afa4;
  --border: #374139;

  --accent: #a9c4a5;
  --accent-dark: #d1e3ca;
  --accent-soft: #2d3c30;

  --gold: #c8a775;
  --shadow: 0 15px 45px rgba(0, 0, 0, 0.15);
}

body.dark-theme .decoration-circle {
  background: #354238;
  border-color: #6f796c;
}

body.dark-theme .decoration-line {
  background: #a18b65;
}

body.dark-theme .nav-button.primary {
  color: #172019;
}

/* Tablet */

@media (max-width: 1050px) {
  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reader-layout {
    grid-template-columns: 235px minmax(0, 1fr);
    gap: 15px;
  }

  .sidebar {
    padding: 17px 13px;
  }
}

/* Smaller tablets and phones */

@media (max-width: 760px) {
  .hero {
    min-height: 255px;
  }

  .hero-decoration {
    width: 140px;
    opacity: 0.6;
  }

  .reader-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    min-height: auto;
  }

  .toc-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-bookmark {
    margin-top: 20px;
  }
}

@media (max-width: 540px) {
  .topbar {
    height: 64px;
    padding: 0 16px;
  }

  .tagline {
    display: none;
  }

  .container,
  .site-footer {
    width: calc(100% - 30px);
  }

  .hero {
    min-height: 260px;
    padding: 40px 0;
  }

  .hero h1 {
    font-size: clamp(2.55rem, 11vw, 3.3rem);
  }

  .hero-description {
    max-width: 300px;
    font-size: 0.88rem;
  }

  .hero-decoration {
    position: absolute;
    right: -45px;
    bottom: -65px;
    opacity: 0.25;
  }

  .section-heading {
    align-items: center;
    margin-bottom: 17px;
  }

  .section-heading h2 {
    font-size: 1.55rem;
  }

  .book-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 13px;
  }

  .book-card {
    padding: 14px;
  }

  .book-card-main {
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 13px;
  }

  .book-cover {
    min-height: 125px;
  }

  .reader-toolbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 19px 15px 15px;
  }

  .reader-controls {
    width: 100%;
  }

  .font-controls {
    margin-right: auto;
  }

  .chapter-content {
    min-height: 350px;
    padding: 36px 21px 45px;
    line-height: 1.85;
  }

  .chapter-content h1 {
    font-size: 1.65em;
  }

  .reader-footer {
    gap: 7px;
    padding: 13px 10px;
  }

  .nav-button {
    padding: 10px;
    font-size: 0.73rem;
  }

  .reader-footer > span {
    font-size: 0.66rem;
    white-space: nowrap;
  }

  .site-footer {
    font-size: 0.66rem;
  }
}

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



/* =========================================
   7. HERO BOOK ARTWORK
========================================= */

.hero-artwork2 {
    position: relative;

    min-height: 510px;

    display: grid;
    place-items: center;
}

.artwork-glow2 {
    position: absolute;

    width: 400px;
    height: 400px;

    border-radius: 50%;

    background: #e6e7d6;
    filter: blur(2px);
}

.book-cover2 {
    position: relative;
    z-index: 2;

    width: 310px;
    height: 440px;

    overflow: hidden;

    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 25px 20px;

    background:
        linear-gradient(
            155deg,
            #d5c99d 0%,
            #b2b88e 48%,
            #3e6854 100%
        );

    color: #ffffff;

    box-shadow:
        18px 24px 35px rgba(27, 50, 37, 0.20),
        inset 4px 0 7px rgba(0, 0, 0, 0.15);

    transform: rotate(3deg);
    transition: transform 0.4s ease;
}

.book-cover2:hover {
    transform: rotate(0deg) translateY(-5px);
}

.cover-top2 {
    position: relative;
    z-index: 3;

    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.cover-art2 {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.cover-sun2 {
    position: absolute;

    width: 155px;
    height: 155px;

    top: 100px;
    left: 78px;

    background: #e8c789;
    border-radius: 50%;
}

.cover-mountain2 {
    position: absolute;
    bottom: 0;

    width: 0;
    height: 0;

    border-left: 200px solid transparent;
    border-right: 200px solid transparent;
}

.mountain-back2 {
    left: -100px;

    border-bottom: 260px solid #68836c;
}

.mountain-front2 {
    left: 20px;

    border-bottom: 205px solid #315b49;
}

.cover-path2 {
    position: absolute;

    width: 100px;
    height: 180px;

    left: 110px;
    bottom: -110px;

    border-radius: 50% 50% 0 0;

    background: #c4b98b;
    transform: rotate(-20deg);
}

.cover-title2 {
    position: absolute;
    z-index: 3;

    top: 175px;

    width: 100%;

    text-align: center;

    font-family: var(--heading-font);
    font-size: 2rem;
    line-height: 1.1;
    letter-spacing: 2px;
}

.cover-title2 em {
    color: #f0dca8;
}

.cover-author2 {
    position: absolute;
    z-index: 3;
    bottom: 25px;

    font-size: 0.55rem;
    letter-spacing: 2px;
    font-weight: 600;
}

.floating-note2 {
    position: absolute;
    z-index: 4;

    display: flex;
    align-items: center;
    gap: 12px;

    padding: 15px 18px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;

    box-shadow: var(--shadow);
}

.note-top2 {
    top: 65px;
    right: -5px;
}

.note-bottom2 {
    bottom: 60px;
    left: -15px;
}

.note-icon2 {
    display: grid;
    place-items: center;

    width: 38px;
    height: 38px;

    border-radius: 10px;
    background: var(--surface-soft);

    color: var(--accent);
    font-size: 1.2rem;
}

.floating-note2 div {
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

.floating-note2 strong {
    font-size: 0.8rem;
}

.floating-note2 small {
    color: var(--text-muted);
    font-size: 0.7rem;
}