:root {
    --reader-background: #f4f1ea;
    --reader-surface: #fffdf8;
    --reader-text: #25211d;
    --reader-muted: #70685f;
    --reader-border: #ded8cf;
    --reader-accent: #2167d5;
    --reader-header: #071936;
    --reader-font-size: 18px;
    --reader-content-width: 820px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--reader-background);
    color: var(--reader-text);
    font-family: Georgia, "Times New Roman", serif;
}

body.reader-dark {
    --reader-background: #11151d;
    --reader-surface: #191f2a;
    --reader-text: #e7eaf0;
    --reader-muted: #a8b0bf;
    --reader-border: #303847;
    --reader-header: #080c13;
}

body.reader-sepia {
    --reader-background: #e8ddc7;
    --reader-surface: #f5ecd9;
    --reader-text: #44382d;
    --reader-muted: #756656;
    --reader-border: #cfc0a4;
    --reader-header: #3e3024;
}

.reader-header {
    position: sticky;
    z-index: 100;
    top: 0;
    display: grid;
    grid-template-columns: auto minmax(180px, 1fr) auto;
    align-items: center;
    gap: 26px;
    min-height: 72px;
    padding: 10px 28px;
    background: var(--reader-header);
    color: #ffffff;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.18);
}

.reader-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
    font-family: Arial, sans-serif;
    font-size: 19px;
    font-weight: 900;
    text-decoration: none;
}

.reader-brand img {
    border-radius: 50%;
}

.reader-brand strong {
    color: #65a0ff;
}

.reader-book-info {
    min-width: 0;
    font-family: Arial, sans-serif;
    text-align: center;
}

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

.reader-book-info strong {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-book-info span {
    margin-top: 3px;
    color: #b8c4d8;
    font-size: 11px;
}

.reader-controls {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: Arial, sans-serif;
}

.reader-controls button,
.reader-controls a {
    display: inline-flex;
    min-width: 48px;
    height: 40px;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        transform 0.2s ease;
}

.reader-controls button:hover,
.reader-controls a:hover {
    border-color: rgba(101, 160, 255, 0.65);
    background: rgba(101, 160, 255, 0.15);
}

.reader-controls button:active,
.reader-controls a:active {
    transform: translateY(1px);
}

.reader-controls a {
    min-width: 54px;
}

.reader-access-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 13px max(24px, calc((100% - 1100px) / 2));
    background: #fff0e4;
    color: #7c3d10;
    font-family: Arial, sans-serif;
}

.reader-access-banner strong,
.reader-access-banner span {
    display: block;
}

.reader-access-banner span {
    margin-top: 3px;
    font-size: 13px;
}

.reader-access-banner a {
    padding: 9px 14px;
    border-radius: 9px;
    background: #ff7a1a;
    color: #ffffff;
    font-size: 13px;
    font-weight: 900;
    text-decoration: none;
}

.reader-access-active {
    background: #e8f8f0;
    color: #0e7345;
}

.reader-main {
    width: min(
        calc(100% - 34px),
        var(--reader-content-width)
    );
    margin: 0 auto;
    padding: 65px 0 90px;
}

.reader-title {
    margin-bottom: 45px;
    text-align: center;
}

.reader-title > span {
    color: var(--reader-accent);
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.reader-title h1 {
    margin: 15px 0 10px;
    font-size: clamp(40px, 7vw, 72px);
    line-height: 1;
    letter-spacing: -0.04em;
}

.reader-title p {
    margin: 0;
    color: var(--reader-muted);
    font-size: 16px;
}

.reader-progress {
    position: fixed;
    z-index: 110;
    top: 72px;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
}

.reader-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: #ff7a1a;
}

.reader-chapters {
    display: grid;
    gap: 25px;
}

.reader-chapter {
    padding: clamp(25px, 5vw, 54px);
    border: 1px solid var(--reader-border);
    border-radius: 18px;
    background: var(--reader-surface);
    box-shadow: 0 12px 35px rgba(30, 25, 20, 0.07);
    scroll-margin-top: 95px;
}

.reader-chapter header {
    margin-bottom: 30px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--reader-border);
}

