:root {
    --ink: #1d1a17;
    --muted: #746d64;
    --paper: #fffdf8;
    --cream: #f7efe2;
    --line: #e5ded2;
    --terracotta: #a6492d;
    --leaf: #2f6d57;
    --gold: #c7932f;
    --blue: #315a86;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
}

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

a:hover {
    color: var(--leaf);
}

.store-header {
    background: rgba(255, 253, 248, 0.96);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.store-brand {
    align-items: center;
    color: var(--ink);
    display: inline-flex;
    gap: 10px;
}

.store-brand:hover {
    color: var(--ink);
}

.store-brand small {
    color: var(--muted);
    display: block;
    font-size: 0.74rem;
    line-height: 1;
}

.brand-mark {
    align-items: center;
    background: var(--terracotta);
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    font-weight: 700;
    height: 38px;
    justify-content: center;
    width: 38px;
}

.store-search {
    display: flex;
    flex: 1;
    max-width: 460px;
}

.store-search input {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px 0 0 8px;
    min-width: 0;
    padding: 10px 12px;
    width: 100%;
}

.store-search button {
    background: var(--leaf);
    border: 1px solid var(--leaf);
    border-radius: 0 8px 8px 0;
    color: #fff;
    font-weight: 600;
    padding: 0 16px;
}

.nav-link {
    color: var(--ink);
    font-weight: 600;
}

.hero {
    background:
        linear-gradient(90deg, rgba(29, 26, 23, 0.82), rgba(29, 26, 23, 0.38)),
        url("https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?auto=format&fit=crop&w=1800&q=80");
    background-position: center;
    background-size: cover;
    color: #fff;
    min-height: 460px;
    padding: 78px 0 90px;
}

.hero h1 {
    font-size: clamp(2.2rem, 6vw, 4.8rem);
    font-weight: 800;
    line-height: 1;
    margin-bottom: 18px;
    max-width: 850px;
}

.hero p {
    color: rgba(255, 255, 255, 0.88);
    font-size: 1.1rem;
    max-width: 620px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.btn-store {
    background: var(--gold);
    border: 1px solid var(--gold);
    border-radius: 8px;
    color: var(--ink);
    font-weight: 700;
    padding: 11px 18px;
}

.btn-store:hover {
    background: #d8a840;
    border-color: #d8a840;
    color: var(--ink);
}

.btn-soft {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    color: #fff;
    font-weight: 700;
    padding: 11px 18px;
}

.btn-soft:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.section {
    padding: 56px 0;
}

.section-alt {
    background: var(--cream);
}

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

.section-heading h2 {
    font-size: clamp(1.7rem, 3vw, 2.35rem);
    font-weight: 800;
    margin: 0;
}

.section-heading p {
    color: var(--muted);
    margin: 0;
    max-width: 520px;
}

.book-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.book-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(71, 55, 38, 0.07);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.book-cover-wrap {
    background: #efe5d5;
    aspect-ratio: 3 / 4;
    display: block;
    overflow: hidden;
}

.book-cover {
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.cover-fallback {
    align-items: center;
    background:
        linear-gradient(135deg, rgba(166, 73, 45, 0.95), rgba(47, 109, 87, 0.95)),
        #a6492d;
    color: #fff;
    display: flex;
    font-size: 1.02rem;
    font-weight: 800;
    justify-content: center;
    padding: 16px;
    text-align: center;
}

.book-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 7px;
    padding: 13px;
}

.book-card h3 {
    display: -webkit-box;
    font-size: 0.98rem;
    font-weight: 800;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.22;
    margin: 0;
    min-height: 2.4em;
    overflow: hidden;
}

.book-meta {
    color: var(--muted);
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-price {
    color: var(--leaf);
    font-size: 1rem;
    font-weight: 800;
}

.book-card .btn {
    border-radius: 8px;
    font-size: 0.9rem;
    margin-top: auto;
    padding: 8px 10px;
}

.store-pagination {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 26px;
}

.page-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.page-control,
.page-number,
.page-ellipsis {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    font-weight: 800;
    justify-content: center;
    min-height: 38px;
}

.page-control,
.page-number {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
}

.page-control {
    padding: 8px 13px;
}

.page-number {
    min-width: 38px;
    padding: 8px;
}

.page-number.is-active {
    background: var(--terracotta);
    border-color: var(--terracotta);
    color: #fff;
}

.page-control:hover,
.page-number:hover {
    border-color: var(--leaf);
    color: var(--leaf);
}

.page-number.is-active:hover {
    color: #fff;
}

.page-control.is-disabled {
    color: var(--muted);
    opacity: 0.45;
}

.page-ellipsis {
    color: var(--muted);
    min-width: 28px;
}

.store-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(71, 55, 38, 0.08);
    padding: 26px;
}

.account-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
}

.account-share-panel {
    grid-column: 2;
    text-align: center;
}

.detail-hero {
    background: var(--cream);
    padding: 46px 0;
}

.detail-cover {
    border-radius: 8px;
    box-shadow: 0 18px 36px rgba(71, 55, 38, 0.18);
    max-height: 520px;
}

.detail-title {
    font-size: clamp(2rem, 4vw, 3.4rem);
    font-weight: 850;
    line-height: 1.05;
}

.detail-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0;
}

