:root {
    --primary-color: #6c5ce7;
    --secondary-color: #00b894;
    --accent-color: #ff6b6b;
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --bg-light: #0f3460;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-color: #2d3561;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Main Container */
#mainContainer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Text Input Section */
#textInputSection {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    padding: 2rem;
    backdrop-filter: blur(10px);
}

#textInputSection h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    color: var(--text-primary);
}

#textInput {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 1rem;
    font-family: inherit;
}

#textInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Button Styles */
.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.primary-btn, .secondary-btn, .control-btn, .icon-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    flex: 1;
    min-width: 150px;
}

.primary-btn:hover {
    background: #5f4fd1;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.4);
}

.secondary-btn {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    width: 100%;
}

.secondary-btn:hover {
    border-color: var(--primary-color);
    background: var(--bg-medium);
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    min-width: auto;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Normal Reading Section */
#normalReadingSection {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}

.reading-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 400px;
}

#searchInput {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.9rem;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

.search-nav-btn {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.5rem;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.search-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.search-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.search-results {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.progress-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.progress-info span {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.normal-text {
    line-height: 1.8;
    font-size: 1.1rem;
    max-height: 70vh;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 0.5rem;
    user-select: none;
}

.normal-text span {
    cursor: pointer;
    padding: 0.2rem 0.3rem;
    border-radius: 0.25rem;
    transition: background 0.2s;
}

.normal-text span:hover {
    background: rgba(255, 255, 255, 0.1);
}

.normal-text span.current-word {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.normal-text span.search-match {
    background: rgba(255, 255, 0, 0.3);
    border-radius: 0.25rem;
}

.normal-text span.search-current {
    background: rgba(255, 200, 0, 0.6);
    border: 2px solid #ffd700;
}

/* RSVP Reading Section */
#rsvpReadingSection {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rsvp-container {
    text-align: center;
    width: 100%;
    max-width: 800px;
}

.rsvp-word {
    font-size: 60px;
    font-weight: 700;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 3rem;
    letter-spacing: 0.05em;
    user-select: none;
    word-break: break-word;
    padding: 1rem;
}

.rsvp-word .focus-letter {
    color: var(--accent-color);
}

.rsvp-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 1.5rem;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.control-btn:hover {
    background: var(--primary-color);
    transform: scale(1.1);
}

.control-btn:active {
    transform: scale(0.95);
}

/* Progress Bar */
.rsvp-progress {
    margin-top: 2rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
    width: 0%;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Settings Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-medium);
    border-radius: 1rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background 0.3s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 1.5rem;
}

.setting-group {
    margin-bottom: 1.5rem;
}

.setting-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-group input[type="number"],
.setting-group input[type="color"] {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

.setting-group input[type="color"] {
    height: 50px;
    cursor: pointer;
}

.setting-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.setting-desc {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Library Section */
#librarySection {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
}

.library-header h2 {
    font-size: 1.5rem;
}

.books-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.library-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    transition: all 0.3s;
}

.library-item:hover {
    border-color: var(--primary-color);
    background: rgba(108, 92, 231, 0.1);
}

.book-info {
    flex: 1;
    min-width: 0;
}

.book-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    word-break: break-word;
}

.book-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.book-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-dark);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.book-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
    transition: width 0.3s ease;
}

.book-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.book-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
    flex-shrink: 0;
}

.book-btn {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 0.5rem;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    min-width: 40px;
}

.book-btn:hover {
    background: var(--primary-color);
    transform: scale(1.1);
}

.input-group {
    margin-bottom: 1rem;
}

.input-group input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.2rem;
    }

    #mainContainer {
        padding: 1rem 0.5rem;
    }

    #textInputSection {
        padding: 1rem;
    }

    #textInput {
        min-height: 200px;
        font-size: 0.9rem;
    }

    .rsvp-word {
        font-size: 48px;
        min-height: 100px;
    }

    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .button-group {
        flex-direction: column;
    }

    .primary-btn {
        min-width: 100%;
    }

    .library-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .book-actions {
        margin-left: 0;
        margin-top: 1rem;
        width: 100%;
        justify-content: flex-end;
    }

    .library-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .library-header button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .rsvp-word {
        font-size: 36px;
        min-height: 80px;
    }

    header {
        padding: 0.75rem 1rem;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5f4fd1;
}
