:root {
    color-scheme: light;
    --bg: #f6f8fb;
    --bg-2: #edf2f7;
    --surface: rgba(255, 255, 255, 0.78);
    --surface-strong: #ffffff;
    --ink: #111827;
    --muted: #5f6b7a;
    --line: rgba(17, 24, 39, 0.12);
    --line-strong: rgba(17, 24, 39, 0.2);
    --primary: #0f9f9a;
    --primary-ink: #ffffff;
    --accent: #ff6b57;
    --fresh: #78c850;
    --violet: #7c5cff;
    --warning: #d98917;
    --shadow: 0 22px 70px rgba(23, 32, 48, 0.16);
    --shadow-soft: 0 14px 34px rgba(23, 32, 48, 0.12);
    --radius: 8px;
    --max: 1180px;
    --header: 82px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #070a10;
    --bg-2: #0e151b;
    --surface: rgba(15, 20, 29, 0.76);
    --surface-strong: #121923;
    --ink: #f5f7fb;
    --muted: #a6b1c2;
    --line: rgba(255, 255, 255, 0.12);
    --line-strong: rgba(255, 255, 255, 0.22);
    --primary: #36d1c4;
    --primary-ink: #061011;
    --accent: #ff7d62;
    --fresh: #98e35f;
    --violet: #9b8cff;
    --warning: #f0b84c;
    --shadow: 0 26px 80px rgba(0, 0, 0, 0.5);
    --shadow-soft: 0 16px 38px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 100%),
        repeating-linear-gradient(90deg, transparent 0 46px, rgba(15, 159, 154, 0.06) 46px 47px),
        repeating-linear-gradient(0deg, transparent 0 46px, rgba(255, 107, 87, 0.04) 46px 47px);
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -3;
    background:
        linear-gradient(90deg, rgba(15, 159, 154, 0.08), transparent 26%, transparent 72%, rgba(255, 107, 87, 0.07)),
        repeating-linear-gradient(135deg, transparent 0 18px, rgba(124, 92, 255, 0.04) 18px 19px);
    pointer-events: none;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 30;
    padding: 10px 12px;
    color: var(--primary-ink);
    background: var(--primary);
    border-radius: var(--radius);
    transform: translateY(-140%);
    transition: transform 180ms ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.signal-canvas {
    position: fixed;
    inset: 0;
    z-index: -2;
    width: 100vw;
    height: 100vh;
    opacity: 0.42;
    pointer-events: none;
}

.site-shell {
    width: min(100% - 32px, var(--max));
    margin: 0 auto;
}

.site-main {
    padding: 34px 0 70px;
}

.page-content {
    padding: 24px 0 70px;
}

.site-header {
    position: sticky;
    top: 14px;
    z-index: 20;
    min-height: var(--header);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    margin: 14px 0 24px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: max-content;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0;
}

.brand-logo {
    display: block;
    width: 142px;
    height: 54px;
    object-fit: contain;
    border-radius: var(--radius);
    background: #ffffff;
}

.brand-logo--footer {
    width: 156px;
    height: 62px;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--primary-ink);
    background:
        linear-gradient(135deg, var(--primary), var(--fresh)),
        var(--primary);
    box-shadow: inset -8px -8px 18px rgba(0, 0, 0, 0.16);
}

.primary-nav {
    justify-self: center;
    min-width: 0;
}

.menu {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.menu a {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--muted);
    white-space: nowrap;
    transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.menu a:hover,
.menu a:focus-visible {
    color: var(--ink);
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.24);
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

.cart-link {
    display: inline-flex;
    flex-shrink: 0;
    min-height: 44px;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: color-mix(in srgb, var(--surface-strong) 74%, transparent);
    white-space: nowrap;
}

.cart-link strong {
    display: grid;
    min-width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 6px;
    color: var(--primary-ink);
    background: var(--primary);
    font-size: 0.78rem;
}

.nav-toggle {
    display: none;
    width: 42px;
    height: 42px;
    place-items: center;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--surface-strong);
}

.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    margin: 3px 0;
    background: currentColor;
    transition: transform 180ms ease, opacity 180ms ease;
}

.nav-open .nav-toggle span:nth-child(1) {
    transform: translateY(5px) rotate(45deg);
}

.nav-open .nav-toggle span:nth-child(2) {
    opacity: 0;
}

.nav-open .nav-toggle span:nth-child(3) {
    transform: translateY(-5px) rotate(-45deg);
}

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.button:hover,
.button:focus-visible {
    transform: translateY(-2px);
    border-color: var(--line-strong);
}

