/* ═══════════════════════════════════════════════════════════════════
   Scholar — app.css  v2.0  (redesign moderne)
   Typo : Lora (titres) + DM Sans (interface)
   Layout : sidebar fixe gauche + contenu pleine largeur
   ═══════════════════════════════════════════════════════════════════ */



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

/* ── Variables ──────────────────────────────────────────────────── */
:root {
    /* Palette */
    --c-bg:          #FAF8F5;
    --c-bg2:         #F3F0EB;
    --c-surface:     #FFFFFF;
    --c-border:      #E8E3DA;
    --c-border-soft: #F0EDE6;

    /* Vert sapin — brand */
    --c-pine:        #1C3D2F;
    --c-pine-mid:    #2D5A42;
    --c-pine-light:  #4CAF82;
    --c-pine-pale:   #E6F5ED;

    /* Accents */
    --c-gold:        #C9A84C;
    --c-gold-pale:   #FBF4E0;
    --c-amber:       #E8943A;
    --c-amber-pale:  #FEF1E4;
    --c-rose:        #D4607A;
    --c-rose-pale:   #FDEDF1;
    --c-sky:         #4A8BB5;
    --c-sky-pale:    #EBF4FC;
    --c-violet:      #7B5EA7;
    --c-violet-pale: #F0EBF9;

    /* Text */
    --c-text:        #1A1814;
    --c-text-mid:    #3D3829;
    --c-muted:       #8C8273;
    --c-muted-light: #B5AA9E;

    /* Danger */
    --c-danger:      #C0392B;
    --c-danger-pale: #FDECEB;

    /* Sidebar */
    --sidebar-w:     240px;

    /* Radius */
    --r-sm:   6px;
    --r-md:   10px;
    --r-lg:   16px;
    --r-xl:   24px;
    --r-full: 9999px;

    /* Shadows */
    --shadow-xs:  0 1px 2px rgba(28,61,47,.04);
    --shadow-sm:  0 2px 6px rgba(28,61,47,.06), 0 1px 2px rgba(28,61,47,.04);
    --shadow-md:  0 4px 16px rgba(28,61,47,.08), 0 2px 4px rgba(28,61,47,.05);
    --shadow-lg:  0 12px 40px rgba(28,61,47,.12), 0 4px 12px rgba(28,61,47,.06);
    --shadow-glow:0 0 0 3px rgba(76,175,130,.22);

    /* Typography */
    --font-ui:    'DM Sans', system-ui, sans-serif;
    --font-serif: 'Lora', Georgia, serif;

    /* ── Alias de compatibilité (anciennes variables) ── */
    --color-bg:      var(--c-bg);
    --color-border:  var(--c-border);
    --color-text:    var(--c-text);
    --color-muted:   var(--c-muted);
    --color-primary: var(--c-pine-mid);
    --color-danger:  var(--c-danger);
    --color-surface: var(--c-surface);
    --radius:        var(--r-md);
}

/* ── Base ───────────────────────────────────────────────────────── */
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-ui);
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--c-pine-mid); text-decoration: none; transition: color .15s; }
a:hover { color: var(--c-pine); }

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--c-pine);
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow: hidden;
}

/* Texture subtile sur la sidebar */
.sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

/* Logo */
.sidebar-brand {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -.3px;
    text-decoration: none;
}
.sidebar-brand-icon {
    width: 34px; height: 34px;
    background: rgba(255,255,255,.12);
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* Nav items */
.sidebar-nav {
    flex: 1;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}
.sidebar-nav-section {
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255,255,255,.3);
    padding: 14px 8px 6px;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r-md);
    color: rgba(255,255,255,.65);
    font-size: .875rem;
    font-weight: 400;
    transition: background .15s, color .15s;
    position: relative;
}
.sidebar-nav a svg {
    flex-shrink: 0;
    opacity: .8;
    transition: opacity .15s;
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}
.sidebar-nav a:hover svg { opacity: 1; }
.sidebar-nav a.active {
    background: rgba(76,175,130,.2);
    color: #fff;
    font-weight: 500;
}
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 18px;
    background: var(--c-pine-light);
    border-radius: 0 3px 3px 0;
}

