:root {
    color-scheme: light;
    --bg: #fbf8f2;
    --paper: #fffdf8;
    --ink: #2b2926;
    --muted: #716a60;
    --line: #e5d7c3;
    --accent: #8f1f1f;
    --accent-strong: #6f1717;
    --green: #8f1f1f;
    --blue: #8f1f1f;
    --soft: #efe5d6;
    --warm: #d4bea0;
    --shadow: 0 16px 34px rgba(91, 55, 24, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, rgba(251, 248, 242, 0.9) 0 132px, rgba(251, 248, 242, 0.58) 132px),
    url("books-bg.svg") center 208px / 180px 180px repeat,
    var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(251, 248, 242, 0) 132px, rgba(251, 248, 242, 0.26) 132px, rgba(251, 248, 242, 0.62) 100%),
    repeating-linear-gradient(90deg, rgba(130, 91, 48, 0.055) 0 1px, transparent 1px 94px);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-strong);
    text-decoration: underline;
}

.wrap {
    width: min(1220px, calc(100% - 32px));
    margin: 0 auto;
}

/* Header / Menu */
.site-header {
    position: relative;
    z-index: 20;
    overflow: hidden;
    border-bottom: 1px solid rgba(139, 115, 83, 0.24);
    background: rgba(251, 248, 242, 0.96);
    box-shadow: none;
}

.header-inner {
    display: grid;
    grid-template-columns: 185px minmax(430px, 1fr) minmax(220px, 300px);
    align-items: center;
    gap: 18px;
    min-height: 74px;
    padding: 8px 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.header-left::-webkit-scrollbar {
    display: none;
}

.brand {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    gap: 8px;
    color: var(--ink);
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 0;
    white-space: nowrap;
    margin-right: 0;
    width: max-content;
}

.brand:hover {
    color: var(--ink);
    text-decoration: none;
}

.brand img {
    display: block;
    width: 74px;
    height: 42px;
    object-fit: contain;
}

.brand-logo {
    display: grid;
    place-items: center;
    width: 74px;
    height: 42px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.brand-logo img {
    width: 74px;
    height: 42px;
}

.brand-title {
    font-size: 18px;
    font-weight: 900;
    line-height: 1;
}

.header-left > a:not(.brand),
.main-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: auto;
    border-radius: 0;
    color: var(--accent);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.45;
    padding: 0;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.header-left > a:not(.brand):hover,
.main-nav a:hover {
    background: transparent;
    color: var(--accent-strong);
    text-decoration: none;
}

.header-left > a:not(.brand).is-active,
.main-nav a.is-active {
    background: transparent;
    color: var(--accent-strong);
    box-shadow: none;
}

.main-nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 2px 16px;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow-x: auto;
    scrollbar-width: none;
}

.main-nav a:not(:last-child)::after {
    content: " ";
}

.main-nav::-webkit-scrollbar {
    display: none;
}

.search {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.search input {
    min-width: 0;
    flex: 1;
    border: 1px solid #dfcfb9;
    outline: 0;
    border-radius: 6px;
    background: #fffdf8;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    min-height: 38px;
    padding: 8px 12px;
}

.search input::placeholder {
    color: #9aa3ad;
}

.search button {
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    min-height: 38px;
    padding: 8px 14px;
    transition: background 0.18s ease, box-shadow 0.18s ease;
}

.search button:hover {
    background: var(--accent-strong);
    box-shadow: 0 8px 16px rgba(181, 71, 45, 0.18);
}

/* Popular Navigation */
.popular-nav {
    border-bottom: 1px solid var(--line);
    background: var(--soft);
    padding: 10px 0;
    font-size: 12.5px;
}

.popular-nav .wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 42px;
}

.popular-section {
    display: flex;
    align-items: center;
    gap: 14px;
}

.popular-section h3 {
    margin: 0;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

.popular-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 14px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.popular-list a {
    color: var(--ink);
    font-weight: 600;
}

.popular-list a:hover {
    color: var(--accent);
}

/* Modern Popular Pages */
.modern-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 16px;
    padding-bottom: 56px;
}

.modern-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 253, 248, 0.94);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 15px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(23, 32, 27, 0.04);
}

.modern-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
    text-decoration: none;
}