.button-primary {
    color: var(--primary-ink);
    border-color: transparent;
    background:
        linear-gradient(135deg, var(--primary), var(--fresh)),
        var(--primary);
    box-shadow: 0 14px 34px color-mix(in srgb, var(--primary) 28%, transparent);
}

.button-ghost {
    color: var(--ink);
    background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
}

.theme-toggle {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--surface-strong);
    white-space: nowrap;
}

.theme-toggle__track {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--muted) 22%, transparent);
}

.theme-toggle__dot {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    background: var(--primary);
    transition: transform 180ms ease;
}

html[data-theme="dark"] .theme-toggle__dot {
    transform: translateX(18px);
}

.site-notice {
    margin: 0 0 20px;
    padding: 14px 16px;
    border: 1px solid color-mix(in srgb, var(--primary) 44%, var(--line));
    border-radius: var(--radius);
    color: var(--ink);
    background: color-mix(in srgb, var(--primary) 12%, var(--surface-strong));
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.hero-section {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(360px, 0.78fr);
    align-items: center;
    gap: 44px;
    min-height: 660px;
    padding: 34px 0 54px;
}

.hero-copy h1,
.section-heading h1 {
    max-width: 780px;
    margin: 0;
    font-size: 4.4rem;
    line-height: 0.98;
    letter-spacing: 0;
}

.hero-text,
.section-heading p,
.reader-preview p,
.account-panel p,
.empty-library p,
.locked-reader p,
.site-footer p {
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.72;
}

.hero-text {
    max-width: 620px;
    margin: 22px 0 0;
}

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

.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    max-width: 620px;
    margin-top: 28px;
}

.hero-stats span {
    min-height: 72px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    backdrop-filter: blur(12px);
}

.hero-stats strong {
    display: block;
    color: var(--ink);
    font-size: 1.38rem;
}

.hero-visual {
    position: relative;
    min-height: 520px;
    perspective: 1200px;
}

.book-model {
    position: absolute;
    left: 50%;
    top: 46%;
    width: 245px;
    height: 330px;
    transform: translate(-50%, -50%) rotateY(-24deg) rotateX(12deg);
    transform-style: preserve-3d;
    animation: bookFloat 6s ease-in-out infinite;
}

.book-model__front,
.book-model__side,
.book-model__pages {
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.34);
}

.book-model__front {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px;
    color: #ffffff;
    background:
        linear-gradient(135deg, rgba(15, 159, 154, 0.96), rgba(120, 200, 80, 0.88) 48%, rgba(255, 107, 87, 0.9)),
        #0f9f9a;
    box-shadow: var(--shadow);
    transform: translateZ(28px);
}

.book-model__front span {
    font-weight: 900;
}

.book-model__front strong {
    max-width: 180px;
    font-size: 2rem;
    line-height: 1.05;
}

.book-model__side {
    width: 56px;
    left: auto;
    right: -28px;
    background: linear-gradient(180deg, #1b4c49, #101820);
    transform: rotateY(90deg) translateZ(28px);
}

.book-model__pages {
    background: repeating-linear-gradient(90deg, #f2f5f9 0 6px, #d9e1ea 6px 8px);
    transform: translateZ(-28px);
}

.book-orbit {
    position: absolute;
    inset: 42px 14px 24px;
    transform: rotate(-7deg);
}

.book-orbit span {
    position: absolute;
    border: 1px solid color-mix(in srgb, var(--primary) 34%, transparent);
    border-radius: var(--radius);
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--primary) 10%, transparent), transparent);
}

.book-orbit span:nth-child(1) {
    inset: 34px 42px;
}

.book-orbit span:nth-child(2) {
    inset: 88px 10px 72px 86px;
}

.book-orbit span:nth-child(3) {
    inset: 132px 110px 28px 24px;
}

.floating-panel {
    position: absolute;
    width: 172px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
}

.floating-panel span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}

.floating-panel strong {
    display: block;
    margin-top: 6px;
    font-size: 1.28rem;
}

.floating-panel--top {
    top: 76px;
    right: 22px;
}

.floating-panel--bottom {
    left: 20px;
    bottom: 58px;
}

.genre-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 56px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(14px);
}

.genre-chip {
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: transparent;
    transition: color 180ms ease, background 180ms ease, border-color 180ms ease;
}

