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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

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

body.auth-body {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

/* Navbar */
.navbar {
    background: var(--card-bg);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
}

.nav-links a:hover {
    color: var(--primary);
}

.nav-user {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.logout-form {
    display: inline;
}

.btn-link {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1rem;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Auth Pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-container {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.auth-container h1 {
    color: var(--primary);
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-weight: 500;
    color: var(--text-muted);
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-muted);
}

.auth-link a {
    color: var(--primary);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

.error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

textarea:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* Landing Page */
.landing-hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2rem;
    padding: 3rem;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(99, 102, 241, 0.08));
    position: relative;
    overflow: hidden;
}

.landing-hero::before,
.landing-hero::after {
    content: "";
    position: absolute;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.25) 0%, rgba(37, 99, 235, 0) 70%);
    z-index: 0;
}

.landing-hero::before {
    top: -120px;
    right: -80px;
}

.landing-hero::after {
    bottom: -140px;
    left: -80px;
}

.landing-hero-content,
.landing-hero-card {
    position: relative;
    z-index: 1;
}

.landing-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.landing-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-top: 1rem;
    max-width: 36rem;
}

.landing-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.landing-note {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.landing-hero-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    display: grid;
    gap: 1rem;
}

.landing-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.landing-metric:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.landing-metric-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.landing-metric-value {
    font-weight: 700;
}

.landing-callout {
    margin-top: 0.5rem;
    padding: 1rem;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 12px;
    font-size: 0.95rem;
}

.landing-callout-author {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.landing-section {
    margin-top: 3rem;
}

.landing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.landing-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.landing-steps {
    margin-top: 1rem;
    padding-left: 1.2rem;
    color: var(--text-muted);
}

.landing-steps li {
    margin-bottom: 0.75rem;
}

.landing-list {
    margin-top: 1rem;
    color: var(--text-muted);
    list-style: none;
    padding-left: 0;
}

.landing-list li {
    margin-bottom: 0.75rem;
    padding-left: 1.25rem;
    position: relative;
}

.landing-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--primary);
}

.landing-cta {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.16), rgba(15, 23, 42, 0.08));
    border-radius: 18px;
    padding: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.landing-cta p {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

@media (max-width: 720px) {
    .landing-hero {
        padding: 2rem;
    }

    .landing-cta {
        flex-direction: column;
        align-items: flex-start;
    }
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.alert-danger {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* Tier Info */
.tier-info {
    margin-bottom: 1rem;
}

.badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-card.highlight {
    border: 2px solid var(--warning);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.category-description {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.category-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.category-card h3 {
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.category-card p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.category-stats {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
    white-space: nowrap;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.category-card .btn {
    margin-top: 1rem;
    align-self: flex-start;
}

.untried-badge {
    background: var(--primary);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Breadcrumb */
.breadcrumb {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

/* Question List */
.question-list,
.questions-list,
.review-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.question-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.question-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.question-header h3 {
    margin: 0;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.question-preview {
    color: var(--text-muted);
    margin: 0;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.question-content h3 {
    margin-bottom: 0.25rem;
}

.question-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.category-tag {
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.badge-new {
    background: #e0f2fe;
    color: #0369a1;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.actions {
    margin-top: 1.5rem;
}

/* Score Badges */
.score-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.score-low {
    background: #fef2f2;
    color: var(--danger);
}

.score-mid {
    background: #fffbeb;
    color: var(--warning);
}

.score-high {
    background: #f0fdf4;
    color: var(--success);
}

.score-none {
    background: var(--bg);
    color: var(--text-muted);
}

/* Practice Page */
.practice-container {
    max-width: 800px;
}

.question-box {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.question-box h2 {
    margin-bottom: 1rem;
}

.question-text {
    font-size: 1.1rem;
    line-height: 1.8;
}

.hint-box {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.hint-box summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 500;
}

.hint-box p {
    margin-top: 0.5rem;
    color: var(--text-muted);
}

/* Result Page */
.result-container {
    max-width: 800px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.score-display {
    font-size: 2rem;
    font-weight: 700;
    padding: 1rem 2rem;
    border-radius: 8px;
}

.score-display.score-low {
    background: #fef2f2;
}

.score-display.score-mid {
    background: #fffbeb;
}

.score-display.score-high {
    background: #f0fdf4;
}

.score-number {
    font-size: 3rem;
}

.score-max {
    font-size: 1.5rem;
    opacity: 0.6;
}

.result-section {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.result-section h3 {
    margin-bottom: 0.75rem;
    color: var(--primary);
}

.user-answer {
    white-space: pre-wrap;
    background: var(--bg);
    padding: 1rem;
    border-radius: 4px;
}

.feedback-section {
    border-left: 4px solid var(--primary);
}

.feedback-content {
    line-height: 1.8;
}

.result-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Data Table */
.data-table {
    width: 100%;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
}

.data-table th {
    background: var(--bg);
    font-weight: 600;
}

.data-table tr:not(:last-child) td {
    border-bottom: 1px solid var(--border);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    background: var(--card-bg);
    border-radius: 8px;
}

.empty-state.success {
    background: #f0fdf4;
}

.empty-state h3 {
    color: var(--success);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    background: var(--card-bg);
    padding: 2rem 3rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-content p {
    color: var(--text);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.loading-content .loading-hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 400;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .question-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .question-meta {
        width: 100%;
        justify-content: space-between;
    }

    .result-header {
        flex-direction: column;
        gap: 1rem;
    }

    .result-actions {
        flex-direction: column;
    }

    .data-table {
        display: block;
        overflow-x: auto;
    }
}
