* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #f5f5f5;
    --secondary-color: #5ec576;
    --primary-light: rgba(245, 245, 245, 0.2);
    --bg-color: #ffffff;
    --card-bg: #f9f9f9;
    --text-color: #333;
    --text-secondary: #666;
    --border-color: #e8e8e8;
}

:root.dark-mode {
    --primary-color: #1a1a1a;
    --secondary-color: #d9544f;
    --bg-color: #0d0d0d;
    --card-bg: #1a1a1a;
    --text-color: #e0e0e0;
    --text-secondary: #b0b0b0;
    --border-color: #333333;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background-color 0.3s ease;
}

.container {
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 700px;
    width: 100%;
    transition: background-color 0.3s ease;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

h1 {
    color: var(--text-color);
    font-size: 2.5em;
    margin: 0;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

.settings-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.auth-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

.theme-toggle-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.theme-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(51, 51, 51, 0.3);
}

/* Input Section */
.input-section {
    margin-bottom: 30px;
}

.input-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    color: #999;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--secondary-color);
    border-bottom-color: var(--secondary-color);
}

.tab-btn:hover {
    color: var(--secondary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

textarea {
    width: 100%;
    height: 150px;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
    background: var(--card-bg);
    color: var(--text-color);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-light);
}

.pdf-upload-label {
    display: block;
    cursor: pointer;
}

.pdf-upload-box {
    border: 2px dashed var(--secondary-color);
    border-radius: 10px;
    padding: 40px 20px;
    text-align: center;
    background: rgba(94, 197, 118, 0.05);
    transition: all 0.3s ease;
}

.pdf-upload-box:hover {
    border-color: var(--secondary-color);
    background: rgba(94, 197, 118, 0.1);
}

.pdf-upload-box.drag-over {
    border-color: var(--secondary-color);
    background: rgba(94, 197, 118, 0.15);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.pdf-upload-box p {
    color: var(--secondary-color);
    font-weight: 600;
    margin: 0;
}

.pdf-status {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    display: none;
    font-size: 14px;
}

.pdf-status.success {
    display: block;
    background: #c8e6c9;
    color: #2e7d32;
    border: 1px solid #66bb6a;
}

.pdf-status.error {
    display: block;
    background: #ffcdd2;
    color: #c62828;
    border: 1px solid #ef5350;
}

.pdf-status.loading {
    display: block;
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #42a5f5;
}

/* Browse Tab */
.browse-container {
    width: 100%;
    height: 600px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.gutenberg-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.browse-header {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.browse-instructions {
    background: #f0f0f0;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.browse-instructions p {
    margin: 5px 0;
    font-size: 14px;
    color: #555;
    font-weight: 600;
}

.browse-instructions p:first-child {
    margin-top: 0;
}

.browse-instructions p:last-child {
    margin-bottom: 0;
}

.import-textarea {
    width: 100%;
    height: 80px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    transition: all 0.3s ease;
}

.import-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-light);
}

.btn-import {
    background: var(--primary-color);
    color: white;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-import:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(51, 51, 51, 0.3);
}

/* Display Section */
.display-section {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    padding: 40px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    transition: background-color 0.3s ease;
}

:root.dark-mode .display-section {
    background: rgba(255, 255, 255, 0.05);
}

.word-display {
    font-size: 48px;
    font-weight: 600;
    color: var(--primary-color);
    text-align: center;
    min-height: 70px;
    line-height: 1.2;
}

.word-part {
    transition: color 0.1s ease;
}

.middle-letter {
    color: var(--secondary-color);
    font-weight: 700;
}

/* Progress Bar */
.progress-bar-container {
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--secondary-color);
    border-radius: 10px;
    width: 0%;
    transition: width 0.1s ease;
}

/* Controls Section */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

.speed-control label {
    font-weight: 600;
    color: var(--text-color);
    min-width: 120px;
}

#speedSlider {
    flex: 1;
    height: 6px;
    border-radius: 5px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
}

#speedSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(94, 197, 118, 0.4);
}

#speedSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(94, 197, 118, 0.4);
}

#speedValue {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 50px;
    text-align: right;
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
}

.btn-play {
    background: var(--secondary-color);
    color: white;
}

.btn-play:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(94, 197, 118, 0.3);
}

.btn-pause {
    background: #ffa726;
    color: white;
}

.btn-pause:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 167, 38, 0.3);
}

.btn-reset {
    background: #ef5350;
    color: white;
}

.btn-reset:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(239, 83, 80, 0.3);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#annotateBtn {
    display: none;
}

/* Stats */
.stats {
    display: flex;
    justify-content: space-around;
    font-size: 14px;
    color: var(--text-secondary);
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.stats span {
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    animation: slideUp 0.3s ease;
    transition: background-color 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes checkmarkFade {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid var(--border-color);
}

.modal-header h2 {
    color: var(--text-color);
    font-size: 1.5em;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 30px;
}

.color-info {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 25px;
    border-left: 4px solid var(--secondary-color);
}

.color-info p {
    margin: 8px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.color-info p:first-child {
    margin-top: 0;
}

.color-info p:last-child {
    margin-bottom: 0;
}

.color-setting {
    margin-bottom: 20px;
}

.color-setting label {
    display: block;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}

.color-setting input[type="color"] {
    width: 100%;
    height: 50px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.color-setting input[type="color"]:hover {
    border-color: var(--primary-color);
}

.color-preview {
    display: flex;
    gap: 15px;
    margin: 30px 0;
}

.preview-box {
    flex: 1;
    height: 100px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.primary-preview {
    background: var(--primary-color);
}

.secondary-preview {
    background: var(--secondary-color);
}

/* Toggle Setting */
.toggle-setting {
    margin: 25px 0;
    padding: 15px;
    background: var(--card-bg);
    border-radius: 8px;
}

.toggle-setting label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-color);
}

.toggle-setting input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--secondary-color);
}

.toggle-setting span {
    font-weight: 600;
}

/* Auth Styles */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field input {
    flex: 1;
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    padding: 0;
    transition: color 0.3s ease;
}

.password-toggle-btn:hover {
    color: var(--text-color);
}

.auth-input {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.auth-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-light);
}