.genre-chip:hover,
.genre-chip.is-active {
    color: var(--primary-ink);
    border-color: transparent;
    background: var(--primary);
}

.section-block {
    padding: 8px 0 70px;
}

.section-heading {
    max-width: 760px;
    margin-bottom: 28px;
}

.section-heading h2,
.reader-preview h2,
.account-panel h2,
.empty-library h2,
.locked-reader h1 {
    margin: 0;
    font-size: 2.6rem;
    line-height: 1.08;
    letter-spacing: 0;
}

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

.book-card {
    display: grid;
    grid-template-rows: 290px 1fr;
    min-height: 570px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: var(--shadow-soft);
    transform-style: preserve-3d;
    transition: opacity 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.book-card.is-hidden {
    display: none;
}

.book-card:hover {
    border-color: var(--line-strong);
    transform: translateY(-4px);
}

.book-cover {
    position: relative;
    display: flex;
    min-height: 100%;
    align-items: end;
    padding: 20px;
    overflow: hidden;
    color: #ffffff;
    background: #0f9f9a;
    isolation: isolate;
}

.book-cover::before {
    content: "";
    position: absolute;
    inset: 18px;
    z-index: -1;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: var(--radius);
    background:
        linear-gradient(90deg, transparent 0 46%, rgba(255, 255, 255, 0.14) 46% 48%, transparent 48%),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.11) 0 1px, transparent 1px 16px);
}

.book-cover__shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(112deg, transparent 0 28%, rgba(255, 255, 255, 0.26) 48%, transparent 58%);
    transform: translateX(-55%);
    transition: transform 520ms ease;
}

.book-card:hover .book-cover__shine,
.book-detail__cover:hover .book-cover__shine {
    transform: translateX(55%);
}

.book-cover__label {
    position: relative;
    z-index: 1;
    max-width: 230px;
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1.08;
    text-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
}

.cover-mint {
    background: linear-gradient(135deg, #0f9f9a, #78c850);
}

.cover-coral {
    background: linear-gradient(135deg, #1b1f2a, #ff6b57 58%, #ffd166);
}

.cover-violet {
    background: linear-gradient(135deg, #2d245f, #7c5cff 55%, #36d1c4);
}

.cover-amber {
    background: linear-gradient(135deg, #2a2618, #d98917 54%, #78c850);
}

.cover-blue {
    background: linear-gradient(135deg, #12202f, #2c7be5 54%, #36d1c4);
}

.cover-mono {
    background: linear-gradient(135deg, #171c22, #64748b 54%, #dfe7ef);
}

.book-card__body {
    display: flex;
    min-height: 280px;
    flex-direction: column;
    padding: 18px;
}

.book-card__meta,
.book-card__stats,
.book-detail__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 0.88rem;
}

.book-card__meta {
    justify-content: space-between;
}

.book-card h3 {
    margin: 14px 0 8px;
    font-size: 1.32rem;
    line-height: 1.18;
}

.book-card__author {
    margin: 0 0 16px;
    color: var(--muted);
}

.book-card__stats {
    margin-top: auto;
}

.book-card__stats span,
.book-card__stats strong,
.book-detail__stats span {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
}

.book-card__stats strong {
    color: var(--primary);
}

.book-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.book-card__actions form {
    margin: 0;
}

.reader-band {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 0.58fr);
    gap: 20px;
    align-items: stretch;
    padding: 28px 0 60px;
}

.surface-panel,
.reader-preview {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
}

.reader-preview {
    min-height: 420px;
    padding: 24px;
    overflow: hidden;
}

.reader-preview__bar {
    display: flex;
    gap: 8px;
    margin-bottom: 70px;
}

.reader-preview__bar span {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    background: var(--line-strong);
}

.reader-lines {
    display: grid;
    gap: 12px;
    margin-top: 34px;
}

.reader-lines span {
    display: block;
    height: 14px;
    border-radius: 5px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 24%, transparent), transparent);
}

.reader-lines span:nth-child(2) {
    width: 84%;
}

.reader-lines span:nth-child(3) {
    width: 68%;
}

.reader-lines span:nth-child(4) {
    width: 92%;
}

.account-panel,
.auth-panel,
.empty-library,
.locked-reader {
    padding: 24px;
}

.register-page {
    padding: 34px 0 70px;
}

.register-benefits {
    display: grid;
    align-content: start;
    gap: 12px;
}

.register-benefits h2 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.12;
}

.register-benefits p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.benefit-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.benefit-list span {
    display: flex;
    min-height: 38px;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
}

.signup-form,
#loginform {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.signup-form label,
#loginform p {
    display: grid;
    gap: 8px;
    margin: 0;
    color: var(--muted);
    font-weight: 700;
}