/* User area */
.sidebar-user {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-avatar {
    width: 32px; height: 32px;
    background: rgba(255,255,255,.15);
    border-radius: var(--r-full);
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}
.sidebar-user-name {
    flex: 1;
    font-size: .8rem;
    color: rgba(255,255,255,.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-logout {
    color: rgba(255,255,255,.4) !important;
    padding: 4px !important;
    gap: 0 !important;
    border-radius: var(--r-sm) !important;
    transition: color .15s, background .15s;
}
.sidebar-logout:hover {
    color: rgba(255,255,255,.8) !important;
    background: rgba(255,255,255,.08) !important;
}

/* ── Main layout ────────────────────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.main-content {
    flex: 1;
    padding: 36px 40px;
    width: 100%;
}
.footer {
    margin-left: var(--sidebar-w);
    text-align: center;
    padding: 20px 24px;
    color: var(--c-muted-light);
    font-size: .75rem;
    border-top: 1px solid var(--c-border);
}

/* ── Page header ────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
}
.page-header h1 {
    font-family: var(--font-serif);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--c-text);
    letter-spacing: -.3px;
    line-height: 1.2;
}
.page-header-sub {
    font-size: .875rem;
    color: var(--c-muted);
    margin-top: 4px;
}

/* ── Stat chips (dashboard) ────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow .2s, transform .2s;
    text-decoration: none;
    color: var(--c-text);
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    color: var(--c-text);
}
.stat-icon {
    width: 46px; height: 46px;
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon-pine   { background: var(--c-pine-pale); color: var(--c-pine-mid); }
.stat-icon-gold   { background: var(--c-gold-pale); color: var(--c-gold); }
.stat-icon-amber  { background: var(--c-amber-pale); color: var(--c-amber); }
.stat-icon-sky    { background: var(--c-sky-pale); color: var(--c-sky); }
.stat-icon-violet { background: var(--c-violet-pale); color: var(--c-violet); }
.stat-icon-rose   { background: var(--c-rose-pale); color: var(--c-rose); }
.stat-value {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 2px;
}
.stat-label { font-size: .78rem; color: var(--c-muted); font-weight: 400; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--r-md);
    font-size: .875rem;
    font-weight: 500;
    font-family: var(--font-ui);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:active { transform: translateY(1px); }
.btn svg { flex-shrink: 0; }

.btn-primary {
    background: var(--c-pine);
    color: #fff;
    border-color: var(--c-pine);
    box-shadow: 0 1px 3px rgba(28,61,47,.3);
}
.btn-primary:hover {
    background: var(--c-pine-mid);
    color: #fff;
    box-shadow: 0 3px 10px rgba(28,61,47,.25);
}
.btn-accent {
    background: var(--c-pine-light);
    color: #fff;
    border-color: var(--c-pine-light);
    box-shadow: 0 1px 3px rgba(76,175,130,.3);
}
.btn-accent:hover {
    background: #3d9e70;
    color: #fff;
}
.btn-outline {
    background: var(--c-surface);
    border-color: var(--c-border);
    color: var(--c-text-mid);
}
.btn-outline:hover {
    background: var(--c-bg2);
    border-color: #ccc8be;
    color: var(--c-text);
}
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--c-muted);
}
.btn-ghost:hover {
    background: var(--c-bg2);
    color: var(--c-text);
}
.btn-danger {
    background: var(--c-danger);
    color: #fff;
    border-color: var(--c-danger);
}
.btn-danger:hover { background: #a93226; color: #fff; }

.btn-sm  { padding: 6px 12px; font-size: .8rem; border-radius: var(--r-sm); }
.btn-xs  { padding: 3px 8px; font-size: .75rem; border-radius: var(--r-sm); }
.btn-full { width: 100%; justify-content: center; }
.btn-icon {
    padding: 8px;
    border-radius: var(--r-sm);
    background: transparent;
    border-color: transparent;
    color: var(--c-muted);
}
.btn-icon:hover { background: var(--c-bg2); color: var(--c-text); }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.card-sm { padding: 16px 18px; border-radius: var(--r-md); }
.card-hover {
    transition: box-shadow .2s, transform .2s;
}
.card-hover:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--c-border-soft);
}
.card-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--c-text);
}

/* Note card spécifique */
.note-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .2s, transform .2s;
}
.note-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* ── Forms ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

/* Labels en casse normale pour les formulaires de citations */
#citation-form-wrap .form-group label,
#edit-citation-modal .form-group label {
    text-transform: none;
    letter-spacing: 0;
    font-size: .82rem;
}
.form-group label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--c-muted);
    margin-bottom: 7px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--r-md);
    font-size: .9rem;
    font-family: var(--font-ui);
    background: var(--c-surface);
    color: var(--c-text);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    appearance: none;
}
.form-control:focus {
    border-color: var(--c-pine-light);
    box-shadow: var(--shadow-glow);
}
.form-control::placeholder { color: var(--c-muted-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-hint { font-size: .78rem; color: var(--c-muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Filter bar ─────────────────────────────────────────────────── */
.filter-bar {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 16px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-xs);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filter-bar .form-group { margin: 0; }
.filter-bar label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--c-muted);
    margin-bottom: 5px;
}
.filter-bar .form-control { font-size: .875rem; padding: 8px 12px; }

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--r-md);
    margin-bottom: 20px;
    font-size: .875rem;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: var(--c-pine-pale); color: #155724; border-color: #b7e4c7; }
.alert-error   { background: var(--c-danger-pale); color: #721c24; border-color: #f5c6cb; }
.alert-info    { background: var(--c-sky-pale); color: #0c5460; border-color: #bee5eb; }
.alert-warning { background: var(--c-gold-pale); color: #856404; border-color: #ffeeba; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: var(--r-full);
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .03em;
}
.badge-draft     { background: #F1F0ED; color: #7A7060; }
.badge-validated { background: var(--c-pine-pale); color: var(--c-pine-mid); }
.badge-archived  { background: var(--c-gold-pale); color: #8A6B1A; }
.badge-active    { background: var(--c-sky-pale); color: var(--c-sky); }
.badge-completed { background: var(--c-pine-pale); color: var(--c-pine-mid); }

/* ── Type pills (note types) ────────────────────────────────────── */
.type-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--r-full);
    font-size: .72rem;
    font-weight: 500;
}
.type-citation    { background: var(--c-sky-pale); color: var(--c-sky); }
.type-summary     { background: var(--c-pine-pale); color: var(--c-pine-mid); }
.type-analysis    { background: var(--c-violet-pale); color: var(--c-violet); }
.type-question    { background: var(--c-amber-pale); color: var(--c-amber); }
.type-idea        { background: var(--c-gold-pale); color: var(--c-gold); }
.type-hypothesis  { background: var(--c-rose-pale); color: var(--c-rose); }
.type-reading_sheet { background: var(--c-pine-pale); color: var(--c-pine-mid); }
.type-free        { background: #F3F1ED; color: var(--c-muted); }

/* ── Divider ────────────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--c-border);
    margin: 20px 0;
}

/* ── Auth pages ─────────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-bg);
    padding: 24px;
}
.auth-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-xl);
    padding: 48px 44px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
}
.auth-card h1 {
    font-family: var(--font-serif);
    font-size: 1.7rem;
    font-weight: 600;
    color: var(--c-pine);
    margin-bottom: 6px;
}
.auth-card .subtitle { color: var(--c-muted); font-size: .9rem; margin-bottom: 32px; }
.auth-logo {
    width: 52px; height: 52px;
    background: var(--c-pine);
    border-radius: var(--r-lg);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 24px;
}

/* ── Empty states ───────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 72px 32px;
}
.empty-state-icon {
    width: 72px; height: 72px;
    background: var(--c-pine-pale);
    border-radius: var(--r-xl);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
    color: var(--c-pine-light);
}
.empty-state h2 {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--c-text);
}
.empty-state p { color: var(--c-muted); margin-bottom: 24px; max-width: 360px; margin-left: auto; margin-right: auto; }

/* ── Section labels ─────────────────────────────────────────────── */
.section-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--c-muted);
    margin-bottom: 10px;
}

/* ── Utility ────────────────────────────────────────────────────── */
.text-muted   { color: var(--c-muted); }
.text-sm      { font-size: .875rem; }
.text-xs      { font-size: .78rem; }
.text-center  { text-align: center; }
.text-serif   { font-family: var(--font-serif); }
.font-semibold { font-weight: 600; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 14px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 14px; } .mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 6px; } .gap-2 { gap: 12px; }
.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── Color dot ──────────────────────────────────────────────────── */
.color-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ── Tag pill ───────────────────────────────────────────────────── */
.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-full);
    font-size: .75rem;
    font-weight: 500;
    border-width: 1px;
    border-style: solid;
}

