/*
  Bushraat - shared styles
  Warm paper background, deep green accent, serif for titles.
  Loaded on every page; page-specific presentation is kept here.
*/

:root {
    --bg: #faf9f6;
    --surface: #ffffff;
    --border: #e5e2da;
    --ink: #17181a;
    --ink-soft: #6f6e68;
    --accent: #2f5d4f;
    --accent-soft: #e7efec;
    --accent-hover: #244a3f;
    --surface-subtle: #f5f4f0;
    --border-strong: #d8d5cc;
    --radius: 8px;
    --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--sans), serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--serif), serif;
    font-size: 20px;
    letter-spacing: 0.2px;
}

.brand svg {
    flex-shrink: 0;
}

/* buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    font-family: var(--sans), serif;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn:hover {
    background: #244a3f;
}

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

.btn-ghost {
    background: transparent;
    color: var(--accent);
}

.btn-ghost:hover {
    background: var(--accent-soft);
}

/* size/tone modifiers, combine with .btn (and .btn-ghost where noted) */

.btn-sm {
    width: auto;
    padding: 7px 14px;
    font-size: 13px;
}

.btn-inline {
    width: auto;
    padding: 12px 24px;
}

.btn-muted {
    color: var(--ink-soft);
    border-color: var(--border);
}

.btn-danger {
    color: #9a3b3b;
    border-color: #e3b4b4;
}

.btn-danger:hover {
    background: #fbeeee;
}

/* forms */

.field {
    margin-bottom: 20px;
}

.field label {
    display: block;
    font-size: 13px;
    color: var(--ink-soft);
    margin-bottom: 7px;
}

.field input {
    width: 100%;
    padding: 11px 12px;
    font-size: 15px;
    font-family: var(--sans), serif;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.message {
    padding: 11px 14px;
    margin-bottom: 20px;
    border-radius: var(--radius);
    font-size: 14px;
    border: 1px solid transparent;
}

.message.error {
    background: #fbeeee;
    color: #9a3b3b;
    border-color: #f0d7d7;
}

.message.success {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: #d3e3dd;
}


/* password visibility control */

.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    width: 32px;
    height: 32px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
}

.password-toggle:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

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

.password-toggle svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* login / register */

.auth {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth .brand {
    margin-bottom: 34px;
}

.auth-panel {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 36px 34px;
}

.auth-panel h1 {
    font-family: var(--serif), serif;
    font-weight: normal;
    font-size: 24px;
    margin: 0 0 6px;
}

.auth-panel .lede {
    font-size: 14px;
    color: var(--ink-soft);
    margin: 0 0 28px;
}

.auth-footer {
    text-align: center;
    margin-top: 22px;
    font-size: 14px;
    color: var(--ink-soft);
}

.auth-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* page and section headings, used across most inner pages */

.page-head {
    margin-bottom: 38px;
}

.page-head h1 {
    font-family: var(--serif), serif;
    font-weight: normal;
    font-size: 30px;
    margin: 0 0 8px;
}

.page-head p {
    font-size: 15px;
    color: var(--ink-soft);
    margin: 0;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.section-head h2 {
    font-family: var(--serif), serif;
    font-weight: normal;
    font-size: 19px;
    margin: 0;
}

.section-head span {
    font-size: 13px;
    color: var(--ink-soft);
}

/* app shell: sidebar + main column, used on every page behind login */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 232px;
    flex-shrink: 0;
    padding: 30px 22px;
    border-right: 1px solid var(--border);
}

.sidebar .brand {
    margin-bottom: 40px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: var(--radius);
    font-size: 14.5px;
    color: var(--ink-soft);
    text-decoration: none;
}

.nav-link svg {
    flex-shrink: 0;
}

.nav-link:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.main {
    flex: 1;
    min-width: 0;
    padding: 44px 48px 60px;
}

.content {
    max-width: 980px;
    margin: 0 auto;
}

@media (max-width: 860px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 16px 22px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .sidebar .brand {
        margin-bottom: 0;
    }

    .nav {
        display: flex;
        gap: 4px;
    }

    .nav-link span {
        display: none;
    }

    .main {
        padding: 32px 24px 48px;
    }
}

/* book grid, used on the dashboard and the saved-books page */

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

.book-card {
    display: flex;
    flex-direction: column;
}

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

.book-cover {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 10px;
    display: flex;
    align-items: flex-end;
    padding: 14px;
    color: #fff;
    margin-bottom: 12px;
    overflow: hidden;
    background: var(--accent);
    box-shadow: 0 1px 2px rgba(23, 24, 26, .06);
    transition: box-shadow .25s cubic-bezier(.2, .8, .3, 1);
}

.book-card:hover .book-cover {
    box-shadow: 0 14px 28px rgba(23, 24, 26, .12), 0 2px 6px rgba(23, 24, 26, .06);
}

.book-cover img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .5s cubic-bezier(.2, .8, .3, 1);
}

