/* ===================== Self-hosted Inter font ===================== */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('fonts/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

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

:root {
    --color-primary: #2563eb;
    --color-primary-light: #3b82f6;
    --color-primary-dark: #1d4ed8;
    --color-primary-bg: #eff6ff;
    --color-primary-subtle: rgba(37, 99, 235, 0.08);
    --color-danger: #dc2626;
    --color-danger-bg: #fef2f2;
    --color-success: #059669;
    --color-success-bg: #f0fdf4;
    --color-purple: #7c3aed;
    --color-purple-light: #8b5cf6;
    --color-purple-dark: #6d28d9;
    --color-purple-bg: #f5f3ff;
    --color-purple-subtle: rgba(124, 58, 237, 0.08);
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #0f172a;
    --color-text-secondary: #334155;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 40px -5px rgba(0, 0, 0, 0.1);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

::selection {
    background: rgba(37, 99, 235, 0.15);
    color: var(--color-text);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

.container--wide {
    max-width: 1600px;
}

/* ===================== Icon Utilities ===================== */
.icon-xs {
    width: 14px;
    height: 14px;
    stroke-width: 2;
    vertical-align: -2px;
    flex-shrink: 0;
}

.icon-sm {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    vertical-align: -3px;
    flex-shrink: 0;
}

.icon-md {
    width: 20px;
    height: 20px;
    stroke-width: 1.75;
    vertical-align: -4px;
    flex-shrink: 0;
}

.icon-lg {
    width: 24px;
    height: 24px;
    stroke-width: 1.75;
    flex-shrink: 0;
}

.icon-xl {
    width: 32px;
    height: 32px;
    stroke-width: 1.5;
    flex-shrink: 0;
}

/* Icon circle wrapper */
.icon-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.icon-circle--sm {
    width: 36px;
    height: 36px;
}

.icon-circle--md {
    width: 48px;
    height: 48px;
}

.icon-circle--lg {
    width: 56px;
    height: 56px;
}

.icon-circle--xl {
    width: 64px;
    height: 64px;
}

.icon-circle--primary {
    background: linear-gradient(135deg, var(--color-primary-bg), rgba(37, 99, 235, 0.15));
    color: var(--color-primary);
}

.icon-circle--purple {
    background: linear-gradient(135deg, var(--color-purple-bg), rgba(124, 58, 237, 0.15));
    color: var(--color-purple);
}

.icon-circle--success {
    background: linear-gradient(135deg, var(--color-success-bg), rgba(5, 150, 105, 0.15));
    color: var(--color-success);
}

.icon-circle--muted {
    background: var(--color-border-light);
    color: var(--color-text-muted);
}

/* ===================== Scrollbar ===================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ===================== Header ===================== */
header {
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.header-logo:hover {
    color: var(--color-primary);
}

.header-logo-icon {
    width: 22px;
    height: 22px;
    stroke-width: 2.25;
    color: var(--color-primary);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-user {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.header-logout {
    font-size: 0.8rem;
    padding: 0.35rem 0.85rem;
}

/* ===================== Main ===================== */
main {
    flex: 1;
    padding: 3.5rem 0 4rem;
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================== Footer ===================== */
footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

/* ===================== Flash Messages ===================== */
.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    padding-left: 2.75rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideDown 0.3s ease-out, fadeOut 0.4s ease-in 8s forwards;
    position: relative;
}

.flash-message {
    flex: 1;
}

.flash-close {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
    padding: 0.2rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-fast), background var(--transition-fast);
    flex-shrink: 0;
}

.flash-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08);
}

.flash::before {
    content: '';
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        max-height: 80px;
        margin-bottom: 1.5rem;
        padding: 0.75rem 1.25rem;
    }
    to {
        opacity: 0;
        max-height: 0;
        margin-bottom: 0;
        padding: 0;
        overflow: hidden;
    }
}

.flash-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.flash-error::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E");
}

.flash-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.flash-success::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 11.08V12a10 10 0 1 1-5.93-9.14'/%3E%3Cpolyline points='22 4 12 14.01 9 11.01'/%3E%3C/svg%3E");
}

.flash-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.flash-info::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
}