/* ── Scrollbar styling ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-muted-light); }

/* ── Source type chip ───────────────────────────────────────────── */
.source-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--c-bg2);
    border: 1px solid var(--c-border);
    border-radius: var(--r-full);
    font-size: .75rem;
    color: var(--c-muted);
    font-weight: 500;
}

/* ── Breadcrumb ─────────────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    color: var(--c-muted);
    margin-bottom: 20px;
}
.breadcrumb a { color: var(--c-muted); }
.breadcrumb a:hover { color: var(--c-pine); }
.breadcrumb-sep { color: var(--c-border); }

/* ── Progress bar ───────────────────────────────────────────────── */
.progress-bar {
    height: 4px;
    background: var(--c-border);
    border-radius: var(--r-full);
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--c-pine-light);
    border-radius: var(--r-full);
    transition: width .3s ease;
}

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20,30,24,.5);
    backdrop-filter: blur(3px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-card {
    background: var(--c-surface);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--c-border);
}
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--c-border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════
   SCHOLAR EDITOR — éditeur vanilla JS (ne pas toucher)
   La toolbar (.se-toolbar) et la zone (.se-area)
   sont injectées dynamiquement par editor.js.
   ATTENTION : ne pas mettre display:flex sur #editor.
   ═══════════════════════════════════════════════════ */