.book-card:hover .book-cover img {
    transform: scale(1.05);
}

.book-cover span {
    font-family: var(--serif), serif;
    font-size: 15px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* cycle four cover tones so a grid of books doesn't look like one flat block */

.book-card:nth-child(4n+1) .book-cover {
    background: #2f5d4f;
}

.book-card:nth-child(4n+2) .book-cover {
    background: #33465c;
}

.book-card:nth-child(4n+3) .book-cover {
    background: #7c5c42;
}

.book-card:nth-child(4n+4) .book-cover {
    background: #3a3a38;
}

.book-title {
    font-size: 14.5px;
    font-weight: 600;
    margin: 0 0 3px;
    line-height: 1.3;
}

.book-author {
    font-size: 13px;
    color: var(--ink-soft);
    margin: 0 0 12px;
}

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

/* data tables, used on the admin dashboard */

.table-wrap {
    overflow-x: auto;
    margin-bottom: 8px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-soft);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table th:last-child,
.table td:last-child {
    text-align: right;
}

.table .row-actions {
    display: inline-flex;
    gap: 8px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* dashboard refinements */

.dashboard-content {
    max-width: 1080px
}

.welcome-block {
    display: grid;
    grid-template-columns:minmax(0, 1fr) minmax(300px, 420px);
    align-items: end;
    gap: 40px;
    margin-bottom: 44px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border)
}

.eyebrow {
    margin: 0 0 9px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em
}

.welcome-block h1 {
    font: normal 32px/1.2 var(--serif);
    margin: 0 0 8px
}

.welcome-block p:last-child {
    margin: 0;
    color: var(--ink-soft);
    font-size: 14.5px
}

.search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 4px 4px 14px;
    background: var(--surface)
}

.search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    font: 14px var(--sans);
    padding: 9px 0;
    background: transparent;
    color: var(--ink)
}

.search button {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    cursor: pointer
}

.search > svg {
    color: var(--ink-soft);
    flex-shrink: 0
}

.dashboard-section {
    margin-top: 42px
}


.empty {
    text-align: center;
    padding: 64px 20px;
    border: 1px solid var(--border);
    border-radius: 14px
}

.empty svg {
    display: inline-block;
    width: 34px;
    height: 34px;
    padding: 20px;
    margin-bottom: 18px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    box-sizing: content-box;
}

.empty h2 {
    font: normal 20px var(--serif);
    margin: 0 0 8px
}

.empty p {
    font-size: 14px;
    color: var(--ink-soft);
    margin: 0 0 18px
}

.field select, .field textarea {
    font: 14px var(--sans);
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 12px
}

.field select:focus, .field textarea:focus {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft)
}


@media (max-width: 900px) {
    .welcome-block {
        grid-template-columns:1fr
    }
}

@media (max-width: 560px) {
    .welcome-block h1 {
        font-size: 27px
    }

    .main {
        padding: 28px 18px 42px
    }
}


/* page-specific presentation */

/* authentication */

.auth-panel {
    border-radius: 14px;
    box-shadow: 0 12px 35px rgba(23, 24, 26, .045);
}

.auth-forgot {
    margin: 14px 0 0;
    text-align: center;
    font-size: 13px;
}

.auth-forgot a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.auth-forgot a:hover {
    text-decoration: underline;
}

/* admin */

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 44px;
}

.stat,
.form-card,
.profile-card,
.form-panel {
    border-radius: 14px;
    background: var(--surface);
}

.stat {
    min-width: 0;
    padding: 20px;
}

.stat .value {
    margin: 0 0 3px;
    font-family: var(--serif), serif;
    font-size: 28px;
    line-height: 1.1;
}