/* ===================== Buttons ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-base);
    line-height: 1.4;
    white-space: nowrap;
    font-family: inherit;
}

.btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-border-light);
    border-color: #cbd5e1;
    color: var(--color-text);
}

.btn-icon {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.3rem 0.55rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
}

.btn-icon:hover {
    background: var(--color-border-light);
    border-color: #cbd5e1;
    color: var(--color-text);
}

.btn-icon.btn-danger:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--color-danger);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 0;
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:hover {
    color: var(--color-danger);
    background: #fef2f2;
}

/* ===================== Upload Section ===================== */
.upload-section {
    text-align: center;
    max-width: 640px;
    margin: 0 auto;
    padding-top: 0.5rem;
}

.upload-section h2 {
    margin-bottom: 0.25rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-xl);
    padding: 3.5rem 2rem;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--color-surface);
}

.drop-zone:hover,
.drop-zone--active {
    border-color: var(--color-primary);
    background: var(--color-primary-bg);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.drop-zone:hover .drop-zone-icon,
.drop-zone--active .drop-zone-icon {
    color: var(--color-primary);
    transform: translateY(-2px);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.drop-zone-icon {
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
    transition: all var(--transition-base);
}

.drop-zone-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.drop-zone-hint {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.drop-zone-formats {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

/* ===================== Preview List ===================== */
.preview-container {
    margin-top: 1.5rem;
    text-align: left;
}

.preview-container h3 {
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.preview-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-fast);
}

.preview-item:hover {
    box-shadow: var(--shadow);
    border-color: #cbd5e1;
}

.preview-item img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
}

.preview-info {
    display: flex;
    flex-direction: column;
}

.preview-name {
    font-size: 0.82rem;
    font-weight: 500;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-size {
    font-size: 0.72rem;
    color: var(--color-text-muted);
}

.preview-saved {
    color: var(--color-success, #059669);
    font-size: 0.68rem;
}

#submit-btn {
    margin-top: 1.5rem;
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

/* ===================== Download Banner ===================== */
.download-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    margin-bottom: 1.25rem;
    background: var(--color-success-bg);
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease-out;
}

.download-banner .banner-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.download-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.82rem;
}

.btn-prof {
    background: var(--color-purple);
    color: #fff;
    box-shadow: 0 1px 3px rgba(124, 58, 237, 0.25);
}

.btn-prof:hover:not(:disabled) {
    background: var(--color-purple-dark);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
    transform: translateY(-1px);
}

.btn-prof:active:not(:disabled) {
    transform: translateY(0);
}

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

/* ===================== Review Section ===================== */
.review-section {
    padding-top: 0.5rem;
}

.review-section h2 {
    margin-bottom: 0.25rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
    font-size: 0.88rem;
}

.input-title {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    font-family: inherit;
    background: var(--color-surface);
}

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

/* ===================== Exercise Cards ===================== */
.exercises-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.exercise-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow var(--transition-base);
}

.exercise-card:hover {
    box-shadow: var(--shadow-md);
}

.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 1rem;
    background: var(--color-border-light);
    border-bottom: 1px solid var(--color-border);
}

.exercise-header .exercise-number {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-primary);
}

.exercise-actions {
    display: flex;
    gap: 0.35rem;
}

/* -- Per-exercise note toggle -- */
.exercise-note-toggle {
    padding: 0.35rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.btn-note-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-note-toggle:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-bg, rgba(59, 130, 246, 0.06));
}

.btn-note-toggle.has-note {
    border-style: solid;
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-bg, rgba(59, 130, 246, 0.06));
}

.exercise-note-area {
    display: none;
    margin-top: 0.4rem;
}

.exercise-note-area.visible {
    display: block;
}

.exercise-note-textarea {
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    resize: vertical;
    min-height: 2.2rem;
    transition: border-color var(--transition-base);
}

.exercise-note-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.exercise-note-textarea::placeholder {
    color: var(--color-muted);
    font-style: italic;
}

.exercise-card--prof .btn-note-toggle:hover,
.exercise-card--prof .btn-note-toggle.has-note {
    border-color: var(--color-purple);
    color: var(--color-purple);
    background: var(--color-purple-bg);
}

.exercise-card--prof .exercise-note-textarea:focus {
    border-color: var(--color-purple);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.exercise-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
}

/* 3-column layout: photo | editor | preview */
.exercise-body--3col {
    grid-template-columns: 1fr 1.3fr 1.3fr;
}

