.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.reader-page {
    min-height: 100vh;
}

.reader-page .navbar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 100;
}

body.reader-page[data-theme="matrix"] .navbar {
    position: fixed;
}

.reader-page .reader-main {
    position: relative;
}

.reader-navbar .nav-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
}

.reader-back {
    align-self: center;
    color: var(--text-light);
    font-weight: 800;
}

.reader-back:hover {
    color: var(--primary-color);
}

.reader-theme-selector {
    justify-self: end;
}

.reader-main {
    width: min(1500px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 5.5rem 0 0.35rem;
}

.reader-heading {
    display: none;
    align-items: end;
    justify-content: space-between;
    gap: 2rem;
    padding: 1.5rem 0;
}

.reader-heading h1 {
    margin: 0;
    font-size: clamp(1.75rem, 4vw, 3rem);
}

.reader-save-status {
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.reader-notice {
    position: fixed;
    right: clamp(1rem, 3vw, 2rem);
    bottom: clamp(1rem, 3vw, 2rem);
    z-index: 220;
    max-width: min(420px, calc(100vw - 2rem));
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: color-mix(in srgb, var(--light-bg) 94%, transparent);
    color: var(--text-dark);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
    font-size: 0.88rem;
    font-weight: 800;
    line-height: 1.35;
}

.reader-notice-error {
    border-color: color-mix(in srgb, #d9534f 55%, var(--border-color));
    background:
        linear-gradient(135deg, color-mix(in srgb, #d9534f 12%, transparent), transparent),
        color-mix(in srgb, var(--light-bg) 94%, transparent);
}

.reader-shell {
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    min-height: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--primary-color) 20%, var(--border-color));
    border-radius: 22px;
    background: color-mix(in srgb, var(--light-bg) 91%, transparent);
    box-shadow: 0 30px 90px color-mix(in srgb, var(--text-dark) 18%, transparent);
    backdrop-filter: blur(18px);
}

body[data-theme="matrix"] .reader-shell {
    background: color-mix(in srgb, var(--light-bg) 91%, transparent);
}

body[data-theme="matrix"] .reader-stage {
    background: color-mix(in srgb, #fffdf8 95%, var(--primary-color));
}

.reader-sidebar {
    min-width: 0;
    min-height: 0;
    padding: 1.25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
    border-right: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--light-bg) 78%, transparent);
}

.reader-sidebar::-webkit-scrollbar {
    width: 8px;
}

.reader-sidebar::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary-color) 65%, transparent);
}

.reader-book-summary {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 0.9rem;
    align-items: center;
    padding-bottom: 1.1rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid var(--border-color);
}

