* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection in content areas */
.content-text,
.content-text *,
.title-page,
.title-page *,
input,
textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background: #faf9f7;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    color: #2c2c2c;
    margin: 0;
    padding: 20px;
    padding-top: 60px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.ebook-wrapper {
    max-width: 900px;
    margin: 0 auto;
    background: #fefefe;
    border: 1px solid #d0ccc7;
    overflow: hidden;
    height: 85vh;
    display: flex;
    flex-direction: column;
}

.ebook-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Mobile responsive design */
@media (max-width: 768px) {
    body {
        padding: 8px;
        padding-top: 8px;
    }

    .ebook-wrapper {
        max-width: 100%;
        border: none;
        height: auto;
        min-height: 100vh;
        border-radius: 0;
    }

    .ebook-container {
        flex-direction: column;
        position: relative;
        overflow: visible;
    }


    .ebook-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 300px;
        height: 100vh;
        background: #fefefe;
        border-right: 1px solid #d0ccc7;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
        overflow-y: auto;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }

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

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.28s ease;
    }

    .sidebar-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    .sidebar-header {
        padding: 16px;
        font-size: 0.95rem;
        font-weight: 600;
        border-bottom: 1px solid #d0ccc7;
        background: #fafafa;
    }

    .chapter-item {
        padding: 14px 16px;
        font-size: 0.9rem;
        border-bottom: 1px solid #e8e8e8;
        min-height: 48px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .chapter-item:active {
        background: #f0f0f0;
        transform: scale(0.98);
        transition: all 0.1s ease;
    }

    .chapter-item {
        transition: all 0.15s ease;
    }

    .chapter-title {
        font-size: 0.95rem;
        font-weight: 500;
        line-height: 1.3;
        margin-bottom: 2px;
    }

    .chapter-subtitle {
        font-size: 0.8rem;
        line-height: 1.2;
        color: #666;
    }

    .content-header {
        padding: 16px;
        position: relative;
        border-bottom: 1px solid #d0ccc7;
        background: #fefefe;
    }

    /* Hide content header border on mobile title page */
    .content-header.title-page-mobile {
        border-bottom: none;
        background: transparent;
        padding: 12px 16px;
    }

    .hamburger-btn {
        position: fixed;
        top: 20px;
        left: 20px;
        display: inline-flex;
        padding: 14px 21px;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        z-index: 1002;
        border: none;
        border-radius: 100px;
        background: var(--toggle-bg) !important;
        border: 1px solid var(--toggle-border) !important;
        box-shadow: var(--toggle-shadow) !important;
        backdrop-filter: blur(4px);
        font-size: 0.85rem;
        font-weight: 500;
        color: var(--toggle-text) !important;
        text-shadow: 0 0 1px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease, opacity 0.3s ease;
        line-height: 1;
        min-height: 48px;
    }

    .hamburger-btn.sidebar-open {
        opacity: 0;
        pointer-events: none;
    }

    /* Hide hamburger button on desktop */
    @media (min-width: 769px) {
        .hamburger-btn,
        .content-header .hamburger-btn,
        #hamburgerBtn {
            display: none !important;
            visibility: hidden !important;
            opacity: 0 !important;
            pointer-events: none !important;
        }
    }

    .hamburger-btn:hover {
        transform: translateY(-1px);
        background: var(--toggle-hover-bg) !important;
        border: 1px solid var(--toggle-hover-border) !important;
        box-shadow: var(--toggle-hover-shadow) !important;
        backdrop-filter: blur(5px);
    }

    .hamburger-btn:active {
        transform: translateY(0px);
        background: var(--toggle-active-bg) !important;
        border: 1px solid var(--toggle-active-border) !important;
        box-shadow: var(--toggle-active-shadow) !important;
        backdrop-filter: blur(3px);
    }

    .hamburger-line {
        width: 14px;
        height: 1.5px;
        background: rgba(0, 0, 0, 0.8);
        margin: 2px 0;
        transition: all 0.2s ease;
        border-radius: 1px;
        box-shadow: 0 0 1px rgba(0, 0, 0, 0.2);
    }

    .hamburger-lines {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .hamburger-text {
        color: var(--toggle-text) !important;
        font-size: 0.85rem !important;
        font-weight: 500;
        letter-spacing: 0.5px;
        text-shadow: 0 0 1px rgba(0, 0, 0, 0.1);
        margin: 0;
    }

    .content-title {
        font-size: 1.4rem;
        line-height: 1.3;
        margin-bottom: 4px;
    }

    .content-meta {
        font-size: 0.85rem;
        color: #666;
    }

    .dark-mode-toggle {
        top: 16px;
        right: 16px;
        padding: 14px 21px;
        font-size: 0.8rem;
        min-height: 48px;
    }

    .content-body {
        padding: 16px;
        overflow-y: visible;
        flex: 1;
    }

    .nav-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 4px;
        padding-top: 4px;
    }

    .ebook-wrapper {
        height: auto;
        min-height: 100vh;
        border-radius: 0;
    }

    .ebook-sidebar {
        height: 100vh;
        width: 280px;
        left: -280px;
    }

    .sidebar-overlay {
        height: 100vh;
    }

    .sidebar-header {
        padding: 14px;
        font-size: 0.9rem;
    }

    .chapter-item {
        padding: 12px 14px;
        min-height: 44px;
    }

    .chapter-title {
        font-size: 0.9rem;
    }

    .chapter-subtitle {
        font-size: 0.75rem;
    }

    .content-header {
        padding: 12px;
    }

    .hamburger-btn {
        top: 20px;
        left: 16px;
        padding: 14px 21px;
        font-size: 0.8rem;
        min-height: 48px;
    }

    .hamburger-line {
        width: 12px;
        height: 1.5px;
    }

    .hamburger-text {
        font-size: 0.8rem !important;
        font-weight: 500 !important;
    }

    .content-title {
        font-size: 1.2rem;
        margin-left: 0;
    }

    .content-meta {
        font-size: 0.8rem;
        margin-left: 0;
    }

    .dark-mode-toggle {
        top: 24px;
        right: 16px;
        padding: 14px 21px;
        font-size: 0.8rem !important;
        min-height: 48px;
    }

    .content-body {
        padding: 12px;
        overflow-y: visible;
    }

    .content-text {
        max-width: 100%;
        font-size: 0.9rem;
    }
}


