:root {
    --bg-color: #fdfcfb;
    --text-color: #1c1c1c;
    --accent-color: #c0392b;
    /* Deep Red */
    --secondary-text: #7f8c8d;
    --border-color: #e0e0e0;
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --font-serif: "Georgia", serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-serif);
    line-height: 1.6;
    overflow-x: hidden;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1,
h2 {
    font-weight: normal;
    letter-spacing: -0.02em;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn.red {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.btn:hover {
    background: rgba(0, 0, 0, 0.03);
}

.btn.red:hover {
    background: var(--accent-color);
    color: white;
}

.btn-link {
    background: none;
    border: none;
    color: var(--secondary-text);
    text-decoration: underline;
    cursor: pointer;
    font-family: var(--font-sans);
    padding: 0;
}

/* Views */
.view {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.hidden {
    display: none !important;
}

/* Library View */
#library-view header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 1rem;
}

.doc-list {
    display: grid;
    gap: 1.5rem;
    margin-top: 1rem;
}

.doc-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.doc-item:hover {
    transform: translateX(4px);
    border-color: var(--accent-color);
}

.doc-info h3 {
    margin: 0;
    font-size: 1.1rem;
}

.doc-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--secondary-text);
    font-family: var(--font-sans);
}

/* Reader View */
#reader-view {
    justify-content: center;
    align-items: center;
    height: 70vh;
}

#reader-container {
    text-align: center;
    position: relative;
    width: 100%;
    overflow: hidden;
}

.rsvp-wrap {
    display: flex;
    align-items: baseline;
    justify-content: center;
    width: 100%;
}

.rsvp-word {
    font-size: 3.5rem;
    font-weight: normal;
    padding: 0 1rem;
    min-width: 200px;
    text-align: center;
}

.rsvp-context {
    color: var(--secondary-text);
    opacity: 0.3;
    font-size: 1.2rem;
    transition: opacity 0.3s ease;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
}

#rsvp-before {
    text-align: right;
}

#rsvp-after {
    text-align: left;
}

#reader-view.playing .rsvp-context {
    opacity: 0;
}

#reader-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    margin-top: 2rem;
}

.speed-control {
    font-family: var(--font-sans);
    display: flex;
    flex-direction: column;
    align-items: center;
}

#wpm-slider {
    width: 250px;
    accent-color: var(--accent-color);
}

.progress-container {
    width: 100%;
    height: 2px;
    background: var(--border-color);
    position: relative;
}

.progress-bar {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.1s linear;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-color);
    padding: 2.5rem;
    width: 90%;
    max-width: 600px;
    border: 1px solid var(--border-color);
}

.modal-content h2 {
    margin-top: 0;
}

#doc-title,
#doc-content {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    padding: 0.8rem;
    font-family: var(--font-sans);
}

#doc-content {
    height: 200px;
    font-family: var(--font-serif);
    resize: none;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: flex-end;
}

.storage-note {
    font-size: 0.75rem;
    color: var(--secondary-text);
    margin-top: 1.5rem;
    font-family: var(--font-sans);
    font-style: italic;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    #app {
        padding: 1rem;
    }

    .rsvp-word {
        font-size: 2.5rem;
    }

    .modal-content {
        padding: 1.5rem;
    }

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