body {
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 12px;
    background: #f9fafb;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

/* First row: Title, companion text, and welcome */
.header-row-1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-row-1 h1 {
    margin: 0;
    color: #333;
    font-size: 1.8em;
    font-weight: 600;
    flex: 0 0 auto;
}

.companion-text {
    margin: 0;
    color: #666;
    font-size: 14px;
    text-align: center;
    flex: 1;
}

.user-welcome {
    flex: 0 0 auto;
}

.user-welcome span {
    color: #333;
    font-size: 14px;
}

/* Second row: Navigation buttons */
.header-row-2 {
    display: flex;
    justify-content: flex-end;
    width: 100%;
}

.nav-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.content {
    display: flex;
    padding: 20px;
    gap: 20px;
}

.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.right-panel {
    flex: 1;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    min-height: 400px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-group label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

textarea {
    width: 100%;
    min-height: 195px;
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 19px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
    /* Remove grammar/spell check underlines */
    text-decoration: none !important;
    -webkit-text-decoration-line: none !important;
    text-decoration-line: none !important;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Editable text area styling */
.editable-text-area {
    width: 100%;
    min-height: 195px;
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 19px;
    font-family: inherit;
    box-sizing: border-box;
    background-color: #fff;
    color: #333;
    line-height: 1.4;
    transition: border-color 0.3s ease;
    text-decoration: none !important;
    -webkit-text-decoration-line: none !important;
    text-decoration-line: none !important;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.editable-text-area:focus {
    outline: none;
    border-color: #667eea;
}

/* Removed placeholder styling - no longer needed */

/* Word selection styling */
.word-selectable {
    cursor: pointer;
    padding: 1px 2px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
    display: inline-block;
}

.word-selectable:hover {
    background-color: #f0f8ff;
}

.word-selected {
    background-color: #b0e0e6 !important; /* watery-green color */
}

/* Removed placeholder and button styling - no longer needed */

.language-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 100%;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e1e5e9;
    font-size: 13px;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
}

.checkbox-group.disabled {
    opacity: 0.5;
    pointer-events: none;
    background: #e9ecef;
}

.checkbox-group.disabled input[type="checkbox"] {
    cursor: not-allowed;
}

.translate-btn {
    background: #4f46e5;
    color: white;
    border: 1px solid #4f46e5;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    white-space: nowrap;
}

.translate-btn:hover {
    background: #3730a3;
    border-color: #3730a3;
}

.translate-btn:disabled {
    background: #9ca3af;
    border-color: #9ca3af;
    cursor: not-allowed;
}

.listen-btn {
    background: #059669;
    color: white;
    border: 1px solid #059669;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    white-space: nowrap;
}

.listen-btn:hover {
    background: #047857;
    border-color: #047857;
}

.listen-btn:disabled {
    background: #9ca3af;
    border-color: #9ca3af;
    cursor: not-allowed;
}

/* Pause and Stop Button Styles */
.pause-btn {
    background: #f59e0b;
    color: white;
    border: 1px solid #f59e0b;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    white-space: nowrap;
}

.pause-btn:hover {
    background: #d97706;
    border-color: #d97706;
}

.pause-btn:disabled {
    background: #9ca3af;
    border-color: #9ca3af;
    cursor: not-allowed;
}

.stop-btn {
    background: #dc2626;
    color: white;
    border: 1px solid #dc2626;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    white-space: nowrap;
}

.stop-btn:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.stop-btn:disabled {
    background: #9ca3af;
    border-color: #9ca3af;
    cursor: not-allowed;
}

/* TTS Progress Indicator Styles */
.tts-progress-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 10px;
    min-width: 200px;
}

.tts-progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.tts-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

.tts-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.tts-progress-text {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

/* Restructured Controls Layout */
.listening-controls-row {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
    width: 100%;
    box-sizing: border-box;
}

.translation-controls-row {
    display: flex;
    justify-content: flex-start;
    margin: 10px 0;
    width: 100%;
    box-sizing: border-box;
}

/* Desktop layout for listening controls */
@media (min-width: 768px) {
    .listening-controls-row {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
    }

    .listening-controls-row .listen-btn,
    .listening-controls-row .pause-btn,
    .listening-controls-row .stop-btn {
        flex: 0 0 auto;
        width: 90px;
    }

    .listening-controls-row .speaking-rate-group {
        flex: 1;
        min-width: 180px;
        max-width: none;
        margin-left: auto;
    }

    .listening-controls-row .tts-progress-container {
        flex: 1;
        min-width: 200px;
        max-width: 300px;
    }
}

/* Desktop layout for listening controls */
@media (max-width: 767px) {
    .listening-controls-row {
        flex-direction: column;
        align-items: stretch;
    }

    .listening-controls-row .listen-btn,
    .listening-controls-row .pause-btn,
    .listening-controls-row .stop-btn {
        width: 100%;
    }

    .listening-controls-row .speaking-rate-group {
        width: 100%;
    }

    .listening-controls-row .tts-progress-container {
        width: 100%;
    }
}

/* Audio state button styles */
.listen-btn.playing {
    background: #dc2626;
    border-color: #dc2626;
}

.listen-btn.playing:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.listen-btn.paused {
    background: #f59e0b;
    border-color: #f59e0b;
}

.listen-btn.paused:hover {
    background: #d97706;
    border-color: #d97706;
}

.translations {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.translation-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.translation-lang {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 5px;
}

.translation-text {
    color: #333;
    line-height: 1.5;
    font-size: 18px;
}

.loading {
    text-align: center;
    color: #666;
    font-style: italic;
}

.error {
    color: #dc3545;
    background: #f8d7da;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #f5c6cb;
}

.session-info {
    background: #e3f2fd;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #1976d2;
    width: 100%;
    box-sizing: border-box;
}

/* Audio Controls Styling */
.audio-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
}

.speaking-rate-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.speaking-rate-group label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

.speaking-rate-select {
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
    width: 100%;
    min-width: 160px;
    box-sizing: border-box;
}

.speaking-rate-select:focus {
    outline: none;
    border-color: #667eea;
}

.speaking-rate-select:hover {
    border-color: #b8c5f2;
}

/* Responsive layout for audio controls */
@media (min-width: 768px) {
    .audio-controls {
        flex-direction: row;
        align-items: flex-start;
        gap: 20px;
    }
    
    .listen-btn {
        margin-top: 0;
        flex-shrink: 0;
    }
    
    .speaking-rate-group {
        flex-shrink: 0;
    }
}

/* Controls Row Styling - constrained by textarea width */
.controls-row {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
    /* Match the textarea width exactly - same as input-group */
    width: 100%;
    box-sizing: border-box;
}

.controls-row .translate-btn {
    margin: 0;
}

.controls-row .listen-btn {
    margin: 0;
}

.controls-row .speaking-rate-group {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
}

/* Desktop layout - respect textarea width */
@media (min-width: 768px) {
    .controls-row {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        flex-wrap: nowrap; /* Don't wrap, constrain instead */
    }
    
    .controls-row .translate-btn {
        flex: 0 0 auto;
        width: 110px;
    }
    
    .controls-row .listen-btn {
        flex: 0 0 auto;
        width: 90px;
    }
    
    .controls-row .speaking-rate-group {
        flex: 1;
        min-width: 180px;
        max-width: none;
        margin-left: 15px;
        margin-right: 0;
    }
}

/* Desktop layout - stack vertically within textarea width */
@media (max-width: 767px) {
    .controls-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls-row .translate-btn,
    .controls-row .listen-btn {
        width: 100%;
    }
    
    .controls-row .speaking-rate-group {
        justify-content: center;
        margin-left: 0;
        max-width: 100%;
    }
}

/* Text highlighting and selection styles */
.highlighted-text {
    background-color: #fff3cd;
    border: 2px solid #ffeaa7;
    border-radius: 4px;
    padding: 2px 4px;
    position: relative;
}

/* Floating Analysis Panel */
.analysis-panel {
    position: absolute;
    z-index: 1000;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0;
    width: 240px;
    display: none;
}

.analysis-panel-header {
    background: #667eea;
    color: white;
    padding: 6px 10px;
    border-radius: 6px 6px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.analysis-panel-title {
    font-weight: 600;
    font-size: 12px;
}

.analysis-panel-close {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.analysis-panel-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.analysis-language-selector {
    padding: 8px 10px;
}

.analysis-language-selector label {
    font-size: 11px;
    margin-bottom: 4px;
    display: block;
}

.analysis-language-selector select {
    width: 100%;
    padding: 4px;
    font-size: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.analysis-buttons {
    padding: 8px 10px;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.analysis-buttons .analyze-btn {
    padding: 6px 12px;
    font-size: 14px;
    min-width: 40px;
}

.model-name {
    padding: 0 10px 8px 10px;
    font-size: 10px;
    color: #666;
    text-align: center;
}


.analysis-language-selector label {
    font-size: 12px;
    font-weight: 600;
    color: #333;
}

.analysis-language-selector select {
    padding: 6px 8px;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    cursor: pointer;
}

.analysis-language-selector select:focus {
    outline: none;
    border-color: #667eea;
}

.analysis-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
}

.analyze-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.analyze-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

.model-name {
    text-align: center;
    font-size: 8px;
    color: #666;
    margin-top: 2px;
    line-height: 1;
    font-weight: normal;
}

/* Docked Analysis Window */
.analysis-window {
    position: fixed;
    width: 650px;
    max-height: 813px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    overflow: hidden;
}

.analysis-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.analysis-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.analysis-window .close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.analysis-window .close-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    color: #f0f0f0;
}

.analysis-header .window-actions {
    display: flex;
    gap: 8px;
}

.minimize-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

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

.analysis-content {
    padding: 20px;
    max-height: 650px;
    overflow-y: auto;
    font-size: 17px;
    line-height: 1.6;
}

.analysis-content .analysis h3 {
    color: #667eea;
    margin-top: 15px;
    margin-bottom: 10px;
    font-size: 16px;
}

.analysis-content .analysis h3:first-child {
    margin-top: 0;
}

.analysis-content .analysis p {
    color: #333;
    margin-bottom: 15px;
}

/* Responsive design for analysis window */
@media (max-width: 768px) {
    .analysis-window {
        width: calc(100vw - 40px);
        right: 20px;
        left: 20px;
        max-height: 60vh;
    }
}

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

.auth-modal-content {
    background: white;
    border-radius: 15px;
    padding: 40px;
    max-width: 450px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h2 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1.8em;
    font-weight: 300;
}

.auth-header p {
    margin: 0;
    color: #666;
    font-size: 1em;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-form h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.4em;
    font-weight: 400;
    text-align: center;
}

.auth-form .input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-form .input-group label {
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.auth-form .input-group input,
.auth-form .input-group select {
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 16px;
    background: white;
    transition: border-color 0.3s ease;
}

.auth-form .input-group input:focus,
.auth-form .input-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.auth-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 10px;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.auth-btn:active {
    transform: translateY(0);
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-switch {
    text-align: center;
    margin-top: 15px;
    color: #666;
    font-size: 14px;
}

.auth-switch a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
    display: none;
}

.auth-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.auth-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* User Info Styles - moved to header styles above */

.logout-btn {
    background: #dc2626;
    color: white;
    border: 1px solid #dc2626;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.logout-btn:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

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

.settings-modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.settings-header {
    background: #f8f9fa;
    color: #333;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid #eee;
}

.settings-header h2 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #e9ecef;
    color: #333;
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
}

.tab-btn {
    background: none;
    border: none;
    padding: 15px 25px;
    cursor: pointer;
    font-size: 16px;
    color: #6c757d;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
    background: white;
}

.tab-btn:hover:not(.active) {
    color: #495057;
    background: #e9ecef;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
}

.tab-content.active {
    display: block;
}

/* Language Sets Container */
.language-sets-container {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
}

.language-set {
    flex: 1;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #e1e5e9;
}

.language-set h3 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 1.2em;
}

.language-set p {
    margin: 0 0 15px 0;
    color: #6c757d;
    font-size: 14px;
}

/* Languages Grid */
.languages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 15px;
    background: white;
}

.language-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    font-size: 14px;
}

.language-option:hover {
    border-color: #4f46e5;
    background: #f8f9ff;
}

.language-option.selected {
    border-color: #4f46e5;
    background: #4f46e5;
    color: white;
}

.language-option input[type="checkbox"] {
    margin-right: 8px;
    accent-color: #4f46e5;
}

.language-option.selected input[type="checkbox"] {
    accent-color: white;
}

.language-name {
    font-weight: 500;
}

.language-code {
    font-size: 12px;
    opacity: 0.7;
    margin-left: auto;
}

/* Selected Languages Display */
.selected-languages {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 12px;
    min-height: 60px;
    font-size: 14px;
}

.selected-languages strong {
    color: #495057;
}

.selected-language-tag {
    display: inline-block;
    background: #4f46e5;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    margin: 2px;
    font-size: 12px;
}

/* Settings Actions */
.settings-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    padding-top: 20px;
    border-top: 1px solid #e1e5e9;
}

.save-btn, .cancel-btn {
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 120px;
}

.save-btn {
    background: #4f46e5;
    color: white;
    border: 1px solid #4f46e5;
}

.save-btn:hover {
    background: #3730a3;
    border-color: #3730a3;
}

.save-btn:disabled {
    background: #9ca3af;
    border-color: #9ca3af;
    cursor: not-allowed;
}

.cancel-btn {
    background: #9ca3af;
    color: white;
    border: 1px solid #9ca3af;
}

.cancel-btn:hover {
    background: #6b7280;
    border-color: #6b7280;
}

/* Settings Button */
.settings-btn {
    background: #6366f1;
    color: white;
    border: 1px solid #6366f1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.settings-btn:hover {
    background: #4f46e5;
    border-color: #4f46e5;
}

.recap-btn {
    background: #f59e0b;
    color: white;
    border: 1px solid #f59e0b;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.recap-btn:hover {
    background: #d97706;
    border-color: #d97706;
}

/* Settings Message */
.settings-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    display: none;
}

.settings-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.settings-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* History Settings Styles */
.history-settings-container {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #e1e5e9;
    margin-bottom: 30px;
}

.history-setting h3 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 1.2em;
}