/* Sidebar with chapters */
.ebook-sidebar {
    width: 240px;
    background: #fefefe;
    border-right: 1px solid #d0ccc7;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    height: 60px;
    padding: 16px;
    border-bottom: 1px solid #d0ccc7;
    font-weight: 500;
    display: flex;
    align-items: center;
    color: #2c2c2c;
}

.chapters-list {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

/* Sticky title page and selected item */
.title-page-item {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--sidebar-bg);
    border-bottom: 2px solid var(--sidebar-border) !important;
}

.chapter-item.selected-sticky {
    position: sticky;
    top: 0;
    z-index: 9;
    background: var(--sidebar-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Adjust sticky positioning when title is present */
.has-title-sticky .chapter-item.selected-sticky {
    top: var(--title-height, 70px); /* Dynamic height based on title */
}

.chapter-item {
    padding: 10px 16px;
    border-bottom: 1px solid #d0ccc7;
    cursor: pointer;
    transition: all 0.2s;
    color: #2c2c2c;
}

.chapter-item:hover {
    background: #f5f4f2;
}

.chapter-item.active {
    background: #f5f4f2;
    border-left: 3px solid #2c2c2c;
    padding-left: 13px;
}

/* Grey out inactive chapters when one is selected */
.chapters-list.has-active .chapter-item:not(.active):not(.title-page-item) {
    opacity: 0.75;
}

.chapters-list.has-active .chapter-item:not(.active):not(.title-page-item) .chapter-title {
    color: #999;
}

.chapters-list.has-active .chapter-item:not(.active):not(.title-page-item) .chapter-subtitle {
    color: #bbb;
}

/* Lighter grey-out when title page is active */
.chapters-list.has-active.title-active .chapter-item:not(.active):not(.title-page-item) {
    opacity: 0.75;
}

.chapters-list.has-active.title-active .chapter-item:not(.active):not(.title-page-item) .chapter-title {
    color: #666;
}

.chapters-list.has-active.title-active .chapter-item:not(.active):not(.title-page-item) .chapter-subtitle {
    color: #888;
}

/* Restore color on hover */
.chapters-list.has-active .chapter-item:not(.active):not(.title-page-item):hover {
    opacity: 1;
}

.chapters-list.has-active .chapter-item:not(.active):not(.title-page-item):hover .chapter-title {
    color: var(--text-primary);
}

.chapters-list.has-active .chapter-item:not(.active):not(.title-page-item):hover .chapter-subtitle {
    color: #666;
}

.chapter-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: #2c2c2c;
}

.chapter-subtitle {
    font-size: 0.8rem;
    color: #666;
    margin-top: 2px;
}

.title-page-item {
    border-bottom: 1px solid #d0ccc7;
    padding-bottom: 12px;
    margin-bottom: 0;
}

.title-page-item .chapter-title {
    font-weight: 600;
    font-size: 1rem;
}

.title-page-item .chapter-subtitle {
    font-style: italic;
    font-size: 0.85rem;
}

/* Section headers and dividers */
.section-header {
    padding: 12px 16px;
    background: #f8f8f8;
    border-bottom: 1px solid #e8e8e8;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    letter-spacing: 0.3px;
    margin: 0;
    text-align: left;
}

/* Dark mode section styles */
.dark-mode .section-header {
    background: #1a1a1a;
    border-bottom-color: #333;
}

.dark-mode .section-title {
    color: #888;
}

/* Main content area */
.ebook-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fefefe;
}

