/* ── Variables ── */
:root {
    --bg: #F7F6F2;
    --surface: #FFFFFF;
    --border: #E4E2DB;
    --text: #1A1A1A;
    --text-muted: #6B6860;
    --accent: #2A5C45;
    --accent-light: #EAF2EE;
    --accent-hover: #1E4433;
    --correct: #1E7145;
    --correct-bg: #EAF5EF;
    --error: #C0392B;
    --error-bg: #FDEDEB;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 2px 8px rgba(0,0,0,0.08), 0 16px 48px rgba(0,0,0,0.1);
}

/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

/* ── Navbar ── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 40px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.brand-icon {
    font-size: 22px;
    color: var(--accent);
}

.brand-name {
    font-family: 'DM Serif Display', serif;
    font-size: 22px;
    letter-spacing: -0.3px;
}

.nav-tagline {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Main ── */
.main-content {
    flex: 1;
    padding: 60px 20px 80px;
}

/* ── Upload Page ── */
.upload-page {
    max-width: 560px;
    margin: 0 auto;
}

.hero {
    text-align: center;
    margin-bottom: 40px;
}

.hero-title {
    font-family: 'DM Serif Display', serif;
    font-size: 44px;
    line-height: 1.15;
    letter-spacing: -1px;
    color: var(--text);
    margin-bottom: 14px;
}

    .hero-title em {
        font-style: italic;
        color: var(--accent);
    }

.hero-sub {
    font-size: 17px;
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Alert */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #F5C6C2;
}

.alert-icon {
    font-size: 16px;
}

/* ── Upload Card ── */
.upload-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 24px;
}

    .drop-zone:hover,
    .drop-zone.drag-over {
        border-color: var(--accent);
        background: var(--accent-light);
    }

.file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.drop-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.drop-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.drop-sub {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.browse-link {
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}

.drop-hint {
    font-size: 12px;
    color: #AAA8A0;
}

/* Selected file state */
.drop-zone-selected {
    text-align: center;
}

.file-icon {
    width: 48px;
    height: 48px;
    background: var(--correct-bg);
    color: var(--correct);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    margin: 0 auto 12px;
}

.file-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    word-break: break-all;
}

.file-size {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.remove-file {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    position: relative;
    z-index: 3;
    transition: border-color 0.2s, color 0.2s;
}

    .remove-file:hover {
        border-color: var(--error);
        color: var(--error);
    }

/* Options Row */
.options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.option-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.step-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    transition: background 0.15s;
}

    .step-btn:hover {
        background: var(--bg);
    }

.step-input {
    width: 48px;
    height: 36px;
    border: none;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    -moz-appearance: textfield;
}

    .step-input::-webkit-outer-spin-button,
    .step-input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

/* Generate Button */
.btn-generate {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
}

    .btn-generate:hover {
        background: var(--accent-hover);
    }

    .btn-generate:active {
        transform: scale(0.99);
    }

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

.btn-arrow {
    font-size: 18px;
}

/* Features Row */
.features-row {
    display: flex;
    justify-content: center;
    gap: 28px;
    margin-top: 28px;
    flex-wrap: wrap;
}

.feature {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--text-muted);
}

.feat-icon {
    font-size: 15px;
}

/* ── Loading Overlay ── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(247, 246, 242, 0.92);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-box {
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 56px;
    box-shadow: var(--shadow-lg);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-title {
    font-family: 'DM Serif Display', serif;
    font-size: 22px;
    margin-bottom: 6px;
}

.loading-sub {
    font-size: 14px;
    color: var(--text-muted);
}

/* ── Results Page ── */
.results-page {
    max-width: 740px;
    margin: 0 auto;
}

.results-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 36px;
    gap: 16px;
    flex-wrap: wrap;
}

.back-link {
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    padding-top: 6px;
    white-space: nowrap;
}

    .back-link:hover {
        color: var(--accent);
    }

.results-meta {
    flex: 1;
}

.results-title {
    font-family: 'DM Serif Display', serif;
    font-size: 34px;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.results-sub {
    font-size: 14px;
    color: var(--text-muted);
}

.btn-print {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s;
}

    .btn-print:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

/* Question Cards */
.questions-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    box-shadow: var(--shadow);
    animation: fadeUp 0.35s ease both;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.question-card:nth-child(1) {
    animation-delay: 0.05s;
}

.question-card:nth-child(2) {
    animation-delay: 0.10s;
}

.question-card:nth-child(3) {
    animation-delay: 0.15s;
}

.question-card:nth-child(4) {
    animation-delay: 0.20s;
}

.question-card:nth-child(5) {
    animation-delay: 0.25s;
}

.question-card:nth-child(6) {
    animation-delay: 0.30s;
}

.question-card:nth-child(7) {
    animation-delay: 0.35s;
}

.question-card:nth-child(8) {
    animation-delay: 0.40s;
}

.question-card:nth-child(9) {
    animation-delay: 0.45s;
}

.question-card:nth-child(10) {
    animation-delay: 0.50s;
}

.question-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
}

.question-number {
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
    letter-spacing: 0.3px;
}

.question-text {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.55;
    color: var(--text);
}

/* Options */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    transition: border-color 0.15s;
}

.option-correct {
    border-color: var(--correct);
    background: var(--correct-bg);
}