.reader-book-summary img {
    width: 64px;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 3px 6px 6px 3px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.reader-book-summary strong,
.reader-book-summary span {
    display: block;
}

.reader-book-summary strong {
    color: var(--text-dark);
    line-height: 1.25;
}

.reader-book-summary span {
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.reader-library-panel,
.reader-contents-panel {
    min-height: 0;
}

.reader-book-list {
    display: grid;
    gap: 0.7rem;
    margin-top: 1rem;
}

.reader-book-option {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 0.75rem;
    align-items: center;
    width: 100%;
    padding: 0.65rem;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--text-dark);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.reader-book-option:hover,
.reader-book-option.active {
    border-color: color-mix(in srgb, var(--primary-color) 32%, var(--border-color));
    background: color-mix(in srgb, var(--primary-color) 10%, transparent);
}

.reader-book-option img {
    width: 48px;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 3px 6px 6px 3px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.reader-book-option strong,
.reader-book-option span {
    display: block;
}

.reader-book-option strong {
    line-height: 1.5;
    padding-bottom: 0.12em;
}

.reader-book-option span {
    margin-top: 0.28rem;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.reader-library-detail {
    display: none;
    align-content: start;
    justify-items: center;
    min-height: 0;
    padding: clamp(1.25rem, 4vw, 3rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    background:
        radial-gradient(circle at 20% 18%, color-mix(in srgb, var(--primary-color) 18%, transparent), transparent 30%),
        color-mix(in srgb, var(--light-bg) 91%, transparent);
}

.reader-library-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(0.8rem, 2.2vw, 1.4rem);
    align-items: start;
    justify-items: center;
    max-width: 1040px;
    margin: 0 auto;
}

.reader-book-showcase {
    display: grid;
    gap: 0.75rem;
    justify-items: center;
    min-width: 0;
    width: min(720px, 100%);
    padding: clamp(0.85rem, 2vw, 1.25rem);
    border: 1px solid color-mix(in srgb, var(--primary-color) 22%, transparent);
    border-radius: 22px;
    background:
        radial-gradient(circle at 50% 32%, color-mix(in srgb, var(--primary-color) 16%, transparent), transparent 48%),
        color-mix(in srgb, var(--light-bg) 54%, transparent);
    box-shadow: inset 0 1px 0 color-mix(in srgb, white 16%, transparent);
    cursor: grab;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.reader-book-showcase:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary-color) 75%, white);
    outline-offset: 4px;
}

.reader-book-showcase.is-dragging {
    cursor: grabbing;
}

.reader-book-scene {
    --book-pan-x: 0px;
    --book-pan-y: 0px;
    --book-scale: 1;
    display: grid;
    place-items: center;
    width: 100%;
    min-height: clamp(340px, 38vw, 480px);
    perspective: 1400px;
    transform: translate(var(--book-pan-x), var(--book-pan-y)) scale(var(--book-scale));
    transform-origin: center;
}

.reader-book-model {
    --book-rotate-x: -8deg;
    --book-rotate-y: -24deg;
    --book-depth: 32px;
    position: relative;
    width: min(330px, 62%);
    aspect-ratio: 0.645 / 1;
    transform-style: preserve-3d;
    transform: rotateX(var(--book-rotate-x)) rotateY(var(--book-rotate-y));
    transition: transform 0.08s linear;
}

.reader-book-face {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 5px 13px 13px 5px;
    background: #15110f;
    backface-visibility: hidden;
}

.reader-book-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.reader-book-front {
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
    transform: translateZ(calc(var(--book-depth) / 2));
}

.reader-book-back {
    border-radius: 13px 5px 5px 13px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
    transform: translateZ(calc(var(--book-depth) / -2)) rotateY(180deg);
}

.reader-book-spine {
    left: 0;
    right: auto;
    width: var(--book-depth);
    border-radius: 5px;
    transform-origin: left center;
    transform: rotateY(-90deg) translateX(calc(var(--book-depth) / -2));
}

.reader-book-spine img {
    object-fit: fill;
}

.reader-book-pages,
.reader-book-top-pages,
.reader-book-bottom-pages {
    background:
        repeating-linear-gradient(90deg, #f6ecd9 0 2px, #d8c7aa 2px 3px),
        linear-gradient(180deg, #fff9ec, #d6c6aa);
}

.reader-book-pages {
    left: auto;
    right: 0;
    width: var(--book-depth);
    border-radius: 2px 8px 8px 2px;
    transform-origin: right center;
    transform: rotateY(90deg) translateX(calc(var(--book-depth) / 2));
}

.reader-book-top-pages,
.reader-book-bottom-pages {
    inset: auto auto auto 0;
    width: 100%;
    height: var(--book-depth);
    border-radius: 5px 13px 8px 8px;
    background:
        repeating-linear-gradient(0deg, #f6ecd9 0 2px, #d8c7aa 2px 3px),
        linear-gradient(90deg, #fff9ec, #d6c6aa);
}

.reader-book-top-pages {
    bottom: 100%;
    transform-origin: bottom center;
    transform: rotateX(90deg) translateY(calc(var(--book-depth) / 2));
}

.reader-book-bottom-pages {
    top: 100%;
    transform-origin: top center;
    transform: rotateX(-90deg) translateY(calc(var(--book-depth) / -2));
}

.reader-library-copy h2 {
    margin: 0 0 0.5rem;
    color: var(--text-dark);
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.18;
    padding-bottom: 0.14em;
    text-align: center;
}

.reader-library-copy,
.reader-library-copy .section-kicker {
    width: 100%;
    text-align: center;
}

.reader-library-author {
    margin-bottom: 1.1rem;
    color: var(--primary-color);
    font-weight: 900;
    text-align: center;
}

.reader-library-blurb {
    max-width: 74ch;
    margin: 0 auto;
    padding: clamp(1.1rem, 2.4vw, 1.6rem);
    border: 1px solid color-mix(in srgb, var(--primary-color) 18%, var(--border-color));
    border-radius: 20px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--light-bg) 82%, transparent), color-mix(in srgb, var(--primary-color) 7%, transparent));
    color: var(--text-light);
    font-size: clamp(1rem, 1.6vw, 1.18rem);
    line-height: 1.65;
    text-align: left;
    box-shadow: inset 0 1px 0 color-mix(in srgb, white 14%, transparent);
}

.reader-library-blurb p {
    margin: 0 0 0.85rem;
}

.reader-library-questions {
    display: grid;
    gap: 0.45rem;
    margin: 0.9rem 0 1rem;
    padding: 0;
    list-style: none;
}

.reader-library-questions li {
    position: relative;
    padding-left: 1.15rem;
    color: var(--text-dark);
    font-weight: 800;
}

.reader-library-questions li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

.reader-library-closing-question {
    color: var(--primary-color);
    font-weight: 900;
}

.reader-purchase-links {
    margin-top: 1.25rem;
    text-align: center;
}

.reader-purchase-links h3 {
    margin: 0 0 0.65rem;
    color: var(--text-dark);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.reader-purchase-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: center;
}

.reader-purchase-link {
    display: inline-grid;
    gap: 0.18rem;
    min-width: 132px;
    padding: 0.75rem 0.9rem;
    border: 1px solid color-mix(in srgb, var(--primary-color) 28%, var(--border-color));
    border-radius: 15px;
    background: color-mix(in srgb, var(--light-bg) 72%, transparent);
    color: var(--text-dark);
    text-decoration: none;
}

.reader-purchase-link strong,
.reader-purchase-link span {
    display: block;
}

.reader-purchase-link strong {
    font-size: 0.88rem;
}

.reader-purchase-link span {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.reader-purchase-link.is-live:hover {
    border-color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 12%, var(--light-bg));
    transform: translateY(-1px);
}

.reader-purchase-link.is-coming-soon {
    opacity: 0.68;
    cursor: default;
}

.reader-library-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
    margin-top: 0;
}

.reader-library-actions .reader-purchase-links {
    flex-basis: 100%;
    margin-top: 0;
}

.reader-library-actions .reader-purchase-links h3 {
    margin-bottom: 0.45rem;
}

.reader-coming-soon {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0.62rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--light-bg) 76%, transparent);
    font-size: 0.82rem;
    font-weight: 900;
}