.card-rank {
    flex: 0 0 36px;
    height: 36px;
    display: grid;
    place-items: center;
    background: var(--soft);
    color: var(--accent);
    border-radius: 50%;
    font-weight: 800;
    font-size: 13px;
}

.modern-card:hover .card-rank {
    background: var(--accent);
    color: white;
}

.card-content {
    flex: 1;
    min-width: 0;
}

.card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-subtitle {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.card-meta {
    margin-top: 7px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--muted);
}

.card-meta strong {
    color: var(--ink);
}

.dot {
    opacity: 0.5;
}

.card-arrow {
    font-size: 18px;
    color: var(--line);
    transition: transform 0.2s ease;
}

.modern-card:hover .card-arrow {
    color: var(--accent);
    transform: translateX(4px);
}

.alphabet-note {
    margin: 24px auto 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.alphabet {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(38px, 1fr));
    gap: 12px;
    align-items: center;
    justify-content: center;
    width: min(1120px, 100%);
    margin: 10px auto 32px;
    padding: 18px 22px;
    border: 1px solid rgba(143, 31, 31, 0.14);
    border-radius: 8px;
    background: rgba(255, 253, 248, 0.9);
    box-shadow: 0 14px 32px rgba(91, 55, 24, 0.08);
    backdrop-filter: blur(8px);
}

.alphabet a {
    width: 100%;
    min-width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.54);
    color: var(--accent);
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    box-shadow: inset 0 -1px 0 rgba(91, 55, 24, 0.08);
    transition: background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.alphabet a:hover {
    border-color: rgba(143, 31, 31, 0.26);
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(143, 31, 31, 0.18);
    transform: translateY(-2px);
}

.author-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.letter-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.letter-card h2 {
    margin: 0 0 14px;
    font-size: 22px;
    color: #111827;
}

.author-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.author-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid #f1f5f9;
}

.author-list li:last-child {
    border-bottom: none;
}

.author-list a {
    color: #111827;
    text-decoration: none;
    font-weight: 600;
    line-height: 1.35;
}

.author-list a:hover {
    color: #15803d;
}

.author-list span {
    min-width: 28px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #374151;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.empty {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
}

@media (max-width: 760px) {
    .alphabet {
        grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
        gap: 8px;
        margin: 18px auto 26px;
        padding: 14px;
    }

    .alphabet a {
        min-width: 34px;
        height: 34px;
        font-size: 14px;
    }
}

@media (max-width: 420px) {
    .alphabet {
        grid-template-columns: repeat(auto-fit, minmax(32px, 1fr));
        gap: 7px;
        padding: 12px;
    }

    .author-grid {
        grid-template-columns: 1fr;
    }
}

/* Intro / Page Headers */
.intro {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin: 18px 0 22px;
    border: 1px solid rgba(139, 115, 83, 0.2);
    border-radius: 8px;
    background: rgba(255, 253, 248, 0.92);
    box-shadow: 0 12px 30px rgba(50, 38, 24, 0.07);
    padding: 22px 24px;
}

.intro h1,
.intro h2 {
    margin: 0;
    font-size: clamp(22px, 2.4vw, 31px);
    line-height: 1.14;
}

.intro p,
.author-hero p {
    max-width: 640px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 15px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.intro-stat {
    min-width: 130px;
    border-left: 3px solid var(--accent);
    padding-left: 14px;
}

.intro-stat strong {
    display: block;
    font-size: 23px;
    line-height: 1;
}

.intro-stat span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12.5px;
}

/* Authors */
.author-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    padding-bottom: 50px;
}

.letter-card {
    min-height: 150px;
    scroll-margin-top: 86px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 248, 0.94);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.letter-card h2 {
    margin: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(239, 229, 214, 0.82);
    color: var(--accent-strong);
    font-size: 31px;
    line-height: 1;
    padding: 10px 14px;
}

.author-list,
.work-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.author-list li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid #eadfcd;
    padding: 10px 14px;
}

.author-list a,
.work-list a {
    color: var(--accent);
}

.author-list li:last-child {
    border-bottom: 0;
}

.author-list span {
    color: var(--muted);
    font-size: 12px;
}

.empty,
.notice,
.back-link {
    color: var(--muted);
    font-size: 14px;
}

.empty {
    margin: 14px;
}