.content-header {
    padding: 16px;
    border-bottom: 1px solid #d0ccc7;
    position: fixed;
    top: -100px;
    left: 240px;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-primary);
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
    margin: 0;
}

.content-header.sticky-visible {
    top: 0 !important;
    opacity: 1;
    pointer-events: all;
}

.content-header-left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content-header-left-items {
    display: flex;
    align-items: center;
}

.share-link-btn {
    width: 32px;
    height: 32px;
    border: none;
    cursor: pointer;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    position: relative;
}

.share-link-btn {
    background: var(--share-btn-bg) !important;
}

.share-link-btn:hover {
    background: var(--share-btn-hover-bg) !important;
    transform: scale(1.05);
}

.share-link-btn svg {
    width: 18px;
    height: 18px;
    color: var(--share-icon-color);
    transition: color 0.15s ease;
}

.share-link-btn:hover svg {
    color: var(--share-icon-hover-color);
}

.share-tooltip {
    position: absolute;
    top: 50%;
    right: 40px;
    transform: translateY(-50%);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 6px 10px;
    border: none;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    font-weight: 500;
}

.share-tooltip::before {
    content: '';
    position: absolute;
    top: 50%;
    right: -4px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 4px solid var(--text-primary);
}

.share-tooltip.show {
    opacity: 1;
    visibility: visible;
}

.share-tooltip.copied {
    background: var(--text-primary);
}

.share-tooltip.copied::before {
    border-bottom-color: var(--text-primary);
}

/* Dark mode tooltip styles */
.dark-mode .share-tooltip {
    background: white;
    color: black;
}

.dark-mode .share-tooltip::before {
    border-left-color: white;
}

.dark-mode .share-tooltip.copied {
    background: white;
}

.dark-mode .share-tooltip.copied::before {
    border-left-color: white;
}

.content-header-titles {
    margin-left: 0;
}

.content-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c2c2c;
}

.content-meta {
    margin: 2px 0 0 0;
    font-size: 0.85rem;
    color: #666;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .content-header-titles {
        margin-left: 12px;
    }
    
    .content-title {
        font-size: 1rem;
    }
    
    .content-meta {
        font-size: 0.8rem;
    }
    
    .share-link-btn {
        width: 28px;
        height: 28px;
    }
    
    .share-link-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    display: inline-flex;
    padding: 14px 21px;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    z-index: 1000;
    border: none;
    border-radius: 100px;
    background: var(--toggle-bg) !important;
    border: 1px solid var(--toggle-border) !important;
    box-shadow: var(--toggle-shadow) !important;
    backdrop-filter: blur(4px);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--toggle-text) !important;
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    line-height: 1;
    min-height: 48px;
}

/* Explicit light mode styles to ensure proper reset */
body:not(.dark-mode) .dark-mode-toggle {
    color: rgba(0, 0, 0, 0.8) !important;
}

body:not(.dark-mode) .hamburger-btn {
    color: rgba(0, 0, 0, 0.8) !important;
}

.dark-mode-toggle:hover {
    transform: translateY(-1px);
    background: var(--toggle-hover-bg) !important;
    border: 1px solid var(--toggle-hover-border) !important;
    box-shadow: var(--toggle-hover-shadow) !important;
    backdrop-filter: blur(5px);
}

.dark-mode-toggle:active {
    transform: translateY(0px);
    background: var(--toggle-active-bg) !important;
    border: 1px solid var(--toggle-active-border) !important;
    box-shadow: var(--toggle-active-shadow) !important;
    backdrop-filter: blur(3px);
}

/* Body and main layout styles using theme variables */
body {
    background-color: var(--bg-primary) !important;
    color: var(--text-secondary) !important;
}

/* Main layout styles using theme variables */
.ebook-wrapper {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-primary) !important;
}