.history-setting p {
    margin: 0 0 20px 0;
    color: #6c757d;
    font-size: 14px;
}

.retention-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.retention-option {
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.retention-option:hover {
    border-color: #4f46e5;
    background: #f8f9ff;
}

.retention-option input[type="radio"] {
    margin-right: 15px;
    accent-color: #4f46e5;
    transform: scale(1.2);
}

.retention-option:has(input:checked) {
    border-color: #4f46e5;
    background: #f8f9ff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}

.radio-label {
    font-weight: 500;
    font-size: 16px;
    color: #495057;
    margin-right: 10px;
}

.retention-option small {
    color: #6c757d;
    font-size: 12px;
    margin-left: auto;
}

.history-info {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #4f46e5;
}

.history-info p {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #495057;
}

.history-info ul {
    margin: 10px 0;
    padding-left: 20px;
    color: #6c757d;
}

.history-info li {
    margin: 5px 0;
    font-size: 13px;
}

/* Desktop responsiveness for main layout */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        margin: 0;
        border-radius: 10px;
    }
    
    .header {
        padding: 16px;
        gap: 12px;
    }
    
    .header-row-1 {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    
    .header-row-1 h1 {
        font-size: 1.5em;
    }
    
    .companion-text {
        font-size: 13px;
    }
    
    .user-welcome span {
        font-size: 14px;
    }
    
    .nav-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    
    .content {
        flex-direction: column;
        padding: 16px;
        gap: 16px;
    }
    
    .left-panel, .right-panel {
        flex: none;
        width: 100%;
    }
    
    .right-panel {
        min-height: 300px;
        padding: 16px;
    }
    
    .language-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .checkbox-group {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .session-info {
        font-size: 13px;
        padding: 8px;
    }
    
    /* Button layout adjustments */
    .recap-btn, .settings-btn, .logout-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .header {
        padding: 12px;
    }
    
    .header-row-1 h1 {
        font-size: 1.3em;
    }
    
    .content {
        padding: 12px;
    }
    
    .nav-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .language-options {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .checkbox-group {
        padding: 8px;
        font-size: 14px;
    }
    
    textarea {
        font-size: 16px;
        min-height: 120px;
    }
    
    .controls-row {
        gap: 10px;
    }
    
    .translate-btn, .listen-btn {
        padding: 12px;
        font-size: 13px;
    }
    
    .speaking-rate-select {
        font-size: 14px;
        padding: 8px;
    }
}

/* Responsive design for auth modal */
@media (max-width: 768px) {
    .auth-modal-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .auth-header h2 {
        font-size: 1.5em;
    }
    
    .auth-form h3 {
        font-size: 1.2em;
    }
    
    /* Responsive design for settings modal */
    .language-sets-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .languages-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    
    .settings-modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .settings-actions {
        flex-direction: column;
        align-items: center;
    }
}

/* Selected Texts Popup Styles */
.selected-texts-popup {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-width: 350px;
    max-height: 500px;
    overflow: hidden;
    font-family: system-ui, -apple-system, sans-serif;
}

.selected-texts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
    position: relative;
    cursor: move;
}

.selected-texts-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.popup-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.reload-popup-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reload-popup-btn:hover {
    background: #e9ecef;
    color: #333;
}

.reload-popup-btn:active {
    transform: rotate(45deg);
}

.close-popup-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-popup-btn:hover {
    background: #e9ecef;
    color: #333;
}

.selected-texts-content {
    max-height: 400px;
    overflow-y: auto;
}

.selected-texts-loading {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.selected-texts-loading .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.selected-texts-list {
    padding: 0;
}

.selected-text-item {
    border-bottom: 1px solid #e1e5e9;
    padding: 0;
}

.selected-text-item:last-child {
    border-bottom: none;
}

.selected-text-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
    line-height: 1.4;
}

.selected-text-title:hover {
    background: #f8f9fa;
}

.selected-text-content {
    padding: 0 20px 14px;
    font-size: 13px;
    line-height: 1.5;
    color: #555;
    display: none;
}

.selected-text-use-btn {
    background: #4f46e5;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-left: 8px;
}

.selected-text-use-btn:hover {
    background: #3730a3;
}

.selected-texts-empty {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.selected-texts-empty .empty-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.selected-texts-empty p {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.4;
}

/* Minimize button styles */
.minimize-popup-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.minimize-popup-btn:hover {
    background: #e9ecef;
    color: #333;
}

/* Delete button container styles */
.delete-button-container {
    padding: 8px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
}

.delete-selected-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}

.delete-selected-btn:hover {
    background: #c82333;
}

.delete-selected-btn:active {
    background: #bd2130;
}

/* Checkbox styles for selected texts */
.selected-text-checkbox {
    margin-right: 12px;
    transform: scale(1.1);
}

/* Minimized popup styles */
.selected-texts-popup.minimized {
    max-height: 60px;
    overflow: hidden;
}

.selected-texts-popup.minimized .selected-texts-content,
.selected-texts-popup.minimized .delete-button-container {
    display: none !important;
}

.selected-texts-popup.minimized .selected-texts-header {
    border-bottom: none;
}

.selected-texts-popup.minimized .minimize-popup-btn {
    font-size: 16px;
}

/* Stories Playground Popup Styles */
.stories-playground-popup {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 400px;
  max-height: 70vh;
  background: white;
  border: 2px solid #e1e5e9;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  overflow: hidden;
  transition: all 0.3s ease;
}

.stories-playground-popup.minimized {
  height: 50px;
  overflow: hidden;
}

.stories-playground-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e1e5e9;
  cursor: move;
}

.stories-playground-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.stories-playground-content {
  max-height: calc(70vh - 70px);
  overflow-y: auto;
  padding: 0;
}

.stories-playground-loading {
  padding: 40px 20px;
  text-align: center;
  color: #666;
}

.stories-playground-empty {
  padding: 40px 20px;
  text-align: center;
  color: #666;
}

.stories-playground-empty .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.stories-playground-list {
  padding: 0;
}

.story-playground-item {
  border-bottom: 1px solid #f0f0f0;
  padding: 0;
  margin: 0;
}

.story-playground-item:last-child {
  border-bottom: none;
}

.story-playground-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #f8f9fa;
  cursor: pointer;
  transition: background-color 0.2s;
}