.stat .label {
    margin: 0;
    color: var(--ink-soft);
    font-size: 13px;
}

.content > section + section {
    margin-top: 48px;
}

.form-card {
    margin-bottom: 22px;
    padding: 24px;
}

.form-card h3 {
    margin: 0 0 18px;
    font-family: var(--serif), serif;
    font-size: 17px;
    font-weight: normal;
}

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

.form-card .btn {
    width: auto;
    padding-inline: 20px;
}

.cancel-link {
    display: inline-block;
    margin-left: 12px;
    color: var(--ink-soft);
    font-size: 13.5px;
    text-decoration: none;
}

.cancel-link:hover {
    color: var(--accent);
}

.field textarea,
.field select {
    width: 100%;
    box-sizing: border-box;
}

.field textarea {
    resize: vertical;
}

.field small {
    display: block;
    margin-top: 6px;
    color: var(--ink-soft);
    font-size: 12px;
    line-height: 1.5;
}

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

.row-actions form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.row-actions select {
    min-width: 125px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--sans), sans-serif;
    font-size: 13px;
}

.upload-progress {
    margin-top: 16px;
}

.upload-progress[hidden] {
    display: none;
}

.upload-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.875rem;
}

.upload-progress-track {
    width: 100%;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #e5e7eb;
}

.upload-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: currentColor;
    transition: width 0.15s ease;
}

#bookSubmitButton:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* tables */

.table-wrap {
    margin-bottom: 8px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-subtle);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table th:last-child,
.table td:last-child {
    text-align: right;
}

.table .row-actions {
    width: 100%;
}

/* book detail */

.book-page {
    max-width: 1120px;
    margin: 0 auto;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 30px;
    color: var(--ink-soft);
    font-size: 14px;
    text-decoration: none;
    transition: color .18s ease;
}

.back-link:hover {
    color: var(--accent);
}

.book-detail {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    align-items: start;
    gap: 52px;
}

.book-cover-large {
    width: 260px;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--accent-soft);
    box-shadow: 0 14px 34px rgba(23, 24, 26, .09);
}

.book-cover-large img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
}

.book-cover-placeholder {
    display: flex;
    align-items: flex-end;
    width: 100%;
    height: 100%;
    padding: 22px;
    background: var(--accent);
    color: #fff;
    font: 21px/1.3 var(--serif);
}

.book-info {
    min-width: 0;
    padding-top: 4px;
}

.book-info h1 {
    margin: 0 0 8px;
    font: normal 36px/1.15 var(--serif);
    letter-spacing: -.3px;
    overflow-wrap: anywhere;
}

.book-info .by {
    margin: 0 0 30px;
    color: var(--ink-soft);
    font-size: 15px;
}

.book-info .by span {
    color: var(--ink);
}

.meta-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(100px, 1fr));
    margin-bottom: 28px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.meta-item {
    padding: 16px 18px 16px 0;
}

.meta-item + .meta-item {
    padding-left: 18px;
    border-left: 1px solid var(--border);
}

.meta-item .label {
    margin: 0 0 5px;
    color: var(--ink-soft);
    font-size: 12px;
}

.meta-item .value {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.book-info .description {
    max-width: 68ch;
    margin: 0 0 30px;
    color: var(--ink-soft);
    font-size: 15px;
    line-height: 1.75;
}

.book-info .actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.book-info .actions form {
    margin: 0;
}

.book-info .actions .btn {
    min-width: 145px;
}

/* continue reading */

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

.reading-card {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    align-items: stretch;
    min-width: 0;
    min-height: 270px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(23, 24, 26, .04);
    transition: transform .25s cubic-bezier(.2, .8, .3, 1),
    box-shadow .25s cubic-bezier(.2, .8, .3, 1), border-color .2s ease;
}

.reading-card:hover {
    transform: translateY(-2px);
    border-color: #d7e1db;
    box-shadow: 0 16px 32px rgba(23, 24, 26, .09), 0 3px 8px rgba(23, 24, 26, .04);
}

.reading-cover {
    position: relative;
    display: flex;
    align-items: flex-end;
    align-self: stretch;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    isolation: isolate;
}

.reading-cover img {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    transition: transform .5s cubic-bezier(.2, .8, .3, 1);
}

.reading-card:hover .reading-cover img {
    transform: scale(1.035);
}

.reading-cover::before {
    position: absolute;
    inset: 0;
    z-index: 1;
    content: "";
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, .48) 100%);
}

