html {
    scroll-behavior: smooth;
}

:root {
    --bg: #171311;
    --panel: rgba(35, 29, 26, 0.92);
    --line: rgba(255, 240, 220, 0.12);
    --line-strong: rgba(220, 120, 120, 0.28);
    --text: #f7f1e8;
    --text-soft: #d7ccbf;
    --text-muted: #b8ab9c;
    --accent: #b91c1c;
    --accent-soft: rgba(185, 28, 28, 0.16);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
}

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    background: var(--bg) !important;
    color: var(--text) !important;
}

body > .min-h-screen {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(185, 28, 28, 0.18), transparent 24%),
        radial-gradient(circle at top right, rgba(153, 27, 27, 0.12), transparent 22%),
        linear-gradient(180deg, #181210 0%, #120f0d 55%, #161311 100%) !important;
}

header {
    background: rgba(20, 16, 15, 0.88) !important;
    border-color: var(--line) !important;
}

main,
section,
article,
aside,
form,
nav,
div {
    border-color: inherit;
}

.bg-white\/5,
.bg-white\/10,
.bg-black\/30,
.bg-black\/40,
.bg-black\/50,
.bg-neutral-800,
.bg-neutral-900,
.bg-zinc-950\/90,
.bg-zinc-950\/95 {
    background-color: transparent !important;
}

.rounded-3xl.border,
.rounded-2xl.border,
.rounded-xl.border,
.rounded-2xl,
.rounded-3xl {
    border-color: var(--line) !important;
}

.text-white,
.text-stone-50,
.text-zinc-100,
.text-stone-100 {
    color: var(--text) !important;
}

.text-zinc-500,
.text-zinc-400,
.text-zinc-300,
.text-zinc-200,
.text-stone-200,
.text-stone-300,
.text-stone-400 {
    color: var(--text-soft) !important;
}

.text-yellow-400,
.text-yellow-300,
.text-yellow-200,
.text-amber-100,
.text-amber-200,
.text-orange-200,
.text-orange-300 {
    color: #fecaca !important;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: #fff9f0 !important;
}

p,
label,
li,
span,
a,
button,
input,
textarea,
select,
small,
td,
th {
    color: inherit;
}

.bg-yellow-400,
.bg-amber-200,
.bg-orange-500 {
    background-color: var(--accent) !important;
}

.hover\:bg-yellow-300:hover,
.hover\:bg-amber-100:hover,
.hover\:bg-orange-400:hover {
    background-color: #dc2626 !important;
}

.text-black,
.text-zinc-950,
.text-neutral-950 {
    color: #221913 !important;
}

.border-yellow-400\/50,
.border-yellow-400\/40,
.border-yellow-400\/30,
.border-amber-300\/40,
.border-amber-300\/30,
.border-amber-200\/60,
.border-orange-400,
.border-orange-400\/70 {
    border-color: var(--line-strong) !important;
}

.bg-yellow-400\/10,
.bg-amber-300\/10,
.bg-orange-500\/20 {
    background-color: var(--accent-soft) !important;
}

.bg-emerald-500\/18,
.bg-emerald-500\/20 {
    background-color: rgba(52, 211, 153, 0.18) !important;
}

.border-emerald-400\/60 {
    border-color: rgba(52, 211, 153, 0.42) !important;
}

.text-emerald-100 {
    color: #dcfce7 !important;
}

.bg-red-500\/10,
.bg-red-500\/18,
.bg-red-500\/20 {
    background-color: rgba(248, 113, 113, 0.14) !important;
}

.border-red-400\/40,
.border-red-400\/60,
.border-red-400\/65,
.border-red-500\/30 {
    border-color: rgba(248, 113, 113, 0.4) !important;
}

.text-red-100,
.text-red-200,
.text-red-300 {
    color: #fee2e2 !important;
}

input,
textarea,
select {
    background: rgba(22, 19, 17, 0.92) !important;
    border: 1px solid var(--line) !important;
    color: var(--text) !important;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted) !important;
}