.ebook-sidebar {
    background: var(--sidebar-bg) !important;
    border-right: 1px solid var(--sidebar-border) !important;
}

.sidebar-header {
    border-bottom: 1px solid var(--sidebar-border) !important;
    color: var(--text-primary) !important;
}

.chapter-item {
    border-bottom: 1px solid var(--sidebar-border) !important;
    color: var(--text-secondary) !important;
}

.chapter-item:hover {
    background: var(--sidebar-item-hover) !important;
}

.chapter-item.active {
    background: var(--sidebar-item-active) !important;
    border-left: 3px solid var(--sidebar-active-accent) !important;
}

.chapter-title {
    color: var(--text-primary) !important;
}

.chapter-subtitle {
    color: var(--text-tertiary) !important;
}

.chapters-list.has-active .chapter-item:not(.active):not(.title-page-item) .chapter-title {
    color: var(--text-quaternary) !important;
}

.chapters-list.has-active .chapter-item:not(.active):not(.title-page-item) .chapter-subtitle {
    color: var(--text-muted) !important;
}

.chapters-list.has-active.title-active .chapter-item:not(.active):not(.title-page-item) .chapter-title {
    color: var(--text-tertiary) !important;
}

.chapters-list.has-active.title-active .chapter-item:not(.active):not(.title-page-item) .chapter-subtitle {
    color: var(--text-quaternary) !important;
}

.chapters-list.has-active .chapter-item:not(.active):not(.title-page-item):hover .chapter-title {
    color: var(--text-primary) !important;
}

.chapters-list.has-active .chapter-item:not(.active):not(.title-page-item):hover .chapter-subtitle {
    color: var(--text-tertiary) !important;
}

.ebook-content {
    background: var(--bg-primary) !important;
}

.content-header {
    border-bottom: 1px solid var(--border-primary) !important;
}

.content-title {
    color: var(--text-primary) !important;
}

.content-meta {
    color: var(--text-tertiary) !important;
}

.author-personal-note {
    color: var(--text-tertiary) !important;
}

/* Animated Highlighter Effect */
.highlight-animated {
    position: relative;
    display: inline-block;
    z-index: 1;
    background-image: linear-gradient(to right, rgba(255, 235, 59, 0.3) 0%, rgba(255, 235, 59, 0.3) 100%);
    background-position: 0 0;
    background-repeat: no-repeat;
    background-size: 0% 100%;
    transition: background-size 1.2s cubic-bezier(0.8, 0, 0.2, 1);
    transition-delay: 0.2s;
    will-change: background-size;
}

.highlight-animated.is-active {
    background-size: 100% 100%;
}

/* Dark mode highlighter */
.dark-mode .highlight-animated {
    background-image: linear-gradient(to right, rgba(255, 235, 100, 0.2) 0%, rgba(255, 235, 100, 0.2) 100%) !important;
}

/* Utility class to trigger animation on scroll */
.highlight-on-scroll {
    opacity: 1;
}

.highlight-on-scroll .highlight-animated {
    transition-delay: 0s;
}

.highlight-on-scroll.animate .highlight-animated {
    transition-delay: 0.2s;
}

.hamburger-line {
    background: var(--text-tertiary) !important;
}

.dark-mode .dark-mode-toggle {
    background: var(--toggle-bg) !important;
    border: 1px solid var(--toggle-border) !important;
    box-shadow: var(--toggle-shadow) !important;
    backdrop-filter: blur(4px);
    color: var(--toggle-text) !important;
    text-shadow: 0 0 1px rgba(167, 139, 250, 0.1) !important;
}

.dark-mode .dark-mode-toggle:hover {
    transform: translateY(-1px);
    background: var(--toggle-hover-bg) !important;
    border: 1px solid var(--toggle-hover-border) !important;
    box-shadow: var(--toggle-hover-shadow) !important;
    backdrop-filter: blur(5px);
}

.dark-mode .dark-mode-toggle:active {
    transform: translateY(0px);
    background: var(--toggle-active-bg) !important;
    border: 1px solid var(--toggle-active-border) !important;
    box-shadow: var(--toggle-active-shadow) !important;
    backdrop-filter: blur(3px);
}

