:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-soft: #f1f5f9;
    --ink: #202124;
    --muted: #5f6368;
    --line: #dfe3ea;
    --primary: #2563eb;
    --primary-soft: #eef4ff;
    --premium: #202124;
    --radius: 20px;
    --radius-sm: 14px;
    --shadow: 0 1px 2px rgba(60, 64, 67, 0.08);
    --shadow-hover: 0 4px 14px rgba(60, 64, 67, 0.1);
    --ease: cubic-bezier(0.2, 0, 0, 1);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    overflow-x: hidden;
    background: #ffffff;
    color: var(--ink);
    font-family: Inter, Roboto, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

body.modal-open {
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto minmax(240px, 1fr) auto;
    gap: 24px;
    align-items: center;
    padding: 14px clamp(18px, 4vw, 56px);
    border-bottom: 1px solid rgba(223, 227, 234, 0.74);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(22px);
}

.brand,
.user-chip,
.auth-panel,
.hero-actions,
.status-row,
.book-card-head,
.reader-topbar,
.reader-controls {
    display: flex;
    align-items: center;
}

.brand {
    gap: 10px;
    min-height: 44px;
    font-size: 22px;
    font-weight: 760;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 1px 4px rgba(60, 64, 67, 0.18);
}

.top-nav {
    display: flex;
    justify-content: center;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
}

.top-nav a,
.nav-link-button {
    min-height: 40px;
    border-radius: 999px;
    padding: 10px 14px;
    transition: background 180ms var(--ease), color 180ms var(--ease);
}

.nav-link-button {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
}

.top-nav a:hover,
.nav-link-button:hover {
    background: var(--surface-soft);
    color: var(--ink);
}

.auth-panel {
    justify-content: flex-end;
    gap: 10px;
}

.user-chip {
    gap: 9px;
    max-width: 210px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    padding: 5px 11px 5px 5px;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
}

.user-chip img,
.profile-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-soft);
}

.user-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0 18px;
    cursor: pointer;
    font-weight: 650;
    transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), background 180ms var(--ease), border-color 180ms var(--ease);
}

.button:hover {
    transform: translateY(-1px);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
    box-shadow: none;
}

.button-dark {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.24);
}

.button-dark:hover {
    box-shadow: 0 6px 18px rgba(26, 115, 232, 0.28);
}

.button-light {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

.button-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--muted);
}

.button-light:hover,
.button-ghost:hover {
    background: var(--surface-soft);
}

.button-light.is-active {
    border-color: rgba(26, 115, 232, 0.35);
    background: var(--primary-soft);
    color: var(--primary);
}

main {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    gap: 28px;
    align-items: stretch;
    min-height: 460px;
    padding: 56px 0 34px;
}

.hero-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 420px;
}

.hero-copy h1 {
    max-width: 820px;
    margin: 0;
    font-size: clamp(42px, 6vw, 76px);
    line-height: 1.02;
    letter-spacing: 0;
}

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

.hero-text {
    max-width: 680px;
    margin: 22px 0 0;
    color: var(--muted);
    font-size: 19px;
    line-height: 1.68;
}

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

.hero-panel,
.profile-card,
.panel,
.book-card,
.reader-card,
.legal-card {
    border: 1px solid rgba(223, 227, 234, 0.9);
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: var(--shadow);
}

.hero-panel {
    display: grid;
    align-content: center;
    gap: 18px;
    padding: 28px;
    background: #ffffff;
}

.metric {
    display: block;
    font-size: 42px;
    font-weight: 780;
    line-height: 1;
}

.metric-label {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}

.section {
    padding: 30px 0 50px;
    animation: sectionIn 420ms var(--ease) both;
}

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

.section-heading h2,
.panel h3 {
    margin: 0;
}

.section-heading h2 {
    font-size: clamp(28px, 3vw, 36px);
    line-height: 1.1;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 160px 190px 190px;
    gap: 12px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 14px;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08);
}

.field {
    display: grid;
    gap: 7px;
}

.field span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 760;
    text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fafc;
    padding: 12px 14px;
    color: var(--ink);
    outline: none;
    transition: border-color 160ms var(--ease), background 160ms var(--ease), box-shadow 160ms var(--ease);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: rgba(26, 115, 232, 0.72);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    align-items: stretch;
}

.book-card {
    display: flex;
    min-height: 390px;
    flex-direction: column;
    padding: 16px;
    transition: transform 220ms var(--ease), box-shadow 220ms var(--ease), border-color 220ms var(--ease);
}

.book-card:hover {
    transform: translateY(-2px);
    border-color: rgba(26, 115, 232, 0.24);
    box-shadow: var(--shadow-hover);
}

.cover {
    display: flex;
    position: relative;
    overflow: hidden;
    min-height: 172px;
    flex-direction: column;
    justify-content: flex-end;
    border-radius: 18px;
    padding: 18px;
    color: #172033;
    isolation: isolate;
}

.cover::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.08));
}

.cover::after {
    content: "";
    position: absolute;
    top: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.38);
}

.cover-warm {
    background: #fff4df;
}

.cover-blue {
    background: #eaf2ff;
}