.exercise-photo img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.exercise-photo img:hover {
    transform: scale(1.02);
}

/* Zoom overlay hint on photo */
.exercise-photo {
    position: relative;
}

.exercise-photo::after {
    content: '🔍 Cliquez pour zoomer';
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.3rem 0.7rem;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 999px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.exercise-photo:has(img):hover::after {
    opacity: 1;
}

.no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 200px;
    background: var(--color-border-light);
    border-radius: 8px;
    color: var(--color-text-muted);
    font-size: 0.88rem;
}

.exercise-textarea {
    width: 100%;
    padding: 0.65rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.83rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    resize: vertical;
    transition: all var(--transition-fast);
    background: var(--color-surface);
    line-height: 1.6;
}

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

.exercise-figure {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    text-align: center;
}

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

.exercise-figure .figure-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #92400e;
}

.figure-actions-bar {
    display: flex;
    gap: 0.25rem;
}

/* -- Tooltips for figure action buttons -- */
.figure-actions-bar .btn-icon {
    position: relative;
}

.figure-actions-bar .btn-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    background: var(--color-text);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.figure-actions-bar .btn-icon::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--color-text);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.figure-actions-bar .btn-icon:hover::after,
.figure-actions-bar .btn-icon:hover::before {
    opacity: 1;
}

.exercise-figure .figure-img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: #fff;
}

.exercise-figure--empty {
    display: none;
}

/* -- Figure drop / paste zone -- */
.figure-drop-zone {
    position: relative;
    margin-top: 0.5rem;
    padding: 1.2rem 1rem;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    text-align: center;
    background: #fafafa;
    transition: all var(--transition-base);
    display: none;
}

.figure-drop-zone.visible {
    display: block;
}

.figure-drop-zone.active {
    border-color: var(--color-primary);
    background: var(--color-primary-bg);
}

.figure-drop-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.figure-drop-hint .drop-icon {
    color: var(--color-primary);
    opacity: 0.6;
}

.figure-drop-hint .drop-text {
    line-height: 1.5;
}

.figure-drop-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.figure-file-label,
.figure-camera-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text);
}

.figure-file-label:hover,
.figure-camera-label:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-bg);
}

.figure-file-input,
.figure-camera-input {
    display: none;
}

.figure-drop-close {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0.2rem;
    border-radius: 4px;
    line-height: 1;
    transition: all var(--transition-base);
}

.figure-drop-close:hover {
    background: var(--color-border-light);
    color: var(--color-text);
}

.figures-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-add-figure {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    background: none;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.btn-add-figure:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.preview-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}

.exercise-preview {
    padding: 0.75rem;
    background: var(--color-border-light);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    min-height: 60px;
    font-size: 0.9rem;
    line-height: 1.65;
}

/* Preview column in 3-col layout */
.exercise-preview-col {
    display: flex;
    flex-direction: column;
}

.exercise-preview-col .exercise-preview {
    flex: 1;
    overflow-y: auto;
    max-height: 600px;
}

.exercise-preview-col .preview-label {
    margin-top: 0;
}

/* Sticky columns in 3-col layout for easier comparison */
.exercise-body--3col .exercise-photo,
.exercise-body--3col .exercise-preview-col {
    position: sticky;
    top: 1rem;
    align-self: start;
}

.exercise-preview p {
    margin-bottom: 0.5em;
}

.exercise-preview p:last-child {
    margin-bottom: 0;
}

/* Figure marker in preview */
.figure-marker {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.1rem 0.45rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #92400e;
}

/* ===================== Custom Note ===================== */
.input-note {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-size: 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    resize: vertical;
    font-family: inherit;
    transition: all var(--transition-fast);
    background: var(--color-surface);
}

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