.reading-cover span {
    position: relative;
    z-index: 2;
    max-width: 100%;
    padding: 16px;
    font-family: var(--serif), serif;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.reading-card:nth-child(4n+1) .reading-cover {
    background: #2f5d4f;
}

.reading-card:nth-child(4n+2) .reading-cover {
    background: #33465c;
}

.reading-card:nth-child(4n+3) .reading-cover {
    background: #7c5c42;
}

.reading-card:nth-child(4n+4) .reading-cover {
    background: #3a3a38;
}

.reading-progress-track {
    position: absolute;
    right: 14px;
    bottom: 14px;
    left: 14px;
    z-index: 3;
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, .3);
}

.reading-progress-fill {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 3px;
    border-radius: inherit;
    background: #fff;
}

.reading-body {
    display: flex;
    min-width: 0;
    flex-direction: column;
    padding: 22px;
    overflow: hidden;
}

.reading-format {
    margin: 0 0 9px;
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .11em;
    line-height: 1.2;
    text-transform: uppercase;
}

.reading-body h2 {
    margin: 0 0 5px;
    color: var(--ink);
    font-family: var(--serif), serif;
    font-size: 19px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: -.01em;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.reading-body .reading-author {
    margin: 0;
}

.reading-description {
    max-width: 48ch;
    margin: 12px 0 0;
    color: var(--ink-soft);
    font-size: 13.5px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.reading-position {
    margin-top: auto;
    padding-top: 20px;
}

.reading-position-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--ink-soft);
    font-size: 12.5px;
}

.reading-position-row strong {
    color: var(--ink);
    font-weight: 600;
}

.reading-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reading-actions form,
.reading-clear-form {
    display: flex;
    width: 100%;
    margin: 0;
}


.reading-continue,
.reading-clear {
    width: 100%;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.2;
}

.reading-continue {
    justify-content: space-between;
    background: transparent;
    color: var(--ink);
    border-color: var(--border);
}

.reading-continue:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.reading-continue svg {
    flex-shrink: 0;
    transition: transform .15s ease;
}

.reading-continue:hover svg {
    transform: translateX(2px);
}

.reading-clear {
    background: transparent;
    color: var(--ink-soft);
    border-color: var(--border);
}

.reading-clear:hover {
    background: var(--surface-subtle);
    border-color: var(--border-strong);
    color: var(--ink);
}

.reading-clear:disabled {
    opacity: .6;
    cursor: wait;
}

/* profile */

.profile-layout {
    display: flex;
    align-items: flex-start;
    gap: 32px;
}

.profile-card {
    width: 240px;
    flex-shrink: 0;
    padding: 30px 24px;
    text-align: center;
}

.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 66px;
    height: 66px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-family: var(--serif), serif;
    font-size: 24px;
}

.profile-card h2 {
    margin: 0 0 3px;
    font-size: 16px;
}

.profile-card .email {
    margin: 0 0 18px;
    color: var(--ink-soft);
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}

.profile-card .since {
    margin: 0 0 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--ink-soft);
    font-size: 12.5px;
}

.form-panel {
    flex: 1;
    min-width: 0;
    max-width: 460px;
    padding: 32px;
}

.form-panel h2 {
    margin: 0 0 24px;
    font-family: var(--serif), serif;
    font-size: 18px;
    font-weight: normal;
}

.form-panel hr {
    margin: 8px 0 24px;
    border: 0;
    border-top: 1px solid var(--border);
}

.form-panel .hint {
    margin: -12px 0 20px;
    color: var(--ink-soft);
    font-size: 12.5px;
}

/* landing page */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1080px;
    margin: 0 auto;
    padding: 26px 24px;
}

.topbar .actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.topbar .actions a.link {
    color: var(--ink-soft);
    font-size: 14.5px;
    text-decoration: none;
}

.topbar .actions a.link:hover {
    color: var(--accent);
}

.hero {
    display: flex;
    align-items: center;
    gap: 60px;
    max-width: 1080px;
    margin: 0 auto;
    padding: 60px 24px 90px;
}

.hero-copy {
    flex: 1;
    min-width: 0;
}