.preorder-modal {
    position: relative;
    background: #ffffff; /* Light mode background */
    color: #2c2c2c;
    max-width: 500px;
    width: 100%;
    padding: 25px;
    border-radius: 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.dark-mode .preorder-modal {
    background: #1a1a1a !important; /* Dark mode background */
    color: #ffffff !important;
    border: 1px solid #404040;
}

.dark-mode .email-input {
    background: #1a1a1a !important;
    color: #ffffff !important;
    border: 1px solid #525252 !important;
}

.dark-mode .email-input::placeholder {
    color: #b0b0b0 !important;
}

.dark-mode .email-submit-btn {
    background: #10b981 !important;
    color: #ffffff !important;
    border: 1px solid #10b981 !important;
}

.dark-mode .email-submit-btn:hover {
    background: #059669 !important;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 600;
}

.form-label {
    color: var(--text-primary) !important;
}

.form-input {
    background: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    color: var(--input-text) !important;
}

.email-input {
    background: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    color: var(--input-text) !important;
}

.email-input:focus {
    border-color: var(--input-focus-border) !important;
    box-shadow: 0 0 0 1px var(--input-focus-border) !important;
}

.preorder-btn {
    background: var(--button-bg) !important;
    color: var(--button-text) !important;
}

.preorder-btn:hover {
    background: var(--button-hover-bg) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 30px;
    height: 30px;
    background: var(--modal-close-bg);
    border: 1px solid var(--border-primary);
    font-size: 24px;
    cursor: pointer;
    color: var(--modal-close-color);
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background: var(--modal-close-hover-bg);
}

.modal-footer {
    padding: 20px;
    color: var(--text-quaternary) !important;
}

.signup-title {
    color: var(--text-primary) !important;
}

.signup-description {
    color: var(--text-tertiary) !important;
}

.email-input::placeholder {
    color: var(--input-placeholder) !important;
}

.notify-btn {
    background: var(--button-bg) !important;
    color: var(--button-text) !important;
    border: 1px solid var(--button-bg) !important;
}

.notify-btn:hover {
    background: var(--button-hover-bg) !important;
    color: var(--button-hover-text) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.keyboard-shortcut {
    display: inline-block;
    margin-left: 12px;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.dark-mode .keyboard-shortcut {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: rgba(255, 255, 255, 0.7) !important;
}

.modal-message {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-primary) !important;
    color: var(--text-secondary) !important;
}

.modal-message.success {
    background: var(--success-bg) !important;
    border: 1px solid var(--success-border) !important;
    color: var(--success-text) !important;
}

.modal-message.error {
    background: var(--error-bg) !important;
    border: 1px solid var(--error-border) !important;
    color: var(--error-text) !important;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .ebook-sidebar {
        box-shadow: var(--mobile-sidebar-shadow);
    }

    .chapter-item:active {
        background: var(--sidebar-item-hover) !important;
    }

    /* Mobile sticky adjustments */
    .title-page-item {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .chapter-item.selected-sticky {
        position: sticky;
        top: 0;
        z-index: 9;
    }

    .has-title-sticky .chapter-item.selected-sticky {
        top: var(--title-height, 70px);
    }

    /* Mobile sticky header */
    @media (max-width: 768px) {
        .content-header {
            position: fixed;
            top: -100px;
            left: 0;
            right: 0;
            z-index: 100;
            transition: all 0.3s ease;
            opacity: 0;
            pointer-events: none;
            margin: 0;
        }

        .content-header.sticky-visible {
            top: 0 !important;
            opacity: 1;
            pointer-events: all;
        }
    }

    .content-header {
        background: var(--bg-primary) !important;
        border-bottom: 1px solid var(--border-primary) !important;
    }

    .content-header.title-page-mobile {
        background: transparent !important;
        border-bottom: none !important;
    }

    .dark-mode .hamburger-btn {
        background: var(--toggle-bg) !important;
        border: 1px solid var(--toggle-border) !important;
        box-shadow: var(--toggle-shadow) !important;
        backdrop-filter: blur(4px);
        color: var(--toggle-text) !important;
    }

    .dark-mode .hamburger-btn:hover {
        transform: translateY(-1px);
        background: var(--toggle-hover-bg) !important;
        border: 1px solid var(--toggle-hover-border) !important;
        box-shadow: var(--toggle-hover-shadow) !important;
        backdrop-filter: blur(5px);
    }

    .dark-mode .hamburger-btn:active {
        transform: translateY(0px);
        background: var(--toggle-active-bg) !important;
        border: 1px solid var(--toggle-active-border) !important;
        box-shadow: var(--toggle-active-shadow) !important;
        backdrop-filter: blur(3px);
    }

    .dark-mode .hamburger-line {
        background: rgba(232, 220, 198, 0.8) !important;
        box-shadow: 0 0 1px rgba(232, 220, 198, 0.2) !important;
    }

    .dark-mode .hamburger-text {
        color: var(--toggle-text) !important;
        text-shadow: 0 0 1px rgba(167, 139, 250, 0.1) !important;
    }

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

@media (max-width: 480px) {
    .comparison-item {
        background: var(--bg-secondary) !important;
        color: var(--text-tertiary) !important;
    }
}

.content-title {
    font-size: 1.8rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: #2c2c2c;
}

.content-meta {
    font-size: 0.9rem;
    color: #666;
}

.content-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    line-height: 1.6;
}

.content-text {
    width: 100%;
    margin: 0;
    text-align: left;
    transition: opacity 0.15s ease;
}


.content-text ul,
.content-text ol {
    padding-left: 20px;
    margin-bottom: 16px;
}

.content-text li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.content-text ol {
    counter-reset: item;
}

.content-text ol > li {
    display: block;
    margin-bottom: 8px;
    position: relative;
}

.content-text ol > li:before {
    content: counter(item) ".";
    counter-increment: item;
    font-weight: bold;
    position: absolute;
    left: -20px;
}


/* Pre-order Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.preorder-modal {
    background: var(--bg-primary);
    border: 2px solid var(--text-primary);
    padding: 30px;
    max-width: 500px;
    width: 90%;
    position: relative;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.2s ease;
}

.modal-overlay.show .preorder-modal {
    transform: scale(1);
    opacity: 1;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 22px;
    color: var(--modal-close-color);
}

.signup-section {
    margin-bottom: 25px;
    text-align: center;
}

.signup-title {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #2c2c2c; /* Light mode color */
}

.dark-mode .signup-title {
    color: #ffffff !important; /* Dark mode color with higher specificity */
}

.signup-description {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 20px;
    color: #444444; /* Light mode color */
}

.dark-mode .signup-description {
    color: #cccccc !important; /* Dark mode color with higher specificity */
}

.signup-description small {
    color: #666666; /* Light mode color */
    opacity: 0.8;
    font-style: italic;
    font-size: 0.9rem;
}

.dark-mode .signup-description small {
    color: #888888 !important; /* Dark mode color with higher specificity */
}

.email-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.email-input {
    padding: 12px;
    font-size: 1rem;
    border: 1px solid var(--border-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s ease;
}

.email-input:focus {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 1px var(--text-primary);
}

.email-input::placeholder {
    color: #666;
}

.notify-btn {
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: 1px solid var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.notify-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.notify-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.modal-message {
    margin-top: 1rem;
    padding: 12px;
    border: 1px solid var(--border-primary);
    display: none;
    text-align: center;
}

.modal-message.success {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-message.error {
    background: var(--bg-primary);
    color: var(--text-primary);
}


.modal-footer {
    text-align: center;
    font-size: 0.85rem;
    color: #666;
}


.ebook-wrapper {
    transition: filter 0.25s ease;
}

.ebook-wrapper.blurred {
    filter: blur(3px);
    pointer-events: none;
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 16px;
        align-items: flex-start;
        padding-top: 40px;
    }

    .preorder-modal {
        padding: 24px;
        margin: 0;
        width: 100%;
        max-width: none;
        border: 1px solid var(--text-primary);
        border-radius: 0;
        max-height: 85vh;
        overflow-y: auto;
    }

    .modal-close {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        font-size: 20px;
    }

    .modal-title {
        font-size: 1.6rem;
        margin-bottom: 20px;
        line-height: 1.2;
    }

    .pricing-section {
        gap: 12px;
        margin-bottom: 20px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .original-price {
        font-size: 1.4rem;
    }

    .discounted-price {
        font-size: 2rem;
    }

    .discount-badge {
        font-size: 0.75rem;
        padding: 4px 8px;
        border-radius: 2px;
    }

    .value-claim {
        padding: 16px;
        margin: 16px 0;
        border: 1px solid #0066cc;
    }

    .claim-text {
        font-size: 1.2rem;
        line-height: 1.3;
        margin-bottom: 8px;
    }

    .claim-subtext {
        font-size: 0.85rem;
    }

    .price-comparison {
        flex-direction: column;
        gap: 10px;
        padding: 0;
        margin-top: 16px;
    }

    .comparison-item {
        font-size: 0.95rem;
        text-align: center;
        flex: none;
        padding: 8px;
        background: #f8f8f8;
        border-radius: 4px;
        line-height: 1.3;
    }

    .preorder-form {
        margin-bottom: 20px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-label {
        font-size: 0.95rem;
        margin-bottom: 6px;
    }

    .form-input {
        padding: 12px;
        font-size: 1rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        min-height: 48px;
    }

    .preorder-btn {
        padding: 14px;
        font-size: 1.1rem;
        border-radius: 4px;
        min-height: 52px;
        margin-bottom: 16px;
    }

    .modal-footer {
        font-size: 0.9rem;
        line-height: 1.4;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 12px;
        padding-top: 30px;
    }

    .preorder-modal {
        padding: 20px;
        max-height: 90vh;
    }

    .modal-title {
        font-size: 1.4rem;
        margin-bottom: 16px;
    }

    .pricing-section {
        gap: 8px;
        margin-bottom: 16px;
    }

    .original-price {
        font-size: 1.2rem;
    }

    .discounted-price {
        font-size: 1.8rem;
    }

    .discount-badge {
        font-size: 0.7rem;
        padding: 3px 6px;
    }

    .value-claim {
        padding: 14px;
        margin: 14px 0;
    }

    .claim-text {
        font-size: 1.1rem;
    }

    .claim-subtext {
        font-size: 0.8rem;
    }

    .comparison-item {
        font-size: 0.85rem;
        padding: 6px;
    }

    .form-input {
        padding: 10px;
        min-height: 44px;
    }

    .preorder-btn {
        padding: 12px;
        font-size: 1rem;
        min-height: 48px;
    }
}

/* Title Page Styling */
.title-page {
    text-align: center;
    padding: 60px 20px;
    max-width: 600px;
    margin: 0 auto;
}

.title-section {
    margin-bottom: 60px;
}

.main-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.subtitle {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.tagline {
    font-size: 1rem;
    color: var(--text-tertiary);
    font-style: italic;
    margin-bottom: 0;
}

.author-section {
    padding: 30px 0;
    border-top: 1px solid var(--border-secondary);
}

.author-byline {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.author-expertise {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.4;
    margin-bottom: 6px;
}

.author-personal-note {
    font-size: 0.95rem;
    color: #555;
    font-weight: 400;
    line-height: 1.5;
    margin-top: 16px;
    margin-bottom: 8px;
    font-style: italic;
}

.author-note {
    font-size: 0.9rem;
    color: #888;
    font-weight: 400;
}

.value-prop {
    margin-bottom: 50px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.value-prop h3 {
    font-size: 1.6rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 600;
}

.value-prop p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 30px;
    color: #333;
}


/* Mobile title page adjustments */
@media (max-width: 768px) {
    .title-page {
        padding: 20px 16px;
        padding-top: 40px;
        gap: 24px;
        height: auto;
        min-height: 100vh;
        max-height: none;
        justify-content: flex-start;
    }

    .title-section {
        margin-bottom: 0;
    }

    .main-title {
        font-size: 2.8rem;
        margin-bottom: 16px;
        line-height: 1.1;
        letter-spacing: -0.01em;
    }

    .subtitle {
        font-size: 1.4rem;
        margin-bottom: 10px;
        line-height: 1.4;
        color: #444;
    }

    .tagline {
        font-size: 1.1rem;
        line-height: 1.5;
        margin-bottom: 4px;
        color: #666;
    }

    .author-section {
        padding: 20px 0;
        margin: 16px 0;
    }

    .author-byline {
        font-size: 1.3rem;
        margin-bottom: 10px;
        font-weight: 600;
    }

    .author-expertise {
        font-size: 1rem;
        line-height: 1.5;
        margin-bottom: 6px;
        color: #444;
    }

    .author-personal-note {
        font-size: 0.95rem;
        line-height: 1.5;
        margin-top: 12px;
        margin-bottom: 6px;
        color: #444;
    }

    .author-note {
        font-size: 0.95rem;
        line-height: 1.4;
        color: #666;
        margin-bottom: 2px;
    }

    .target-audience-section {
        margin: 0;
        padding: 0;
    }

    .value-prop h3 {
        font-size: 1.4rem;
        margin-bottom: 16px;
    }

    .value-prop p {
        font-size: 1rem;
        line-height: 1.6;
        margin-bottom: 24px;
    }
}

@media (max-width: 480px) {
    .title-page {
        padding: 16px 12px;
        padding-top: 32px;
        gap: 20px;
    }

    .main-title {
        font-size: 2.4rem;
        margin-bottom: 14px;
    }

    .subtitle {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }

    .tagline {
        font-size: 1rem;
        margin-bottom: 3px;
    }

    .author-section {
        padding: 16px 0;
        margin: 12px 0;
    }

    .author-byline {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }

    .author-expertise {
        font-size: 0.95rem;
        margin-bottom: 5px;
    }

    .author-personal-note {
        font-size: 0.9rem;
        line-height: 1.5;
        margin-top: 8px;
        margin-bottom: 5px;
        color: #444;
    }

    .author-note {
        font-size: 0.9rem;
        margin-bottom: 2px;
    }

    .value-prop h3 {
        font-size: 1.3rem;
        margin-bottom: 14px;
    }

    .value-prop p {
        font-size: 0.95rem;
        line-height: 1.6;
        margin-bottom: 20px;
    }
}

/* Draft Preview Marquee Banner */
.draft-marquee {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 32px;
    background-color: #ef4444;
    color: #ffffff;
    z-index: 9999;
    overflow: hidden;
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.marquee-content {
    display: flex;
    align-items: center;
    white-space: nowrap;
    animation: marquee 15s linear infinite;
}

@keyframes marquee {
    0% {
        transform: translateX(100vw);
    }
    100% {
        transform: translateX(-100%);
    }
}

/* Adjust body top margin to account for marquee */
body {
    margin-top: 32px;
}

/* Mobile adjustments for marquee */
@media (max-width: 768px) {
    .draft-marquee {
        height: 28px;
        font-size: 12px;
    }
    
    body {
        margin-top: 28px;
    }

    .marquee-content {
        animation: marquee 12s linear infinite;
    }
}

@media (max-width: 480px) {
    .draft-marquee {
        height: 24px;
        font-size: 11px;
    }
    
    body {
        margin-top: 24px;
    }

    .marquee-content {
        animation: marquee 10s linear infinite;
    }
}

/* Feedback Button */
.feedback-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: inline-flex;
    padding: 14px 21px;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    z-index: 1000;
    border: none;
    border-radius: 100px;
    background: var(--toggle-bg) !important;
    border: 1px solid var(--toggle-border) !important;
    box-shadow: var(--toggle-shadow) !important;
    backdrop-filter: blur(4px);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--toggle-text) !important;
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    line-height: 1;
    min-height: 48px;
}

.feedback-button:hover {
    transform: translateY(-1px);
    background: var(--toggle-hover-bg) !important;
    border: 1px solid var(--toggle-hover-border) !important;
    box-shadow: var(--toggle-hover-shadow) !important;
    backdrop-filter: blur(5px);
}

.feedback-button:active {
    transform: translateY(0px);
    background: var(--toggle-active-bg) !important;
    border: 1px solid var(--toggle-active-border) !important;
    box-shadow: var(--toggle-active-shadow) !important;
    backdrop-filter: blur(3px);
}

/* Feedback Form */
.feedback-form {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    max-width: calc(100vw - 40px);
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    padding: 20px;
    z-index: 1001;
    display: none;
    backdrop-filter: blur(10px);
}

.feedback-form.expanded {
    display: block;
    animation: feedback-expand 0.2s ease-out;
}

@keyframes feedback-expand {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.feedback-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.feedback-form h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.feedback-close-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.feedback-close-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.feedback-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    width: 100%;
    overflow: hidden;
}

.feedback-input {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--input-text);
    font-size: 0.85rem;
    font-family: inherit;
    box-sizing: border-box;
}

.feedback-input:focus {
    outline: none;
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 1px var(--input-focus-border);
}

.feedback-input::placeholder {
    color: var(--input-placeholder);
}

.feedback-textarea {
    width: 100%;
    height: 80px;
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--input-text);
    font-size: 0.9rem;
    resize: vertical;
    min-height: 60px;
    max-height: 150px;
    font-family: inherit;
    line-height: 1.4;
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 1px var(--input-focus-border);
}

.feedback-textarea::placeholder {
    color: var(--input-placeholder);
}

.feedback-form-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.feedback-submit-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.feedback-submit-btn:hover {
    background: var(--button-hover-bg);
    transform: translateY(-1px);
}

.feedback-message {
    margin-top: 8px;
    padding: 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
    display: none;
}

.feedback-message.success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.feedback-message.error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

/* Mobile adjustments for feedback */
@media (max-width: 768px) {
    .feedback-button {
        bottom: 16px;
        right: 16px;
        padding: 12px 18px;
        font-size: 0.8rem;
        min-height: 44px;
    }

    .feedback-form {
        bottom: 16px;
        right: 16px;
        left: 16px;
        width: auto;
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .feedback-form {
        bottom: 12px;
        right: 12px;
        left: 12px;
        padding: 14px;
    }

    .feedback-input-row {
        flex-direction: column;
        gap: 6px;
    }
}
