/* =============================================
   USPI Immobase — Swiss Editorial Stylesheet
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --ink: #0a0a0a;
    --ink-soft: #2a2a2a;
    --paper: #fafaf7;
    --paper-tint: #f0eee9;
    --rule: #1a1a1a;
    --rule-soft: #d0cec8;
    --accent: #8B0000;
    --accent-soft: #a52828;
    --muted: #6a6a6a;
    --highlight: #f4e8e0;
}

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

body {
    font-family: "Inter", -apple-system, sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
}

h1, h2, h3, h4 {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1.15;
}

h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; font-weight: 600; }

p {
    font-size: 1.05rem;
    color: var(--ink-soft);
    line-height: 1.6;
}

em, .italic { font-style: italic; }

a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid currentColor;
    transition: color 0.15s;
}
a:hover { color: var(--ink); }
a.no-underline, .nav-link { border-bottom: none; }

/* ============ TYPOGRAPHY UTILS ============ */
.label {
    font-family: "Inter", sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--muted);
}

.mono {
    font-family: "JetBrains Mono", "SF Mono", monospace;
    font-feature-settings: "tnum";
}

.section-number {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    display: block;
}

.rule {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 0;
}
.rule-soft {
    border: none;
    border-top: 1px solid var(--rule-soft);
    margin: 0;
}

/* ============ MASTHEAD (Header) ============ */
.masthead {
    border-bottom: 2px solid var(--ink);
    background: var(--paper);
}

.masthead-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 18px 32px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 30px;
}

.masthead-brand {
    font-family: "Playfair Display", serif;
    font-weight: 900;
    font-size: 1.3rem;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.masthead-brand .accent {
    color: var(--accent);
    font-style: italic;
}

.masthead-title {
    text-align: center;
    border-left: 1px solid var(--rule-soft);
    border-right: 1px solid var(--rule-soft);
    padding: 0 24px;
}
.masthead-title .label {
    display: block;
}
.masthead-title h1 {
    font-size: 1.1rem;
    font-weight: 400;
    font-style: italic;
    margin-top: 2px;
}

.masthead-nav {
    display: flex;
    gap: 20px;
}
.masthead-nav a {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: none;
}
.masthead-nav a:hover { color: var(--accent); }

/* ============ MAIN CONTAINER ============ */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 50px 32px;
}

/* ============ HERO (Editorial style) ============ */
.hero {
    text-align: center;
    padding: 60px 0 50px;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 50px;
}

.hero .section-number {
    color: var(--muted);
}

.hero h1 {
    max-width: 800px;
    margin: 0 auto 20px;
}

.hero .subtitle {
    font-size: 1.15rem;
    color: var(--muted);
    max-width: 600px;
    margin: 0 auto 35px;
    font-style: italic;
}

.hero-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    font-family: "Inter", sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-decoration: none;
    border: 1.5px solid var(--ink);
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover {
    background: var(--ink);
    color: var(--paper);
}
.btn-accent {
    background: var(--accent);
    color: var(--paper);
    border-color: var(--accent);
}
.btn-accent:hover {
    background: var(--ink);
    border-color: var(--ink);
}
.btn-outline {
    border-color: var(--ink);
}

/* ============ STATS / DASHBOARD (editorial) ============ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    margin-bottom: 60px;
}

.stat-cell {
    padding: 28px 20px;
    border-right: 1px solid var(--rule-soft);
    text-align: center;
}
.stat-cell:last-child { border-right: none; }

.stat-number {
    font-family: "Playfair Display", serif;
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
    margin-bottom: 6px;
}
.stat-cell.accent .stat-number {
    color: var(--accent);
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted);
}

/* ============ SECTIONS ============ */
.section {
    margin-bottom: 60px;
}

.section-header {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 20px;
    align-items: baseline;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--ink);
    margin-bottom: 30px;
}
.section-header .section-number {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0;
}
.section-header h2 {
    margin: 0;
}

/* ============ MODULES GRID (editorial) ============ */
.branches-list {
    display: flex;
    flex-direction: column;
    gap: 35px;
}

.branch-group {
    border-top: 1px solid var(--rule);
    padding-top: 24px;
}