.label-hint {
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

/* ===================== Loading Overlay ===================== */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.loading-overlay.visible {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.loading-content {
    text-align: center;
    padding: 2.5rem 3rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 400px;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

.loading-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.35rem;
}

.loading-hint {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===================== Processing Overlay (background tasks) ===================== */
.processing-overlay {
    display: none;
    padding: 3rem 1rem;
    align-items: center;
    justify-content: center;
    min-height: 40vh;
}

.processing-overlay.visible {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.processing-content {
    text-align: center;
    padding: 2.5rem 3rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 480px;
    width: 100%;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.processing-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.35rem;
}

.processing-detail {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
    animation: pulse 2s ease-in-out infinite;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--color-border);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    border-radius: 999px;
    transition: width 0.4s ease;
    min-width: 2%;
}

.processing-progress {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

/* ===================== Prof Review Page ===================== */
.exercise-card--prof {
    border-left: 4px solid var(--color-purple);
}

.exercise-header--prof {
    background: var(--color-purple-bg);
    border-bottom-color: #ddd6fe;
}

.exercise-header--prof .exercise-number {
    color: var(--color-purple);
}

.exercise-body--prof {
    display: block;
    padding: 1rem;
}

.correction-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-purple);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.correction-textarea {
    width: 100%;
    padding: 0.65rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.83rem;
    border: 1px solid #ddd6fe;
    border-radius: var(--radius);
    resize: vertical;
    transition: all var(--transition-fast);
    line-height: 1.6;
}

.correction-textarea:focus {
    outline: none;
    border-color: var(--color-purple);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.prof-preview .corr-line {
    color: #dc2626;
    font-weight: 500;
    padding-left: 0.5rem;
    border-left: 3px solid #dc2626;
    margin-left: 0.25rem;
}

.download-banner--prof {
    background: var(--color-purple-bg);
    border-color: #ddd6fe;
}

/* ===================== Confirm Modal ===================== */
.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
}

.confirm-overlay.visible {
    display: flex;
    animation: fadeIn 0.15s ease-out;
}

.confirm-box {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 2rem 2.25rem 1.5rem;
    max-width: 380px;
    width: 90%;
    text-align: center;
    animation: confirmIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes confirmIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.confirm-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fef2f2;
    color: var(--color-danger);
    margin: 0 auto 0.75rem;
}

.confirm-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.3rem;
}

.confirm-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

.confirm-actions {
    display: flex;
    gap: 0.65rem;
}

.confirm-actions .btn {
    flex: 1;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    border-radius: var(--radius);
}

.btn-delete {
    background: var(--color-danger);
    color: #fff;
    box-shadow: 0 1px 3px rgba(220, 38, 38, 0.25);
}

.btn-delete:hover {
    background: #b91c1c;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

/* ===================== Form Actions (sticky bottom bar) ===================== */
.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 0;
    position: sticky;
    bottom: 0;
    background: rgba(248, 250, 252, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--color-border);
    margin: 0 -1.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    z-index: 50;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.generate-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ===================== Home Page ===================== */
.home-section {
    text-align: center;
    padding: 1rem 0;
}

.home-hero {
    margin-bottom: 2.5rem;
}

.home-hero h2 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 0.4rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.home-hero .subtitle {
    font-size: 1.05rem;
    max-width: 460px;
    margin: 0 auto;
}

.home-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    max-width: 640px;
    margin: 0 auto;
}

.home-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2.25rem 1.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--color-text);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.home-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    transition: background var(--transition-base);
}

.home-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.home-card--new:hover {
    border-color: var(--color-primary);
}

.home-card--new:hover::before {
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
}

.home-card--new:hover .icon-circle {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(37, 99, 235, 0.25));
}

.home-card--list:hover {
    border-color: var(--color-purple);
}

.home-card--list:hover::before {
    background: linear-gradient(90deg, var(--color-purple), var(--color-purple-light));
}

.home-card--list:hover .icon-circle {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(124, 58, 237, 0.25));
}

.home-card-icon {
    transition: transform var(--transition-base);
}

.home-card:hover .home-card-icon {
    transform: scale(1.05);
}

.home-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.home-card p {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.home-card-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: var(--color-purple);
    color: #fff;
    border-radius: 11px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 0.35rem;
    vertical-align: middle;
}

/* ===================== Mes Recueils Page ===================== */
.recueils-section {
    padding-top: 0.5rem;
}

.recueils-section h2 {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

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

.search-bar {
    position: relative;
    margin-bottom: 1rem;
}

.search-bar .input-title {
    padding-left: 2.5rem;
}

.search-bar-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}

.search-no-results {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.recueils-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.recueil-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    transition: all var(--transition-base);
}

.recueil-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.recueil-card-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.recueil-info {
    flex: 1;
    min-width: 0;
}

.recueil-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recueil-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-bottom: 0.35rem;
}