#editor {
    border: 1.5px solid var(--c-border);
    border-radius: var(--r-lg);
    background: var(--c-surface);
    overflow: visible; /* sticky toolbar nécessite visible */
    position: relative;
}
#editor:focus-within {
    border-color: var(--c-pine-light);
    box-shadow: var(--shadow-glow);
}

.se-toolbar {
    display: flex; flex-wrap: wrap; gap: 2px;
    padding: 8px 12px; border-bottom: 1px solid var(--c-border-soft);
    background: var(--c-bg); user-select: none; align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border: 1.5px solid var(--c-border);
    border-bottom: 1px solid var(--c-border-soft);
    margin: -1.5px -1.5px 0 -1.5px; /* compense la bordure du #editor */
}
#editor:focus-within .se-toolbar {
    border-color: var(--c-pine-light);
    border-bottom-color: var(--c-border-soft);
}
.se-group  { display: inline-flex; gap: 2px; align-items: center; }
.se-sep    { display: inline-block; width: 1px; height: 20px; background: var(--c-border); margin: 0 5px; flex-shrink: 0; }
.se-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    min-width: 30px; height: 28px; padding: 0 7px;
    border: 1px solid transparent; border-radius: var(--r-sm);
    background: transparent; cursor: pointer;
    font-size: .82rem; font-family: var(--font-ui);
    color: var(--c-text-mid); white-space: nowrap; line-height: 1;
    transition: background .12s, color .12s;
}
.se-btn:hover  { background: var(--c-pine-pale); color: var(--c-pine-mid); }
.se-btn.active { background: var(--c-pine-pale); color: var(--c-pine-mid); font-weight: 600; }
.se-btn-apply  { background: var(--c-pine) !important; color: #fff !important; }
.se-btn-apply:hover { background: var(--c-pine-mid) !important; }
.se-color-btn { position: relative; }
.se-select {
    height: 28px; padding: 0 8px; border: 1px solid var(--c-border); border-radius: var(--r-sm);
    font-size: .82rem; font-family: var(--font-ui); background: var(--c-surface); cursor: pointer; color: var(--c-text-mid);
}
.se-select:focus { outline: none; border-color: var(--c-pine-light); }
.se-link-panel {
    position: absolute; top: calc(100% + 6px); left: 12px; right: 12px;
    background: var(--c-surface); border: 1.5px solid var(--c-pine-light);
    border-radius: var(--r-md); padding: 12px 14px;
    box-shadow: var(--shadow-lg); z-index: 100;
    display: flex; flex-direction: column; gap: 8px;
}
.se-link-panel input {
    width: 100%; padding: 7px 10px; border: 1px solid var(--c-border); border-radius: var(--r-sm);
    font-family: var(--font-ui); font-size: .875rem; color: var(--c-text); background: var(--c-bg); outline: none;
}
.se-link-panel input:focus { border-color: var(--c-pine-light); }
.se-bubble {
    position: absolute; display: none; align-items: center; gap: 2px;
    background: var(--c-pine); border-radius: var(--r-md);
    padding: 4px 6px; box-shadow: var(--shadow-lg); z-index: 999; pointer-events: all;
}
.se-bubble button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 26px; background: transparent; border: none; cursor: pointer;
    color: rgba(255,255,255,.8); border-radius: var(--r-sm); transition: background .12s, color .12s;
}
.se-bubble button:hover { background: rgba(255,255,255,.15); color: #fff; }
.se-bubble-sep { display: inline-block; width: 1px; height: 16px; background: rgba(255,255,255,.2); margin: 0 3px; }
.se-area {
    min-height: 440px; padding: 24px 32px; outline: none;
    font-size: .97rem; line-height: 1.85; color: var(--c-text); font-family: var(--font-ui);
}
.se-area:empty::before {
    content: attr(data-placeholder); color: var(--c-muted-light);
    pointer-events: none; white-space: pre-line; font-style: italic;
}
.se-area h1 { font-family: var(--font-serif); font-size: 1.7rem; font-weight: 600; margin: 24px 0 12px; color: var(--c-pine); line-height: 1.3; }
.se-area h2 { font-family: var(--font-serif); font-size: 1.3rem; font-weight: 600; margin: 20px 0 10px; color: var(--c-text); }
.se-area h3 { font-size: 1.05rem; font-weight: 700; margin: 16px 0 8px; color: var(--c-text-mid); }
.se-area h4 { font-size: 1rem; font-weight: 600; margin: 12px 0 6px; color: var(--c-muted); }
.se-area p  { margin: 0 0 12px; }
.se-area ul, .se-area ol { padding-left: 26px; margin-bottom: 12px; }
.se-area li { margin-bottom: 4px; }
.se-area blockquote {
    border-left: 4px solid var(--c-pine-light); margin: 16px 0; padding: 12px 20px;
    background: var(--c-pine-pale); color: var(--c-text-mid); font-style: italic;
    border-radius: 0 var(--r-md) var(--r-md) 0;
}
.se-area pre {
    background: #1C2B22; color: #B6E2C8; padding: 18px 20px; border-radius: var(--r-md);
    overflow-x: auto; margin: 14px 0; font-family: 'JetBrains Mono','Consolas',monospace; font-size: .875rem; line-height: 1.6;
}
.se-area pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.se-area code { background: var(--c-pine-pale); color: var(--c-pine-mid); padding: 2px 6px; border-radius: 4px; font-size: .875em; font-family: 'JetBrains Mono','Consolas',monospace; }
.se-area img  { max-width: 100%; border-radius: var(--r-md); margin: 8px 0; display: block; }
.se-area figure { margin: 16px 0; }
.se-area figcaption { text-align: center; font-size: .85rem; color: var(--c-muted); margin-top: 6px; font-style: italic; outline: none; }
.se-area table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.se-area th, .se-area td { border: 1px solid var(--c-border); padding: 8px 14px; }
.se-area th { background: var(--c-bg2); font-weight: 600; }
.se-area tr:hover td { background: var(--c-bg); }
.se-area a  { color: var(--c-pine-mid); text-decoration: underline; text-underline-offset: 3px; }


/* ── Rendu lecture seule (notes/show.php) ────────────────────────────────────
   #note-render hérite de .se-area via la classe mais on renforce ici
   les éléments qui pourraient être écrasés par des styles de carte     */
#note-render { min-height: 0 !important; }
#note-render h1 { font-family: var(--font-serif); font-size: 1.7rem; font-weight: 600; margin: 20px 0 12px; color: var(--c-pine); line-height: 1.3; }
#note-render h2 { font-family: var(--font-serif); font-size: 1.3rem; font-weight: 600; margin: 16px 0 8px; }
#note-render h3 { font-size: 1.05rem; font-weight: 700; margin: 14px 0 6px; }
#note-render h4 { font-size: 1rem; font-weight: 600; margin: 10px 0 4px; color: var(--c-muted); }
#note-render p  { margin: 0 0 12px; }
#note-render ul, #note-render ol { padding-left: 26px; margin-bottom: 12px; }
#note-render li { margin-bottom: 4px; line-height: 1.7; }
#note-render blockquote {
    border-left: 4px solid var(--c-pine-light); margin: 16px 0; padding: 12px 20px;
    background: var(--c-pine-pale); color: var(--c-text-mid); font-style: italic;
    border-radius: 0 var(--r-md) var(--r-md) 0;
}
#note-render pre {
    background: #1C2B22; color: #B6E2C8; padding: 18px 20px; border-radius: var(--r-md);
    overflow-x: auto; margin: 14px 0; line-height: 1.6;
    font-family: 'JetBrains Mono','Consolas',monospace; font-size: .875rem;
}
#note-render pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
#note-render code {
    background: var(--c-pine-pale); color: var(--c-pine-mid);
    padding: 2px 6px; border-radius: 4px; font-size: .875em;
    font-family: 'JetBrains Mono','Consolas',monospace;
}
#note-render img  { max-width: 100%; border-radius: var(--r-md); margin: 8px 0; display: block; }
#note-render figure { margin: 16px 0; }
#note-render figcaption { text-align: center; font-size: .85rem; color: var(--c-muted); margin-top: 6px; font-style: italic; }
#note-render table { width: 100%; border-collapse: collapse; margin: 14px 0; }
#note-render th, #note-render td { border: 1px solid var(--c-border); padding: 8px 14px; }
#note-render th { background: var(--c-bg2); font-weight: 600; }
#note-render tr:hover td { background: var(--c-bg); }
#note-render a  { color: var(--c-pine-mid); text-decoration: underline; text-underline-offset: 3px; }
#note-render hr { border: none; border-top: 2px solid var(--c-border); margin: 20px 0; }
/* Alignements texte (préservés depuis l'éditeur) */
#note-render [style*="text-align: center"], #note-render [style*="text-align:center"] { text-align: center; }
#note-render [style*="text-align: right"],  #note-render [style*="text-align:right"]  { text-align: right; }
#note-render [style*="text-align: justify"],#note-render [style*="text-align:justify"]{ text-align: justify; }