.branch-title {
    font-family: "Inter", sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--accent);
    margin-bottom: 18px;
}
.branch-title .count {
    color: var(--muted);
    font-weight: 400;
    margin-left: 8px;
}

.modules-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0;
    border-left: 1px solid var(--rule-soft);
}

.module-card {
    border-right: 1px solid var(--rule-soft);
    border-bottom: 1px solid var(--rule-soft);
    padding: 22px 18px;
    background: var(--paper);
    color: var(--ink);
    text-decoration: none;
    transition: background 0.15s;
    display: block;
}
.module-card:hover {
    background: var(--highlight);
    color: var(--ink);
}
.module-card .module-name {
    font-family: "Playfair Display", serif;
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1.3;
    margin-bottom: 8px;
    color: var(--ink);
}
.module-card .module-meta {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.45;
}

/* ============ MODULE PAGE ============ */
.module-hero {
    padding: 40px 0;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 40px;
}
.module-hero .label { color: var(--muted); margin-bottom: 8px; display: block; }
.module-hero h1 { margin-bottom: 12px; }
.module-hero .module-info {
    display: flex;
    gap: 24px;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--muted);
}
.module-hero .module-info strong {
    color: var(--ink);
    font-weight: 600;
}

.qcm-list {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--rule);
}

.qcm-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 24px;
    align-items: center;
    padding: 24px 0;
    border-bottom: 1px solid var(--rule-soft);
    cursor: pointer;
    transition: padding 0.15s;
}
.qcm-item:hover {
    padding-left: 12px;
}

.qcm-item .qcm-num {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent);
}

.qcm-item .qcm-content h3 {
    font-size: 1.15rem;
    margin-bottom: 4px;
    font-family: "Playfair Display", serif;
    font-weight: 700;
}
.qcm-item .qcm-content .qcm-desc {
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
}

.qcm-item .qcm-action {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ============ QUIZ INTERFACE ============ */
.quiz-app {
    background: var(--paper);
    padding: 40px;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}

.quiz-header {
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--rule-soft);
}
.quiz-title {
    font-family: "Playfair Display", serif;
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.quiz-subtitle {
    font-size: 0.92rem;
    color: var(--muted);
    font-style: italic;
}

.quiz-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 18px;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.78rem;
    color: var(--muted);
    flex-wrap: wrap;
    gap: 10px;
}
.quiz-meta .quiz-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.quiz-meta .quiz-stat .value {
    color: var(--ink);
    font-weight: 600;
}
#quiz-timer.warn { color: var(--accent-soft); }
#quiz-timer.urgent { color: var(--accent); font-weight: 700; }

.quiz-keyboard-hint {
    display: flex;
    gap: 14px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--rule-soft);
    font-size: 0.72rem;
    color: var(--muted);
    flex-wrap: wrap;
    align-items: center;
}
.quiz-keyboard-hint kbd {
    display: inline-block;
    padding: 2px 7px;
    background: var(--paper);
    border: 1px solid var(--ink);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.7rem;
    color: var(--ink);
    margin: 0 2px;
}

/* Progress bar (thin editorial line) */
.quiz-progress {
    height: 2px;
    background: var(--rule-soft);
    margin-bottom: 30px;
    position: relative;
}
.quiz-progress-fill {
    height: 100%;
    background: var(--ink);
    transition: width 0.3s;
}

/* Resume banner */
.resume-banner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 20px;
    align-items: center;
    padding: 20px 24px;
    background: var(--paper-tint);
    border: 1px solid var(--ink);
    margin-bottom: 30px;
}
.resume-banner h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
    font-family: "Playfair Display", serif;
}
.resume-banner .resume-detail {
    font-size: 0.85rem;
    color: var(--muted);
}
.resume-banner .resume-actions {
    display: flex;
    gap: 10px;
}

/* Question card */
.question-card {
    padding: 30px 0;
    margin-bottom: 30px;
}

.question-text {
    font-family: "Playfair Display", serif;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--ink);
    margin-bottom: 20px;
}

/* Hint section (learning mode only) */
.hint-section {
    margin-bottom: 20px;
    border-top: 1px dashed var(--rule-soft);
    padding-top: 16px;
}