.reader-library-mode .reader-contents-panel,
.reader-library-mode .reader-toolbar,
.reader-library-mode .reader-viewport,
.reader-library-mode .reader-navigation,
.reader-library-mode .reader-side-turn,
.reader-library-mode .reader-focus-exit {
    display: none;
}

.reader-library-mode .reader-library-detail {
    display: grid;
}

.reader-library-mode .reader-stage {
    grid-template-rows: minmax(0, 1fr);
}

.reader-page:not(.reader-library-mode) .reader-library-panel,
.reader-page:not(.reader-library-mode) .reader-library-detail {
    display: none;
}

.reader-sidebar-heading,
.notes-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.reader-sidebar-heading h2,
.notes-panel h2,
.note-composer h2 {
    margin: 0;
    font-size: 1.25rem;
}

.sidebar-close {
    display: none !important;
}

.reader-toc {
    margin-top: 0.75rem;
}

.reader-toc button {
    display: block;
    width: 100%;
    padding: 0.68rem 0.75rem;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-light);
    font: inherit;
    font-size: 0.88rem;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
}

.reader-toc button:hover,
.reader-toc button.active {
    background: color-mix(in srgb, var(--primary-color) 13%, transparent);
    color: var(--primary-color);
}

.reader-stage {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
    background: color-mix(in srgb, #fffdf8 95%, var(--primary-color));
}

@media (min-width: 901px) {
    .reader-page {
        height: 100dvh;
        overflow: hidden;
    }

    .reader-main {
        display: grid;
        grid-template-rows: minmax(0, 1fr);
        width: min(1520px, calc(100% - 2rem));
        height: 100dvh;
        padding: 6.75rem 0 0.75rem;
    }

    .reader-shell {
        height: 100%;
        transition: grid-template-columns 0.22s ease;
    }

    .reader-shell.contents-collapsed {
        grid-template-columns: 0 minmax(0, 1fr);
    }

    .reader-shell.contents-collapsed .reader-sidebar {
        padding-inline: 0;
        overflow: hidden;
        visibility: hidden;
        border-right: 0;
    }
}

.reader-side-turn {
    position: absolute;
    top: 50%;
    z-index: 6;
    display: grid;
    place-items: center;
    width: 46px;
    height: 76px;
    border: 1px solid color-mix(in srgb, var(--primary-color) 40%, var(--border-color));
    background: color-mix(in srgb, var(--light-bg) 88%, transparent);
    color: var(--primary-color);
    font: inherit;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    transform: translateY(-50%);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.reader-stage.page-turn-controls-visible .reader-side-turn {
    opacity: 0.72;
    pointer-events: auto;
}

.reader-stage.page-turn-controls-visible .reader-side-turn:hover,
.reader-side-turn:focus-visible {
    opacity: 1;
    pointer-events: auto;
}

.reader-side-turn-previous {
    left: 0.8rem;
    border-radius: 0 12px 12px 0;
}

.reader-side-turn-next {
    right: 0.8rem;
    border-radius: 12px 0 0 12px;
}

.reader-focus-exit {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 75;
    display: none;
}

.reader-page.reader-focus-mode {
    height: 100dvh;
    overflow: hidden;
}

.reader-page.reader-focus-mode .navbar {
    transform: translateY(-110%);
    pointer-events: none;
}

.reader-page.reader-focus-mode .reader-main {
    position: fixed;
    inset: 0;
    z-index: 70;
    width: 100%;
    height: 100dvh;
    padding: 0;
}

.reader-page.reader-focus-mode .reader-shell {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.reader-page.reader-focus-mode .reader-sidebar {
    display: none;
}

.reader-page.reader-focus-mode .reader-stage {
    grid-template-rows: minmax(0, 1fr);
    height: 100dvh;
    border-radius: 0;
}

.reader-page.reader-focus-mode .reader-toolbar,
.reader-page.reader-focus-mode .reader-navigation {
    display: none;
}

.reader-page.reader-focus-mode .reader-viewport {
    min-height: 0;
}

.reader-page.reader-focus-mode .reader-focus-exit {
    display: inline-flex;
    opacity: 0.78;
}

.reader-toolbar,
.reader-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: color-mix(in srgb, var(--light-bg) 94%, transparent);
}

.reader-toolbar {
    border-bottom: 1px solid var(--border-color);
}

.reader-navigation {
    border-top: 1px solid var(--border-color);
}

.reader-toolbar-group {
    display: flex;
    gap: 0.35rem;
}

.reader-mode-control {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
}

.reader-mode-control select {
    padding: 0.48rem 1.8rem 0.48rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: color-mix(in srgb, var(--light-bg) 86%, transparent);
    color: var(--text-dark);
    font: inherit;
}

.reader-tool,
.reader-icon-button,
.reader-page-button {
    border: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--light-bg) 86%, transparent);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.reader-tool,
.reader-page-button {
    padding: 0.62rem 0.85rem;
    border-radius: 9px;
}

.reader-icon-button {
    display: inline-grid;
    place-items: center;
    min-width: 38px;
    min-height: 38px;
    padding: 0.3rem;
    border-radius: 50%;
}

.reader-icon-button span {
    font-size: 0.65em;
}

.reader-tool:hover,
.reader-icon-button:hover,
.reader-page-button:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.note-count {
    display: inline-grid;
    place-items: center;
    min-width: 1.35rem;
    height: 1.35rem;
    margin-left: 0.25rem;
    border-radius: 999px;
    background: var(--primary-color);
    color: white;
    font-size: 0.7rem;
}

.reader-viewport {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.reader-viewport iframe {
    background: #fffdf8;
}

.reader-page[data-reading-mode="dark"] .reader-viewport,
.reader-page[data-reading-mode="dark"] .reader-viewport iframe {
    background: #17191d;
}

.reader-page[data-reading-mode="paper"] .reader-viewport,
.reader-page[data-reading-mode="paper"] .reader-viewport iframe {
    background: #efe1c2;
}

.reader-gesture-layer,
.reader-gesture-hint {
    display: none;
}

.reader-loading {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    place-content: center;
    gap: 0.4rem;
    text-align: center;
    color: #514b45;
    background: #fffdf8;
}

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

.reader-loading-mark {
    color: var(--primary-color);
    font-size: 3rem;
    animation: reader-pulse 1.2s ease-in-out infinite;
}

.reader-loading span:last-child,
.reader-muted {
    color: var(--text-muted);
    font-size: 0.86rem;
}

@keyframes reader-pulse {
    50% { opacity: 0.45; transform: scale(0.92); }
}

.reader-progress-wrap {
    display: grid;
    grid-template-columns: minmax(90px, auto) minmax(70px, 180px) 42px;
    gap: 0.7rem;
    align-items: center;
    min-width: 0;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 700;
}

#chapterLabel {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-progress {
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 22%, transparent);
}