button,
a {
    transition: all 0.22s ease;
}

.hover\:bg-white\/5:hover,
.hover\:bg-white\/10:hover,
.hover\:bg-neutral-800:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.hover\:border-yellow-400\/40:hover,
.hover\:border-amber-300\/40:hover,
.hover\:border-orange-400:hover {
    border-color: rgba(220, 120, 120, 0.42) !important;
}

.prose p {
    margin-bottom: 1rem;
    line-height: 1.9;
    color: var(--text-soft) !important;
}

.prose h2,
.prose h3 {
    color: #fffaf5 !important;
    margin-top: 1.75rem;
    margin-bottom: 1rem;
}

.prose a {
    color: #fca5a5 !important;
}

:where(h1, h2, h3, p, a, span) {
    overflow-wrap: anywhere;
}

table {
    width: 100%;
}

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

.header-search {
    flex: 1;
    max-width: 34rem;
    margin: 0 1rem;
    gap: 0.75rem;
}

.header-search--desktop {
    display: none;
}

.header-search__input,
.search-panel__input {
    width: 100%;
    border-radius: 999px;
    padding: 0.9rem 1.1rem;
    background: rgba(31, 25, 23, 0.96) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 240, 220, 0.04);
}

.header-search__button,
.search-panel__button {
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 0.85rem 1.15rem;
    background: var(--accent-soft);
    color: #fecaca;
    font-weight: 600;
}

.header-search--mobile {
    display: flex;
    margin-bottom: 0.75rem;
}

.hero-shell,
.page-shell,
.content-shell {
    display: grid;
    gap: 1.75rem;
}

.hero-shell {
    grid-template-columns: minmax(0, 1.1fr) minmax(22rem, 0.95fr);
    align-items: start;
}

.hero-copy,
.hero-panel,
.page-hero,
.section-panel,
.sidebar-panel,
.reader-panel,
.document-header,
.document-hero {
    border: 1px solid var(--line);
    border-radius: 1.75rem;
    background: linear-gradient(180deg, rgba(37, 31, 28, 0.94), rgba(24, 20, 18, 0.96));
    box-shadow: var(--shadow);
}

.hero-copy {
    padding: 2rem;
}

.hero-copy--home {
    max-width: none;
}

.hero-badge,
.page-hero__eyebrow,
.section-panel__eyebrow,
.sidebar-panel__eyebrow,
.hero-panel__eyebrow,
.reader-panel__eyebrow {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    background: var(--accent-soft);
    color: #fecaca;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.hero-title,
.page-hero__title,
.document-hero__title,
.document-header__title,
.reader-panel__title {
    margin: 1rem 0 0;
    font-size: clamp(2rem, 4vw, 3.6rem);
    line-height: 1.02;
}

.hero-summary,
.page-hero__summary,
.document-hero__summary,
.document-header__summary,
.reader-panel__summary {
    margin-top: 1rem;
    color: var(--text-soft);
    font-size: 1.02rem;
    line-height: 1.85;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-top: 1.6rem;
}

.hero-primary-action,
.hero-secondary-action,
.book-card__action,
.hero-panel__footer-link,
.reader-panel__backlink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.85rem 1.2rem;
    font-weight: 700;
    text-decoration: none;
}

.hero-primary-action {
    background: linear-gradient(135deg, #fca5a5, #b91c1c);
    color: #fff5f5 !important;
}

.hero-secondary-action,
.book-card__action,
.hero-panel__footer-link,
.reader-panel__backlink {
    border: 1px solid var(--line-strong);
    background: rgba(185, 28, 28, 0.08);
    color: #fecaca !important;
}

.hero-panel {
    padding: 1.5rem;
}

.hero-panel__title,
.section-panel__title {
    margin-top: 0.65rem;
    font-size: 1.5rem;
    line-height: 1.2;
}

.hero-panel__grid,
.book-grid,
.chapter-card-list,
.search-results {
    display: grid;
    gap: 1.25rem;
}

.hero-panel__grid,
.book-grid {
    grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr));
}