.hint-toggle {
    background: transparent;
    border: 1.5px solid var(--ink);
    color: var(--ink);
    padding: 7px 14px;
    font-family: "Inter", sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    border-radius: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s;
}
.hint-toggle:hover {
    background: var(--ink);
    color: var(--paper);
}
.hint-toggle .hint-count {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.7rem;
    background: var(--ink);
    color: var(--paper);
    padding: 2px 6px;
    margin-left: 4px;
}
.hint-toggle:hover .hint-count {
    background: var(--paper);
    color: var(--ink);
}

.hint-content {
    margin-top: 14px;
    background: var(--paper-tint);
    border-left: 3px solid var(--accent);
    padding: 16px 20px;
}

.hint-item {
    margin-bottom: 12px;
}
.hint-item:last-child { margin-bottom: 0; }

.hint-type-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--accent);
    display: block;
    margin-bottom: 4px;
}
.hint-item p {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--ink);
    margin: 0;
}

.hint-source .hint-type-label::before {
    content: "Référence : ";
    color: var(--muted);
}

/* Dark mode hint */
body.dark-mode .hint-content {
    background: #2a2a2a;
    border-left-color: var(--accent);
}

.marked-banner {
    background: var(--highlight);
    border-left: 3px solid var(--accent);
    padding: 8px 14px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 16px;
}

/* Options - editorial list */
.options-list {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--rule-soft);
}

.option {
    display: grid;
    grid-template-columns: 50px 1fr;
    gap: 16px;
    align-items: start;
    padding: 16px 0;
    border-bottom: 1px solid var(--rule-soft);
    cursor: pointer;
    transition: padding-left 0.15s;
}
.option:hover {
    padding-left: 12px;
}
.option.selected {
    padding-left: 12px;
    background: var(--highlight);
    margin: 0 -12px;
    padding-right: 12px;
}
.option.selected .option-letter {
    color: var(--accent);
}

.option-letter {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    padding-top: 2px;
}
.option-text {
    font-size: 1.02rem;
    line-height: 1.5;
    color: var(--ink);
}

/* Navigation */
.quiz-nav {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0;
    border-top: 1px solid var(--rule);
    padding-top: 20px;
    align-items: center;
}
.quiz-nav .btn-prev { justify-self: start; }
.quiz-nav .btn-next { justify-self: end; }
.quiz-nav .btn-mark { justify-self: center; }

/* ============ RESULTS ============ */
.results {
    padding: 50px 0;
    text-align: center;
}

.score-display {
    margin-bottom: 40px;
}
.score-fraction {
    font-family: "Playfair Display", serif;
    font-size: 5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
    margin-bottom: 6px;
}
.score-percent {
    font-family: "JetBrains Mono", monospace;
    font-size: 1.2rem;
    color: var(--accent);
    letter-spacing: 0.1em;
}
.score-comment {
    font-family: "Playfair Display", serif;
    font-style: italic;
    font-size: 1.3rem;
    color: var(--ink);
    margin-bottom: 40px;
}

/* Marked recap */
.marked-recap {
    background: var(--highlight);
    border: 1px solid var(--accent);
    padding: 30px;
    margin: 40px 0;
    text-align: left;
}
.marked-recap .section-number { color: var(--accent); }
.marked-recap h3 {
    margin-bottom: 6px;
    color: var(--accent);
}
.marked-recap .recap-help {
    color: var(--muted);
    font-style: italic;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.marked-recap-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.marked-recap-item {
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 14px;
    padding: 14px;
    background: var(--paper);
    border-left: 2px solid var(--accent);
}
.marked-recap-num {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    padding-top: 2px;
}
.marked-recap-q {
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 0.95rem;
}
.marked-recap-answers {
    font-size: 0.82rem;
    color: var(--muted);
}

/* Actions */
.results-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 30px 0 50px;
}

/* Corrections */
.corrections {
    border-top: 1px solid var(--rule);
    padding-top: 40px;
    text-align: left;
    margin-top: 30px;
}
.corrections-header {
    text-align: center;
    margin-bottom: 30px;
}
.corrections-header h3 {
    font-size: 1.5rem;
}