/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile first (breakpoint 768px)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Bouton hamburger (visible uniquement sur mobile) ─────────────── */
.hamburger {
    display: none;
    position: fixed;
    top: 12px; left: 12px;
    z-index: 300;
    width: 40px; height: 40px;
    background: var(--c-pine);
    border: none; border-radius: var(--r-md);
    cursor: pointer;
    align-items: center; justify-content: center;
    flex-direction: column; gap: 5px;
    padding: 10px;
    box-shadow: var(--shadow-md);
}
.hamburger span {
    display: block;
    width: 18px; height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .25s, opacity .25s;
}

/* Overlay fond quand sidebar ouverte */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 190;
    backdrop-filter: blur(2px);
}

@media (max-width: 768px) {

    /* ── Sidebar en drawer ───────────────────────────────────────── */
    .sidebar {
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        z-index: 200;
        width: var(--sidebar-w);
    }
    .sidebar.is-open {
        transform: translateX(0);
    }
    .sidebar-overlay.is-open {
        display: block;
    }

    /* ── Hamburger visible ───────────────────────────────────────── */
    .hamburger {
        display: flex;
    }

    /* ── Main layout pleine largeur ──────────────────────────────── */
    .main-wrapper {
        margin-left: 0;
        padding-top: 0;
    }
    .main-content {
        padding: 64px 16px 24px; /* 64px pour laisser place au hamburger */
    }
    .footer {
        margin-left: 0;
    }

    /* ── Page header empilé sur mobile ───────────────────────────── */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .page-header > div:last-child,
    .page-header > a:last-child {
        width: 100%;
    }

    /* ── Grids 2 colonnes → 1 colonne ───────────────────────────── */
    [style*="grid-template-columns:1fr 320px"],
    [style*="grid-template-columns:1fr 300px"],
    [style*="grid-template-columns:1fr 340px"],
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 320px"],
    [style*="grid-template-columns: 1fr 300px"],
    [style*="grid-template-columns: 1fr 340px"],
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* ── Sidebar sticky → statique sur mobile ────────────────────── */
    [style*="position:sticky"],
    [style*="position: sticky"] {
        position: static !important;
        max-height: none !important;
    }

    /* ── Stat grid dashboard ─────────────────────────────────────── */
    .stat-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    /* ── Tableaux infos bibliographiques ─────────────────────────── */
    table[style*="border-collapse:collapse"] td:first-child,
    table[style*="border-collapse: collapse"] td:first-child {
        padding-bottom: 2px;
    }

    /* ── Barre de filtres ────────────────────────────────────────── */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-bar .form-group,
    .filter-bar .form-control {
        width: 100%;
    }

    /* ── Grille notes (carte) → 1 colonne ───────────────────────── */
    #view-card {
        grid-template-columns: 1fr !important;
    }

    /* ── Boutons actions page header ─────────────────────────────── */
    .page-header .btn {
        flex: 1;
        text-align: center;
        justify-content: center;
    }

    /* ── Editor toolbar wrapping ─────────────────────────────────── */
    .se-toolbar {
        gap: 4px;
        padding: 6px 8px;
    }

    /* ── Modales plein écran sur mobile ──────────────────────────── */
    .card[style*="max-width:560px"],
    .card[style*="max-width: 560px"],
    .card[style*="max-width:580px"],
    .card[style*="max-width: 580px"],
    .card[style*="max-width:760px"],
    .card[style*="max-width: 760px"] {
        max-width: 100% !important;
        margin: 0 !important;
    }

    /* ── Forms grids → colonne ───────────────────────────────────── */
    [style*="grid-template-columns:180px 1fr"],
    [style*="grid-template-columns: 180px 1fr"],
    [style*="grid-template-columns:120px 1fr"],
    [style*="grid-template-columns: 120px 1fr"],
    [style*="grid-template-columns:1fr 1fr"][class=""],
    [style*="grid-template-columns: 1fr 1fr"][class=""] {
        grid-template-columns: 1fr !important;
    }

    /* ── Réduire les padding des cards ──────────────────────────── */
    .card { padding: 16px; }
    .card-sm { padding: 12px 14px; }
}