.hero-panel__footer-link {
    margin-top: 1.1rem;
}

.library-stats {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.library-stat {
    border: 1px solid var(--line);
    border-radius: 1.3rem;
    padding: 1.2rem 1.25rem;
    background: rgba(28, 23, 21, 0.86);
}

.library-stat strong {
    display: block;
    font-size: 1.35rem;
    color: #fff4de;
}

.library-stat span {
    display: block;
    margin-top: 0.35rem;
    color: var(--text-muted);
}

.page-shell {
    gap: 1.5rem;
}

.page-shell--narrow {
    max-width: 72rem;
    margin: 0 auto;
}

.page-hero {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.6rem 1.8rem;
}

.page-hero__badge,
.section-panel__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 7rem;
    border-radius: 999px;
    padding: 0.8rem 1rem;
    background: rgba(185, 28, 28, 0.1);
    color: #fecaca;
    font-weight: 700;
}

.book-grid {
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
}

.book-grid--home {
    margin-top: 1.25rem;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.book-card {
    display: grid;
    gap: 1rem;
    align-content: start;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 1.6rem;
    background: linear-gradient(180deg, rgba(34, 28, 25, 0.94), rgba(23, 19, 17, 0.98));
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.22);
}

.book-card--hero {
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.book-card__cover-link {
    text-decoration: none;
}

.book-cover {
    --book-accent: #f59e0b;
    position: relative;
    min-height: 16rem;
    overflow: hidden;
    border-radius: 1.4rem;
    padding: 1.2rem;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.24), transparent 28%),
        linear-gradient(160deg, var(--book-accent) 0%, #201714 58%, #140f0d 100%);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 16px 0 0 rgba(0, 0, 0, 0.16),
        0 18px 38px rgba(0, 0, 0, 0.28);
}

.book-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(0deg, rgba(0, 0, 0, 0.22), transparent 50%),
        repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0, rgba(255, 255, 255, 0.04) 2px, transparent 2px, transparent 14px);
    pointer-events: none;
}

.book-cover__eyebrow {
    position: relative;
    z-index: 1;
    display: inline-flex;
    max-width: max-content;
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    background: rgba(255, 255, 255, 0.12);
    color: #fff4e5;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.book-cover__title {
    position: relative;
    z-index: 1;
    display: block;
    max-width: 12rem;
    margin-top: 1.2rem;
    font-size: 1.45rem;
    line-height: 1.12;
    color: #fff9f2;
}

.book-cover__initials {
    position: absolute;
    right: 1rem;
    bottom: 0.8rem;
    font-size: 3.8rem;
    font-weight: 700;
    line-height: 1;
    color: rgba(255, 255, 255, 0.16);
}

.book-card__body {
    display: grid;
    gap: 0.7rem;
}

.book-card__meta,
.search-result__meta {
    color: #fca5a5;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.book-card__title,
.chapter-card__title,
.page-list__title,
.search-result__title {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.2;
}

.book-card__title a {
    color: inherit;
    text-decoration: none;
}

.book-card__summary,
.chapter-card__summary,
.page-list__summary,
.search-result__summary {
    color: var(--text-soft);
    line-height: 1.7;
}

.content-shell--with-sidebar {
    grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr);
    align-items: start;
}

.content-sidebar {
    position: sticky;
    top: 6rem;
}

.sidebar-panel,
.section-panel,
.reader-panel,
.document-header,
.document-hero {
    padding: 1.5rem;
}

.book-tree {
    margin-top: 1rem;
    display: grid;
    gap: 0.85rem;
}

.book-tree__chapter {
    border: 1px solid rgba(255, 240, 220, 0.08);
    border-radius: 1.1rem;
    padding: 0.85rem;
    background: rgba(255, 255, 255, 0.02);
}

