:root {
  --bg: #0b0d10;
  --bg-elev: #12161b;
  --bg-soft: #171c22;
  --line: #705f26;
  --line-soft: #1e252d;

  --text: #e7e3db;
  --text-soft: #b7b1a7;
  --text-dim: #8f8a82;

  --accent: #d2b278;
  --accent-soft: #9f8860;

  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);

  --reader-width: 920px;
  --cover-width: 360px;

  --font-ui: Inter, "Segoe UI", Arial, sans-serif;
  --font-text: "Georgia", "Times New Roman", serif;
  --font-code: "JetBrains Mono", "Fira Code", Consolas, monospace;

  --radius: 18px;
  --radius-sm: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(210, 178, 120, 0.06), transparent 28%),
    linear-gradient(180deg, #0a0c0f 0%, #0d1116 100%);
  color: var(--text);
}

body {
  font-family: var(--font-text);
  font-size: 20px;
  line-height: 1.82;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

code {
  font-family: var(--font-code);
}

/* ---------------- app ---------------- */

.app {
  min-height: 100vh;
}

/* ---------------- topbar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 62px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 18px;
  background: rgba(12, 15, 19, 0.86);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(14px);
}

.topbar__left,
.topbar__center,
.topbar__right {
  display: flex;
  align-items: center;
}

.topbar__center {
  justify-content: center;
}

.topbar__right {
  justify-content: flex-end;
}

.topbar__title {
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.topbar__title--center {
  max-width: 50vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(210, 178, 120, 0.55);
  margin-right: 10px;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 14px;
}

.back-link:hover {
  color: #e0c08a;
}

/* ---------------- shells ---------------- */

.reader-shell,
.library-shell {
  padding: 30px 18px 72px;
  display: flex;
  justify-content: center;
}

.reader-stage {
  width: 100%;
  max-width: calc(var(--reader-width) + 64px);
  padding: 26px;
  border-radius: 26px;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.02),
    rgba(255,255,255,0.01)
  );
  border: 1px solid rgba(255,255,255,0.04);
  box-shadow: var(--shadow);
}

.reader-content {
  width: 100%;
  max-width: var(--reader-width);
  margin: 0 auto;
}

/* ---------------- library ---------------- */

.library-panel {
  width: 100%;
  max-width: 1080px;
}

.page-head {
  margin-bottom: 26px;
}

.page-eyebrow {
  margin: 0 0 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.page-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.1;
  color: #f3efe7;
  letter-spacing: -0.03em;
}

.page-subtitle {
  margin: 12px 0 0;
  color: var(--text-soft);
  font-family: var(--font-ui);
  font-size: 15px;
}

.page-subtitle code,
.empty-state code {
  font-family: var(--font-code);
  font-size: 0.95em;
  color: #f0d6a8;
  background: rgba(210, 178, 120, 0.08);
  border: 1px solid rgba(210, 178, 120, 0.14);
  border-radius: 8px;
  padding: 0.12em 0.38em;
}

.book-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.book-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.025),
    rgba(255,255,255,0.012)
  );
  text-decoration: none;
  transition:
    transform 0.14s ease,
    border-color 0.14s ease,
    background 0.14s ease,
    box-shadow 0.14s ease;
}

.book-card:hover {
  transform: translateY(-3px);
  border-color: rgba(210, 178, 120, 0.45);
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.035),
    rgba(255,255,255,0.018)
  );
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.book-card__body {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.book-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(210, 178, 120, 0.08);
  border: 1px solid rgba(210, 178, 120, 0.12);
  flex-shrink: 0;
  font-size: 18px;
}

.book-card__content {
  min-width: 0;
}

.book-card__title {
  color: #f2ede5;
  font-size: 1.08rem;
  line-height: 1.35;
  margin-bottom: 8px;
  word-break: break-word;
}

.book-card__meta {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-dim);
  word-break: break-word;
}

.book-card__action {
  margin-top: 16px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--accent);
}

.empty-state {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text-soft);
}

.empty-state__icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.025);
  color: var(--text-dim);
  font-family: var(--font-ui);
}

.empty-state__text p {
  margin: 0 0 8px;
}

.empty-state__text p:last-child {
  margin-bottom: 0;
}

/* ---------------- book header ---------------- */

.cover {
  display: flex;
  justify-content: center;
  margin: 14px 0 26px;
}

.cover img {
  display: block;
  width: min(100%, var(--cover-width));
  max-height: 560px;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.book-meta {
  text-align: center;
  margin: 0 auto 22px;
  max-width: 760px;
}

.book-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f3efe7;
}

.book-author {
  margin: 14px 0 0;
  font-family: var(--font-ui);
  font-size: clamp(1rem, 2vw, 1.2rem);
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-soft);
}