.reader-chapter header span {
    color: var(--reader-accent);
    font-family: Arial, sans-serif;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.reader-chapter h2 {
    margin: 9px 0 0;
    font-size: clamp(27px, 4vw, 39px);
    line-height: 1.12;
}

.reader-text {
    color: var(--reader-text);
    font-size: var(--reader-font-size);
    line-height: 1.9;
    overflow-wrap: anywhere;
}

.reader-text p {
    margin: 0 0 1.3em;
}

.reader-text h1,
.reader-text h2,
.reader-text h3 {
    line-height: 1.25;
}

.reader-text blockquote {
    margin: 24px 0;
    padding: 15px 20px;
    border-left: 4px solid #ff7a1a;
    background: rgba(255, 122, 26, 0.08);
}

.reader-limit-panel {
    margin-top: 35px;
    padding: 45px;
    border-radius: 20px;
    background: var(--reader-header);
    color: #ffffff;
    text-align: center;
}

.reader-limit-panel > span {
    font-size: 35px;
}

.reader-limit-panel h2 {
    margin: 14px 0 10px;
    font-size: 32px;
}

.reader-limit-panel p {
    margin: 0 0 22px;
    color: #bdc7d8;
}

.reader-primary-button {
    display: inline-flex;
    min-height: 48px;
    align-items: center;
    padding: 0 20px;
    border-radius: 11px;
    background: #2167d5;
    color: #ffffff;
    font-family: Arial, sans-serif;
    font-weight: 900;
    text-decoration: none;
}

.reader-overlay {
    position: fixed;
    z-index: 190;
    inset: 0;
    display: none;
    background: rgba(0, 0, 0, 0.48);
}

.reader-overlay.open {
    display: block;
}

.reader-index {
    position: fixed;
    z-index: 200;
    top: 0;
    right: -440px;
    display: flex;
    width: min(410px, calc(100vw - 32px));
    height: 100vh;
    flex-direction: column;
    border-left: 1px solid #303847;
    background: #111722;
    color: #ffffff;
    transition: right 0.22s ease;
}

.reader-index.open {
    right: 0;
}

.reader-index > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 20px;
    border-bottom: 1px solid #303847;
    font-family: Arial, sans-serif;
}

.reader-index header strong,
.reader-index header span {
    display: block;
}

.reader-index header span {
    margin-top: 4px;
    color: #aab5c7;
    font-size: 12px;
}

.reader-index header button {
    width: 38px;
    height: 38px;
    border: 1px solid #384254;
    border-radius: 10px;
    background: #1b2432;
    color: #ffffff;
    font-size: 22px;
    cursor: pointer;
}

.reader-index nav {
    display: grid;
    gap: 5px;
    padding: 12px;
    overflow-y: auto;
}

.reader-index nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px;
    border-radius: 10px;
    color: #d7deea;
    font-family: Arial, sans-serif;
    font-size: 13px;
    text-decoration: none;
}

.reader-index nav a:hover {
    background: #1b2636;
    color: #ffffff;
}

.reader-index nav a span {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border-radius: 9px;
    background: #203a65;
    color: #9dc0ff;
    font-weight: 900;
}

.reader-empty {
    padding: 30px;
    border: 1px dashed var(--reader-border);
    border-radius: 15px;
    color: var(--reader-muted);
    text-align: center;
}

@media (max-width: 800px) {
    .reader-header {
        grid-template-columns: 1fr auto;
        padding: 9px 14px;
    }

    .reader-book-info {
        display: none;
    }

    .reader-controls button[data-font-decrease],
    .reader-controls button[data-font-increase] {
        display: none;
    }

    .reader-controls a {
        display: none;
    }

    .reader-access-banner {
        align-items: flex-start;
        padding: 12px 16px;
    }
}

@media (max-width: 520px) {
    .reader-brand > span {
        display: none;
    }

    .reader-controls {
        gap: 4px;
    }

    .reader-controls button {
        padding: 0 8px;
    }

    .reader-main {
        width: min(calc(100% - 20px), 820px);
        padding-top: 40px;
    }

    .reader-chapter {
        padding: 25px 19px;
        border-radius: 14px;
    }

    .reader-text {
        line-height: 1.8;
    }

    .reader-limit-panel {
        padding: 32px 20px;
    }
}

@media print {
    body {
        display: none !important;
    }
}

/* Interações do leitor */
.reader-title-actions {
    display: flex;
    justify-content: center;
    margin-top: 22px;
}

.reader-title-actions form,
.reader-chapter-actions form {
    margin: 0;
}

.reader-interaction-button,
.reader-chapter-button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 14px;
    border: 1px solid rgba(7, 25, 54, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    color: #123565;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.reader-interaction-button:hover,
.reader-chapter-button:hover {
    border-color: #2167d5;
    color: #2167d5;
    transform: translateY(-1px);
}

.reader-interaction-button.liked,
.reader-chapter-button.liked {
    border-color: rgba(255, 122, 26, 0.35);
    background: #fff0e4;
    color: #ff6b00;
}

.reader-interaction-button small,
.reader-chapter-button small {
    display: inline-grid;
    min-width: 20px;
    height: 20px;
    place-items: center;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(33, 103, 213, 0.1);
    color: inherit;
    font-size: 10px;
}

.reader-chapter-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

.reader-chapter-button {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 12px;
}

.reader-interaction-button[disabled],
.reader-chapter-button[disabled] {
    cursor: wait;
    opacity: 0.65;
}

.reader-dark .reader-interaction-button,
.reader-dark .reader-chapter-button {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.07);
    color: #e7edf8;
}

.reader-dark .reader-interaction-button.liked,
.reader-dark .reader-chapter-button.liked {
    border-color: rgba(255, 122, 26, 0.45);
    background: rgba(255, 122, 26, 0.14);
    color: #ff9b5a;
}

.reader-sepia .reader-interaction-button,
.reader-sepia .reader-chapter-button {
    border-color: rgba(95, 69, 43, 0.22);
    background: rgba(255, 252, 242, 0.85);
    color: #66492f;
}

@media (max-width: 600px) {
    .reader-chapter-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .reader-chapter-actions form,
    .reader-chapter-button {
        width: 100%;
    }
}
