* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --earth-brown: #6B4E3D;
    --sage-green: #87936F;
    --sand: #F5F2E8;
    --stone-gray: #8B8680;
    --cream: #FAF8F3;
    --soft-black: #1A1815;  /* Darkened from #2C2825 */
    --moss: #5A6650;
}

body {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 500;  /* Increased for better mobile readability */
    line-height: 1.8;
    color: var(--soft-black);
    background: linear-gradient(135deg, var(--cream) 0%, var(--sand) 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    font-size: 1.1rem;  /* Base font size increased */
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(135, 147, 111, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(107, 78, 61, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(90, 102, 80, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
}

#app {
    position: relative;
    z-index: 2;
}

/* Table of Contents */
.toc {
    min-height: 100vh;
    padding: 60px 40px;
    max-width: 900px;
    margin: 0 auto;
    animation: fadeIn 1s ease;
}

.toc-header {
    text-align: center;
    margin-bottom: 60px;
    border-bottom: 1px solid rgba(107, 78, 61, 0.1);
    padding-bottom: 40px;
}

.toc-header h1 {
    font-family: 'EB Garamond', 'Crimson Text', serif;
    font-weight: 400;
    font-size: 2rem;
    letter-spacing: 0.08em;
    color: var(--earth-brown);
    margin-bottom: 20px;
    text-transform: none;
    font-style: normal;
}

.toc-header .author {
    font-family: 'EB Garamond', serif;
    font-weight: 400;
    font-size: 1.1rem;
    letter-spacing: 0.1em;
    color: var(--stone-gray);
    margin-bottom: 10px;
}

.toc-header .location {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: 1rem;
    color: var(--stone-gray);
    letter-spacing: 0.1em;
}

.download-link {
    position: fixed;
    bottom: 40px;
    right: 40px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.95rem;
    color: var(--stone-gray);
    text-decoration: none;
    transition: all 0.3s ease;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
}

.download-link.visible {
    opacity: 1;
    pointer-events: auto;
}

.download-link:hover {
    color: var(--moss);
}

.toc-list {
    columns: 2;
    column-gap: 60px;
    margin-bottom: 50px;
}

.toc-list ul {
    list-style: none;
}

.toc-list li {
    margin-bottom: 12px;
    break-inside: avoid;
}

.toc-list a {
    color: var(--soft-black);
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-block;
    position: relative;
    padding-left: 0;
}

.toc-list a::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 50%;
    width: 0;
    height: 1px;
    background: var(--sage-green);
    transition: width 0.3s ease;
}

.toc-list a:hover {
    color: var(--moss);
    padding-left: 10px;
}

.toc-list a:hover::before {
    width: 15px;
}


/* Poem Viewer */
.poem-viewer {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    animation: fadeIn 0.8s ease forwards;
}

.poem-viewer.hidden {
    display: none;
}

.poem-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background: linear-gradient(to bottom, var(--cream) 0%, rgba(250, 248, 243, 0.9) 70%, transparent 100%);
    z-index: 10;
}

.book-title {
    font-family: 'Raleway', sans-serif;
    font-weight: 100;
    font-size: 1rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--stone-gray);
    display: none;
}

.page-number {
    font-family: 'Raleway', sans-serif;
    font-weight: 200;
    font-size: 0.9rem;
    color: var(--stone-gray);
    letter-spacing: 0.1em;
    display: none;
}

.poem-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 120px 40px 80px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.poem {
    display: none;
    opacity: 0;
    transform: translateX(30px);
}

.poem.active {
    display: block;
    animation: slideIn 0.6s ease forwards;
}

.poem.exit-left {
    animation: slideOutLeft 0.6s ease forwards;
}

.poem.exit-right {
    animation: slideOutRight 0.6s ease forwards;
}

.poem h2 {
    font-family: 'EB Garamond', 'Crimson Text', serif;
    font-weight: 400;
    font-size: 1.8rem;
    letter-spacing: 0.08em;
    color: var(--earth-brown);
    margin-bottom: 40px;
    text-align: center;
    position: relative;
}

.poem h2::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--sage-green), transparent);
}

.poem-text {
    font-size: 1.3rem;
    font-weight: 500;
    line-height: 2.1;
    color: var(--soft-black);
    white-space: pre-line;
    text-align: left;
    max-width: 600px;
    margin: 0 auto;
}

/* Navigation */
.poem-nav {
    position: fixed;
    bottom: 40px;
    right: 40px;
    display: flex;
    gap: 20px;
    z-index: 10;
}

.nav-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid rgba(139, 147, 127, 0.3); /* sage-green with lower opacity */
    color: rgba(139, 147, 127, 0.3); /* matching arrow color */
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Raleway', sans-serif;
    font-weight: 300;
    position: relative;
    animation: fadeToTransparent 0.5s ease forwards;
}

@keyframes fadeToTransparent {
    from {
        background: rgba(255, 255, 255, 0.2);
        border-color: rgba(139, 147, 127, 0.5);
        color: rgba(139, 147, 127, 0.5);
    }
    to {
        background: transparent;
        border-color: rgba(139, 147, 127, 0.3);
        color: rgba(139, 147, 127, 0.3);
    }
}