.signup-form input,
#loginform input[type="text"],
#loginform input[type="password"] {
    width: 100%;
    min-height: 46px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: color-mix(in srgb, var(--surface-strong) 84%, transparent);
}

#loginform input[type="submit"] {
    min-height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--radius);
    color: var(--primary-ink);
    font-weight: 900;
    background: var(--primary);
}

.archive-hero {
    padding: 48px 0 24px;
}

.archive-hero .section-heading h1 {
    font-size: 3.8rem;
}

.cart-shell {
    padding: 34px 0 70px;
}

.cart-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 22px;
    align-items: start;
}

.cart-items {
    display: grid;
    gap: 14px;
}

.cart-item {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
}

.cart-item__cover {
    display: flex;
    min-height: 164px;
    align-items: end;
    padding: 14px;
    border-radius: var(--radius);
    color: #ffffff;
    font-weight: 900;
    line-height: 1.08;
}

.cart-item__body {
    display: grid;
    align-content: center;
    gap: 10px;
}

.cart-item__body h2 {
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.15;
}

.cart-item__body p {
    margin: 0;
    color: var(--muted);
    line-height: 1.62;
}

.cart-item__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.cart-item__actions strong {
    color: var(--primary);
    font-size: 1.2rem;
}

.cart-summary {
    position: sticky;
    top: 116px;
    display: grid;
    gap: 14px;
    padding: 20px;
}

.cart-summary h2 {
    margin: 0;
    font-size: 1.7rem;
}

.cart-summary p {
    margin: 0;
    color: var(--muted);
    line-height: 1.62;
}

.cart-summary form {
    margin: 0;
}

.summary-row {
    display: flex;
    min-height: 52px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
}

.summary-row span {
    color: var(--muted);
}

.payment-options {
    display: grid;
    gap: 10px;
}

.payment-option {
    display: grid;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
}

.payment-option strong {
    display: block;
    margin-top: 8px;
}

.payment-option p {
    margin-top: 6px;
}

.stripe-badge {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 0 10px;
    border-radius: 6px;
    color: #ffffff;
    background: #635bff;
    font-size: 0.82rem;
    font-weight: 900;
}

.pagination-wrap {
    margin: 36px 0 0;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.page-numbers {
    display: inline-flex;
    min-width: 40px;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.page-numbers.current {
    color: var(--primary-ink);
    background: var(--primary);
}

.book-detail {
    display: grid;
    grid-template-columns: minmax(320px, 0.54fr) minmax(0, 1fr);
    gap: 42px;
    align-items: center;
    padding: 42px 0 72px;
}

.book-detail__cover {
    min-height: 560px;
    perspective: 1000px;
}

.book-cover--large {
    width: min(100%, 420px);
    min-height: 540px;
    margin: 0 auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transform: rotateY(-16deg) rotateX(7deg);
}

.book-detail__copy h1 {
    margin: 0;
    font-size: 3.8rem;
    line-height: 1;
}

.book-detail__stats {
    margin: 24px 0;
}

.entry-content {
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.75;
}

.reader-layout {
    display: grid;
    grid-template-columns: minmax(230px, 310px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    padding: 22px 0 70px;
}

.reader-sidebar {
    position: sticky;
    top: 116px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: var(--shadow-soft);
}

.reader-sidebar h1 {
    margin: 18px 0 8px;
    font-size: 1.6rem;
    line-height: 1.12;
}

.reader-sidebar p {
    color: var(--muted);
}

.reader-progress {
    height: 8px;
    margin-top: 18px;
    overflow: hidden;
    border-radius: 4px;
    background: color-mix(in srgb, var(--muted) 18%, transparent);
}

.reader-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--fresh));
}

.reader-content {
    max-width: 820px;
    padding: 42px;
    font-size: 1.12rem;
    line-height: 1.84;
}

.reader-content h2,
.reader-content h3 {
    color: var(--ink);
    line-height: 1.15;
}

.reader-content h2 {
    margin-top: 0;
    font-size: 2.4rem;
}

.pdf-reader {
    display: grid;
    gap: 14px;
}

.pdf-reader__notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface-strong) 64%, transparent);
}

.pdf-reader__notice span {
    color: var(--muted);
    font-size: 0.92rem;
}