.hero-copy h1 {
    max-width: 14ch;
    margin: 0 0 20px;
    font-family: var(--serif), serif;
    font-size: 44px;
    font-weight: normal;
    line-height: 1.2;
}

.hero-copy p {
    max-width: 42ch;
    margin: 0 0 32px;
    color: var(--ink-soft);
    font-size: 16.5px;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.hero-visual {
    position: relative;
    width: 300px;
    height: 300px;
    flex-shrink: 0;
}

.hero-visual .plate {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 168px;
    height: 224px;
    overflow: hidden;
    border-radius: 6px;
    transition: transform .3s ease;
}

.hero-visual .plate img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
}

.hero-visual .plate:hover {
    z-index: 10;
}

.hero-visual .plate:nth-child(1) {
    background: #7c5c42;
    transform: translate(-50%, -50%) rotate(-11deg) translate(-46px, 6px);
}

.hero-visual .plate:nth-child(1):hover {
    transform: translate(-50%, -50%) rotate(-11deg) translate(-46px, 6px) scale(1.05);
}

.hero-visual .plate:nth-child(2) {
    background: #33465c;
    transform: translate(-50%, -50%) rotate(7deg) translate(30px, -4px);
}

.hero-visual .plate:nth-child(2):hover {
    transform: translate(-50%, -50%) rotate(7deg) translate(30px, -4px) scale(1.05);
}

.hero-visual .plate:nth-child(3) {
    background: var(--accent);
    box-shadow: 0 20px 40px -20px rgba(23, 24, 26, .35);
    transform: translate(-50%, -50%) rotate(-2deg);
}

.hero-visual .plate:nth-child(3):hover {
    transform: translate(-50%, -50%) rotate(-2deg) scale(1.05);
}

.features {
    padding: 70px 24px;
    border-top: 1px solid var(--border);
}

.features-inner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 44px;
    max-width: 1080px;
    margin: 0 auto;
}

.feature svg {
    margin-bottom: 16px;
    color: var(--accent);
}

.feature h3 {
    margin: 0 0 8px;
    font-size: 16.5px;
}

.feature p {
    max-width: 32ch;
    margin: 0;
    color: var(--ink-soft);
    font-size: 14.5px;
    line-height: 1.6;
}

.cta-band {
    padding: 70px 24px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.cta-band h2 {
    margin: 0 0 26px;
    font-family: var(--serif), serif;
    font-size: 28px;
    font-weight: normal;
}

footer {
    padding: 24px;
    border-top: 1px solid var(--border);
}

footer .footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 1080px;
    margin: 0 auto;
    color: var(--ink-soft);
    font-size: 13px;
}

/* reader */

html:has(body.reader-document),
body.reader-document {
    height: 100%;
}

body.reader-document {
    overflow: hidden;
}

.reader-progress {
    height: 3px;
    background: var(--border);
}