/* ── Tablette (769px–1024px) ──────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
    :root { --sidebar-w: 200px; }
    .main-content { padding: 28px 24px; }

    [style*="grid-template-columns:1fr 320px"],
    [style*="grid-template-columns: 1fr 320px"] {
        grid-template-columns: 1fr 260px !important;
    }
    [style*="grid-template-columns:1fr 340px"],
    [style*="grid-template-columns: 1fr 340px"] {
        grid-template-columns: 1fr 260px !important;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   Scholar — Dark Mode
   Activé via : [data-theme="dark"] sur <html>
   3 modes : light | dark | auto (suit prefers-color-scheme)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Palette sombre ─────────────────────────────────────────────── */
[data-theme="dark"] {
    /* Fonds — tons sapin nuit */
    --c-bg:          #161d19;
    --c-bg2:         #1c2620;
    --c-surface:     #212e27;
    --c-border:      #2e3d35;
    --c-border-soft: #263229;

    /* Vert sapin — brand (inchangé, déjà lisible sur fond sombre) */
    --c-pine:        #1C3D2F;
    --c-pine-mid:    #5ecf94;
    --c-pine-light:  #6edfa0;
    --c-pine-pale:   #1a3028;

    /* Accents — versions lumineuses sur fond sombre */
    --c-gold:        #e0b94f;
    --c-gold-pale:   #2a2210;
    --c-amber:       #f0a050;
    --c-amber-pale:  #2a1c0a;
    --c-rose:        #e8758a;
    --c-rose-pale:   #2a1018;
    --c-sky:         #60a8d8;
    --c-sky-pale:    #0e1e2e;
    --c-violet:      #a080cc;
    --c-violet-pale: #1a1228;

    /* Texte */
    --c-text:        #e8e3da;
    --c-text-mid:    #c8bfb2;
    --c-muted:       #8a9a90;
    --c-muted-light: #5a6e62;

    /* Danger */
    --c-danger:      #e05050;
    --c-danger-pale: #2a1010;

    /* Shadows */
    --shadow-xs:  0 1px 2px rgba(0,0,0,.3);
    --shadow-sm:  0 2px 6px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
    --shadow-md:  0 4px 16px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.3);
    --shadow-lg:  0 12px 40px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.35);
    --shadow-glow:0 0 0 3px rgba(110,223,160,.2);
}