.auth-toggle {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    margin: 5px 0;
}

.auth-toggle a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

.auth-error {
    color: #c62828;
    background: #ffcdd2;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ef5350;
    display: none;
    font-size: 14px;
    margin-top: 10px;
}

.auth-error.show {
    display: block;
}

.user-profile {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-info {
    background: var(--card-bg);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
}

.user-info p {
    margin: 5px 0;
    font-size: 14px;
}

/* Saved Texts & History */
.saved-texts-list, .history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.text-item, .history-item {
    background: var(--card-bg);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
}

.text-item h3, .history-item h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: var(--text-color);
}

.text-item p, .history-item p {
    margin: 5px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.text-item-preview {
    font-size: 13px;
    color: #999;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 8px 0;
    line-height: 1.4;
}

.text-item-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.text-item-buttons button {
    flex: 1;
    padding: 8px;
    font-size: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.text-item-buttons .load-btn {
    background: var(--primary-color);
    color: white;
}

.text-item-buttons .load-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(51, 51, 51, 0.2);
}

.text-item-buttons .delete-btn {
    background: #ffcdd2;
    color: #c62828;
}

.text-item-buttons .delete-btn:hover {
    background: #ef5350;
    color: white;
}

.reading-stats {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-box {
    background: var(--bg-color);
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid var(--secondary-color);
}

.stat-box h4 {
    margin: 0 0 5px 0;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-box p {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--secondary-color);
}

/* Annotations Styles */
.annotatable-text {
    padding: 20px;
    background: var(--bg-color);
    border-radius: 10px;
}

.word-span {
    padding: 2px 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
}

.word-span:hover {
    background: rgba(94, 197, 118, 0.2);
}

.word-span.selected {
    background: var(--secondary-color);
    color: white;
    border-radius: 4px;
    padding: 2px 6px;
}

.word-span.highlighted-word {
    background: linear-gradient(to bottom, transparent 60%, rgba(94, 197, 118, 0.4) 60%);
    font-weight: 600;
    color: black;
}

.word-span.highlighted-word.selected {
    background: var(--secondary-color);
    color: white;
}

:root.dark-mode .word-span.highlighted-word {
    background: linear-gradient(to bottom, transparent 60%, rgba(217, 84, 79, 0.4) 60%);
    color: #ffffff;
}

.annotatable-text {
    color: var(--text-color);
}

:root.dark-mode .annotatable-text {
    color: #e8e8e8;
}

/* Highlight color options */
.color-options {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: var(--text-color);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

.color-option.green {
    background: linear-gradient(to bottom, transparent 60%, rgba(94, 197, 118, 0.6) 60%);
}

.color-option.yellow {
    background: linear-gradient(to bottom, transparent 60%, rgba(255, 193, 7, 0.6) 60%);
}

.color-option.blue {
    background: linear-gradient(to bottom, transparent 60%, rgba(66, 165, 245, 0.6) 60%);
}

.color-option.pink {
    background: linear-gradient(to bottom, transparent 60%, rgba(236, 64, 122, 0.6) 60%);
}

.color-option.orange {
    background: linear-gradient(to bottom, transparent 60%, rgba(255, 152, 0, 0.6) 60%);
}

/* Highlighted word color variations */
.word-span.highlight-green {
    background: linear-gradient(to bottom, transparent 60%, rgba(94, 197, 118, 0.4) 60%);
}

.word-span.highlight-yellow {
    background: linear-gradient(to bottom, transparent 60%, rgba(255, 193, 7, 0.4) 60%);
}

.word-span.highlight-blue {
    background: linear-gradient(to bottom, transparent 60%, rgba(66, 165, 245, 0.4) 60%);
}

.word-span.highlight-pink {
    background: linear-gradient(to bottom, transparent 60%, rgba(236, 64, 122, 0.4) 60%);
}

.word-span.highlight-orange {
    background: linear-gradient(to bottom, transparent 60%, rgba(255, 152, 0, 0.4) 60%);
}

:root.dark-mode .word-span.highlight-green {
    background: linear-gradient(to bottom, transparent 60%, rgba(94, 197, 118, 0.5) 60%);
}

:root.dark-mode .word-span.highlight-yellow {
    background: linear-gradient(to bottom, transparent 60%, rgba(255, 193, 7, 0.5) 60%);
}

:root.dark-mode .word-span.highlight-blue {
    background: linear-gradient(to bottom, transparent 60%, rgba(66, 165, 245, 0.5) 60%);
}

:root.dark-mode .word-span.highlight-pink {
    background: linear-gradient(to bottom, transparent 60%, rgba(236, 64, 122, 0.5) 60%);
}

:root.dark-mode .word-span.highlight-orange {
    background: linear-gradient(to bottom, transparent 60%, rgba(255, 152, 0, 0.5) 60%);
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 1.8em;
    }

    .word-display {
        font-size: 36px;
    }

    textarea {
        height: 120px;
        font-size: 14px;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        padding: 10px 20px;
    }
}