.book-divider {
  width: 100%;
  height: 1px;
  margin: auto;
  border: none;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(210, 178, 120, 0.18) 15%,
    rgba(210, 178, 120, 0.9) 50%,
    rgba(210, 178, 120, 0.18) 85%,
    transparent 100%
  );
}

/* ---------------- meta blocks ---------------- */

.annotation,
.notes {
  margin: 26px 0 34px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.015)),
    var(--bg-elev);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.025);
}

.annotation h2,
.notes h2 {
  margin-top: 0;
}

/* ---------------- headings ---------------- */

.reader-content h1,
.reader-content h2,
.reader-content h3,
.reader-content h4 {
  color: #f1ece4;
  line-height: 1.22;
  letter-spacing: -0.015em;
}

.reader-content h1 {
  margin: 0;
}

.reader-content h2 {
  margin: 2.2em 0 0.9em;
  font-size: clamp(1.45rem, 2vw, 1.9rem);
}

.reader-content h3 {
  margin: 1.9em 0 0.75em;
  font-size: clamp(1.22rem, 1.6vw, 1.45rem);
  color: #ece5d8;
}

.reader-content h4 {
  margin: 1.5em 0 0.65em;
  font-size: 1.08rem;
  color: #d8cfbf;
}

/* ---------------- paragraphs ---------------- */

.reader-content p {
  margin: 0 0 1em;
  color: var(--text);
  hanging-punctuation: first last;
}

.reader-content section > p:first-of-type:not(.subtitle):not(.text-author):not(.book-author):not(.book-title):not(.v) {
  text-indent: 1.6em;
}

.reader-content .annotation p,
.reader-content .notes p,
.reader-content blockquote p,
.reader-content .epigraph p,
.reader-content .poem p,
.reader-content .stanza p,
.reader-content .subtitle,
.reader-content .text-author,
.reader-content .book-author,
.reader-content .book-title,
.reader-content .v {
  text-indent: 0;
}

/* ---------------- links / inline ---------------- */

.reader-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.reader-content a:hover {
  color: #e1c28e;
  border-bottom-color: rgba(225, 194, 142, 0.45);
}

.reader-content strong {
  color: #f5f1ea;
  font-weight: 700;
}

.reader-content em {
  color: #e6ddcf;
}

.reader-content code {
  font-family: var(--font-code);
  font-size: 0.92em;
  color: #f0d6a8;
  background: rgba(210, 178, 120, 0.08);
  border: 1px solid rgba(210, 178, 120, 0.14);
  border-radius: 8px;
  padding: 0.12em 0.38em;
}

.reader-content s {
  opacity: 0.72;
}

.reader-content sub,
.reader-content sup {
  font-size: 0.72em;
  line-height: 0;
}

/* ---------------- blockquote / epigraph ---------------- */

.reader-content blockquote,
.reader-content .epigraph {
  margin: 1.5em 0;
  padding: 16px 18px 16px 20px;
  border-left: 3px solid var(--accent-soft);
  background: rgba(255, 255, 255, 0.018);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.reader-content .epigraph {
  max-width: 88%;
  margin-left: auto;
}

.reader-content .text-author {
  margin-top: 0.5em;
  text-align: right;
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.96em;
}

/* ---------------- subtitles ---------------- */

.reader-content .subtitle {
  margin: 1.35em 0 0.65em;
  color: var(--accent);
  font-style: italic;
  font-size: 1.02em;
}

/* ---------------- poems ---------------- */

.reader-content .poem {
  margin: 1.7em 0;
  padding: 18px 18px 14px;
  background: rgba(255,255,255,0.018);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.reader-content .stanza {
  margin: 1.15em 0;
  padding-left: 14px;
  border-left: 2px solid rgba(255,255,255,0.05);
}

.reader-content .v {
  margin: 0.15em 0;
  line-height: 1.7;
}

/* ---------------- images ---------------- */

.reader-content .image {
  margin: 1.8em 0;
}

.reader-content .image img,
.reader-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 16px;
}

/* ---------------- tables ---------------- */

.reader-content table {
  width: 100%;
  margin: 1.7em 0;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-elev);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

.reader-content th,
.reader-content td {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.reader-content th:last-child,
.reader-content td:last-child {
  border-right: none;
}

.reader-content tr:last-child td,
.reader-content tr:last-child th {
  border-bottom: none;
}

.reader-content th {
  background: rgba(255,255,255,0.03);
  color: #f0ebe2;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 600;
  text-align: left;
}

.reader-content td {
  color: var(--text);
}

/* ---------------- horizontal rule ---------------- */

.reader-content hr {
  border: none;
  height: 1px;
  margin: 2.6em 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.08) 15%,
    rgba(255,255,255,0.18) 50%,
    rgba(255,255,255,0.08) 85%,
    transparent 100%
  );
}