/* ── Mode auto : suit l'OS si data-theme="auto" ─────────────────── */
@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        --c-bg:          #161d19;
        --c-bg2:         #1c2620;
        --c-surface:     #212e27;
        --c-border:      #2e3d35;
        --c-border-soft: #263229;
        --c-pine:        #1C3D2F;
        --c-pine-mid:    #5ecf94;
        --c-pine-light:  #6edfa0;
        --c-pine-pale:   #1a3028;
        --c-gold:        #e0b94f;
        --c-gold-pale:   #2a2210;
        --c-amber:       #f0a050;
        --c-amber-pale:  #2a1c0a;
        --c-rose:        #e8758a;
        --c-rose-pale:   #2a1018;
        --c-sky:         #60a8d8;
        --c-sky-pale:    #0e1e2e;
        --c-violet:      #a080cc;
        --c-violet-pale: #1a1228;
        --c-text:        #e8e3da;
        --c-text-mid:    #c8bfb2;
        --c-muted:       #8a9a90;
        --c-muted-light: #5a6e62;
        --c-danger:      #e05050;
        --c-danger-pale: #2a1010;
        --shadow-xs:  0 1px 2px rgba(0,0,0,.3);
        --shadow-sm:  0 2px 6px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
        --shadow-md:  0 4px 16px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.3);
        --shadow-lg:  0 12px 40px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.35);
        --shadow-glow:0 0 0 3px rgba(110,223,160,.2);
    }
}

