* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    color: #1f2937;
}


.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: #1f2937;
    background: #ffffff;
    padding: 30px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #2563eb;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    color: #6b7280;
    font-weight: 500;
}

.tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    background: #f9fafb;
    border-radius: 12px;
    padding: 8px;
    border: 1px solid #e5e7eb;
}

.tab-button {
    background: transparent;
    border: none;
    padding: 15px 30px;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 600;
}

.tab-button.active {
    background: #2563eb;
    color: white;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.tab-button:hover:not(.active) {
    background: #e5e7eb;
    color: #374151;
}

.tab-content {
    display: none;
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.tab-content.active {
    display: block;
}

.add-verse-section {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid #f0f0f0;
}

.add-verse-section h2 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #4a5568;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.reference-container {
    display: flex;
    gap: 12px;
    align-items: center;
}

.reference-container input {
    flex: 1;
    min-width: 0;
    /* Allow input to shrink */
    padding: 12px;
    /* Match button vertical padding */
    height: auto;
    /* Allow natural height calculation */
}

.version-select {
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    background: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
    flex-shrink: 0;
}

.version-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.version-select:hover {
    border-color: #cbd5e0;
}

.fetch-btn {
    background: #2563eb;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
    white-space: nowrap;
    flex-shrink: 0;
    /* Prevent button from shrinking */
}

.fetch-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.fetch-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.fetch-btn.loading {
    background: #6b7280;
    animation: pulse 1.5s infinite;
}

button {
    background: #2563eb;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

button:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.verse-library h2 {
    color: #4a5568;
    font-size: 1.5rem;
    margin: 0;
}

.library-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.add-verse-btn {
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2);
}

.add-verse-btn:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3);
}

.backup-btn,
.restore-btn {
    padding: 10px 16px;
    font-size: 1rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.backup-btn {
    background: #2563eb;
    color: white;
    border: none;
}

.backup-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.restore-btn {
    background: #2563eb;
    color: white;
    border: none;
}

.restore-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.verse-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.verse-item-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.verse-item-compact:hover {
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.1);
}

.verse-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.verse-reference {
    font-weight: 700;
    color: #667eea;
    font-size: 1.1rem;
}

.verse-version {
    font-weight: 400;
    color: #6b7280;
    font-size: 0.9rem;
    font-style: italic;
    background: #e5e7eb;
    padding: 2px 8px;
    border-radius: 12px;
}

.verse-menu {
    position: relative;
}

.menu-toggle {
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(107, 114, 128, 0.2);
    min-width: 40px;
}

.menu-toggle:hover {
    background: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(107, 114, 128, 0.3);
}

.context-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    min-width: 120px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.context-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.context-menu button {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 10px 16px;
    text-align: left;
    font-size: 0.9rem;
    color: #4a5568;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.context-menu button:hover {
    background: #f7fafc;
}

.context-menu button:first-child {
    color: #2563eb;
}

.context-menu button:last-child {
    color: #dc2626;
}

.delete-btn {
    background: #dc2626;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2);
}

.delete-btn:hover {
    box-shadow: 0 6px 20px rgba(229, 62, 62, 0.4);
}

.quiz-controls {
    text-align: center;
    margin-bottom: 30px;
}

.quiz-controls h2 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.verse-selector {
    margin-bottom: 20px;
}

.verse-selector label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #4a5568;
}

.verse-selector select {
    width: 100%;
    max-width: 400px;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}


.quiz-area {
    text-align: center;
    padding-bottom: 120px;
    /* Ensure space for sticky controls */
}

.quiz-area.hidden {
    display: none;
}

.verse-reference h3 {
    color: #667eea;
    font-size: 1.3rem;
    margin-bottom: 20px;
}

.verse-display {
    background: #f8f9fa;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 30px;
    min-height: 120px;
    max-height: 60vh;
    overflow-y: auto;
}

.verse-text {
    font-size: 1.2rem;
    line-height: 1.8;
    color: #4a5568;
}

.word {
    margin-right: 5px;
    transition: all 0.3s ease;
}

.word.correct {
    color: #16a34a;
    font-weight: 600;
}

.word.incorrect {
    color: #dc2626;
    font-weight: 600;
    background: rgba(220, 38, 38, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
}

.word.skipped-incorrect {
    color: #f59e0b;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    text-decoration: line-through;
    opacity: 0.8;
}

.word.pending {
    color: #9ca3af;
    font-family: monospace;
    letter-spacing: 0.5px;
    display: inline-block;
}

.word.skipped {
    color: #9ca3af;
    display: inline-block;
}

.quiz-controls-bottom {
    position: sticky;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 20px 25px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e5e7eb;
    margin-top: 30px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    max-width: 100%;
    z-index: 100;
}

.floating-status {
    text-align: center;
    width: 100%;
}

.floating-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Show floating controls only when quiz tab is active */
#quiz.active .quiz-controls-bottom {
    opacity: 1;
    visibility: visible;
}