.recueil-note {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-style: italic;
}

.recueil-versions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.version-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.22rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.version-badge--student {
    background: var(--color-primary-bg);
    color: var(--color-primary-dark);
    border: 1px solid #bfdbfe;
}

.version-badge--prof {
    background: var(--color-purple-bg);
    color: var(--color-purple-dark);
    border: 1px solid #ddd6fe;
}

.version-badge--draft {
    background: #fefce8;
    color: #a16207;
    border: 1px solid #fde68a;
}

.recueil-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 0.85rem;
    border-top: 1px solid var(--color-border);
}

.btn-prof-outline {
    background: transparent;
    color: var(--color-purple);
    border: 1px solid #ddd6fe;
}

.btn-prof-outline:hover {
    background: var(--color-purple-bg);
    border-color: #c4b5fd;
}

.inline-form {
    display: inline;
}

/* Empty state */
.recueils-empty {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--color-surface);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-xl);
}

.recueils-empty-icon {
    margin-bottom: 1rem;
}

.recueils-empty h3 {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

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

/* ===================== Folders Bar ===================== */
.folders-bar {
    margin-bottom: 1rem;
}

.folders-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.folder-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--color-text-secondary);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    position: relative;
    font-family: inherit;
}

.folder-chip:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-bg);
}

.folder-chip--active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    font-weight: 600;
}

.folder-chip--active:hover {
    background: var(--color-primary-dark);
    color: #fff;
}

.folder-chip--active .folder-chip-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.folder-chip--add {
    border-style: dashed;
    color: var(--color-text-muted);
}

.folder-chip--add:hover {
    border-style: solid;
}

.folder-chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--color-border-light);
    border-radius: 9px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--color-text-muted);
}

.folder-chip-actions {
    display: none;
    align-items: center;
    gap: 0.15rem;
    margin-left: 0.15rem;
}

.folder-chip:hover .folder-chip-actions {
    display: inline-flex;
}

.folder-chip--active .folder-chip-actions {
    display: none;
}

.folder-chip--active:hover .folder-chip-actions {
    display: inline-flex;
}

.folder-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.15rem;
    border-radius: 4px;
    color: inherit;
    opacity: 0.7;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.folder-action-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08);
}

.folder-chip--active .folder-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* New folder inline form */
.new-folder-form {
    margin-bottom: 1rem;
}

.new-folder-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.new-folder-icon {
    color: var(--color-primary);
    flex-shrink: 0;
}

.new-folder-input {
    flex: 1;
    min-width: 0;
    border: none !important;
    box-shadow: none !important;
    padding: 0.3rem 0 !important;
    font-size: 0.9rem !important;
}

.new-folder-input:focus {
    outline: none;
}

/* Active folder header */
.active-folder-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.active-folder-header h3 {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

/* Move-to-folder dropdown */
.move-folder-wrapper {
    position: relative;
    display: inline-flex;
}

.move-folder-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 200;
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    animation: toolbarSlideDown 0.15s ease-out;
}

.move-folder-dropdown.open {
    display: block;
}

.move-folder-dropdown-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.35rem 0.6rem 0.25rem;
}

.move-folder-form {
    display: block;
}

.move-folder-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--color-text-secondary);
    border-radius: 6px;
    transition: all var(--transition-fast);
    text-align: left;
}

.move-folder-option:hover {
    background: var(--color-primary-bg);
    color: var(--color-primary);
}

.move-folder-option--active {
    background: var(--color-primary-subtle);
    color: var(--color-primary);
    font-weight: 600;
}

/* ===================== Pagination ===================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1rem 0;
}

.pagination-info {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.btn-disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: default;
}

/* ===================== Save / Draft Button ===================== */
.btn-save {
    background: var(--color-success);
    color: #fff;
    box-shadow: 0 1px 3px rgba(5, 150, 105, 0.25);
}

.btn-save:hover:not(:disabled) {
    background: #047857;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
    transform: translateY(-1px);
}

.btn-save:active:not(:disabled) {
    transform: translateY(0);
}

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

/* ===================== Toast Notification ===================== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.toast--visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.toast--success {
    background: var(--color-success);
    color: #fff;
}

.toast--error {
    background: var(--color-danger);
    color: #fff;
}

/* ===================== Nav Buttons ===================== */
.nav-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ===================== Auth Pages ===================== */
.auth-section {
    display: flex;
    justify-content: center;
    padding: 1.5rem 0;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    animation: scaleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.85rem;
}

