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

body {
    font-family: 'Source Sans 3', 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 1040px;
    padding: 40px;
    position: relative;
}

.active-session {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 20px;
}

.active-session-main {
    flex: 1;
    min-width: 0;
}

.hint-sidebar {
    width: 280px;
    flex-shrink: 0;
    align-self: flex-start;
    position: sticky;
    top: 20px;
    background: #e7f3ff;
    border-left: 4px solid #2196F3;
    border-radius: 10px;
    padding: 16px;
    max-height: min(70vh, 520px);
    overflow-y: auto;
}

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

header h1 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1rem;
}

.timer-container {
    text-align: center;
    margin-bottom: 20px;
}

.timer {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 30px;
    border-radius: 30px;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.screen-title {
    color: #333;
    font-size: 1.4rem;
    margin-bottom: 20px;
    text-align: center;
}

.sections-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.section-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    text-align: left;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 16px;
    padding: 28px 24px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    font-family: inherit;
}

.section-card:hover {
    transform: translateY(-3px);
    border-color: #667eea;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.25);
}

.section-card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.section-card-description {
    font-size: 0.95rem;
    color: #666;
    line-height: 1.5;
}

.scenarios-status {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
}

.scenarios-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.scenario-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    text-align: left;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 14px;
    padding: 18px 20px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    font-family: inherit;
}

.scenario-card:hover {
    transform: translateY(-3px);
    border-color: #667eea;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.25);
}

.scenario-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
}

.scenario-card-setting {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

.back-button {
    background: none;
    border: none;
    color: #667eea;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 12px;
    font-family: inherit;
}

.back-button:hover {
    text-decoration: underline;
}

.start-container {
    text-align: center;
    padding: 60px 20px;
}

.start-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 18px 40px;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    font-weight: 600;
}

.start-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.start-button:active {
    transform: translateY(0);
}

.start-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.secondary-button {
    background: #f1f3f8;
    color: #333;
    border: 2px solid #d7dce8;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.15s, border-color 0.15s;
}

.secondary-button:hover {
    transform: translateY(-1px);
    border-color: #667eea;
}

.secondary-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.vocab-screen {
    text-align: center;
}

.vocab-scenario-label {
    color: #667eea;
    font-weight: 600;
    margin-bottom: 8px;
}

.vocab-instructions {
    color: #666;
    margin-bottom: 18px;
    line-height: 1.5;
}

.vocab-progress {
    color: #444;
    font-weight: 600;
    margin-bottom: 18px;
}

.vocab-current-card {
    background: #f8f9fa;
    border-radius: 16px;
    padding: 28px 20px;
    margin-bottom: 20px;
}

.vocab-word {
    font-family: 'Source Serif 4', 'Times New Roman', serif;
    font-size: clamp(2.2rem, 5vw, 3.2rem);
    font-weight: 700;
    font-optical-sizing: auto;
    color: #1f2430;
    margin-bottom: 10px;
    line-height: 1.25;
    letter-spacing: 0.01em;
    unicode-bidi: isolate;
}

.vocab-meaning {
    font-family: 'Source Sans 3', sans-serif;
    color: #5b6475;
    font-size: 1.15rem;
    margin-bottom: 16px;
}

.vocab-chip {
    border: 2px solid #d7dce8;
    background: white;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 1rem;
    font-family: 'Source Serif 4', serif;
    cursor: pointer;
    color: #2a3140;
    line-height: 1.3;
}

.vocab-status {
    min-height: 1.4em;
    margin-bottom: 10px;
    color: #2e7d32;
    font-weight: 600;
    font-size: 0.95rem;
}

.vocab-feedback {
    min-height: 1.4em;
    margin-bottom: 16px;
    color: #444;
    font-size: 0.95rem;
}

.vocab-feedback.success {
    color: #2e7d32;
    font-weight: 600;
}

.vocab-feedback.retry {
    color: #c62828;
}

.vocab-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.vocab-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 24px;
}