.reader-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.25s ease;
}

.reader-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(10, 12, 20, 0.48);
    backdrop-filter: blur(3px);
}

.notes-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 110;
    width: min(420px, 92vw);
    height: 100vh;
    padding: 1.5rem;
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--light-bg) 96%, transparent);
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.2);
    transform: translateX(105%);
    transition: transform 0.25s ease;
}

.notes-panel.open {
    transform: translateX(0);
}

.notes-panel-header {
    margin-bottom: 1rem;
}

.notes-help {
    margin-bottom: 0.85rem;
}

.public-notes-setup {
    display: grid;
    gap: 0.9rem;
    margin: 0 0 0.65rem;
    padding: 1rem;
    border: 1px solid color-mix(in srgb, var(--primary-color) 22%, var(--border-color));
    border-radius: 14px;
    background: color-mix(in srgb, var(--primary-color) 7%, transparent);
}

.public-notes-setup.is-signed-in {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.8rem;
}

.public-notes-setup.is-signed-in h3 {
    display: none;
}

.public-notes-setup.is-signed-in #publicNotesStatus {
    margin: 0;
    font-size: 0.76rem;
}

.public-notes-setup h3 {
    margin: 0;
    color: var(--text-dark);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.public-notes-actions {
    display: grid;
    gap: 0.55rem;
}

.public-notes-setup.is-signed-in .public-notes-actions {
    grid-template-columns: auto;
    align-items: center;
    justify-content: end;
}

.public-notes-setup.is-signed-in .public-notes-actions label[for="publicNoteName"],
.public-notes-setup.is-signed-in .public-notes-actions > input {
    display: none !important;
}

.public-notes-actions label {
    color: var(--text-dark);
    font-size: 0.78rem;
    font-weight: 800;
}

.public-notes-visibility {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    color: var(--text-dark);
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
}

.public-notes-visibility input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary-color);
}