.auth-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.auth-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--color-text);
}

.auth-field input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    font-family: inherit;
    background: var(--color-surface);
}

.auth-field input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 2.75rem;
}

.password-toggle {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0.25rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.password-toggle:hover {
    color: var(--color-text);
}

.auth-submit {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    margin-top: 0.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.auth-footer a {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.auth-footer a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ===================== Save Indicator ===================== */
.save-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.save-indicator--unsaved {
    color: #b45309;
    background: #fef3c7;
}

.save-indicator--saving {
    color: var(--color-primary);
    background: var(--color-primary-bg);
}

.save-indicator--saved {
    color: var(--color-success);
    background: var(--color-success-bg);
}

/* ===================== Lightbox ===================== */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox-overlay.visible {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    object-fit: contain;
    cursor: default;
}

.lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background var(--transition-fast);
    z-index: 1201;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.exercise-photo img {
    cursor: zoom-in;
}

/* ===================== Drag Handle ===================== */
.drag-handle {
    cursor: grab;
    color: var(--color-text-muted);
    padding: 0.25rem;
    border-radius: 4px;
    transition: color var(--transition-fast);
    display: inline-flex;
    align-items: center;
}

.drag-handle:hover {
    color: var(--color-text);
}

.drag-handle:active {
    cursor: grabbing;
}

.exercise-card.sortable-ghost {
    opacity: 0.4;
    border: 2px dashed var(--color-primary);
}

.exercise-card.sortable-drag {
    box-shadow: var(--shadow-xl);
}

/* ===================== Workflow Steps (Home) ===================== */
.workflow-steps {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 2.5rem;
    padding: 0 1rem;
}

.workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    max-width: 140px;
    text-align: center;
}

.workflow-step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary-bg);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.workflow-step-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.workflow-step-desc {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.workflow-arrow {
    display: flex;
    align-items: center;
    color: var(--color-border);
    padding-top: 0.25rem;
}

/* ===================== Add Exercise Button ===================== */
.add-exercise-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.add-exercise-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 1;
    padding: 1rem;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: inherit;
}

.add-exercise-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-bg);
}

.add-exercise-btn--photo:hover {
    border-color: #059669;
    color: #059669;
    background: rgba(5, 150, 105, 0.06);
}

/* ── Add from photos modal ── */
.add-photos-box {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 1.5rem;
    max-width: 560px;
    width: 92%;
    animation: confirmIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.add-photos-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.add-photos-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.add-photos-body .drop-zone {
    padding: 2rem 1.5rem;
}

.add-photos-body .preview-container {
    margin-top: 0.75rem;
}

.add-photos-progress {
    text-align: center;
    padding: 2rem 1rem;
}

.add-photos-progress .loading-spinner {
    margin: 0 auto 1rem;
}

.add-photos-progress .processing-title {
    margin-bottom: 1rem;
}

.add-photos-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

/* Mobile label helper – show short labels only on mobile */
.btn-label-short {
    display: none;
}

/* ===================== Math Toolbar ===================== */
.math-toolbar {
    margin-bottom: 0.35rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.math-toolbar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1;
}

.math-toolbar-toggle:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-bg);
}

/* Tooltip on hover */
.math-toolbar-toggle::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    background: var(--color-text);
    color: #fff;
    font-size: 0.72rem;
    font-style: normal;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.math-toolbar-toggle::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--color-text);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.math-toolbar-toggle:hover::after,
.math-toolbar-toggle:hover::before {
    opacity: 1;
}

.math-toolbar-toggle--open {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-bg);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
    position: relative;
    z-index: 1;
    margin-bottom: -1px;
}

.math-toolbar-toggle-icon {
    font-style: italic;
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1;
}

.math-toolbar-toggle-icon sub {
    font-size: 0.6em;
    vertical-align: baseline;
    position: relative;
    top: 0.2em;
}

.math-toolbar-body {
    display: none;
    width: 100%;
    padding: 0.5rem 0.6rem 0.4rem;
    border: 1px solid var(--color-primary);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    background: var(--color-surface);
    flex-direction: column;
    gap: 0.3rem;
}