.correction-card {
    padding: 24px 0;
    border-bottom: 1px solid var(--rule-soft);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0;
    position: relative;
}
.correction-card.correct {
    border-left: 3px solid var(--accent);
    padding-left: 16px;
}
.correction-card.incorrect {
    border-left: 3px solid var(--ink);
    padding-left: 16px;
}
.correction-card.marked {
    background: var(--highlight);
    padding-left: 16px;
    padding-right: 16px;
    margin: 0 -16px;
}

.correction-header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--rule-soft);
}
.correction-num {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}
.correction-status {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}
.correction-card.correct .correction-status { color: var(--accent); }
.correction-card.incorrect .correction-status { color: var(--ink); }

.correction-content {
    grid-column: 1 / -1;
}

.correction-question {
    font-family: "Playfair Display", serif;
    font-weight: 600;
    font-size: 1.1rem;
    line-height: 1.4;
    margin-bottom: 16px;
}

.correction-options {
    margin-bottom: 16px;
    border-left: 2px solid transparent;
}
.correction-option {
    padding: 8px 0;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--paper-tint);
}
.correction-option:last-child { border-bottom: none; }
.correction-option.correct-option {
    background: var(--highlight);
    padding: 8px 12px;
    border-left: 2px solid var(--accent);
    margin-left: -12px;
    color: var(--accent);
    font-weight: 500;
}
.correction-option.wrong-option {
    background: #f0f0f0;
    padding: 8px 12px;
    border-left: 2px solid var(--ink);
    margin-left: -12px;
    text-decoration: line-through;
    opacity: 0.7;
}

.correction-explanation {
    background: var(--paper-tint);
    padding: 14px 18px;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--ink-soft);
    border-left: 2px solid var(--ink);
}
.correction-explanation strong {
    color: var(--ink);
    font-weight: 600;
}
.correction-ref {
    margin-top: 8px;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: 0.05em;
}

.correction-flag {
    grid-column: 1 / -1;
    margin-top: 10px;
    text-align: right;
}
.flag-btn {
    background: transparent;
    border: 1px solid var(--ink);
    color: var(--ink);
    padding: 6px 14px;
    font-family: "Inter", sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.15s;
}
.flag-btn:hover {
    background: var(--ink);
    color: var(--paper);
}
.flag-btn.flagged,
.flag-btn:disabled {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--paper);
    cursor: default;
}

/* ============ STATS PAGE ============ */
.stats-section {
    margin-bottom: 60px;
}
.stats-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.bar-row {
    display: grid;
    grid-template-columns: 200px 1fr 60px;
    gap: 20px;
    align-items: center;
}
.bar-label {
    font-size: 0.9rem;
    color: var(--ink);
}
.bar-label small {
    display: block;
    font-size: 0.7rem;
    color: var(--muted);
    font-family: "JetBrains Mono", monospace;
}
.bar-track {
    height: 14px;
    background: var(--paper-tint);
    position: relative;
    border: 1px solid var(--rule-soft);
}
.bar-fill {
    height: 100%;
    background: var(--ink);
    transition: width 0.6s;
}
.bar-fill.pass { background: var(--accent); }
.bar-fill.fail { background: var(--ink); opacity: 0.4; }
.bar-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink);
    text-align: right;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.history-table th,
.history-table td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--rule-soft);
}
.history-table th {
    font-family: "Inter", sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    background: var(--paper-tint);
}
.history-table tr:hover { background: var(--paper-tint); }

.history-table .score-cell {
    font-family: "JetBrains Mono", monospace;
    font-weight: 600;
    color: var(--accent);
}
.history-table .score-cell.low { color: var(--ink); }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-style: italic;
    border: 1px dashed var(--rule-soft);
    margin: 20px 0;
}

.actions-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 24px;
}