.back-link {
    margin: 22px 0 0;
}

.author-hero {
    display: grid;
    grid-template-columns: 124px minmax(0, 1fr);
    gap: 20px;
    align-items: center;
    margin: 22px 0;
    border: 1px solid rgba(139, 115, 83, 0.2);
    border-radius: 8px;
    background: rgba(255, 253, 248, 0.92);
    box-shadow: 0 12px 30px rgba(50, 38, 24, 0.07);
    padding: 22px 24px;
}

.author-hero h2 {
    margin: 0;
    font-size: clamp(21px, 2.3vw, 29px);
    line-height: 1.15;
}

.author-hero h1,
.reader-header h1 {
    margin: 0;
    font-size: clamp(21px, 2.3vw, 29px);
    line-height: 1.15;
}

.author-photo {
    display: grid;
    place-items: center;
    width: 124px;
    aspect-ratio: 1 / 1.15;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(135deg, var(--soft), #fffdf8 58%, #f3e8da);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.author-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.author-photo span {
    color: var(--accent);
    font-size: 42px;
    font-weight: 800;
    line-height: 1;
}

/* Works */
.work-list {
    display: grid;
    gap: 8px;
    padding-bottom: 50px;
}

.work-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 248, 0.94);
    box-shadow: 0 4px 12px rgba(23, 32, 27, 0.04);
    padding: 11px 14px;
}

.work-list h2 {
    margin: 0;
    font-size: 15px;
}

.work-list time {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12.5px;
}

.work-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 68px;
    min-height: 32px;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font-size: 12.5px;
    font-weight: 800;
    padding: 6px 11px;
}

.work-action:hover {
    background: var(--accent-strong);
    color: white;
    text-decoration: none;
}

/* Reader */
.reader {
    padding: 24px 0 58px;
}

.reader-header {
    border-bottom: 1px solid var(--line);
    margin-bottom: 22px;
    padding-bottom: 18px;
}

.reader-body {
    max-width: 820px;
    border-left: 4px solid var(--line);
    background: white;
    border-radius: 0 8px 8px 0;
    box-shadow: var(--shadow);
    font-size: 17px;
    padding: 24px;
}

.reader-body img,
.reader-body table {
    max-width: 100%;
}

/* Responsive */
@media (max-width: 820px) {
    .header-inner {
        grid-template-columns: 1fr;
        gap: 10px;
        min-height: auto;
        padding: 10px 0;
    }

    .header-left {
        justify-content: center;
    }

    .brand {
        margin: 0 auto;
    }

    .main-nav {
        justify-content: center;
        text-align: center;
    }

    .search {
        width: 100%;
    }

    .intro {
        align-items: start;
        flex-direction: column;
        padding: 20px;
    }

    .author-hero {
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 16px;
    }

    .author-photo {
        width: 92px;
    }

    .work-list li {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 520px) {
    .wrap {
        width: min(100% - 22px, 1220px);
    }

    .site-header {
        position: relative;
    }

    .header-inner {
        padding: 10px 0;
    }

    .brand {
        font-size: 18px;
        margin-right: 0;
    }

    .brand img {
        width: 64px;
        height: 38px;
    }

    .brand-logo {
        width: 64px;
        height: 38px;
        border-radius: 0;
    }

    .brand-logo img {
        width: 64px;
        height: 38px;
    }

    .brand-title {
        font-size: 17px;
    }

    .header-left > a:not(.brand),
    .main-nav a {
        min-height: 32px;
        font-size: 12px;
        padding: 0;
    }

    .search {
        border-radius: 0;
    }

    .search input,
    .search button {
        min-height: 36px;
    }

    .search input {
        font-size: 12.5px;
        padding: 7px 6px 7px 10px;
    }

    .search button {
        padding-inline: 10px;
    }

    .modern-grid {
        grid-template-columns: 1fr;
    }

    .modern-card {
        padding: 13px;
    }

    .alphabet a {
        min-width: 32px;
        height: 32px;
        font-size: 15px;
    }

    .intro h1 {
        font-size: clamp(21px, 7vw, 27px);
    }

    .author-hero h1,
    .reader-header h1 {
        font-size: clamp(20px, 6.5vw, 26px);
    }

    .reader-body {
        font-size: 16px;
        padding: 18px;
    }
}