.math-toolbar-body--open {
    display: flex;
    animation: toolbarSlideDown 0.15s ease-out;
}

@keyframes toolbarSlideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.math-toolbar-group {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
}

.math-toolbar-group-label {
    flex-shrink: 0;
    font-size: 0.64rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding-top: 0.25rem;
    min-width: 62px;
}

.math-toolbar-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
}

.math-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    min-height: 28px;
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1;
    position: relative;
}

.math-toolbar-btn:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-bg);
    color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-xs);
}

.math-toolbar-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.math-toolbar-btn-label {
    pointer-events: none;
}

.math-toolbar-btn-label .katex {
    font-size: 0.85em;
}

/* Prof page toolbar color accent */
.exercise-card--prof .math-toolbar-toggle:hover,
.exercise-card--prof .math-toolbar-toggle--open {
    border-color: var(--color-purple);
    color: var(--color-purple);
    background: var(--color-purple-bg);
}

.exercise-card--prof .math-toolbar-toggle--open {
    border-bottom-color: transparent;
}

.exercise-card--prof .math-toolbar-body {
    border-color: var(--color-purple);
}

.exercise-card--prof .math-toolbar-btn:hover {
    border-color: var(--color-purple);
    background: var(--color-purple-bg);
    color: var(--color-purple);
}

/* ===================== Responsive ===================== */

/* Tablet: 3-col → 2-col (photo + editor stacked, preview below) */
@media (max-width: 1100px) {
    .exercise-body--3col {
        grid-template-columns: 1fr 1fr;
    }

    .exercise-body--3col .exercise-preview-col {
        grid-column: 1 / -1;
    }

    .container--wide {
        max-width: 960px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 1rem;
    }

    .container--wide {
        max-width: 100%;
    }

    main {
        padding: 2.5rem 0 3rem;
    }

    .exercise-body,
    .exercise-body--3col {
        grid-template-columns: 1fr;
    }

    .exercise-body--3col .exercise-preview-col {
        grid-column: auto;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
        margin: 0 -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }

    .generate-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
        width: 100%;
    }

    .generate-buttons .btn {
        width: 100%;
        text-align: center;
        font-size: 0.78rem;
        padding: 0.5rem 0.6rem;
    }

    .generate-buttons .save-indicator {
        grid-column: 1 / -1;
        text-align: center;
        justify-content: center;
    }

    .btn-label-long {
        display: none;
    }

    .btn-label-short {
        display: inline;
    }

    .download-banner {
        flex-direction: column;
        text-align: center;
    }

    .download-actions {
        flex-direction: column;
        width: 100%;
    }

    .download-actions .btn {
        width: 100%;
        text-align: center;
    }

    .home-hero h2 {
        font-size: 1.65rem;
    }

    .home-cards {
        grid-template-columns: 1fr;
    }

    .workflow-steps {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .workflow-arrow {
        display: none;
    }

    .recueils-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .folders-list {
        gap: 0.3rem;
    }

    .folder-chip {
        padding: 0.35rem 0.65rem;
        font-size: 0.78rem;
    }

    .folder-chip-actions {
        display: none !important;
    }

    .move-folder-dropdown {
        right: auto;
        left: 0;
    }

    .new-folder-inline {
        flex-wrap: wrap;
    }

    .recueil-card-main {
        flex-direction: column;
    }

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

    .recueil-actions .btn {
        width: 100%;
        text-align: center;
    }

    .nav-buttons {
        flex-direction: row;
        width: 100%;
    }

    .nav-buttons .btn {
        flex: 1;
        text-align: center;
        font-size: 0.78rem;
        padding: 0.5rem 0.6rem;
    }

    .header-inner {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .auth-card {
        padding: 2rem 1.25rem;
    }

    .add-exercise-group {
        flex-direction: column;
    }

    .add-photos-box {
        width: 96%;
        padding: 1rem;
    }

    .drop-zone {
        padding: 2.5rem 1.5rem;
    }

    .math-toolbar-group {
        flex-direction: column;
        gap: 0.2rem;
    }

    .math-toolbar-group-label {
        min-width: 0;
    }

    .math-toolbar-btn {
        min-width: 28px;
        min-height: 26px;
        padding: 0.1rem 0.3rem;
        font-size: 0.78rem;
    }
}
