* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f7;
    display: flex;
    flex-direction: column;
    height: 100vh;
    color: #1a1a1a;
}

/* === HEADER === */
.header {
    background: linear-gradient(135deg, #4a6cf7, #6a4cf7);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(74, 108, 247, 0.3);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
}

.logo-icon { font-size: 24px; }

.header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* === CHAT === */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 15px;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    background: linear-gradient(135deg, #4a6cf7, #6a4cf7);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.ai {
    background: #f0f2f7;
    color: #1a1a1a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.system {
    background: #fff8e1;
    color: #a06800;
    align-self: center;
    font-size: 13px;
    text-align: center;
    max-width: 90%;
}

.typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f0f2f7;
    border-radius: 16px;
    align-self: flex-start;
    width: fit-content;
}

.typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* === QUICK ACTIONS === */
.quick-actions {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border-top: 1px solid #eee;
    overflow-x: auto;
}

.quick-btn {
    background: #f0f2f7;
    border: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    color: #4a6cf7;
    font-weight: 500;
}

.quick-btn:hover {
    background: #e0e5f5;
    transform: translateY(-1px);
}

/* === FORM === */
.chat-form {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: white;
    border-top: 1px solid #eee;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e5f5;
    border-radius: 24px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus { border-color: #4a6cf7; }

.send-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: linear-gradient(135deg, #4a6cf7, #6a4cf7);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    box-shadow: 0 4px 12px rgba(74, 108, 247, 0.3);
}

.send-btn:hover { transform: scale(1.05); }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === FOOTER === */
.footer {
    background: #f9fafb;
    padding: 8px 20px;
    text-align: center;
    font-size: 13px;
    color: #666;
    border-top: 1px solid #eee;
}

.grade-selector select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    font-size: 13px;
}

/* === TEST SCREEN === */
.hidden { display: none !important; }

.test-screen {
    position: fixed;
    inset: 0;
    background: #f0f2f7;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.test-header {
    background: linear-gradient(135deg, #4a6cf7, #6a4cf7);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.test-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
}

.test-body {
    flex: 1;
    padding: 24px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.test-question {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    color: #1a1a1a;
    white-space: pre-wrap;
}

.test-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.test-option {
    background: white;
    border: 2px solid #e0e5f5;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    color: #1a1a1a;
    font-family: inherit;
}

.test-option:hover {
    border-color: #4a6cf7;
    background: #f5f7ff;
}

.test-option.selected {
    border-color: #4a6cf7;
    background: #e8edff;
    font-weight: 600;
}

/* === MOBILE === */
@media (max-width: 600px) {
    .message {
        max-width: 85%;
        font-size: 14px;
    }
    .header-status span:not(.status-dot) { display: none; }
}
/* === HEADER RIGHT + CLEAR BUTTON === */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.clear-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.clear-btn:active {
    background: rgba(255, 255, 255, 0.4);
}