.cover-gray {
    background: #eef2f7;
}

.cover-green {
    background: #e5f6ed;
}

.cover-violet {
    background: #f1edff;
}

.cover-rose {
    background: #ffe8ec;
}

.cover-mark {
    width: fit-content;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.58);
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 820;
}

.cover strong {
    max-width: 96%;
    margin-top: 34px;
    font-size: 22px;
    line-height: 1.08;
}

.cover small {
    margin-top: 8px;
    color: rgba(32, 33, 36, 0.72);
    font-weight: 650;
}

.book-card-head {
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
}

.book-actions {
    display: flex;
    gap: 8px;
}

.book-badge,
.status-pill,
.tag-row span {
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    border-radius: 999px;
    padding: 0 10px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 780;
}

.book-badge.premium,
.status-pill.premium {
    background: #202124;
    color: #ffffff;
}

.icon-button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    cursor: pointer;
    color: var(--primary);
    transition: transform 160ms var(--ease), background 160ms var(--ease);
}

.icon-button:hover {
    transform: scale(1.04);
    background: var(--primary-soft);
}

.book-card h3 {
    margin: 14px 0 8px;
    font-size: 20px;
    line-height: 1.2;
}

.book-author,
.book-category,
.book-description,
.muted,
.reader-author {
    color: var(--muted);
}

.book-author,
.book-category {
    margin: 0 0 5px;
    font-size: 14px;
}

.book-description {
    margin: 14px 0 16px;
    line-height: 1.55;
}

.book-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin: 12px 0 16px;
    color: var(--muted);
    font-size: 11px;
}

.book-stats span {
    border-radius: 999px;
    background: var(--surface-soft);
    padding: 6px 8px;
    white-space: nowrap;
}

.book-card .button {
    margin-top: auto;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.tag-row span {
    min-height: 24px;
    font-size: 11px;
    font-weight: 720;
}

.mini-progress,
.reader-progress {
    overflow: hidden;
    height: 6px;
    border-radius: 99px;
    background: #e9eef6;
}

.mini-progress {
    margin: 16px 0 12px;
}

.mini-progress div,
.reader-progress div {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #34a853);
    transition: width 260ms var(--ease);
}

.profile-empty,
.profile-content {
    padding: 28px;
}

.profile-empty h3,
.profile-main h3 {
    margin: 0 0 8px;
    font-size: 22px;
}

.profile-empty p,
.profile-main p {
    margin: 0;
    color: var(--muted);
}

.profile-empty .button {
    margin-top: 22px;
}

.profile-content {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 18px;
    align-items: center;
}

.profile-avatar {
    width: 84px;
    height: 84px;
    border: 4px solid #ffffff;
    box-shadow: 0 2px 10px rgba(60, 64, 67, 0.18);
}

.account-type {
    margin-top: 4px !important;
    font-size: 14px;
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.status-row {
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 14px;
}

.profile-lists,
.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.profile-modal {
    position: fixed;
    inset: 0;
    z-index: 58;
    display: grid;
    place-items: center;
    padding: 20px;
}

.profile-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(32, 33, 36, 0.34);
    backdrop-filter: blur(8px);
}

.profile-dialog {
    position: relative;
    z-index: 1;
    width: min(900px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: #ffffff;
    padding: clamp(18px, 3vw, 28px);
    box-shadow: 0 18px 54px rgba(60, 64, 67, 0.2);
    animation: sectionIn 220ms var(--ease) both;
}

.profile-dialog-head {
    margin-bottom: 18px;
}

.panel {
    padding: 22px;
}

.compact-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.list-row,
.admin-row {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fbfcfe;
    padding: 13px 14px;
    text-align: left;
}

.list-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: background 160ms var(--ease), transform 160ms var(--ease);
}

.list-row:hover {
    background: var(--primary-soft);
    transform: translateY(-1px);
}

.list-row small,
.admin-row small {
    color: var(--muted);
}

.admin-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 8px;
    align-items: center;
}

.publish-form {
    display: grid;
    gap: 14px;
}

.form-actions,
.manage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.manage-actions {
    margin-top: 10px;
}

.checkbox-line {
    display: flex;
    gap: 10px;
    align-items: center;
}