/* ── Correctifs dark pour éléments non couverts par les variables ── */

/* Sidebar : reste sur fond sapin foncé, mais ajuster les textes */
[data-theme="dark"] .sidebar,
[data-theme="auto"]:is([data-theme="auto"]) .sidebar {
    background: #0f1c15;
}

/* Images : légèrement atténuées */
[data-theme="dark"] img,
[data-theme="dark"] [data-theme="auto"] img {
    filter: brightness(.92) contrast(.97);
}

/* Scrollbar dark */
[data-theme="dark"] ::-webkit-scrollbar-thumb,
[data-theme="auto"] ::-webkit-scrollbar-thumb {
    background: var(--c-border);
}

/* Badges statuts — couleurs hardcodées à corriger en dark */
[data-theme="dark"] .badge-draft,
[data-theme="auto"] .badge-draft {
    background: #2a2820; color: #a09880;
}

/* Alerts dark */
[data-theme="dark"] .alert-success,
[data-theme="auto"] .alert-success { color: var(--c-pine-mid); border-color: var(--c-border); }
[data-theme="dark"] .alert-error,
[data-theme="auto"] .alert-error   { color: var(--c-danger);   border-color: var(--c-border); }
[data-theme="dark"] .alert-info,
[data-theme="auto"] .alert-info    { color: var(--c-sky);      border-color: var(--c-border); }
[data-theme="dark"] .alert-warning,
[data-theme="auto"] .alert-warning { color: var(--c-gold);     border-color: var(--c-border); }

/* Éditeur Scholar — fond de l'aire d'édition */
[data-theme="dark"] .se-area,
[data-theme="auto"] .se-area {
    background: var(--c-surface) !important;
    color: var(--c-text) !important;
}
[data-theme="dark"] .se-toolbar,
[data-theme="auto"] .se-toolbar {
    background: var(--c-bg2) !important;
    border-color: var(--c-border) !important;
}
[data-theme="dark"] .se-toolbar button,
[data-theme="auto"] .se-toolbar button {
    color: var(--c-text) !important;
}
[data-theme="dark"] .se-toolbar button:hover,
[data-theme="auto"] .se-toolbar button:hover {
    background: var(--c-border) !important;
}

/* Sélection texte */
[data-theme="dark"] ::selection,
[data-theme="auto"] ::selection {
    background: rgba(110,223,160,.25);
    color: var(--c-text);
}

/* Tables */
[data-theme="dark"] table th,
[data-theme="auto"] table th {
    background: var(--c-bg2);
}
[data-theme="dark"] table tr:hover td,
[data-theme="auto"] table tr:hover td {
    background: var(--c-bg2);
}

/* Focus mode bandeau */
[data-theme="dark"] .focus-bandeau,
[data-theme="auto"] .focus-bandeau {
    border-color: var(--c-border);
}

/* ── Bouton thème dans la sidebar ───────────────────────────────── */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border-radius: var(--r-md);
    border: none;
    cursor: pointer;
    background: none;
    font-family: var(--font-ui);
    font-size: .8rem;
    color: rgba(255,255,255,.55);
    transition: background .15s, color .15s;
}
.theme-toggle-btn:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}
.theme-toggle-btn svg { flex-shrink: 0; opacity: .75; }

/* Indicateur mode actif */
.theme-indicator {
    margin-left: auto;
    font-size: .68rem;
    background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.6);
    padding: 1px 6px;
    border-radius: 10px;
}