.story-playground-title:hover {
  background: #e9ecef;
}

.story-playground-title-text {
  flex: 1;
  font-weight: 600;
  color: #333;
  margin-right: 12px;
}

.story-playground-use-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.story-playground-use-btn:hover {
  background: #5a67d8;
}

.story-playground-sentences {
  display: none;
  padding: 0;
  background: white;
}

.story-playground-sentence {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #f5f5f5;
  background: #fafbfc;
  transition: background-color 0.2s;
  cursor: pointer;
}

.story-playground-sentence:hover {
  background: #f0f2f5;
}

.story-playground-sentence:last-child {
  border-bottom: none;
}

.story-playground-sentence .sentence-delete-checkbox {
  margin-right: 12px;
}

.story-playground-actions {
  padding: 8px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e1e5e9;
}

.story-playground-actions .story-playground-delete-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.story-playground-actions .story-playground-delete-btn:hover {
  background: #c82333;
}

.story-playground-sentence-number {
  display: inline-block;
  min-width: 24px;
  font-weight: 600;
  color: #667eea;
  margin-right: 8px;
}

.story-playground-sentence-text {
  color: #333;
  line-height: 1.4;
}

.sentence-delete-checkbox {
  margin: 0;
  flex-shrink: 0;
}

.story-playground-sentence-use-btn {
  background: #059669;
  color: white;
  border: 1px solid #059669;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
  margin-left: auto;
  flex-shrink: 0;
}