.fact {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    padding: 9px 12px;
}

.steps {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.step {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.step span {
    align-items: center;
    background: var(--blue);
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    font-weight: 800;
    height: 32px;
    justify-content: center;
    margin-bottom: 12px;
    width: 32px;
}

.auth-shell {
    align-items: center;
    background:
        linear-gradient(90deg, rgba(29, 26, 23, 0.76), rgba(47, 109, 87, 0.56)),
        url("https://images.unsplash.com/photo-1512820790803-83ca734da794?auto=format&fit=crop&w=1600&q=80");
    background-position: center;
    background-size: cover;
    min-height: calc(100vh - 75px);
    padding: 54px 0;
}

.seller-apply,
.seller-hero {
    background:
        linear-gradient(90deg, rgba(29, 26, 23, 0.78), rgba(49, 90, 134, 0.46)),
        url("https://images.unsplash.com/photo-1519682337058-a94d519337bc?auto=format&fit=crop&w=1800&q=80");
    background-position: center;
    background-size: cover;
    color: #fff;
}

.seller-apply {
    min-height: calc(100vh - 75px);
    padding: 54px 0;
}

.seller-hero {
    padding: 72px 0 78px;
}

.seller-hero h1 {
    font-size: clamp(2.25rem, 5vw, 4.6rem);
    font-weight: 850;
    line-height: 1;
    margin-bottom: 16px;
    max-width: 820px;
}

.seller-hero p {
    color: rgba(255, 255, 255, 0.88);
    font-size: 1.08rem;
    max-width: 680px;
}

.seller-search {
    display: flex;
    margin-top: 24px;
    max-width: 560px;
}

.seller-search input {
    border: 0;
    border-radius: 8px 0 0 8px;
    min-width: 0;
    padding: 13px 14px;
    width: 100%;
}

.seller-search button {
    background: var(--gold);
    border: 0;
    border-radius: 0 8px 8px 0;
    color: var(--ink);
    font-weight: 800;
    padding: 0 18px;
}

.auth-card {
    background: rgba(255, 253, 248, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.16);
    color: var(--ink);
    padding: 28px;
}

.seller-note {
    background: #eef7f2;
    border: 1px solid #cfe6da;
    border-radius: 8px;
    color: #245b43;
    padding: 12px 14px;
}

.qr-box {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: inline-flex;
    justify-content: center;
    min-height: 206px;
    min-width: 206px;
    padding: 13px;
}

.qr-image {
    background: #fff;
    display: block;
    height: 220px;
    max-width: 100%;
    object-fit: contain;
    width: 220px;
}

.share-link {
    display: block;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.auth-card h1 {
    color: var(--ink);
    font-weight: 850;
}

.auth-card .form-label {
    color: var(--ink);
    font-weight: 700;
}

.auth-card .input-group-text {
    background: #f6efe4;
    border-color: var(--line);
    color: var(--muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-card .help-text {
    color: var(--muted);
}

.form-control {
    border-color: var(--line);
    border-radius: 8px;
    padding: 11px 12px;
}

.status-badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.82rem;
    font-weight: 800;
    padding: 6px 10px;
}

.status-paid {
    background: #dff3e7;
    color: #236145;
}

.status-pending {
    background: #fff0cc;
    color: #835c10;
}

.seller-line {
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 18px;
}

.payment-box {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
}

.payment-code {
    background: var(--ink);
    border-radius: 8px;
    color: #fff;
    display: inline-block;
    font-size: 1.35rem;
    font-weight: 850;
    letter-spacing: 1px;
    padding: 10px 14px;
}

.settlement-list {
    display: grid;
    gap: 10px;
}

.settlement-list div {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding-bottom: 10px;
}

.settlement-list div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.settlement-list span {
    color: var(--muted);
}

.settlement-list strong {
    color: var(--ink);
    white-space: nowrap;
}

.empty-state {
    background: #fff;
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 34px;
    text-align: center;
}

.reader-page {
    background: #f1eee8;
    user-select: none;
}

.reader-shell {
    min-height: calc(100vh - 75px);
    padding: 18px;
}

.reader-toolbar {
    align-items: center;
    background: rgba(255, 253, 248, 0.97);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin: 0 auto 18px;
    max-width: 1180px;
    padding: 16px;
}

.reader-toolbar h1 {
    font-size: 1.2rem;
    font-weight: 850;
    margin: 0;
}

.reader-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.reader-count {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 800;
    padding: 8px 10px;
}

.reader-stage {
    align-items: center;
    background: #d9d2c5;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    margin: 0 auto;
    max-width: 1180px;
    min-height: 70vh;
    overflow: auto;
    padding: 16px;
    position: relative;
    transition: filter 0.15s ease;
}

.reader-blurred .reader-stage {
    filter: blur(18px);
}

#readerCanvas {
    background: #fff;
    box-shadow: 0 18px 38px rgba(29, 26, 23, 0.22);
    max-width: 100%;
}

.image-reader-stage {
    overflow: auto;
}

.reader-image {
    background: #fff;
    box-shadow: 0 18px 38px rgba(29, 26, 23, 0.22);
    display: block;
    max-height: 82vh;
    max-width: 100%;
    object-fit: contain;
    position: relative;
    z-index: 1;
}

.image-watermark {
    display: grid;
    gap: 52px;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    inset: 0;
    opacity: 0.18;
    overflow: hidden;
    padding: 46px;
    pointer-events: none;
    position: absolute;
    transform: rotate(-20deg);
    z-index: 2;
}

.image-watermark span {
    color: #8b3f2a;
    font-weight: 850;
    white-space: nowrap;
}

.reader-loading {
    background: rgba(29, 26, 23, 0.86);
    border-radius: 8px;
    color: #fff;
    font-weight: 800;
    left: 50%;
    padding: 10px 14px;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
}

.reader-loading[hidden] {
    display: none;
}

.reader-notice {
    background: var(--ink);
    border-radius: 8px;
    color: #fff;
    font-weight: 800;
    left: 50%;
    opacity: 0;
    padding: 10px 14px;
    pointer-events: none;
    position: fixed;
    top: 90px;
    transform: translateX(-50%);
    transition: opacity 0.15s ease;
    z-index: 50;
}

.reader-notice.is-visible {
    opacity: 1;
}

.store-footer {
    background: var(--ink);
    color: #fff;
    padding: 30px 0;
}

.store-footer .container {
    align-items: center;
    display: flex;
    gap: 18px;
    justify-content: space-between;
}

.store-footer p {
    color: rgba(255, 255, 255, 0.7);
    margin: 4px 0 0;
}

.footer-links {
    display: flex;
    gap: 14px;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.84);
}

@media (max-width: 768px) {
    .hero {
        min-height: auto;
        padding: 58px 0;
    }

    .section-heading,
    .store-footer .container {
        align-items: start;
        flex-direction: column;
    }

    .store-search {
        max-width: none;
    }

    .seller-search {
        max-width: none;
    }

    .book-grid {
        gap: 14px;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .account-grid,
    .reader-toolbar {
        grid-template-columns: 1fr;
    }

    .account-grid {
        display: block;
    }

    .account-grid .store-panel + .store-panel {
        margin-top: 18px;
    }

    .account-share-panel {
        grid-column: auto;
    }

    .reader-toolbar {
        align-items: start;
        flex-direction: column;
    }

    .reader-actions {
        justify-content: start;
    }
}

@media print {
    .reader-page * {
        display: none !important;
    }

    .reader-page::before {
        content: "Printing is disabled for protected reader materials.";
        display: block !important;
        font: 700 18px Arial, sans-serif;
        padding: 24px;
    }
}
