* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-bg: #ffffff;
    --secondary-bg: #f7f7f7;
    --tertiary-bg: #ececf1;
    --text-primary: #0d0d0d;
    --text-secondary: #565869;
    --border-color: #d1d5db;
    --user-bg: #10a37f;
    --assistant-bg: #f4f4f7;
    --correct-color: #10b981;
    --incorrect-color: #ef4444;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-primary);
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--primary-bg);
}

/* Header */
.header {
    padding: 16px 24px;
    background-color: var(--primary-bg);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.header p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Start Screen */
#startScreen {
    align-items: center;
    justify-content: center;
}

.welcome-message {
    text-align: center;
    margin-bottom: 40px;
}

.welcome-message h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 16px;
    color: var(--text-secondary);
}

.start-button {
    padding: 12px 32px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background-color: var(--user-bg);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.start-button:hover {
    background-color: #0d8763;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.start-button:active {
    transform: scale(0.98);
}

/* Chat Screen */
#chatScreen {
    padding: 24px;
}

.chat-log {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.message {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.assistant {
    justify-content: flex-start;
}

.message.assistant .message-content {
    background-color: var(--assistant-bg);
    color: var(--text-primary);
    max-width: 70%;
}

.message.user {
    justify-content: flex-end;
}

.message.user .message-content {
    background-color: var(--user-bg);
    color: white;
    max-width: 70%;
}

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 15px;
}

.message.user .message-content {
    border-bottom-right-radius: 2px;
}

.message.assistant .message-content {
    border-bottom-left-radius: 2px;
}

/* Feedback Message */
.feedback-message {
    padding: 12px 16px;
    border-radius: 12px;
    background-color: var(--assistant-bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    border-left: 4px solid;
}

.feedback-message.correct {
    border-left-color: var(--correct-color);
    background-color: #f0fdf4;
}

.feedback-message.incorrect {
    border-left-color: var(--incorrect-color);
    background-color: #fef2f2;
}

.feedback-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 15px;
}

.feedback-score {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.answer-comparison {
    margin-top: 10px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
    font-size: 13px;
}

.comparison-item {
    margin-bottom: 8px;
}

.comparison-item:last-child {
    margin-bottom: 0;
}

.comparison-item strong {
    color: var(--text-primary);
}

.missing-words, .extra-words {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

/* Auth Screen */
#authScreen {
    justify-content: center;
    align-items: center;
}

.auth-container {
    background-color: var(--primary-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.auth-container h2 {
    margin-bottom: 24px;
    color: var(--text-primary);
}

.auth-container input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background-color: var(--primary-bg);
    color: var(--text-primary);
}

.auth-container input:focus {
    outline: none;
    border-color: var(--user-bg);
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}

.auth-button {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--user-bg);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.auth-button:hover:not(:disabled) {
    background-color: #0d8763;
}

.auth-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-toggle {
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-toggle a {
    color: var(--user-bg);
    text-decoration: none;
    cursor: pointer;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

/* Auth Info in Header */
.auth-info {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-info.hidden {
    display: none;
}

.logout-button {
    padding: 6px 12px;
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-button:hover {
    background-color: #dc2626;
}

/* Dashboard Screen */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.dashboard-container h2 {
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 28px;
}

.dashboard-container h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-size: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-card {
    padding: 24px;
    background-color: var(--assistant-bg);
    border-radius: 8px;
    border-left: 4px solid var(--user-bg);
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--user-bg);
    margin-bottom: 8px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Question List */
.question-list {
    margin-bottom: 20px;
}

#questionStats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.question-stat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 14px;
    background-color: var(--secondary-bg);
    border-radius: 6px;
    font-size: 12px;
    border-left: 3px solid #d1d5db;
    min-height: 90px;
    text-align: center;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.question-stat:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.question-stat span:first-child {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.question-stat span:last-child {
    font-weight: 500;
    font-size: 11px;
}

.question-stat.mastered {
    border-left-color: var(--correct-color);
    background-color: #f0fdf4;
}

.question-stat.mastered span:last-child {
    color: var(--correct-color);
    font-weight: 600;
}

.question-stat.struggling {
    border-left-color: var(--incorrect-color);
    background-color: #fef2f2;
}

.question-stat.struggling span:last-child {
    color: var(--incorrect-color);
    font-weight: 600;
}

.question-stat.needs-practice {
    border-left-color: #f59e0b;
    background-color: #fffbeb;
}

.question-stat.needs-practice span:last-child {
    color: #f59e0b;
    font-weight: 600;
}

.stat-not-attempted {
    color: var(--text-secondary);
    font-style: italic;
}

.dashboard-button {
    padding: 12px 32px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background-color: var(--user-bg);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dashboard-button:hover {
    background-color: #0d8763;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dashboard-button:active {
    transform: scale(0.98);
}

/* Image Button */
.image-button {
    background-color: transparent;
    border: 2px solid var(--user-bg);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-button:hover {
    box-shadow: 0 4px 12px rgba(16, 163, 127, 0.2);
    transform: scale(1.05);
}

.image-button-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 6px;
}

/* Home Button */
#homeBtn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    padding: 10px 24px;
    background-color: var(--user-bg);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#homeBtn:hover {
    background-color: #0d8763;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#homeBtn:active {
    transform: scale(0.98);
}

.input-area.hidden {
    display: none;
}

.input-container {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.answer-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    background-color: var(--primary-bg);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    min-height: 48px;
    max-height: 200px;
    transition: all 0.2s;
}

.answer-input:focus {
    outline: none;
    border-color: var(--user-bg);
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}

.answer-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--secondary-bg);
}

.answer-input::placeholder {
    color: var(--text-secondary);
}

.button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.send-button, .hint-button, .tell-button, .next-button {
    padding: 10px 16px;
    background-color: var(--user-bg);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    white-space: nowrap;
    height: 42px;
}

.send-button {
    background-color: #10a37f;
}

.send-button:hover:not(:disabled) {
    background-color: #0d8763;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.hint-button {
    background-color: #3b82f6;
}

.hint-button:hover:not(:disabled) {
    background-color: #2563eb;
}

.tell-button {
    background-color: #f59e0b;
}

.tell-button:hover:not(:disabled) {
    background-color: #d97706;
}

.next-button {
    background-color: #8b5cf6;
}

.next-button:hover:not(:disabled) {
    background-color: #7c3aed;
}

.send-button:disabled,
.hint-button:disabled,
.tell-button:disabled,
.next-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

/* Scrollbar */
.main-content::-webkit-scrollbar {
    width: 8px;
}

.main-content::-webkit-scrollbar-track {
    background-color: var(--secondary-bg);
}

.main-content::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary);
}

/* Multiple Choice Screen */
.mc-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
    position: relative;
    min-height: 100vh;
}

.mc-question {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 32px;
    padding: 20px;
    background-color: var(--assistant-bg);
    border-radius: 8px;
    border-left: 4px solid var(--user-bg);
}

.mc-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 100px;
}

.mc-option {
    padding: 16px;
    background-color: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
    color: var(--text-primary);
    text-align: left;
}

.mc-option:hover {
    border-color: var(--user-bg);
    background-color: rgba(16, 163, 127, 0.05);
}

.mc-option.selected {
    border-color: var(--user-bg);
    background-color: rgba(16, 163, 127, 0.2);
    font-weight: 600;
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.3);
}

.mc-option.correct {
    border-color: var(--correct-color);
    background-color: #f0fdf4;
}

.mc-option.incorrect {
    border-color: var(--incorrect-color);
    background-color: #fef2f2;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

#mcHomeBtn {
    position: absolute;
    bottom: 20px;
    right: 20px;
}

.mc-submit-button {
    margin-top: 24px;
    padding: 12px 32px;
    background-color: #10a37f;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
}

.mc-submit-button:hover:not(:disabled) {
    background-color: #0d8763;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mc-submit-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mc-feedback {
    margin-top: 32px;
    padding: 20px;
    background-color: #f0fdf4;
    border: 2px solid #10b981;
    border-radius: 8px;
}

.mc-feedback.hidden {
    display: none;
}

.feedback-content {
    text-align: center;
}

.feedback-title {
    font-size: 20px;
    font-weight: 700;
    color: #10b981;
    margin-bottom: 12px;
}

.feedback-text {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.feedback-score {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.mc-next-button {
    padding: 12px 32px;
    background-color: #10a37f;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
}

.mc-next-button:hover {
    background-color: #0d8763;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .message.assistant .message-content,
    .message.user .message-content {
        max-width: 85%;
    }

    .header h1 {
        font-size: 20px;
    }

    .welcome-message h2 {
        font-size: 24px;
    }

    .screen {
        padding: 16px;
    }

    .input-container {
        flex-direction: column;
        gap: 8px;
    }

    .send-button {
        width: 100%;
        align-self: stretch;
    }
}

/* Admin Panel */
.admin-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.admin-container h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.admin-form {
    background-color: var(--primary-bg);
    padding: 20px;
    border-radius: 8px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

.admin-input,
.admin-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--primary-bg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
}

.admin-textarea {
    min-height: 120px;
    resize: vertical;
}

.admin-input:focus,
.admin-textarea:focus {
    outline: none;
    border-color: var(--user-bg);
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}

.admin-status {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
}

.admin-status.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.admin-status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

@media (max-width: 480px) {
    .container {
        height: 100vh;
    }

    .message.assistant .message-content,
    .message.user .message-content {
        max-width: 90%;
    }

    .message-content {
        font-size: 14px;
        padding: 10px 12px;
    }

    .header {
        padding: 12px 16px;
    }

    .header h1 {
        font-size: 18px;
    }

    .header p {
        font-size: 12px;
