@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Outfit:wght@600;700;800&display=swap');

* {
    box-sizing: border-box;
}

:root {
    --bg: #f8fafc;
    --panel: #ffffff;
    --panel-2: #f1f5f9;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --success: #10b981;
    --success-bg: #dcfce7;
    --success-border: #bbf7d0;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-bg: #fee2e2;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
}

body {
    margin: 0;
    background: radial-gradient(circle at top right, #e0e7ff 0%, transparent 40%), var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
}

.app {
    min-height: 100vh;
}

.topbar {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5vw;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #ffffff;
    font-weight: 800;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.brand strong {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.brand span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.timer {
    min-width: 120px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: #ffffff;
    border-radius: 10px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

main {
    width: min(1300px, 92%);
    margin: auto;
    padding: 40px 0;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.hero {
    max-width: 720px;
    margin: 10px 0 36px;
}

.label {
    display: inline-block;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.hero h1 {
    margin: 10px 0 14px;
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: clamp(32px, 5vw, 54px);
    font-weight: 800;
    line-height: 1.1;
    color: var(--text);
    letter-spacing: -0.5px;
}

.hero p {
    color: var(--muted);
    font-size: 16px;
    line-height: 1.6;
}

.paper-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 22px;
}

.paper-card {
    padding: 28px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.paper-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
}

.paper-card h3 {
    margin: 12px 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.paper-card p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
    flex-grow: 1;
}

.paper-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 20px 0 24px;
}

.meta {
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: #475569;
    font-size: 12px;
    font-weight: 600;
}

.button {
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button.primary {
    color: #ffffff;
    background: var(--primary);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.button.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.button.secondary {
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border);
}

.button.secondary:hover {
    background: var(--panel-2);
    border-color: var(--border-hover);
}

.exam-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
}

.exam-main, .side-card, .question-card, .result-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.exam-main {
    padding: 32px;
}

.exam-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.exam-header h2 {
    margin: 4px 0 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.counter {
    color: var(--muted);
    font-weight: 600;
    font-size: 14px;
    background: var(--panel-2);
    padding: 6px 14px;
    border-radius: 9999px;
}

.question-card {
    padding: 32px;
    box-shadow: none;
    background: var(--panel-2);
    border-color: var(--border);
}

.question-number {
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
}

.question-text {
    margin: 14px 0 28px;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.6;
    color: var(--text);
}

.options {
    display: grid;
    gap: 12px;
}

.option {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 15px;
    color: var(--text);
}

.option:hover {
    border-color: var(--primary);
    background: rgba(240, 242, 254, 0.5);
}

.option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 1px var(--primary);
}

.option input {
    margin-top: 3px;
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

.navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 28px;
}

.exam-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.side-card {
    padding: 24px;
}

.side-card h3 {
    margin: 0 0 18px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.q-number {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    background: var(--panel-2);
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.q-number:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.q-number.current {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

.q-number.answered {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: #15803d;
}

.prediction {
    text-align: center;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    border-color: #c7d2fe;
}

.prediction span {
    display: block;
    color: #4338ca;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.prediction small {
    display: block;
    color: #3730a3;
    font-size: 13px;
    margin-top: 4px;
}

.prediction strong {
    display: block;
    margin: 8px 0;
    font-size: 38px;
    font-weight: 800;
    color: #1e1b4b;
}

.submit {
    width: 100%;
    color: #ffffff;
    background: var(--danger);
    padding: 14px;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.submit:hover {
    background: var(--danger-hover);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.result-card {
    max-width: 680px;
    margin: 40px auto;
    padding: 48px;
    text-align: center;
}

.result-card h1 {
    margin: 10px 0 18px;
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
}

.score {
    margin: 16px 0 28px;
    font-size: 72px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -1px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin: 28px 0;
}

.result-stat {
    padding: 18px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.result-stat strong {
    display: block;
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
}

.result-stat span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.prediction-result {
    margin: 24px 0 32px;
    padding: 24px;
    border: 1px solid #c7d2fe;
    border-radius: 16px;
    background: linear-gradient(135deg, #e0e7ff, #e0e7ff 50%, #c7d2fe);
    color: #3730a3;
}

.prediction-result strong {
    display: block;
    margin: 8px 0;
    font-size: 32px;
    font-weight: 800;
    color: #1e1b4b;
}

@media (max-width: 900px) {
    .exam-layout {
        grid-template-columns: 1fr;
    }

    .exam-sidebar {
        order: -1;
    }
}

@media (max-width: 600px) {
    main {
        width: 94%;
        padding: 24px 0;
    }

    .topbar {
        padding: 0 4%;
    }

    .hero h1 {
        font-size: 36px;
    }

    .question-card, .exam-main {
        padding: 20px;
    }

    .question-text {
        font-size: 18px;
    }

    .result-card {
        padding: 28px;
    }

    .score {
        font-size: 54px;
    }
}

/* Modal & Profile Pill */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.profile-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 9999px;
    box-shadow: var(--shadow-sm);
    font-size: 13px;
}

.profile-name {
    font-weight: 700;
    color: var(--text);
}

.profile-school {
    color: var(--muted);
    font-size: 12px;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edit-profile-btn {
    border: none;
    background: var(--primary-light);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 32px;
    width: min(480px, 100%);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
}

.modal-header p {
    margin: 6px 0 24px;
    color: var(--muted);
    font-size: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.form-group-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 12px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.form-group input {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.readonly-input {
    background: var(--panel-2);
    color: var(--muted);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 12px !important;
}

.full-width {
    width: 100%;
    margin-top: 10px;
}

/* Paper Search Bar */
.search-bar-wrap {
    margin-top: 20px;
}

.search-input {
    width: 100%;
    max-width: 460px;
    padding: 14px 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    font-size: 14px;
    outline: none;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Exam Header & Flag Button */
.exam-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.flag-btn {
    border: 1px solid var(--border);
    background: #ffffff;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.2s ease;
}

.flag-btn:hover {
    border-color: #f59e0b;
    color: #b45309;
    background: #fef3c7;
}

.flag-btn.active {
    border-color: #f59e0b;
    background: #fef3c7;
    color: #b45309;
}

.q-number.flagged {
    border-color: #f59e0b !important;
    background: #fef3c7 !important;
    color: #b45309 !important;
}

/* Topic Breakdown */
.topic-breakdown {
    margin: 24px 0;
    text-align: left;
}

.topic-breakdown h4 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.topic-card {
    background: var(--panel-2);
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.topic-card strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.topic-card small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

/* Review Section */
.review-container {
    max-width: 900px;
    margin: 0 auto;
}

.review-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.review-header h2 {
    margin: 4px 0 0;
    font-size: 24px;
    font-weight: 800;
}

.review-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.review-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.review-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.review-q-num {
    font-weight: 700;
    color: var(--primary);
    font-size: 13px;
}

.review-topic {
    font-size: 12px;
    background: var(--panel-2);
    padding: 4px 10px;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 500;
}

.review-q-text {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.5;
}

.review-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.review-opt {
    padding: 14px 18px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 14px;
    background: var(--panel-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.review-opt.correct-opt {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: #15803d;
    font-weight: 600;
}

.review-opt.user-wrong-opt {
    background: var(--danger-bg);
    border-color: #fecaca;
    color: #b91c1c;
    font-weight: 600;
}

.explanation-box {
    background: #e0e7ff;
    border: 1px solid #c7d2fe;
    border-radius: 10px;
    padding: 16px;
    color: #3730a3;
    font-size: 13px;
    line-height: 1.6;
}

.explanation-box strong {
    display: block;
    margin-bottom: 4px;
    font-weight: 700;
}

/* Student AI Prediction Card */
.student-prediction-card {
    background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
    color: #ffffff;
    border-radius: 20px;
    padding: 28px 32px;
    margin: 24px 0 36px;
    box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.3);
}

.pred-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 18px;
    margin-bottom: 18px;
}

.pred-card-head .label {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: none;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 1px;
}

.pred-card-head h3 {
    margin: 6px 0 0;
    font-size: 24px;
    font-weight: 800;
}

.pred-score-badge {
    text-align: right;
}

.pred-score-badge span {
    display: block;
    font-size: 36px;
    font-weight: 900;
    line-height: 1;
}

.pred-score-badge small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.85;
}

.pred-recommendation {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.pred-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    text-align: center;
}

.pred-stats-row div {
    background: rgba(255, 255, 255, 0.08);
    padding: 12px;
    border-radius: 10px;
}

.pred-stats-row strong {
    display: block;
    font-size: 20px;
    font-weight: 800;
}

.pred-stats-row small {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    opacity: 0.8;
}