.story-playground-sentence-use-btn:hover {
  background: #047857;
  border-color: #047857;
}

.story-playground-delete-btn {
  background: #dc2626;
  color: white;
  border: 1px solid #dc2626;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  margin-top: 8px;
  width: 100%;
}

.story-playground-delete-btn:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* Desktop responsiveness */
@media (max-width: 768px) {
  .stories-playground-popup {
    width: calc(100vw - 40px);
    top: 10px;
    left: 10px;

/* Shakti Notification Popup Styles */
.shakti-notification-popup {
  position: fixed;
  top: 20px;
  right: 20px;
  min-width: 300px;
  max-width: 500px;
  background: white;
  border: 2px solid #059669;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  transform: translateX(100%);
  transition: all 0.3s ease;
  overflow: hidden;
}

.shakti-notification-popup.show {
  transform: translateX(0);
}

.shakti-notification-popup.success {
  border-color: #059669;
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
}

.shakti-notification-popup.error {
  border-color: #dc2626;
  background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
}

.shakti-notification-popup.warning {
  border-color: #f59e0b;
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
}

.shakti-notification-popup.info {
  border-color: #3b82f6;
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
}

.shakti-notification-content {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 12px;
}

.shakti-notification-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.shakti-notification-popup.success .shakti-notification-icon {
  color: #059669;
}

.shakti-notification-popup.error .shakti-notification-icon {
  color: #dc2626;
}

.shakti-notification-popup.warning .shakti-notification-icon {
  color: #f59e0b;
}

.shakti-notification-popup.info .shakti-notification-icon {
  color: #3b82f6;
}

.shakti-notification-text {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .shakti-notification-popup {
    left: 10px;
    right: 10px;
    min-width: auto;
    max-width: none;
  }

  .stories-playground-popup {
    right: 10px;
    max-height: 80vh;
  }

  .stories-playground-content {
    max-height: calc(80vh - 70px);
  }
}

/* Centered Notification Animations */
@keyframes slideInCenter {
  from {
    opacity: 0;
    transform: translate(-50%, -60%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes slideOutCenter {
  from {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -40%);
  }
}

.centered-notification {
  /* Base styles - these should override any JavaScript inline styles */
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  padding: 15px 25px !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  z-index: 10001 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  max-width: 400px !important;
  text-align: center !important;
  animation: slideInCenter 0.3s ease-out !important;
  border: 2px solid !important;
  background-color: #d4edda !important; /* Default success color */
  color: #155724 !important; /* Default success text color */
  border-color: #c3e6cb !important; /* Default success border color */
} 