.reader-view {
    min-height: 100vh;
    padding: 28px 0 48px;
    background: linear-gradient(180deg, #ffffff, var(--bg));
    animation: sectionIn 280ms var(--ease) both;
}

.reader-shell {
    width: min(860px, calc(100% - 32px));
    margin: 0 auto;
}

.reader-topbar,
.reader-controls {
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.reader-progress {
    margin-bottom: 16px;
}

.reader-card {
    padding: clamp(28px, 5vw, 56px);
}

.reader-meta {
    margin: 0;
    color: var(--primary);
    font-size: 12px;
    font-weight: 820;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.reader-card h2 {
    margin: 12px 0 8px;
    font-size: clamp(32px, 5vw, 52px);
    line-height: 1.05;
}

.reader-description {
    max-width: 760px;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.65;
}

.reader-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.reader-tags span {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    background: var(--surface-soft);
    padding: 0 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 720;
}

.reader-text {
    margin-top: 30px;
    color: #242424;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 22px;
    line-height: 1.95;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.reader-text.is-turning {
    opacity: 0;
    transform: translateY(8px);
}

.reader-lock {
    margin-top: 22px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: linear-gradient(135deg, #ffffff, var(--primary-soft));
    box-shadow: 0 12px 34px rgba(37, 99, 235, 0.12);
    animation: sectionIn 260ms var(--ease) both;
}

.reader-lock h3 {
    margin: 0 0 8px;
    font-size: 24px;
    line-height: 1.15;
}

.reader-lock p {
    margin: 0 0 18px;
    color: var(--muted);
    font-weight: 750;
}

.reader-controls {
    position: sticky;
    bottom: 14px;
    z-index: 5;
    margin-top: 16px;
    border: 1px solid rgba(223, 227, 234, 0.86);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px;
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.reader-controls span {
    color: var(--muted);
    font-size: 14px;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 40;
    max-width: min(420px, calc(100% - 40px));
    padding: 14px 16px;
    border-radius: 16px;
    background: #202124;
    color: #ffffff;
    box-shadow: var(--shadow-hover);
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 20px;
}

.auth-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(32, 33, 36, 0.38);
    backdrop-filter: blur(8px);
}

.auth-dialog {
    position: relative;
    z-index: 1;
    width: min(520px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: #ffffff;
    padding: 24px;
    box-shadow: 0 18px 54px rgba(60, 64, 67, 0.2);
    animation: sectionIn 220ms var(--ease) both;
}

.auth-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.auth-dialog-head h2 {
    margin: 0;
    font-size: 28px;
}

.auth-choice-grid {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.auth-choice {
    display: grid;
    gap: 4px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #ffffff;
    padding: 15px 16px;
    cursor: pointer;
    color: var(--ink);
    text-align: left;
    transition: background 180ms var(--ease), border-color 180ms var(--ease);
}

.auth-choice:hover {
    border-color: rgba(26, 115, 232, 0.32);
    background: var(--primary-soft);
}

.auth-choice span {
    color: var(--muted);
    font-size: 13px;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 14px;
    border-radius: 999px;
    background: var(--surface-soft);
    padding: 4px;
}

.auth-tab {
    min-height: 38px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    color: var(--muted);
    font-weight: 700;
}

.auth-tab.is-active {
    background: #ffffff;
    color: var(--ink);
    box-shadow: var(--shadow);
}

.auth-form {
    display: grid;
    gap: 12px;
}

.auth-submit {
    margin-top: 4px;
}

.site-footer {
    display: grid;
    gap: 14px;
    justify-items: center;
    margin: 22px 0 38px;
    padding: 24px 0 6px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
}

.footer-about {
    display: grid;
    max-width: 620px;
    gap: 6px;
    justify-items: center;
    text-align: center;
}

.footer-about strong {
    color: var(--ink);
    font-size: 16px;
}

.footer-about span {
    line-height: 1.6;
}

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

.site-footer a,
.footer-link-button {
    border-radius: 999px;
    padding: 8px 10px;
    transition: background 160ms var(--ease), color 160ms var(--ease);
}

.footer-link-button {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
}

.site-footer a:hover,
.footer-link-button:hover {
    background: var(--surface-soft);
    color: var(--ink);
}

.site-footer p {
    margin: 0;
}

.legal-page {
    width: min(760px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0 64px;
}

.legal-card {
    padding: clamp(24px, 5vw, 42px);
}

.legal-card h1 {
    margin: 0 0 14px;
    font-size: clamp(34px, 6vw, 54px);
    line-height: 1;
}

.legal-card p {
    color: var(--muted);
    line-height: 1.7;
}

.legal-card .button {
    margin-top: 18px;
}

.empty-note {
    color: var(--muted);
}

[hidden] {
    display: none !important;
}

@keyframes sectionIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@media (max-width: 1120px) {
    .book-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .field-grow {
        grid-column: 1 / -1;
    }
}

@media (max-width: 820px) {
    .site-header {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .top-nav,
    .auth-panel {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .hero {
        grid-template-columns: 1fr;
        min-height: auto;
        padding-top: 40px;
    }

    .hero-copy {
        min-height: auto;
    }

    .book-grid,
    .profile-content,
    .profile-lists,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .profile-actions {
        justify-content: flex-start;
    }

    .admin-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    main {
        width: min(100% - 28px, 1180px);
    }

    .hero-copy h1 {
        font-size: 40px;
    }

    .hero-text,
    .reader-text {
        font-size: 18px;
    }

    .toolbar {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .section-heading {
        display: grid;
        gap: 12px;
    }

    .button {
        width: 100%;
    }

    .auth-dialog {
        padding: 18px;
        border-radius: 20px;
    }

    .auth-tabs {
        grid-template-columns: 1fr;
        border-radius: 18px;
    }

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

    .reader-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        border-radius: 22px;
    }

    .reader-controls span {
        grid-column: 1 / -1;
        text-align: center;
        order: -1;
    }

    .cover {
        min-height: 190px;
    }
}
