:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --text: #1a1a1a;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --error: #dc2626;
    --border: #e5e7eb;
    --radius: 8px;
    --claude: #d97706;
    --chatgpt: #10a37f;
    --gemini: #4285f4;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Top bar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar h1 { font-size: 1.25rem; }
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.topbar nav a { color: var(--primary); text-decoration: none; font-size: 0.9rem; }

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-container {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-container h1 { margin-bottom: 0.25rem; }
.subtitle { color: var(--muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* Forms */
.form-group { margin-bottom: 1rem; text-align: left; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.9rem; }
input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
}
textarea { resize: vertical; }

.checkbox-group { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.checkbox-label { display: flex; align-items: center; gap: 0.4rem; font-weight: normal; cursor: pointer; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-full { width: 100%; }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

/* Response grid */
.response-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}
.response-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.response-card.loading { opacity: 0.7; }
.provider-name { font-size: 1rem; margin-bottom: 0.25rem; }
.provider-claude { color: var(--claude); }
.provider-chatgpt { color: var(--chatgpt); }
.provider-gemini { color: var(--gemini); }
.response-text { margin-top: 0.75rem; font-size: 0.9rem; line-height: 1.7; }
.response-text h1, .response-text h2, .response-text h3 { margin: 0.75rem 0 0.25rem; font-size: 1rem; }
.response-text p { margin: 0.4rem 0; }
.response-text ul, .response-text ol { margin: 0.4rem 0; padding-left: 1.5rem; }
.response-text code { background: #f1f5f9; padding: 0.15rem 0.35rem; border-radius: 3px; font-size: 0.85em; }
.response-text pre { background: #f1f5f9; padding: 0.75rem; border-radius: var(--radius); overflow-x: auto; margin: 0.5rem 0; }
.response-text pre code { background: none; padding: 0; }
.response-text blockquote { border-left: 3px solid var(--border); padding-left: 0.75rem; color: var(--muted); margin: 0.5rem 0; }
.response-text table { border-collapse: collapse; margin: 0.5rem 0; width: 100%; }
.response-text th, .response-text td { border: 1px solid var(--border); padding: 0.35rem 0.5rem; text-align: left; font-size: 0.85rem; }
.response-text th { background: #f8fafc; }
.error-text { color: var(--error); }

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* History */
.history-list { display: flex; flex-direction: column; gap: 0.75rem; }
.history-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.history-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.question-preview { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.75rem; }
.question-display { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.5rem; }

/* Save section */
.save-section { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* Image upload */
.upload-row { display: flex; align-items: center; gap: 0.75rem; }
.btn-upload { cursor: pointer; }
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1rem; transition: border-color 0.2s, background 0.2s; }
.drop-zone.drop-active { border-color: var(--primary); background: #eff6ff; }
.drop-hint { margin-top: 0.5rem; text-align: center; }
.image-preview { max-width: 100%; display: block; }
.cropper-wrap { height: 400px; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border); }
#image-preview-wrap,
#student-image-preview-wrap { margin-top: 0.5rem; }
.crop-hint { margin: 0.5rem 0 0.25rem; font-style: italic; }
.crop-controls { display: flex; gap: 0.5rem; margin: 0.5rem 0; }
#image-preview-wrap input[type="text"] { margin-bottom: 0.5rem; }
#image-preview-wrap .btn { margin-right: 0.5rem; }
#extract-status { margin-top: 0.5rem; }

/* Synthesize */
.synthesize-section { margin: 1.5rem 0; text-align: center; }
.synthesis-card { border: 2px solid var(--primary); background: #f8faff; }
.provider-synthesis { color: var(--primary); }

/* Check student answer */
.check-section { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.check-card { border: 2px solid #f59e0b; background: #fffbeb; }
.provider-check { color: #d97706; }

/* Card actions */
.card-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.btn-icon { display: inline-flex; align-items: center; gap: 0.3rem; }

/* Settings */
.settings-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.settings-section h3 { margin-bottom: 0.75rem; }
.key-status { font-size: 0.8rem; margin-left: 0.5rem; font-weight: 600; }
.key-status.configured { color: #16a34a; }
.key-status.not-configured { color: var(--muted); }

/* Tabs */
.tab-bar { display: flex; gap: 0; margin-bottom: 1.5rem; border-bottom: 2px solid var(--border); }
.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Bottom reset */
.bottom-reset { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* Section divider */
.section-divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* Quick check progress */
#quick-progress .progress-step { padding: 0.25rem 0; font-size: 0.9rem; }
#quick-progress .progress-step.done { color: #16a34a; }

/* Utilities */
.muted { color: var(--muted); font-size: 0.85rem; }
h2 { margin-bottom: 1rem; }

@media (max-width: 600px) {
    .response-grid { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; gap: 0.5rem; }
    .tab-btn { padding: 0.6rem 1rem; font-size: 0.9rem; }
}