.public-notes-actions input {
    width: 100%;
    padding: 0.7rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: color-mix(in srgb, var(--white) 72%, transparent);
    color: var(--text-dark);
    font: inherit;
}

.public-notes-actions input:focus {
    outline: 2px solid color-mix(in srgb, var(--primary-color) 45%, transparent);
    border-color: var(--primary-color);
}

.public-notes-actions .public-notes-visibility input {
    width: 1rem;
    height: 1rem;
    padding: 0;
}

.notes-chapter-nav {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 0.75rem;
    padding: 0.55rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: color-mix(in srgb, var(--white) 54%, transparent);
}

.notes-chapter-nav span {
    overflow: hidden;
    color: var(--text-dark);
    font-size: 0.78rem;
    font-weight: 900;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.color-key {
    margin-bottom: 0.9rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--border-color);
}

.color-key h3 {
    margin-bottom: 0.25rem;
    color: var(--text-dark);
    font-size: 1rem;
}

.color-key > p {
    margin-bottom: 0.7rem;
    font-size: 0.76rem;
}

.color-key-list {
    display: grid;
    gap: 0.45rem;
}

.color-key-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
}

.color-key-row input {
    min-width: 0;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--border-color);
    border-radius: 7px;
    background: color-mix(in srgb, var(--white) 72%, transparent);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.78rem;
}