.record-btn {
    background: #16a34a;
    box-shadow: 0 2px 4px rgba(22, 163, 74, 0.2);
}

.record-btn:hover {
    box-shadow: 0 6px 20px rgba(56, 161, 105, 0.4);
}

.record-btn.recording {
    background: #dc2626;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.reset-btn {
    background: #6b7280;
    box-shadow: 0 2px 4px rgba(107, 114, 128, 0.2);
}

.reset-btn:hover {
    box-shadow: 0 6px 20px rgba(113, 128, 150, 0.4);
}


/* Status styling moved to floating panel */

.recording-status {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.recording-status.recording {
    color: #dc2626;
}

.recording-status.listening {
    color: #16a34a;
}

.quiz-transcript-display {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    text-align: center;
}

.quiz-transcript-line {
    font-size: 0.98rem;
    color: #1f2937;
}

.quiz-transcript-line.hidden {
    display: none;
}

.quiz-transcript-label {
    font-weight: 600;
    margin-right: 6px;
    color: #111827;
}

.quiz-transcript-value {
    font-family: 'Inter', sans-serif;
    color: #111827;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.modal-header h2 {
    color: #4a5568;
    margin: 0;
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #718096;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #f7fafc;
    color: #4a5568;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 20px;
}

.verse-preview {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
    font-style: italic;
    color: #4a5568;
}

.modal-actions .delete-btn {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.modal-actions .delete-btn:hover {
    background: #c53030;
}

.settings-btn {
    background: #4a5568;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.settings-btn:hover {
    background: #2d3748;
}

.help-text {
    font-size: 0.875rem;
    color: #718096;
    margin-top: 5px;
    margin-bottom: 0;
}

.help-text a {
    color: #3182ce;
    text-decoration: none;
}

.help-text a:hover {
    text-decoration: underline;
}

.modal-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.modal-content li {
    margin: 5px 0;
    color: #4a5568;
}

.cancel-btn {
    background: #e2e8f0;
    color: #4a5568;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: #cbd5e0;
}

.save-btn {
    background: #16a34a;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(22, 163, 74, 0.2);
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 161, 105, 0.4);
}

.edit-btn {
    background: #2563eb;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.edit-btn:hover {
    box-shadow: 0 6px 20px rgba(49, 130, 206, 0.4);
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    .tab-content {
        padding: 20px;
    }

    .reference-container {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .reference-container input {
        width: 100%;
        min-width: auto;
    }

    .fetch-btn {
        width: 100%;
        max-width: none;
    }

    .quiz-controls-bottom {
        padding: 15px 20px;
        margin-top: 20px;
        bottom: 10px;
    }

    .quiz-area {
        padding-bottom: 100px;
    }

    .floating-buttons {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    .floating-buttons button {
        width: 100%;
        max-width: 250px;
    }

    .verse-display {
        padding: 20px;
        margin-bottom: 20px;
        max-height: 50vh;
    }

    .verse-text {
        font-size: 1.1rem;
        line-height: 1.6;
    }

    .library-controls {
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
    }

    .add-verse-btn,
    .backup-btn,
    .restore-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .verse-item-compact {
        padding: 12px 15px;
    }

    .verse-info {
        gap: 8px;
    }

    .verse-reference {
        font-size: 1rem;
    }

    .verse-version {
        font-size: 0.8rem;
        padding: 1px 6px;
    }

    .menu-toggle {
        padding: 6px 10px;
        font-size: 0.9rem;
        min-width: 36px;
    }

    .context-menu {
        min-width: 100px;
    }

    .modal-content {
        padding: 20px;
        width: 95%;
    }

    .modal-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .tab-content {
        padding: 15px;
    }

    .library-controls {
        gap: 6px;
    }

    .add-verse-btn,
    .backup-btn,
    .restore-btn {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .reference-container {
        gap: 12px;
    }

    .version-select {
        min-width: 70px;
        font-size: 0.9rem;
    }

    .verse-display {
        padding: 15px;
        margin-bottom: 15px;
        max-height: 45vh;
    }

    .verse-text {
        font-size: 1rem;
        line-height: 1.5;
    }

    .quiz-controls-bottom {
        padding: 12px 15px;
        margin-top: 15px;
        bottom: 5px;
    }

    .quiz-area {
        padding-bottom: 80px;
    }

    .floating-buttons button {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}