.option-letter {
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    color: var(--text-muted);
}

.option-correct .option-letter {
    border-color: var(--correct);
    background: var(--correct);
    color: #fff;
}

.option-text {
    font-size: 14px;
    flex: 1;
    line-height: 1.45;
}

.option-tick {
    color: var(--correct);
    font-weight: 700;
    font-size: 16px;
    margin-left: auto;
}

/* Explanation */
.explanation {
    background: #FDFBF6;
    border: 1px solid #EDE9DC;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    font-size: 13.5px;
    color: var(--text-muted);
    line-height: 1.6;
}

.explanation-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #B5A890;
    margin-bottom: 6px;
}

/* Results Footer */
.results-footer {
    text-align: center;
    margin-top: 40px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 13px 28px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

    .btn-secondary:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: #BBB9B2;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* ── Print ── */
@media print {
    .navbar, .results-header .back-link, .btn-print, .results-footer, .footer {
        display: none;
    }

    .question-card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .option-correct {
        background: #f0f0f0 !important;
    }
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .navbar {
        padding: 14px 20px;
    }

    .nav-tagline {
        display: none;
    }

    .hero-title {
        font-size: 32px;
    }

    .upload-card {
        padding: 24px 20px;
    }

    .question-card {
        padding: 20px;
    }

    .results-title {
        font-size: 26px;
    }
}

/* ── Nav Links ── */
.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 7px 16px;
    border-radius: 20px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

    .nav-link:hover,
    .nav-link-active {
        color: var(--accent);
        border-color: var(--accent-light);
        background: var(--accent-light);
    }

/* ── Extract button color ── */
.btn-extract {
    background: #1A4A7A;
}

    .btn-extract:hover {
        background: #133A62;
    }

/* ── Extract info grid ── */
.extract-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.info-icon {
    font-size: 15px;
}

/* ── Type summary badges ── */
.type-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.type-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
}

    .type-badge.type-mcq {
        background: #EEF2FF;
        color: #3730A3;
        border-color: #C7D2FE;
    }

    .type-badge.type-truefalse {
        background: #FEF9C3;
        color: #854D0E;
        border-color: #FDE68A;
    }

    .type-badge.type-fillintheblanks {
        background: #ECFDF5;
        color: #065F46;
        border-color: #A7F3D0;
    }

    .type-badge.type-shortanswer {
        background: #FFF7ED;
        color: #9A3412;
        border-color: #FED7AA;
    }

/* ── Question type tag ── */
.question-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.question-type-tag {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.question-type-mcq .question-type-tag {
    background: #EEF2FF;
    color: #3730A3;
    border-color: #C7D2FE;
}

.question-type-truefalse .question-type-tag {
    background: #FEF9C3;
    color: #854D0E;
    border-color: #FDE68A;
}

.question-type-fillintheblanks .question-type-tag {
    background: #ECFDF5;
    color: #065F46;
    border-color: #A7F3D0;
}

.question-type-shortanswer .question-type-tag {
    background: #FFF7ED;
    color: #9A3412;
    border-color: #FED7AA;
}

/* ── True / False options ── */
.tf-options {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.tf-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    background: var(--bg);
    flex: 1;
    justify-content: center;
}

    .tf-option.option-correct {
        border-color: var(--correct);
        background: var(--correct-bg);
        color: var(--correct);
    }

/* ── Fill in the blank answer ── */
.fill-text {
    font-size: 16px;
    line-height: 1.8;
    letter-spacing: 0.1px;
}

.blank-answer {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px 18px;
    background: var(--correct-bg);
    border: 1px solid #A7F3D0;
    border-radius: var(--radius-sm);
}

.blank-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--correct);
}

.blank-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--correct);
}

/* ── Short answer ── */
.short-answer {
    margin-top: 12px;
    padding: 14px 18px;
    background: #FFF7ED;
    border: 1px solid #FED7AA;
    border-radius: var(--radius-sm);
}

.answer-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #9A3412;
    margin-bottom: 6px;
}

.answer-text {
    font-size: 14px;
    color: #7C2D12;
    line-height: 1.6;
}

/* ── No answer note ── */
.no-answer-note {
    font-size: 12px;
    color: #AAA8A0;
    font-style: italic;
    margin-top: 8px;
}

/* ── AI / Pure badges ── */
.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.badge-ai {
    background: #EEF2FF;
    color: #3730A3;
    border: 1px solid #C7D2FE;
}

.badge-pure {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

/* ── Other text notice ── */
.other-text-notice {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 24px;
    font-size: 13.5px;
    color: #92400E;
    line-height: 1.6;
}

.other-text-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.other-text-notice strong {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
}

/* ── Match table ── */
.match-table-wrapper {
    margin: 12px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.match-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

    .match-table thead tr {
        background: var(--accent);
    }

    .match-table thead th {
        color: #fff;
        font-weight: 600;
        padding: 10px 16px;
        text-align: left;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .match-table tbody tr:nth-child(even) {
        background: var(--bg);
    }

    .match-table tbody tr:nth-child(odd) {
        background: var(--surface);
    }

    .match-table tbody td {
        padding: 10px 16px;
        border-top: 1px solid var(--border);
        color: var(--text);
    }