.color-key-row button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.color-swatch {
    position: relative;
    display: inline-block;
    width: 1.2rem;
    height: 1.2rem;
    flex: 0 0 auto;
    border: 1px solid rgba(0, 0, 0, 0.22);
    border-radius: 50%;
    background: var(--swatch-color);
    -webkit-touch-callout: none;
}

.color-swatch[data-color-meaning]::after {
    position: absolute;
    bottom: calc(100% + 0.55rem);
    left: 50%;
    z-index: 20;
    width: max-content;
    max-width: min(220px, 72vw);
    padding: 0.45rem 0.6rem;
    border-radius: 7px;
    color: #fff;
    background: rgba(24, 22, 20, 0.94);
    content: attr(data-color-meaning);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.3;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 0.25rem);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.color-swatch[data-color-meaning]:hover::after,
.color-swatch[data-color-meaning]:focus-visible::after,
.color-swatch[data-color-meaning].show-meaning::after {
    opacity: 1;
    transform: translate(-50%, 0);
}

.notes-list {
    display: grid;
    gap: 0.6rem;
}

.note-card {
    position: relative;
    display: grid;
    gap: 0.38rem;
    padding: 0.78rem 0.85rem;
    padding-right: 4.2rem;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 10px;
    background: color-mix(in srgb, var(--white) 68%, transparent);
}

.note-card-color {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
}

.note-card-quote,
.note-card-thought {
    min-width: 0;
    color: var(--text-dark);
    font-size: 0.82rem;
}

.note-card-quote {
    color: var(--text-light);
    font-style: italic;
}

.note-card-quote span,
.note-card-thought span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-card-quote.expanded span,
.note-card-thought.expanded span {
    overflow: visible;
    white-space: normal;
}

.note-read-more {
    margin-top: 0.15rem;
    padding: 0 !important;
}

.public-note-card {
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary-color) 8%, transparent), color-mix(in srgb, var(--white) 68%, transparent));
}

.note-card-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.25rem;
    margin-right: -3.35rem;
}

.note-card-actions > button {
    justify-self: start;
}

.note-action-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    min-height: 1.5rem;
}

.note-delete-slot {
    justify-self: end;
    justify-content: flex-end;
}

.note-card button {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary-color);
    font: inherit;
    font-size: 0.76rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.note-card button:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.58;
}

.note-status-badge {
    position: absolute;
    top: 0.7rem;
    right: 0.75rem;
    padding: 0.16rem 0.4rem;
    border-radius: 999px;
    font-size: 0.64rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.note-status-badge.is-public {
    color: var(--white);
    background: var(--primary-color);
    box-shadow: 0 0 12px color-mix(in srgb, var(--primary-color) 35%, transparent);
}

.note-status-badge.is-private {
    color: var(--text-muted);
    background: color-mix(in srgb, var(--text-muted) 11%, transparent);
}

.note-card p {
    color: var(--text-dark);
    font-size: 0.94rem;
}

.note-composer {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 120;
    width: min(520px, calc(100vw - 2rem));
    max-height: calc(100dvh - 2rem);
    padding: 1.5rem;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: var(--light-bg);
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.35);
    transform: translate(-50%, -50%);
}