/* ============ SEARCH PAGE ============ */
.search-input-wrapper {
    position: relative;
    margin-bottom: 24px;
}
.search-input {
    width: 100%;
    padding: 16px 18px;
    font-family: "Inter", sans-serif;
    font-size: 1.05rem;
    border: 2px solid var(--ink);
    border-radius: 0;
    background: var(--paper);
    color: var(--ink);
}
.search-input:focus {
    outline: none;
    background: var(--paper-tint);
}
.search-filters {
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
    font-size: 0.85rem;
    color: var(--muted);
}
.search-filters select {
    padding: 6px 10px;
    border: 1px solid var(--ink);
    background: var(--paper);
    font-family: "Inter", sans-serif;
    font-size: 0.85rem;
    color: var(--ink);
    border-radius: 0;
}
.search-stats {
    color: var(--muted);
    font-style: italic;
    margin-bottom: 16px;
    font-size: 0.85rem;
}
.search-results {
    display: flex;
    flex-direction: column;
}
.search-result {
    display: block;
    padding: 18px 0;
    border-bottom: 1px solid var(--rule-soft);
    text-decoration: none;
    color: var(--ink);
    transition: padding-left 0.15s;
    border-left: 0 solid var(--ink);
}
.search-result:hover {
    padding-left: 12px;
    border-left: 3px solid var(--ink);
    color: var(--ink);
}
.search-result-meta {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 6px;
    font-weight: 600;
}
.search-result-q {
    font-family: "Playfair Display", serif;
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.35;
    margin-bottom: 6px;
    color: var(--ink);
}
.search-result-snippet {
    font-size: 0.88rem;
    color: var(--muted);
    font-style: italic;
    line-height: 1.5;
}
.search-result-snippet mark {
    background: var(--highlight);
    color: var(--accent);
    padding: 0 4px;
    font-weight: 600;
    font-style: normal;
}

/* ============ FLAGGED PAGE ============ */
.flagged-item {
    padding: 22px 0;
    border-bottom: 1px solid var(--rule-soft);
    border-left: 3px solid var(--accent);
    padding-left: 18px;
    background: var(--highlight);
    margin-bottom: 12px;
}
.flagged-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.78rem;
    color: var(--muted);
}
.flagged-module {
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.78rem;
}
.flagged-question {
    font-family: "Playfair Display", serif;
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 10px;
    line-height: 1.4;
}
.flagged-id {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 14px;
}
.flagged-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============ DARK MODE ============ */
body.dark-mode {
    --ink: #f0eee9;
    --ink-soft: #c8c6c0;
    --paper: #0a0a0a;
    --paper-tint: #1a1a1a;
    --rule: #f0eee9;
    --rule-soft: #3a3a3a;
    --accent: #d86060;
    --accent-soft: #c45050;
    --muted: #8a8a8a;
    --highlight: #2a1818;
}
body.dark-mode {
    background: var(--paper);
    color: var(--ink);
}
body.dark-mode .quiz-option.selected,
body.dark-mode .marked-recap-item,
body.dark-mode .correction-card.marked,
body.dark-mode .flagged-item {
    background: var(--highlight);
}
body.dark-mode .correction-option.correct-option {
    background: rgba(139, 0, 0, 0.3);
    color: var(--accent);
}
body.dark-mode .correction-option.wrong-option {
    background: #2a2a2a;
}
body.dark-mode .correction-explanation {
    background: #1a1a1a;
}
body.dark-mode .history-table th {
    background: #1a1a1a;
}
body.dark-mode .search-input {
    background: #1a1a1a;
    color: var(--ink);
}
body.dark-mode .search-input:focus {
    background: #2a2a2a;
}

.dark-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    border: 1.5px solid var(--ink);
    background: var(--paper);
    color: var(--ink);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 0;
    z-index: 1000;
    transition: background 0.15s, color 0.15s;
}
.dark-toggle:hover {
    background: var(--ink);
    color: var(--paper);
}

/* ============ ANIMATIONS (minimal) ============ */
@keyframes slideRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
.fade-in {
    animation: slideRight 0.25s ease-out;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}