.nav-btn:active {
    animation: buttonTap 0.5s ease forwards;
}

@keyframes buttonTap {
    0% {
        background: rgba(139, 147, 127, 0.15);
        border-color: rgba(139, 147, 127, 0.6);
        color: rgba(139, 147, 127, 0.6);
        transform: scale(1.1);
    }
    100% {
        background: transparent;
        border-color: rgba(139, 147, 127, 0.3);
        color: rgba(139, 147, 127, 0.3);
        transform: scale(1);
    }
}

.nav-btn:hover:not(:disabled) {
    border-color: rgba(139, 147, 127, 0.6);
    color: rgba(139, 147, 127, 0.6);
    background: rgba(139, 147, 127, 0.05);
    transform: scale(1.1);
}

.nav-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
    border-color: rgba(139, 147, 127, 0.15);
    color: rgba(139, 147, 127, 0.15);
}

#toc-btn {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    width: auto;
    height: auto;
    color: var(--moss);
}

#toc-btn:hover {
    color: var(--earth-brown);
    transform: none;
}

/* Side TOC Modal */
.side-toc {
    position: fixed;
    top: 0;
    left: -350px;
    width: 350px;
    height: 100vh;
    background: var(--cream);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    transition: left 0.3s ease;
    z-index: 100;
    overflow-y: auto;
}

.side-toc.open {
    left: 0;
}

.side-toc-content {
    padding: 40px 30px;
}

.close-toc {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--stone-gray);
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-toc:hover {
    color: var(--earth-brown);
}

.side-toc h2 {
    font-family: 'EB Garamond', serif;
    font-size: 1.5rem;
    color: var(--earth-brown);
    margin-bottom: 30px;
    letter-spacing: 0.05em;
}

.contents-home {
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    padding-bottom: 3px;
    border-bottom: 2px solid transparent;
}

.contents-home:hover {
    color: var(--moss);
    border-bottom-color: var(--sage-green);
}

.side-toc-list {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.side-toc-list ul {
    list-style: none;
}

.side-toc-list li {
    margin-bottom: 15px;
}

.side-toc-list a {
    color: var(--soft-black);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    display: block;
    padding: 5px 0;
    border-left: 2px solid transparent;
    padding-left: 0;
}

.side-toc-list a:hover {
    color: var(--moss);
    padding-left: 10px;
    border-left-color: var(--sage-green);
}

.side-toc-list a.active {
    color: var(--earth-brown);
    font-weight: 600;
    border-left-color: var(--earth-brown);
    padding-left: 10px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        font-size: 1.65rem;  /* 75% of 2.2rem */
        font-weight: 600;  /* Thicker text on mobile */
    }

    .toc-header h1 {
        font-size: 2.6rem;  /* 75% of 3.5rem */
        font-weight: 700;
        letter-spacing: 0.1em;
    }

    .toc-header .author {
        font-size: 1.65rem;
        font-weight: 600;
    }

    .toc-header .location {
        font-size: 1.5rem;
        font-weight: 500;
    }

    .toc-list {
        columns: 1;
    }

    .toc-list a {
        font-size: 1.65rem;
        font-weight: 600;
        padding: 12px 0;  /* More touch-friendly spacing */
    }

    .poem-container {
        padding: 100px 20px 100px;  /* More padding for better readability */
    }

    .poem h2 {
        font-size: 2.25rem;  /* 75% of 3rem */
        font-weight: 700;
        margin-bottom: 50px;
    }

    .poem-text {
        font-size: 1.95rem;  /* 75% of 2.6rem */
        font-weight: 600;  /* Thicker text */
        line-height: 1.9;  /* Adjusted line height */
        letter-spacing: 0.02em;  /* Slight letter spacing for clarity */
    }

    .poem-header {
        padding: 22px 20px;
    }

    .book-title {
        font-size: 1.35rem;
        font-weight: 600;
        letter-spacing: 0.15em;
    }

    .page-number {
        font-size: 1.2rem;
        font-weight: 500;
    }

    /* Bigger navigation buttons on mobile */
    .nav-btn {
        width: 60px;
        height: 60px;
        font-size: 1.6rem;
        border-width: 2.5px;
    }

    /* Side TOC adjustments */
    .side-toc {
        width: 85%;  /* Take up more screen on mobile */
        left: -85%;
    }

    .side-toc-list a {
        font-size: 1.5rem;
        font-weight: 600;
        padding: 12px 0;
    }

    .side-toc h2 {
        font-size: 2.1rem;
        font-weight: 700;
    }
}

/* Subtle background texture */
.poem-viewer::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 35px,
            rgba(135, 147, 111, 0.01) 35px,
            rgba(135, 147, 111, 0.01) 70px
        );
    pointer-events: none;
    z-index: 0;
}

/* Page turn effect hint */
.poem-container::after {
    content: '';
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 200px;
    background: linear-gradient(90deg, transparent, rgba(135, 147, 111, 0.05));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.poem-container:hover::after {
    opacity: 1;
}