.note-composer blockquote {
    max-height: 130px;
    margin: 1rem 0;
    padding: 0.8rem 1rem;
    overflow-y: auto;
    border-left: 3px solid var(--primary-color);
    color: var(--text-light);
    background: color-mix(in srgb, var(--primary-color) 8%, transparent);
    font-size: 0.9rem;
}

.note-composer label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--text-dark);
    font-size: 0.82rem;
    font-weight: 800;
}

.note-composer label span {
    color: var(--text-muted);
    font-weight: 600;
}

.public-note-toggle {
    display: flex !important;
    align-items: center;
    gap: 0.55rem;
    margin: 0.85rem 0 0.35rem;
    cursor: pointer;
}

.public-note-toggle input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary-color);
}

.public-note-note {
    margin: 0 0 0.65rem;
    font-size: 0.8rem;
}

.highlight-color-fieldset {
    min-width: 0;
    margin: 0 0 0.85rem;
    padding: 0;
    border: 0;
}

.highlight-color-fieldset legend {
    margin-bottom: 0.55rem;
    color: var(--text-dark);
    font-size: 0.82rem;
    font-weight: 800;
}

.highlight-color-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.highlight-color-option {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
}

.highlight-color-option input {
    position: absolute;
    opacity: 0;
}

.highlight-color-option .color-swatch {
    width: 1.55rem;
    height: 1.55rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.highlight-color-option input:checked + .color-swatch {
    box-shadow: 0 0 0 3px var(--light-bg), 0 0 0 5px var(--primary-color);
    transform: scale(1.06);
}

.highlight-color-option input:focus-visible + .color-swatch {
    outline: 2px solid var(--primary-color);
    outline-offset: 4px;
}

.note-composer textarea,
.note-composer > input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: color-mix(in srgb, var(--white) 72%, transparent);
    color: var(--text-dark);
    font: inherit;
}

.note-composer textarea {
    resize: vertical;
}

.note-composer > input {
    margin-bottom: 0.85rem;
}

.note-composer textarea:focus,
.note-composer > input:focus {
    outline: 2px solid color-mix(in srgb, var(--primary-color) 45%, transparent);
    border-color: var(--primary-color);
}

.note-composer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.7rem;
    margin-top: 1rem;
}

.note-composer-actions .explore-cta {
    border: 0;
    cursor: pointer;
}