.vocab-chip.active {
    border-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

.vocab-chip.done {
    border-color: #4caf50;
    background: #e8f5e9;
    color: #2e7d32;
}

#vocab-continue-btn {
    margin-top: 8px;
}

.info-text {
    margin-top: 15px;
    color: #666;
    font-size: 0.95rem;
}

.scenario-container {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

.scenario-container h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

#scenario-text {
    color: #444;
    line-height: 1.6;
}

.conversation-container {
    margin-bottom: 20px;
}

.conversation-container h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.conversation-history {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 6px;
}

.message {
    padding: 14px 16px;
    border-radius: 15px;
    max-width: 85%;
    line-height: 1.45;
    font-size: 1rem;
    word-break: normal;
    overflow-wrap: anywhere;
    font-family: 'Source Serif 4', 'Times New Roman', serif;
}

.message .bilingual-line {
    margin-bottom: 0.7em;
}

.message .bilingual-line:last-child {
    margin-bottom: 0;
}

.message .spanish-text {
    display: block;
    font-weight: 700;
    font-size: 1.08em;
    line-height: 1.4;
    letter-spacing: 0.01em;
    font-optical-sizing: auto;
    unicode-bidi: isolate;
}

.message .gloss {
    display: block;
    margin-top: 0.2em;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.9em;
    font-style: italic;
    font-weight: 400;
    opacity: 0.78;
    line-height: 1.35;
}

.message-ai .gloss {
    opacity: 0.88;
}

.message-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message-user {
    background: #e9ecef;
    color: #1f2430;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

#hint-text .bilingual-line {
    margin-bottom: 0.55em;
}

#hint-text .bilingual-line:last-child {
    margin-bottom: 0;
}

#hint-text .spanish-text {
    display: block;
    font-family: 'Source Serif 4', serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: #1f2430;
    line-height: 1.4;
}

#hint-text .gloss {
    display: block;
    margin-top: 0.15em;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.9rem;
    font-style: italic;
    color: #5b6475;
}

.message-correction {
    background: #fff3cd;
    color: #856404;
    align-self: center;
    border-left: 4px solid #ffc107;
    max-width: 90%;
    font-size: 0.9rem;
}

.hint-header {
    font-weight: 600;
    color: #1976D2;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

#hint-text {
    color: #333;
    font-size: 0.95rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

.listening-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background: #e8f5e9;
    border-radius: 10px;
    margin-top: 20px;
}

.pulse {
    width: 12px;
    height: 12px;
    background: #4CAF50;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

.listening-indicator span {
    color: #2e7d32;
    font-weight: 600;
}

.mic-controls {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.mic-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 36px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    font-family: inherit;
}

.mic-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.mic-button:active {
    transform: translateY(0);
}

.mic-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.mic-button.recording {
    background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%);
    box-shadow: 0 4px 15px rgba(229, 57, 53, 0.4);
    animation: mic-pulse 1.5s ease-in-out infinite;
}

.mic-button.recording:hover {
    box-shadow: 0 6px 20px rgba(229, 57, 53, 0.6);
}

@keyframes mic-pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(229, 57, 53, 0.4);
    }
    50% {
        box-shadow: 0 4px 25px rgba(229, 57, 53, 0.7);
    }
}

.conversation-controls {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.conversation-controls .secondary-button.paused {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.completion-container {
    text-align: center;
    padding: 60px 20px;
}

.completion-message h2 {
    color: #333;
    margin-bottom: 15px;
}

.completion-message p {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.hidden {
    display: none !important;
}

/* Scrollbar styling */
.conversation-history::-webkit-scrollbar {
    width: 8px;
}

.conversation-history::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.conversation-history::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.conversation-history::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Responsive design */
@media (max-width: 768px) {
    .active-session {
        flex-direction: column;
    }

    .hint-sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    header h1 {
        font-size: 2rem;
    }

    .start-button {
        padding: 15px 30px;
        font-size: 1rem;
    }

    .message {
        max-width: 85%;
    }
}