.book-tree__chapter.is-active {
    border-color: var(--line-strong);
    background: rgba(185, 28, 28, 0.08);
}

.book-tree__chapter-link,
.book-tree__page-link {
    display: flex;
    gap: 0.75rem;
    text-decoration: none;
}

.book-tree__chapter-link {
    align-items: center;
}

.book-tree__chapter-index,
.page-list__index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    height: 2.2rem;
    border-radius: 999px;
    background: rgba(185, 28, 28, 0.12);
    color: #fecaca;
    font-size: 0.82rem;
    font-weight: 700;
}

.book-tree__chapter-title {
    color: #fff4de;
    font-weight: 700;
    line-height: 1.35;
}

.book-tree__pages {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.75rem;
    padding-left: 2.95rem;
}

.book-tree__page-link {
    padding: 0.55rem 0.75rem;
    border-radius: 0.8rem;
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.03);
}

.book-tree__page-link.is-current {
    background: #fecaca;
    color: #450a0a !important;
    font-weight: 700;
}

.document-hero {
    display: grid;
    grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: center;
}

.document-hero__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.2rem;
}

.document-hero__stats span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.65rem 0.9rem;
    background: rgba(255, 255, 255, 0.03);
    color: #fecaca;
    font-size: 0.9rem;
}

.section-panel__header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.chapter-card-list,
.page-list,
.search-results {
    gap: 1rem;
}

.chapter-card,
.page-list__item,
.search-result,
.reader-pager__link {
    display: grid;
    gap: 0.7rem;
    padding: 1.15rem 1.2rem;
    border: 1px solid rgba(255, 240, 220, 0.08);
    border-radius: 1.2rem;
    background: rgba(255, 255, 255, 0.03);
    text-decoration: none;
}

.chapter-card:hover,
.page-list__item:hover,
.search-result:hover,
.reader-pager__link:hover,
.book-card:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
    box-shadow: 0 20px 32px rgba(0, 0, 0, 0.22);
}

.chapter-card__topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: #fca5a5;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.page-list__item {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.breadcrumbs a {
    color: #fca5a5;
    text-decoration: none;
}

.reader-panel__header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1rem;
    margin-top: 0.65rem;
    border-top: 1px solid rgba(255, 240, 220, 0.08);
}

.reader-panel__body {
    margin-top: 2rem;
}

.reader-pager {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.4rem;
    border-top: 1px solid rgba(255, 240, 220, 0.08);
}

.reader-pager__link--next {
    text-align: right;
}

.reader-pager__label {
    display: block;
    color: #fca5a5;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.search-panel {
    border: 1px solid var(--line);
    border-radius: 1.5rem;
    padding: 1rem;
    background: linear-gradient(180deg, rgba(36, 30, 27, 0.94), rgba(24, 20, 18, 0.98));
    box-shadow: var(--shadow);
}

.search-panel.is-loading {
    opacity: 0.72;
}

.search-panel__row {
    display: flex;
    gap: 0.85rem;
}

.search-feedback {
    padding: 1rem 1.2rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-soft);
}

@media (max-width: 1024px) {
    .hero-shell,
    .content-shell--with-sidebar,
    .document-hero {
        grid-template-columns: 1fr;
    }

    .content-sidebar {
        position: static;
    }

    .library-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .page-hero,
    .reader-panel__header,
    .section-panel__header,
    .search-panel__row {
        flex-direction: column;
        align-items: stretch;
    }

    .reader-pager {
        grid-template-columns: 1fr;
    }

    .hero-copy,
    .hero-panel,
    .sidebar-panel,
    .section-panel,
    .reader-panel,
    .document-header,
    .document-hero {
        padding: 1.15rem;
        border-radius: 1.4rem;
    }

    .book-grid,
    .hero-panel__grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) {
    .header-search--desktop {
        display: flex;
    }
}