/* ---------------- responsive ---------------- */

@media (max-width: 980px) {
  :root {
    --cover-width: 320px;
  }

  body {
    font-size: 19px;
  }

  .reader-stage {
    padding: 20px;
  }

  .reader-content .epigraph {
    max-width: 100%;
  }
}

@media (max-width: 700px) {
  :root {
    --cover-width: 280px;
  }

  body {
    font-size: 18px;
    line-height: 1.72;
  }

  .topbar {
    padding: 0 12px;
    grid-template-columns: auto 1fr auto;
  }

  .topbar__title--center {
    max-width: 42vw;
  }

  .reader-shell,
  .library-shell {
    padding: 16px 10px 40px;
  }

  .reader-stage {
    padding: 14px;
    border-radius: 18px;
  }

  .book-title {
    font-size: 2rem;
  }

  .book-author {
    font-size: 1rem;
  }

  .annotation,
  .notes,
  .reader-content .poem,
  .reader-content blockquote,
  .reader-content .epigraph {
    padding: 14px 14px 12px;
  }

  .reader-content th,
  .reader-content td {
    padding: 10px 10px;
  }

  .reader-content section > p:first-of-type:not(.subtitle):not(.text-author):not(.book-author):not(.book-title):not(.v) {
    text-indent: 1.15em;
  }

  .book-list {
    grid-template-columns: 1fr;
  }
}

/* ---------------- reader layout with toc ---------------- */

.reader-layout {
  width: 100%;
  padding: 24px 0 72px;
}

.reader-shell {
  display: flex;
  justify-content: center;
  width: 100%;
}


.toc-box {

  display: flex;
  flex-direction: column;

  height: 100%;
  max-height: none;

  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.012));
  border: 1px solid #30291e;
  border-radius: 22px;
  box-shadow: var(--shadow);

  padding: 0;
  overflow: hidden;

}


.toc-head {

  flex: 0 0 auto;

  padding: 18px 16px 14px;

  border-bottom: 1px solid rgba(255,255,255,0.05);

}

.toc-label {
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.toc-book {
  font-size: 1rem;
  line-height: 1.35;
  color: #f2ede5;
}

.toc-author {
  margin-top: 6px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-dim);
}

.toc-nav {

  flex: 1 1 auto;

  overflow-y: auto;

  padding: 12px 8px 18px;

  display: flex;
  flex-direction: column;
  gap: 4px;

}

.toc-link {
  display: block;
  color: var(--text-soft);
  text-decoration: none;
  border-radius: 12px;
  padding: 8px 10px;
  line-height: 1.35;
  transition: background 0.14s ease, color 0.14s ease;
}

.toc-link:hover {
  background: rgba(255,255,255,0.04);
  color: #f1ece4;
}

.toc-depth-1 {
  padding-left: 10px;
  font-weight: 600;
  color: #ece5d8;
}

.toc-depth-2 {
  padding-left: 22px;
}

.toc-depth-3 {
  padding-left: 34px;
  font-size: 0.96em;
}

.toc-depth-4,
.toc-depth-5,
.toc-depth-6 {
  padding-left: 46px;
  font-size: 0.94em;
  color: var(--text-dim);
}

.toc-empty {
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 14px;
}

.toc-sidebar {
  position: fixed;
  top: 86px;
  left: 16px;
  width: 290px;
  height: calc(100vh - 302px);
  z-index: 20;
}

.toc-toggle {
  display: none;

  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}
/* ---------------- custom scrollbar ---------------- */

* {
  scrollbar-width: thin;
  scrollbar-color: #5c4b33 #12161b;
}

*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

*::-webkit-scrollbar-track {
  background: #12161b;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #7d6645, #5c4b33);
  border-radius: 999px;
  border: 2px solid #12161b;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #9b7c52, #71593c);
}

*::-webkit-scrollbar-corner {
  background: #12161b;
}



@media (max-width: 1280px) {
  .toc-sidebar {
    left: 10px;
    width: 250px;
  }
}

@media (max-width: 1100px) {

  .toc-toggle {
    display: block;
  }

  .toc-sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    height: 100vh;
    width: 300px;
    padding: 20px 12px 20px;

    background: var(--bg);
    border-right: 1px solid var(--line);

    transition: left 0.25s ease;

    z-index: 200;
  }

  .toc-box {
    height: 100%;
    max-height: 90%;

    border: none;
    background: none;
    box-shadow: none;

  }

  .toc-sidebar.open {
    left: 0;

  }

  .reader-layout {
    padding: 16px 0 40px;

  }
}