@media (max-width: 900px) {
    .desktop-focus-toggle,
    .reader-page.reader-focus-mode .reader-focus-exit {
        display: none;
    }

    .reader-main {
        display: grid;
        grid-template-rows: minmax(0, 1fr);
        width: min(100% - 1.5rem, 1100px);
        height: 100dvh;
        padding: 5.75rem 0 0.75rem;
        z-index: auto;
    }

    .reader-heading {
        align-items: start;
        flex-direction: column;
        gap: 0.5rem;
    }

    .reader-shell {
        grid-template-columns: 1fr;
        height: 100%;
        min-height: 0;
        overflow: visible;
        backdrop-filter: none;
    }

    .reader-stage {
        height: 100%;
        overflow: hidden;
        border-radius: inherit;
    }

    .reader-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 110;
        width: min(340px, 88vw);
        height: 100dvh;
        background: var(--light-bg);
        box-shadow: 18px 0 60px rgba(0, 0, 0, 0.28);
        transform: translateX(-105%);
        transition: transform 0.25s ease;
    }

    .reader-library-mode .reader-sidebar {
        position: relative;
        inset: auto;
        z-index: auto;
        width: auto;
        height: auto;
        transform: none;
        box-shadow: none;
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .reader-library-mode .reader-shell,
    .reader-library-mode .reader-stage {
        overflow: visible;
    }

    .reader-library-mode .reader-library-detail {
        overflow: visible;
        overscroll-behavior: auto;
    }

    .reader-library-mode .reader-shell {
        grid-template-rows: auto minmax(0, 1fr);
    }

    .reader-library-mode .reader-book-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .reader-library-mode .reader-book-option {
        grid-template-columns: 42px minmax(0, 1fr);
    }

    .reader-library-mode .reader-book-option img {
        width: 42px;
    }

    .reader-library-card {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.2rem;
    }

    .reader-book-showcase {
        width: min(620px, 100%);
    }

    .reader-book-scene {
        min-height: 360px;
    }

    .reader-book-model {
        width: min(240px, 62%);
    }

    .reader-book-showcase {
        touch-action: none;
    }

    .reader-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: inline-grid !important;
    }

    .reader-side-turn {
        display: none;
    }

    .reader-viewport.reader-ready .reader-gesture-layer {
        position: absolute;
        inset: 0;
        z-index: 2;
        display: block;
        touch-action: none;
        -webkit-tap-highlight-color: transparent;
    }

    .reader-viewport.reader-ready .reader-gesture-layer.selection-pass-through {
        pointer-events: none;
    }

    .reader-gesture-hint:not(:empty) {
        position: absolute;
        left: 50%;
        bottom: 0.75rem;
        z-index: 3;
        display: block;
        max-width: calc(100% - 2rem);
        padding: 0.55rem 0.8rem;
        border-radius: 999px;
        color: white;
        background: rgba(25, 22, 20, 0.84);
        font-size: 0.75rem;
        font-weight: 700;
        text-align: center;
        pointer-events: none;
        transform: translateX(-50%);
    }

}

@media (max-width: 620px) {
    .reader-toolbar {
        gap: 0.35rem;
        padding: 0.55rem;
    }

    .reader-toolbar .reader-tool {
        padding-inline: 0.55rem;
    }

    .reader-toolbar .reader-icon-button {
        min-width: 34px;
        min-height: 34px;
    }

    .reader-mode-control > span {
        display: none;
    }

    .reader-mode-control select {
        width: 68px;
        padding: 0.42rem 0.25rem;
    }

    .reader-navbar .nav-container {
        grid-template-columns: auto 1fr auto;
        gap: 0.5rem;
    }

    .reader-back {
        justify-self: center;
        font-size: 0.8rem;
    }

    .reader-theme-selector .theme-select {
        width: 88px;
    }

    .reader-heading {
        padding: 1rem 0;
    }

    .reader-heading .section-kicker {
        margin-bottom: 0.25rem;
    }

    .reader-heading h1 {
        font-size: 1.45rem;
    }

    .reader-save-status {
        display: none;
    }

    .reader-shell {
        border-radius: 14px;
    }

    .reader-library-mode .reader-main {
        height: auto;
        min-height: 100dvh;
        padding-bottom: 1rem;
    }

    .reader-library-mode .reader-shell {
        min-height: calc(100dvh - 6.75rem);
        overflow: visible;
    }

    .reader-library-card {
        grid-template-columns: 1fr;
        align-content: start;
    }

    .reader-book-showcase {
        padding: 0.75rem 0.5rem;
    }

    .reader-book-scene {
        min-height: 270px;
    }

    .reader-book-model {
        width: min(168px, 62vw);
    }

    .reader-library-copy h2 {
        font-size: clamp(1.8rem, 12vw, 3rem);
    }

    .reader-viewport {
        min-height: 0;
    }

    .reader-navigation {
        display: grid;
        grid-template-columns: auto 1fr auto;
        gap: 0.5rem;
    }

    .reader-page-button {
        width: 42px;
        overflow: hidden;
        white-space: nowrap;
    }

    .reader-page-button span {
        display: inline-block;
        margin-right: 2rem;
    }

    #nextPage {
        direction: rtl;
    }

    #nextPage span {
        margin: 0 2rem 0 0;
    }

    .reader-progress-wrap {
        grid-template-columns: 1fr 34px;
    }

    #chapterLabel {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .reader-loading-mark,
    .notes-panel,
    .reader-sidebar {
        animation: none;
        transition: none;
    }
}