.reader-progress > div {
    height: 100%;
    background: var(--accent);
    transition: width .2s ease;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 62px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.toolbar-title {
    min-width: 0;
    text-align: center;
}

.toolbar-title h1 {
    max-width: 55vw;
    margin: 0;
    overflow: hidden;
    font-size: 14px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.toolbar-controls {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 50px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--ink-soft);
    cursor: pointer;
    text-decoration: none;
    transition: border-color .18s ease, background-color .18s ease, color .18s ease;
}

.icon-btn:hover {
    border-color: var(--border-strong);
    background: var(--surface-subtle);
    color: var(--ink);
}

.reader-body {
    position: relative;
    display: flex;
    height: calc(100vh - 65px);
}

.page {
    flex: 1;
    min-width: 0;
    overflow: auto;
    background: var(--bg);
    color: var(--ink);
}

.pdf-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.pdf-progress {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 10px 28px rgba(23, 24, 26, .12);
    backdrop-filter: blur(12px);
}

.pdf-progress label {
    padding-left: 4px;
    color: var(--ink-soft);
    font-size: 12px;
}

.pdf-progress input {
    width: 72px;
    padding: 7px 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
}

.pdf-progress input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.pdf-progress button {
    min-width: 58px;
    padding: 8px 10px;
    border: 1px solid var(--accent);
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.pdf-progress button:hover {
    background: var(--accent-hover);
}

.pdf-progress button:disabled {
    opacity: .65;
    cursor: wait;
}

/* error page */

main.error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    text-align: center;
}

main.error .code {
    margin-bottom: 12px;
    color: var(--accent);
    font: 72px/1 var(--serif), serif;
    letter-spacing: -2px;
}

main.error h1 {
    margin: 0 0 10px;
    font: normal 28px/1.2 var(--serif), serif;
}

main.error p {
    max-width: 500px;
    margin: 0 0 28px;
    color: var(--ink-soft);
    line-height: 1.6;
}

main.error .error-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

main.error .error-actions .btn {
    width: auto;
    min-width: 120px;
}

/* responsive page-specific layout */

@media (max-width: 900px) {
    .stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .book-detail {
        grid-template-columns: 200px minmax(0, 1fr);
        gap: 32px;
    }

    .book-cover-large {
        width: 200px;
    }

    .book-info h1 {
        font-size: 30px;
    }
}

@media (max-width: 760px) {
    .reading-grid {
        grid-template-columns: 1fr;
    }

    .profile-layout {
        flex-direction: column;
    }

    .profile-card,
    .form-panel {
        width: 100%;
        max-width: none;
    }

    .sidebar {
        background: var(--bg);
    }
}

@media (max-width: 720px) {
    .toolbar-title {
        max-width: 65vw;
    }
}

@media (max-width: 650px) {
    .book-detail {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .book-cover-large {
        width: 210px;
        margin: 0 auto;
    }

    .book-info h1 {
        font-size: 28px;
    }

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

    .meta-item {
        padding: 14px 0;
    }

    .meta-item + .meta-item {
        padding-left: 0;
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .book-info .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .book-info .actions .btn,
    .book-info .actions form {
        width: 100%;
    }
}

@media (max-width: 620px) {
    .section-actions span {
        display: none;
    }

    .reading-card {
        grid-template-columns: 128px minmax(0, 1fr);
        min-height: 240px;
    }

    .reading-body {
        padding: 17px;
    }

    .reading-position {
        padding-top: 17px;
    }

    .table {
        min-width: 680px;
    }
}

@media (max-width: 560px) {
    .auth-panel {
        padding: 28px 22px;
    }

    .topbar {
        padding: 20px 18px;
    }

    .topbar .actions a.link {
        display: none;
    }

    .hero-actions {
        justify-content: center;
    }

    .hero-actions .btn {
        width: 100%;
        max-width: 300px;
    }

    .pdf-progress {
        right: 10px;
        bottom: 10px;
        left: 10px;
        justify-content: flex-end;
    }

    .page-head h1 {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .reading-card {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .reading-cover {
        min-height: 220px;
    }

    .reading-body {
        padding: 18px;
    }

    main.error .error-actions {
        width: 100%;
        flex-direction: column;
    }

    main.error .error-actions .btn {
        width: 100%;
        max-width: 280px;
    }

    main.error .code {
        font-size: 60px;
    }

    main.error h1 {
        font-size: 25px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}


/* responsive refinements
   Layout and presentation only. No application or template logic is changed. */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

img,
svg,
iframe {
    max-width: 100%;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

@media (max-width: 860px) {
    .main {
        min-width: 0;
    }

    .content {
        width: 100%;
    }

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

@media (max-width: 760px) {
    .hero {
        padding-top: 42px;
        padding-bottom: 64px;
    }

    /* The landing-page book artwork is intentionally hidden on smaller screens. */
    .hero-visual {
        display: none;
    }

    .hero-copy {
        width: 100%;
        text-align: center;
    }

    .hero-copy h1,
    .hero-copy p {
        margin-left: auto;
        margin-right: auto;
    }

    .features {
        padding-top: 52px;
        padding-bottom: 52px;
    }

    .features-inner {
        gap: 32px;
    }

    .feature {
        min-width: 0;
    }

    .profile-layout {
        width: 100%;
    }

    .form-panel {
        width: 100%;
    }
}

@media (max-width: 620px) {
    .main {
        padding-left: 18px;
        padding-right: 18px;
    }

    .page-head {
        margin-bottom: 30px;
    }

    .section-head {
        align-items: flex-start;
    }

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

    .book-cover {
        padding: 12px;
    }

    .book-title {
        overflow-wrap: anywhere;
    }

    .book-author {
        overflow-wrap: anywhere;
    }

    .stats {
        gap: 12px;
        margin-bottom: 32px;
    }

    .stat {
        padding: 17px;
    }

    .form-card {
        padding: 18px;
    }

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

    .form-card .btn {
        width: 100%;
    }

    .cancel-link {
        margin-top: 10px;
        margin-left: 0;
    }

    .profile-card,
    .form-panel {
        padding: 24px 18px;
    }

    .book-info .actions .btn,
    .book-info .actions form {
        max-width: 100%;
    }

    .toolbar {
        padding-left: 12px;
        padding-right: 12px;
    }

    .toolbar-title h1 {
        max-width: 58vw;
    }

    .pdf-progress {
        max-width: calc(100vw - 20px);
    }
}

@media (max-width: 480px) {
    .topbar {
        padding-left: 16px;
        padding-right: 16px;
    }

    .topbar .actions {
        gap: 8px;
    }

    .topbar .actions .btn {
        padding-left: 12px;
        padding-right: 12px;
    }

    .hero {
        padding: 34px 18px 54px;
    }

    .hero-copy h1 {
        max-width: 100%;
        font-size: 34px;
    }

    .hero-copy p {
        font-size: 15px;
    }

    .features {
        padding-left: 18px;
        padding-right: 18px;
    }

    .features-inner {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .feature p {
        max-width: none;
    }

    .cta-band {
        padding: 52px 18px;
    }

    .cta-band h2 {
        font-size: 25px;
    }

    .auth {
        padding: 28px 14px;
    }

    .auth-panel {
        max-width: 100%;
        padding: 24px 18px;
    }

    .book-grid {
        gap: 18px 12px;
    }

    .book-cover {
        border-radius: 8px;
    }

    .reading-card {
        width: 100%;
    }

    .reading-cover {
        min-height: 210px;
    }

    .book-cover-large {
        max-width: 210px;
    }

    .meta-row {
        width: 100%;
    }

    .pdf-progress {
        right: 8px;
        bottom: 8px;
        left: 8px;
        padding: 6px;
    }

    .pdf-progress label {
        display: none;
    }

    .pdf-progress input {
        flex: 1;
        min-width: 0;
        width: auto;
    }

    .pdf-progress button {
        flex-shrink: 0;
    }
}

@media (max-width: 360px) {
    .main {
        padding-left: 14px;
        padding-right: 14px;
    }

    .topbar {
        padding-left: 12px;
        padding-right: 12px;
    }

    .topbar .brand {
        font-size: 18px;
    }

    .topbar .actions .btn {
        padding-left: 10px;
        padding-right: 10px;
        font-size: 13px;
    }

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

    .book-grid {
        gap: 16px 10px;
    }

    .book-cover {
        padding: 10px;
    }

    .book-title {
        font-size: 13.5px;
    }

    .book-author {
        font-size: 12.5px;
    }

    .form-card,
    .profile-card,
    .form-panel {
        padding-left: 14px;
        padding-right: 14px;
    }

    .toolbar-title h1 {
        max-width: 50vw;
    }
}

/* mobile navigation */
.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-menu-toggle:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.mobile-menu-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

@media (max-width: 760px) {
    .sidebar {
        position: relative;
        z-index: 20;
        flex-wrap: wrap;
        row-gap: 12px;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        margin-left: auto;
    }

    .sidebar .nav {
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        display: none !important;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        margin: 4px 0 0;
        padding: 10px 0 0;
        border-top: 1px solid var(--border);
    }

    .sidebar.nav-open .nav {
        display: flex !important;
    }

    .sidebar .nav-link {
        display: flex;
        width: 100%;
        margin: 0;
        padding: 12px;
        box-sizing: border-box;
    }

    .sidebar .nav-link span {
        display: inline !important;
        visibility: visible;
        opacity: 1;
    }

    .sidebar .nav-link svg {
        display: block;
        visibility: visible;
        opacity: 1;
    }

    .sidebar .nav-link:last-child {
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    .sidebar {
        padding: 14px 16px;
    }

    .mobile-menu-toggle {
        width: 38px;
        height: 38px;
    }
}

/* landing page: keep sign-in as the primary top action on small screens */
@media (max-width: 560px) {
    .topbar .actions a.link {
        display: inline;
    }

    .topbar .actions .btn {
        display: none;
    }
}