.pdf-reader iframe {
    width: 100%;
    min-height: min(78vh, 920px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
}

.library-shell {
    padding: 34px 0 70px;
}

.library-dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(310px, 0.36fr);
    gap: 22px;
    align-items: start;
}

.library-dashboard__main,
.library-dashboard__side {
    display: grid;
    gap: 22px;
}

.library-dashboard__side {
    position: sticky;
    top: 116px;
}

.library-section {
    display: grid;
    gap: 18px;
}

.library-section__head,
.shared-library-card__head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 18px;
}

.library-section__head h2,
.social-panel h2,
.shared-library-card h3 {
    margin: 0;
    line-height: 1.12;
    letter-spacing: 0;
}

.library-section__head h2 {
    font-size: 2rem;
}

.library-count,
.shared-library-card__head > span {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: color-mix(in srgb, var(--surface-strong) 64%, transparent);
}

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

.shared-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.mini-form,
.inline-form,
.social-panel,
.shared-library-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
}

.mini-form {
    display: grid;
    gap: 12px;
    align-content: start;
    padding: 16px;
}

.mini-form--single {
    margin-top: 14px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.mini-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 800;
}

.mini-form input,
.mini-form select,
.mini-form textarea,
.inline-form input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
}

.mini-form textarea {
    min-height: 112px;
    padding-top: 12px;
    resize: vertical;
}

.shared-library-list,
.impression-feed,
.friend-list,
.shared-book-list {
    display: grid;
    gap: 10px;
}

.shared-library-card {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.shared-library-card__head p,
.muted-note {
    margin: 6px 0 0;
    color: var(--muted);
}

.member-row {
    display: grid;
    gap: 8px;
}

.member-row > div,
.friend-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.member-row span,
.friend-pill {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px;
    box-shadow: none;
}

.shared-book-row {
    display: flex;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface-strong) 58%, transparent);
}

.shared-book-row small {
    color: var(--primary);
    font-weight: 900;
}

.social-panel {
    padding: 18px;
}

.social-panel h2 {
    font-size: 1.35rem;
}

.impression-item {
    display: grid;
    gap: 4px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.impression-item:first-child {
    border-top: 0;
}

.impression-item span {
    color: var(--primary);
    font-size: 0.88rem;
    font-weight: 900;
}

.impression-item p {
    margin: 0;
    color: var(--muted);
    line-height: 1.58;
}

.auth-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    gap: 28px;
    align-items: start;
    margin: 36px 0 70px;
}

.post-list {
    display: grid;
    gap: 16px;
}

.site-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 34px 0 46px;
    border-top: 1px solid var(--line);
}

.brand-footer {
    margin-bottom: 10px;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.footer-links a {
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.ai-advisor {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 28;
    display: grid;
    justify-items: end;
    gap: 12px;
    pointer-events: none;
}

.ai-advisor button,
.ai-advisor input {
    font: inherit;
}

.ai-advisor__toggle,
.ai-advisor__panel {
    pointer-events: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.ai-advisor__toggle {
    display: inline-flex;
    min-height: 54px;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    color: var(--ink);
}

.ai-advisor__toggle span {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: var(--radius);
    color: var(--primary-ink);
    background: linear-gradient(135deg, var(--primary), var(--fresh));
    font-weight: 900;
}

.ai-advisor__toggle strong {
    font-size: 0.95rem;
}

.ai-advisor__panel {
    width: min(420px, calc(100vw - 28px));
    max-height: min(680px, calc(100vh - 110px));
    display: grid;
    grid-template-rows: auto minmax(180px, 1fr) auto auto;
    overflow: hidden;
}

.ai-advisor__panel[hidden] {
    display: none;
}

.ai-advisor__head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 14px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.ai-advisor__head h2 {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.1;
}

.ai-advisor__head button {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--surface-strong);
}

.ai-advisor__messages {
    display: grid;
    align-content: start;
    gap: 10px;
    padding: 14px;
    overflow: auto;
}

.ai-message {
    display: grid;
    gap: 8px;
    max-width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface-strong) 70%, transparent);
}

.ai-message--user {
    justify-self: end;
    color: var(--primary-ink);
    border-color: transparent;
    background: var(--primary);
}

.ai-message p {
    margin: 0;
    color: inherit;
    line-height: 1.5;
}

.ai-rec {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.ai-rec strong {
    line-height: 1.2;
}

.ai-rec span {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.35;
}

.ai-rec a {
    color: var(--primary);
    font-weight: 900;
}

.ai-advisor__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 14px 12px;
}