.shake { animation: shake 0.4s ease; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    main { padding: 30px 18px; }
    .masthead-inner {
        grid-template-columns: 1fr;
        gap: 14px;
        text-align: center;
    }
    .masthead-title { border: none; padding: 0; }
    .masthead-nav { justify-content: center; flex-wrap: wrap; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .stat-cell { border-right: none; border-bottom: 1px solid var(--rule-soft); }
    .stat-cell:nth-child(2n) { border-right: none; }
    .section-header { grid-template-columns: 1fr; gap: 6px; }
    .hero { padding: 30px 0; margin-bottom: 30px; }
    .hero h1 { font-size: 2rem; }
    .quiz-app { padding: 20px; }
    .quiz-nav { grid-template-columns: 1fr; gap: 10px; }
    .quiz-nav .btn { justify-self: stretch; }
    .correction-card { grid-template-columns: 1fr; }
    .bar-row { grid-template-columns: 1fr; gap: 6px; }
    .bar-value { text-align: left; }
    .modules-row { grid-template-columns: 1fr; }
}

/* ============ PRINT ============ */
@media print {
    body { background: white !important; color: black !important; font-size: 11pt; }
    body.dark-mode { background: white !important; color: black !important; }
    .masthead, .quiz-nav, .quiz-keyboard-hint, .quiz-flag, .quiz-progress,
    .quiz-progress-bar, .dark-toggle, .resume-banner, .results-actions,
    .quiz-meta, #quiz-timer, .quiz-mark-btn, .hero-actions, .actions-bar {
        display: none !important;
    }
    .quiz-app, .question-card, .correction-card, .correction-option {
        box-shadow: none !important;
        background: white !important;
        color: black !important;
        page-break-inside: avoid;
    }
    .correction-option.correct-option {
        background: #e8f5e9 !important;
        color: #1b5e20 !important;
    }
    .correction-option.wrong-option {
        background: #ffebee !important;
        color: #b71c1c !important;
    }
    a { color: black !important; text-decoration: none !important; }
    .hero { padding: 20px 0; }
}
/* =============================================
   v3 : NOTATION, EXAMEN, BRANCHES
   ============================================= */

/* Variables de couleur */
:root {
    --correct: #1B5E20;
    --correct-light: #E8F5E9;
    --wrong: #B71C1C;
    --wrong-light: #FFEBEE;
}

/* Cartes de correction */
.correction-card.correct { border-left: 3px solid var(--correct); background: var(--correct-light); }
.correction-card.incorrect { border-left: 3px solid var(--wrong); background: var(--wrong-light); }
.correction-card.correct .correction-status { color: var(--correct); font-weight: 700; }
.correction-card.incorrect .correction-status { color: var(--wrong); font-weight: 700; }
.correction-option.correct-option { background: var(--correct-light); border-left: 3px solid var(--correct); color: var(--correct); font-weight: 600; padding: 8px 12px; margin-left: -12px; }
.correction-option.wrong-option { background: var(--wrong-light); border-left: 3px solid var(--wrong); color: var(--wrong); text-decoration: line-through; padding: 8px 12px; margin-left: -12px; opacity: 0.8; }

/* Badge note (modules) */
.grade-badge { display: inline-flex; align-items: baseline; gap: 8px; padding: 16px 28px; border: 2px solid; margin: 20px 0; }
.grade-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.15em; font-weight: 700; }
.grade-value { font-family: "Playfair Display", serif; font-size: 3rem; font-weight: 700; line-height: 1; }
.grade-scale { font-family: "JetBrains Mono", monospace; font-size: 1rem; color: var(--muted); }
.grade-judgement { font-size: 0.85rem; font-weight: 600; text-transform: uppercase; margin-left: 8px; }

/* Banner verdict examen */
.exam-verdict-banner { text-align: center; padding: 40px 24px; margin: 20px 0 32px; border: 2px solid; }
.exam-verdict-banner.passed { background: var(--correct-light); border-color: var(--correct); }
.exam-verdict-banner.failed { background: var(--wrong-light); border-color: var(--wrong); }
.verdict-status { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.2em; display: block; margin-bottom: 12px; }
.passed .verdict-status { color: var(--correct); }
.failed .verdict-status { color: var(--wrong); }
.verdict-grade-large { font-family: "Playfair Display", serif; font-size: 5rem; font-weight: 700; line-height: 1; margin: 8px 0; }
.passed .verdict-grade-large { color: var(--correct); }
.failed .verdict-grade-large { color: var(--wrong); }
.grade-max { font-size: 1.8rem; color: var(--muted); font-weight: 400; }
.verdict-stats { display: flex; justify-content: center; gap: 24px; font-family: "JetBrains Mono", monospace; font-size: 0.82rem; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }

/* Branches */
.bulletin-branches-section { margin: 0 0 24px; }
.bulletin-section-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--ink); }
.bulletin-branch-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--rule-soft); }
.branch-info { display: flex; align-items: center; gap: 12px; flex: 1; }
.branch-num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 1.5px solid var(--ink); font-family: "JetBrains Mono", monospace; font-size: 0.78rem; font-weight: 700; flex-shrink: 0; }
.branch-label { font-size: 0.9rem; font-weight: 500; }
.branch-questions { font-family: "JetBrains Mono", monospace; font-size: 0.75rem; color: var(--muted); margin-left: 8px; }
.branch-grade-display { font-family: "Playfair Display", serif; font-size: 1.6rem; font-weight: 700; min-width: 50px; text-align: right; }
.branch-pass .branch-grade-display { color: var(--correct); }
.branch-fail .branch-grade-display { color: var(--wrong); }

/* Conditions de réussite */
.conditions-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 24px 0; border-top: 1px solid var(--ink); }
.cond-box { text-align: center; padding: 16px 8px; border-right: 1px solid var(--rule-soft); }
.cond-box:last-child { border-right: none; }
.cond-box.ok { background: rgba(27,94,32,0.04); }
.cond-box.ko { background: rgba(183,28,28,0.04); }
.cond-status { display: block; font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.cond-box.ok .cond-status { color: var(--correct); }
.cond-box.ko .cond-status { color: var(--wrong); }
.cond-text { display: block; font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); }
.cond-val { display: block; font-family: "JetBrains Mono", monospace; font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

/* Threshold box sur page examen */
.exam-threshold-box { max-width: 700px; margin: 24px auto; padding: 28px 32px; border: 1px solid var(--rule-soft); background: var(--paper-tint); }
.threshold-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em; color: var(--ink); padding-bottom: 12px; border-bottom: 1px solid var(--ink); margin-bottom: 16px; }
.threshold-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.threshold-item { text-align: center; }
.threshold-num { display: block; font-family: "Playfair Display", serif; font-size: 1.8rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.threshold-desc { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 4px; line-height: 1.3; }
.threshold-formula { text-align: center; font-family: "JetBrains Mono", monospace; font-size: 0.75rem; color: var(--muted); margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule-soft); }

/* Branch separator in exam */
.branch-separator { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--paper-tint); border-left: 3px solid var(--accent); margin-bottom: 16px; font-size: 0.82rem; }
.branch-sep-num { font-family: "JetBrains Mono", monospace; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }
.branch-sep-name { color: var(--ink-soft); font-weight: 500; }

/* Exam nav grid */
.exam-nav-grid-wrap { margin-top: 32px; padding: 0; }
.exam-nav-header { display: flex; align-items: center; gap: 16px; padding: 0 0 12px 0; border-bottom: 1px solid var(--ink); flex-wrap: nowrap; }
.exam-nav-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em; color: var(--ink); white-space: nowrap; }
.exam-nav-stats { font-family: "JetBrains Mono", monospace; font-size: 0.78rem; color: var(--muted); white-space: nowrap; margin-left: auto; }
.btn-small { padding: 6px 14px !important; font-size: 0.72rem !important; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
.btn-skip { background: transparent !important; color: var(--muted) !important; border: 1px solid var(--rule-soft) !important; font-size: 0.82rem !important; padding: 8px 16px !important; }
.btn-skip:hover { color: var(--accent) !important; border-color: var(--accent) !important; }
.exam-nav-grid { display: grid; grid-template-columns: repeat(30, 1fr); gap: 3px; padding: 12px 0; max-height: 200px; overflow-y: auto; }
.exam-grid-cell { aspect-ratio: 1; min-width: 0; border: 1px solid var(--rule-soft); background: var(--paper); font-family: "JetBrains Mono", monospace; font-size: 0.62rem; font-weight: 600; cursor: pointer; transition: all 0.1s ease; display: flex; align-items: center; justify-content: center; padding: 0; position: relative; color: var(--muted); }
.exam-grid-cell:hover { border-color: var(--ink); z-index: 2; transform: scale(1.15); }
.exam-grid-cell.unanswered { background: var(--paper); color: var(--muted); }
.exam-grid-cell.answered { background: var(--correct-light); color: var(--correct); border-color: var(--correct); }
.exam-grid-cell.current { background: var(--accent); color: var(--paper); border-color: var(--accent); border-width: 2px; z-index: 3; }
.exam-grid-cell.marked::after { content: ''; position: absolute; top: 1px; right: 1px; width: 4px; height: 4px; background: var(--accent); border-radius: 50%; }
.exam-nav-grid::-webkit-scrollbar { width: 6px; }
.exam-nav-grid::-webkit-scrollbar-track { background: var(--paper-tint); }
.exam-nav-grid::-webkit-scrollbar-thumb { background: var(--rule); }

/* Quiz nav bar */
.quiz-nav { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--rule-soft); }
.quiz-nav .btn { padding: 10px 20px; font-size: 0.85rem; }