.ai-advisor__chips button {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: color-mix(in srgb, var(--surface-strong) 68%, transparent);
}

.ai-advisor__form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 14px;
    border-top: 1px solid var(--line);
}

.ai-advisor__form input {
    min-height: 44px;
    min-width: 0;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--surface-strong);
}

.reveal {
    opacity: 1;
    transform: none;
}

.js .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 560ms ease, transform 560ms ease;
}

.js .reveal.is-visible,
.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes bookFloat {
    0%,
    100% {
        transform: translate(-50%, -50%) rotateY(-24deg) rotateX(12deg) translateY(0);
    }
    50% {
        transform: translate(-50%, -50%) rotateY(-18deg) rotateX(14deg) translateY(-16px);
    }
}

@media (max-width: 1180px) {
    .site-header {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .primary-nav {
        justify-self: end;
    }

    .header-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

@media (max-width: 1020px) {
    .hero-section,
    .reader-band,
    .book-detail,
    .reader-layout,
    .auth-panel,
    .library-dashboard,
    .cart-layout {
        grid-template-columns: 1fr;
    }

    .library-dashboard__side {
        position: relative;
        top: auto;
    }

    .cart-summary {
        position: relative;
        top: auto;
    }

    .hero-section {
        min-height: auto;
        padding-top: 18px;
    }

    .hero-copy h1,
    .section-heading h1 {
        font-size: 3.25rem;
    }

    .archive-hero .section-heading h1,
    .book-detail__copy h1 {
        font-size: 3rem;
    }

    .hero-visual {
        min-height: 460px;
    }

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

    .reader-sidebar {
        position: relative;
        top: auto;
    }
}

@media (max-width: 760px) {
    .site-shell {
        width: min(100% - 20px, var(--max));
    }

    .site-main {
        padding-top: 12px;
    }

    .site-header {
        grid-template-columns: auto auto;
        min-height: 68px;
        gap: 10px;
    }

    .brand-logo {
        width: 118px;
        height: 46px;
    }

    .nav-toggle {
        display: grid;
        justify-self: end;
    }

    .primary-nav {
        display: none;
        grid-column: 1 / -1;
        justify-self: stretch;
    }

    .nav-open .primary-nav {
        display: block;
    }

    .menu {
        display: grid;
    }

    .menu a {
        width: 100%;
    }

    .header-actions {
        grid-column: 1 / -1;
        justify-content: space-between;
    }

    .cart-link {
        flex: 1;
        justify-content: center;
    }

    .hide-sm {
        display: none;
    }

    .theme-toggle {
        width: 100%;
        justify-content: space-between;
    }

    .hero-copy h1,
    .section-heading h1 {
        font-size: 2.55rem;
        line-height: 1.04;
    }

    .archive-hero .section-heading h1,
    .book-detail__copy h1 {
        font-size: 2.35rem;
    }

    .section-heading h2,
    .reader-preview h2,
    .account-panel h2,
    .empty-library h2,
    .locked-reader h1 {
        font-size: 2rem;
    }

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

    .hero-visual {
        min-height: 390px;
    }

    .book-model {
        width: 190px;
        height: 260px;
    }

    .floating-panel {
        width: 145px;
    }

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

    .shared-tools,
    .inline-form {
        grid-template-columns: 1fr;
    }

    .cart-item {
        grid-template-columns: 96px minmax(0, 1fr);
    }

    .cart-item__cover {
        min-height: 132px;
        font-size: 0.92rem;
    }

    .library-section__head,
    .shared-library-card__head {
        display: grid;
    }

    .book-card {
        min-height: auto;
    }

    .reader-content {
        padding: 24px;
        font-size: 1rem;
    }

    .book-detail__cover {
        min-height: 430px;
    }

    .book-cover--large {
        min-height: 410px;
    }

    .site-footer {
        flex-direction: column;
    }

    .footer-links {
        justify-content: flex-start;
    }

    .ai-advisor {
        right: 10px;
        bottom: 10px;
        left: 10px;
    }

    .ai-advisor__toggle {
        width: 100%;
        justify-content: center;
    }

    .ai-advisor__panel {
        width: 100%;
        max-height: calc(100vh - 96px);
    }

    .ai-advisor__form {
        grid-template-columns: 1fr;
    }
}

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

    .reveal {
        opacity: 1;
        transform: none;
    }
}