/* Dark mode */
body.dark-mode .exam-verdict-banner.passed { background: rgba(27,94,32,0.12); }
body.dark-mode .exam-verdict-banner.failed { background: rgba(183,28,28,0.12); }
body.dark-mode .cond-box.ok { background: rgba(27,94,32,0.08); }
body.dark-mode .cond-box.ko { background: rgba(183,28,28,0.08); }
body.dark-mode .bulletin-branch-row { border-color: #333; }
body.dark-mode .conditions-grid { border-color: #555; }
body.dark-mode .cond-box { border-color: #333; }
body.dark-mode .branch-num { border-color: #555; }
body.dark-mode .branch-separator { background: #2a2a2a; }
body.dark-mode .exam-grid-cell { background: #1a1a1a; border-color: #333; color: #888; }
body.dark-mode .exam-grid-cell.answered { background: rgba(27,94,32,0.15); color: #66BB6A; border-color: #66BB6A; }
body.dark-mode .exam-grid-cell.current { background: var(--accent); color: #fff; }
body.dark-mode .exam-threshold-box { background: #2a2a2a; }

/* Mobile */
@media (max-width: 640px) {
    .conditions-grid { grid-template-columns: 1fr; }
    .cond-box { border-right: none; border-bottom: 1px solid var(--rule-soft); }
    .verdict-grade-large { font-size: 3.5rem; }
    .verdict-stats { flex-direction: column; gap: 4px; }
    .threshold-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
}

/* Tableau répartition par branche (page examen) */
.exam-breakdown-box {
    max-width: 800px;
    margin: 24px auto;
    padding: 0;
}
.breakdown-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--ink);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--ink);
    margin-bottom: 0;
}
.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.breakdown-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    font-weight: 600;
    border-bottom: 1px solid var(--rule-soft);
}
.breakdown-table th.num-col,
.breakdown-table td.num-col {
    text-align: right;
    font-family: "JetBrains Mono", monospace;
    font-weight: 600;
    width: 80px;
}
.breakdown-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--rule-soft);
    vertical-align: top;
}
.branch-id-cell {
    font-family: "JetBrains Mono", monospace;
    font-weight: 700;
    color: var(--accent);
    width: 30px;
}
.branch-name-cell {
    font-weight: 500;
}
.branch-modules-cell {
    font-size: 0.78rem;
    color: var(--muted);
}
.breakdown-total-row td {
    font-weight: 700;
    border-top: 2px solid var(--ink);
    border-bottom: none;
    padding-top: 12px;
}
.breakdown-total-row .num-col {
    color: var(--accent);
    font-size: 1rem;
}

/* Modale de révision (stats) */
.review-header { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--ink); }
.review-title { font-family: "Playfair Display", serif; font-size: 1.6rem; font-weight: 700; }
.review-meta { font-family: "JetBrains Mono", monospace; font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.review-bulletin { padding: 20px; margin-bottom: 24px; border: 2px solid; }
.review-bulletin.passed { background: var(--correct-light); border-color: var(--correct); }
.review-bulletin.failed { background: var(--wrong-light); border-color: var(--wrong); }
.review-verdict { font-family: "Playfair Display", serif; font-size: 1.4rem; font-weight: 700; }
.review-bulletin.passed .review-verdict { color: var(--correct); }
.review-bulletin.failed .review-verdict { color: var(--wrong); }
.review-branches { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.review-branch-pill { display: inline-block; padding: 4px 12px; border: 1.5px solid; font-family: "JetBrains Mono", monospace; font-size: 0.78rem; font-weight: 600; }
.review-close { position: absolute; top: 16px; right: 20px; font-size: 1.8rem; cursor: pointer; color: var(--muted); }
.review-close:hover { color: var(--accent); }
