/* ==========================================================================
   La trousse péda — styles de l'application
   --------------------------------------------------------------------------
   1. Jetons (couleurs, rayons, ombres)     5. Bibliothèque, outils, aide
   2. Base et accessibilité                 6. Fenêtres et formulaires
   3. Structure (barre latérale, en-tête)   7. Messages
   4. Ma période (frise, cartes)            8. Mobile, impression
   ========================================================================== */

/* 1. JETONS --------------------------------------------------------------- */
:root {
  --ink: #1c2522;          /* texte */
  --muted: #5d6965;        /* texte secondaire (contraste AA sur blanc) */
  --faint: #8a9591;        /* indications */
  --line: #e9dfd5;         /* filets */
  --paper: #ffffff;
  --cream: #f8f2eb;        /* fonds de panneaux */
  --sidebar: #fbf7f2;
  --orange: #e25b20;       /* couleur de la marque (accents, repères) */
  --orange-ink: #b8430f;   /* orange lisible pour texte et boutons pleins */
  --orange-soft: #fdeee4;
  --green: #0e5d4b;        /* sélection */
  --green-soft: #e4f0eb;
  --danger: #b42318;
  --radius: 12px;
  --radius-s: 8px;
  --shadow: 0 1px 2px rgba(60, 40, 25, .06), 0 6px 18px rgba(60, 40, 25, .05);
  --focus: 0 0 0 3px rgba(226, 91, 32, .4);
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

/* 2. BASE ----------------------------------------------------------------- */
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); font-size: 15px; line-height: 1.45; }
body.has-modal { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.15; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-s); }
.skip-link { position: absolute; left: 12px; top: -40px; z-index: 50; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: var(--radius-s); }
.skip-link:focus { top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; background: var(--domain, #999); }
/* Pictogrammes des matières */
.domain-icon { display: inline-block; flex-shrink: 0; object-fit: contain; vertical-align: middle; }
.domain-icon-xs { width: 16px; height: 16px; }
.domain-icon-sm { width: 22px; height: 22px; }
.domain-icon-lg { width: 34px; height: 34px; margin: -3px 0; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: var(--radius-s); padding: 8px 14px;
  font-weight: 700; font-size: 13px; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.button:hover { border-color: #d6c3b3; background: #fffaf6; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.primary { background: var(--orange-ink); border-color: var(--orange-ink); color: #fff; }
.button.primary:hover { background: #9e3a0d; }
.danger-link { border-color: transparent; background: transparent; color: var(--danger); padding-left: 4px; }
.danger-link:hover { background: #fdecea; border-color: transparent; }
.link-button { border: 0; background: none; padding: 0; color: var(--orange-ink); font-weight: 700; text-decoration: underline; }

.icon-button {
  width: 32px; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius-s);
  display: inline-grid; place-items: center; color: var(--muted); font-size: 14px; text-decoration: none; flex-shrink: 0;
}
.icon-button:hover { background: var(--cream); color: var(--ink); }
.icon-button.danger:hover { background: #fdecea; color: var(--danger); border-color: #f3c4bf; }

kbd {
  font: 600 12px/1 "DM Sans", system-ui, sans-serif; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 3px 6px; background: #fff; color: var(--muted);
}

/* 3. STRUCTURE ------------------------------------------------------------ */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 252px; z-index: 30; background: var(--sidebar);
  border-right: 1px solid #f0e6dc; padding: 18px 12px; display: flex; flex-direction: column; overflow-y: auto;
}
.brand { display: flex; justify-content: center; padding: 0 10px 14px; }
.brand-logo { width: 150px; height: 150px; display: block; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 12px; font-weight: 700; color: var(--faint); margin: 18px 12px 6px; }
.nav-item {
  width: 100%; border: 0; background: transparent; text-align: left; padding: 9px 12px; border-radius: 10px;
  display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: #2a3431;
}
a.nav-item { text-decoration: none; }
.nav-item:hover { background: #f5e9df; }
.nav-item.active { background: #f6e2d4; color: var(--orange-ink); }
.nav-icon { width: 18px; text-align: center; color: var(--faint); font-size: 13px; }
.nav-item.active .nav-icon { color: var(--orange); }
.nav-count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid #f0e6dc; }
.nav-item.is-due::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); margin-left: auto; }
.sidebar-scrim { position: fixed; inset: 0; z-index: 25; background: rgba(28, 37, 34, .35); }

.main { margin-left: 252px; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 68px; display: flex; align-items: center; gap: 16px;
  padding: 0 32px; background: rgba(255, 255, 255, .94); backdrop-filter: blur(6px); border-bottom: 1px solid #f2ece6;
}
.menu-button, .topbar-brand { display: none; }
.search-wrap { position: relative; flex: 1; max-width: 560px; }
.search-wrap input {
  width: 100%; border: 1px solid transparent; outline: 0; background: #f8efe8; padding: 11px 44px 11px 40px;
  border-radius: 10px; font-size: 14px;
}
.search-wrap input:focus { background: #fff; border-color: var(--orange); box-shadow: var(--focus); }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-52%); font-size: 18px; color: var(--muted); }
.search-kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.search-wrap input:focus ~ .search-kbd { display: none; }
.topbar-add { margin-left: auto; }

.content { padding: 28px 40px 80px; max-width: 1320px; outline: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 4px 0 20px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(26px, 2.6vw, 34px); letter-spacing: -.025em; margin: 0 0 6px; font-weight: 800; }
.subtitle { color: var(--muted); margin: 0; font-size: 14px; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* 4. MA PÉRIODE ----------------------------------------------------------- */

/* Frise de l'année : l'élément signature de l'application */
.year-strip { display: flex; gap: 4px; margin-bottom: 26px; }
.year-cell {
  position: relative; flex-basis: 0; min-width: 0; text-align: left; border: 1px solid var(--line); background: #fff;
  padding: 10px 14px 12px; display: grid; gap: 1px; transition: background .15s, border-color .15s;
}
.year-cell:first-child { border-radius: var(--radius) 4px 4px var(--radius); }
.year-cell:last-child { border-radius: 4px var(--radius) var(--radius) 4px; }
.year-cell:not(:first-child):not(:last-child) { border-radius: 4px; }
.year-cell:hover { border-color: #d6c3b3; background: #fffaf6; }
.year-cell-name { font-weight: 800; font-size: 14px; }
.year-cell-dates { font-size: 12px; color: var(--muted); }
.year-cell-count { font-size: 12px; color: var(--faint); margin-top: 4px; }
.year-cell.is-selected { background: var(--green); border-color: var(--green); color: #fff; }
.year-cell.is-selected .year-cell-dates, .year-cell.is-selected .year-cell-count { color: #cfe3dc; }
/* Repère « aujourd'hui » : trait orange à la position du jour dans la période en cours */
.year-cell.is-current::before {
  content: ""; position: absolute; left: var(--now, 50%); top: -6px; bottom: -6px; width: 3px; margin-left: -1.5px;
  background: var(--orange); border-radius: 2px;
}
.year-cell-now {
  position: absolute; left: var(--now, 50%); bottom: calc(100% + 6px); transform: translateX(-50%);
  font-size: 11px; font-weight: 700; color: var(--orange-ink); white-space: nowrap;
}
.year-strip { margin-top: 22px; }

.h1-period { color: var(--muted); font-weight: 600; margin-right: .25em; }

.domain-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.domain-slot { position: relative; cursor: grab; border-radius: var(--radius); }
.domain-slot:active { cursor: grabbing; }
.domain-slot.is-dragging { opacity: .45; }
.domain-slot.is-drop-target { outline: 3px dashed var(--orange); outline-offset: 3px; }
.domain-card {
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow);
  border-top: 4px solid var(--domain); padding: 14px 14px 10px;
}
.domain-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.domain-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; margin: 0; }
/* Carte vide : compacte, entièrement cliquable */
.domain-card.is-empty {
  display: flex; align-items: center; justify-content: space-between; width: 100%; text-align: left;
  box-shadow: none; border-style: dashed; border-top: 1px dashed var(--line); border-left: 4px solid var(--domain);
  background: #fffdfb; padding: 12px 14px; color: var(--muted); gap: 8px;
}
.domain-card.is-empty .domain-title { color: #44504c; }
.domain-card.is-empty { cursor: pointer; }
.domain-card.is-empty:hover { border-color: var(--domain); background: #fff; color: var(--ink); }
.domain-card.is-empty .domain-title { font-size: 14px; gap: 6px; white-space: nowrap; }
.domain-card.is-empty .domain-icon-lg { width: 30px; height: 30px; }
.domain-empty-cta { white-space: nowrap; font-size: 12.5px; font-weight: 700; color: var(--orange-ink); }

.resource-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
/* Chaque activité est une petite carte à part, avec le trait de la couleur de la matière */
.resource-row {
  position: relative; display: flex; align-items: center; gap: 6px; border-radius: var(--radius-s);
  border: 1px solid var(--line); border-left: 4px solid var(--domain, var(--line));
  background: color-mix(in srgb, var(--domain, #fff) 5%, #fff);
}
.resource-row:hover, .resource-row:focus-within { background: color-mix(in srgb, var(--domain, #fff) 12%, #fff); border-color: color-mix(in srgb, var(--domain, #ccc) 45%, var(--line)); }
.resource-open {
  flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 8px 8px; border-radius: var(--radius-s);
  display: grid; gap: 2px;
}
.resource-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.resource-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.meta-type { font-weight: 700; color: #44504c; }
/* Dans Ma période, le type devient une pastille aux couleurs de la matière */
.resource-row .meta-type {
  background: color-mix(in srgb, var(--domain, #888) 16%, #fff); color: color-mix(in srgb, var(--domain, #444) 75%, #000);
  border-radius: 999px; padding: 0 8px;
}
.meta-domain { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: #44504c; }
.meta-planned { color: var(--green); font-weight: 600; }
.badge {
  font-size: 10px; font-weight: 800; letter-spacing: .02em; color: var(--orange-ink); background: var(--orange-soft);
  border-radius: 4px; padding: 1px 5px; line-height: 1.4; flex-shrink: 0;
}
.badge-fav { color: #a87200; background: #fff4d6; }
/* Actions discrètes : visibles au survol ou au clavier ; toujours visibles sur écran tactile */
.row-actions { display: flex; gap: 4px; padding-right: 6px; opacity: 0; transition: opacity .12s; }
.resource-row:hover .row-actions, .resource-row:focus-within .row-actions,
.library-row:hover .row-actions, .library-row:focus-within .row-actions { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }
.row-actions .icon-button { width: 30px; height: 30px; }
.domain-add {
  width: 100%; margin-top: 6px; border: 0; background: transparent; text-align: left; padding: 8px;
  border-radius: var(--radius-s); color: var(--orange-ink); font-weight: 700; font-size: 13px;
}
.domain-add:hover { background: var(--orange-soft); }

/* 5. BIBLIOTHÈQUE, OUTILS, AIDE ------------------------------------------ */
.sort { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sort select { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 7px 10px; background: #fff; font-weight: 600; color: var(--ink); }

.filters { display: grid; gap: 10px; margin-bottom: 16px; padding: 12px 14px; background: var(--cream); border-radius: var(--radius); }
.filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.filter-label { width: 70px; font-size: 12px; font-weight: 700; color: var(--muted); }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600;
}
.filter-chip:hover { border-color: #d6c3b3; }
.filter-chip.is-active { background: var(--green); border-color: var(--green); color: #fff; }
.filter-chip.is-active .dot { box-shadow: 0 0 0 2px #fff; }
.filter-chip .domain-icon { background: #fff; border-radius: 50%; padding: 1px; }
.filter-reset { margin-left: auto; border: 0; background: none; color: var(--orange-ink); font-size: 13px; font-weight: 700; padding: 4px 6px; }
.filter-reset:hover { text-decoration: underline; }

.resource-library { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.library-row {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-left: 4px solid var(--domain);
  border-radius: var(--radius-s); background: #fff; padding: 4px 4px 4px 6px;
}
.library-row:hover, .library-row:focus-within { border-color: #dccbbb; border-left-color: var(--domain); box-shadow: var(--shadow); }
.library-row .resource-open { padding: 9px 10px; }
.library-row .resource-name { font-size: 15px; }

.empty-view {
  padding: 44px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius);
  display: grid; justify-items: center; gap: 14px;
}
.empty-view p { margin: 0; max-width: 46ch; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tool-card {
  display: flex; flex-direction: column; gap: 12px; text-align: left; padding: 18px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); color: inherit; text-decoration: none;
}
.tool-card:hover { border-color: var(--orange); }
.tool-card-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--orange-soft); display: grid; place-items: center; font-size: 26px; }
.tool-card-icon.has-img { width: 64px; height: 64px; background: none; border-radius: 0; }
.tool-card-icon.has-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tool-card-text { display: grid; gap: 4px; flex: 1; }
.tool-card-text strong { font-size: 16px; }
.tool-card-text span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.tool-card-open { font-size: 13px; font-weight: 700; color: var(--orange-ink); }
.tool-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chip-count { margin-left: 4px; font-size: 11px; font-weight: 700; opacity: .65; }
.tool-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-tag { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 10px 2px 6px; font-size: 12px; font-weight: 700; background: var(--cream); color: var(--muted); }
.tool-tag .domain-icon { width: 16px; height: 16px; }
.tool-tag[data-cat="gestion"] { background: #fde9dd; color: #a8420f; }
.tool-tag[data-cat="maths"] { background: #e3eefc; color: #1f5fb4; }
.tool-tag[data-cat="francais"] { background: #e4f4ec; color: #0e6a4a; }

.help-section { max-width: 760px; margin-bottom: 30px; }
.help-section h2 { font-size: 18px; margin: 0 0 10px; }
.help-section p { margin: 0 0 10px; color: #33403c; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.steps li::marker { font-weight: 800; color: var(--orange-ink); }
.facts { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: #33403c; }
.backup-card {
  display: flex; gap: 20px; justify-content: space-between; align-items: center; flex-wrap: wrap;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--cream);
}
.backup-card p { margin: 4px 0 0; font-size: 14px; }
.backup-card .hint { color: var(--muted); font-size: 13px; }
.backup-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.backup-actions label.button { cursor: pointer; }
.shortcuts { display: grid; gap: 8px; margin: 0; }
.shortcuts div { display: flex; gap: 12px; align-items: center; }
.shortcuts dt { width: 72px; }
.shortcuts dd { margin: 0; color: #33403c; }

/* 6. FENÊTRES ET FORMULAIRES --------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(28, 25, 22, .38); }
.modal-card {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: #fff; border-radius: 16px; padding: 22px 24px; box-shadow: 0 24px 70px rgba(0, 0, 0, .2);
}
.modal-card.modal-wide { width: min(640px, 100%); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.modal-header h2 { margin: 2px 0 0; font-size: 22px; letter-spacing: -.01em; }
.detail-kicker { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--muted); }
.kicker-type { font-weight: 600; color: var(--faint); }
.kicker-type::before { content: "/"; margin-right: 6px; color: var(--line); }

form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
label input, label select, label textarea, .picker-tools input {
  border: 1px solid #ddd0c4; border-radius: var(--radius-s); padding: 10px 11px; outline: none; background: #fff; font-weight: 500; font-size: 14px;
}
label input:focus, label select:focus, label textarea:focus, .picker-tools input:focus { border-color: var(--orange); box-shadow: var(--focus); }
label textarea { resize: vertical; min-height: 72px; }
.optional, .legend-hint { font-weight: 500; color: var(--faint); font-size: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.form-row .checkbox-row { padding-bottom: 10px; }
.checkbox-row input { accent-color: var(--orange-ink); width: 17px; height: 17px; }
.field-error { color: var(--danger); font-weight: 600; font-size: 12px; }
.input-suffix { position: relative; display: block; }
.input-suffix input { width: 100%; padding-right: 44px; }
.input-suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); font-weight: 600; }

.levels { border: 0; padding: 0; margin: 0; }
.levels legend { font-size: 13px; font-weight: 700; padding: 0; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { border: 1px solid #ddd0c4; border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 700; color: #44504c; background: #fff; }
.chip:hover span { border-color: var(--green); }
.chip input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.chip input:focus-visible + span { box-shadow: var(--focus); }

.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; font-weight: 700; }
.file-drop {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px dashed #d8c9bb; border-radius: 10px;
  background: #fffbf8; cursor: pointer; font-weight: 500; font-size: 14px;
}
.file-drop:hover, .file-drop.is-over { border-color: var(--orange); background: var(--orange-soft); }
.file-drop:focus-within { box-shadow: var(--focus); }
.file-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.file-drop small { color: var(--muted); font-size: 12px; }
.file-drop-icon { font-size: 24px; }
.file-icon {
  width: 38px; height: 38px; border-radius: 9px; background: #c8362d; color: #fff; display: grid; place-items: center;
  font-size: 10px; font-weight: 800; letter-spacing: .04em; flex-shrink: 0;
}
.file-current { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.file-current-text { flex: 1; min-width: 0; }
.file-current-text strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-current-text small { color: var(--muted); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 6px; }
.detail-actions { flex-wrap: wrap; margin-top: 20px; padding-top: 14px; border-top: 1px solid #f2ebe5; }
.spacer { flex: 1; }

/* Fiche détail : le contenu à ouvrir d'abord, les informations ensuite */
.detail-links { display: grid; gap: 10px; margin-bottom: 16px; }
.detail-links:empty { display: none; }
.link-card {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--orange-soft); border: 1px solid #f5cdb4; color: var(--ink); text-decoration: none;
}
a.link-card:hover { border-color: var(--orange); }
.link-card-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--orange-ink); color: #fff; display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.link-card-text { flex: 1; min-width: 0; }
.link-card-text strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-card-text small { color: var(--muted); font-size: 13px; }
.file-card { background: #fff; border-color: var(--line); }
.file-card .file-icon { width: 40px; height: 40px; font-size: 11px; background: #c8362d; }
.file-card.is-missing small { color: var(--danger); }
.file-actions { display: flex; gap: 6px; flex-shrink: 0; }

.detail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin: 0; }
.detail-list .full { grid-column: 1 / -1; }
.detail-list dt { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.detail-list dd { margin: 0; font-size: 14px; font-weight: 600; }
.detail-description { white-space: pre-line; font-weight: 400 !important; line-height: 1.55; }
.level-pill { display: inline-block; background: var(--green-soft); color: var(--green); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; margin: 0 4px 4px 0; }
.plan-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 700; color: var(--muted); }
.plan-chip:hover { border-color: var(--green); color: var(--green); }
.plan-chip.is-on { background: var(--green); border-color: var(--green); color: #fff; }
.detail-nolink { color: var(--muted); font-size: 14px; margin: 14px 0 0; }

.create-card {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 16px;
  border: 1px dashed #e7b99c; background: var(--orange-soft); border-radius: var(--radius);
}
.create-card:hover { border-style: solid; border-color: var(--orange); }
.create-card-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--orange-ink); color: #fff; display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.create-card strong { display: block; font-size: 15px; }
.create-card small { color: var(--muted); font-size: 13px; }
.picker-sep { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.picker-sep::before, .picker-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.picker-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.picker-tools input[type="search"] { flex: 1; min-width: 200px; }
.picker-list { display: grid; gap: 6px; max-height: 340px; overflow-y: auto; padding: 2px; }
.picker-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid #eee4dc;
  border-radius: 10px; cursor: pointer; font-weight: 500;
}
.picker-item:hover { border-color: #e2c8b5; background: #fffaf6; }
.picker-item input { accent-color: var(--orange-ink); width: 18px; height: 18px; flex-shrink: 0; }
.picker-item:has(input:checked:not(:disabled)) { border-color: var(--orange); background: #fffaf6; }
.picker-item.is-disabled { opacity: .6; cursor: default; }
.picker-meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.picker-meta strong { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.picker-tag { font-size: 12px; font-weight: 700; color: var(--green); background: var(--green-soft); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.picker-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 14px; border: 1px dashed var(--line); border-radius: 10px; }

/* 7. MESSAGES ------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; display: flex; align-items: center; gap: 14px;
  background: #173b31; color: #fff; padding: 11px 12px 11px 18px; border-radius: 10px; font-size: 14px; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2); opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
  transition: opacity .18s, transform .18s; max-width: calc(100vw - 32px);
}
body.has-modal .toast { bottom: auto; top: 20px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-undo { border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-weight: 800; border-radius: 7px; padding: 6px 12px; }
.toast-undo:hover { background: rgba(255, 255, 255, .25); }

/* 8. MOBILE --------------------------------------------------------------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
  body.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .menu-button {
    display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line);
    border-radius: 10px; background: #fff; font-size: 18px; flex-shrink: 0;
  }
  .topbar { padding: 0 16px; gap: 10px; }
  .content { padding: 20px 16px 80px; }
  .search-kbd { display: none; }
}
@media (max-width: 640px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; }
  .topbar-brand { display: block; width: 40px; height: 40px; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
  .topbar-add span { display: none; }
  .topbar-add { width: 40px; height: 40px; padding: 0; font-size: 18px; }
  /* Frise : défilement horizontal, cases de largeur égale */
  .year-strip { overflow-x: auto; padding-top: 22px; margin-top: 0; scroll-snap-type: x mandatory; }
  .year-cell { flex: 0 0 132px !important; scroll-snap-align: start; }
  .domain-grid { grid-template-columns: 1fr; }
  .form-row, .detail-list { grid-template-columns: 1fr; }
  .filter-label { width: 100%; }
  .page-head { align-items: flex-start; }
  .library-row { flex-wrap: wrap; }
  .modal { padding: 0; align-items: end; }
  .modal-card { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; padding: 20px 18px; }
  .detail-actions .spacer { display: none; }
  .detail-actions .danger-link { order: 3; width: 100%; }
}

/* IMPRESSION : la période en liste, prête pour le cahier journal ou le classeur */
.h1-dates { display: none; }

/* Visionneuse de PDF */
.modal-card.modal-pdf { width: min(1100px, 100%); height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.modal-pdf .modal-header { margin-bottom: 12px; flex: none; }
.pdf-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.pdf-body { flex: 1; min-height: 0; border: 1px solid var(--line, #dfe5e2); border-radius: 10px; overflow: hidden; background: #f4f6f5; }
.pdf-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.pdf-message { margin: 40px; text-align: center; color: var(--muted); }

/* ---- Impression de « Ma période » : sans en-tête ni pied de page du navigateur, en cartes par matière ---- */
@page { size: A4; margin: 0; }  /* marge nulle : le navigateur n'imprime plus date, titre et adresse */
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { background: #fff !important; }
  *:focus, *:focus-visible { outline: none !important; box-shadow: none; }
  .sidebar, .topbar, .page-actions, .year-strip, .domain-slot:has(.is-empty), .domain-add, .row-actions, .toast, .skip-link, .modal { display: none !important; }
  .main { margin: 0 !important; padding: 0 !important; }
  .content { padding: 14mm 14mm 12mm !important; max-width: none !important; }
  body { font-size: 11pt; }
  .page-head { margin: 0 0 8mm; padding-bottom: 4mm; border-bottom: 2pt solid #1f2a27; }
  .page-head h1 { font-size: 22pt; margin: 0 0 2pt; }
  .h1-dates { display: inline; font-weight: 600; color: var(--muted); font-size: 14pt; }
  .h1-dates::before { content: "· "; }
  .page-head .subtitle { margin: 0; font-size: 10.5pt; }
  .domain-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5mm; align-items: start; }
  .domain-slot { break-inside: avoid; }
  .domain-card {
    box-shadow: none; break-inside: avoid; margin: 0; padding: 4mm 4mm 3mm; border-radius: 4mm;
    border: 1px solid #c9d1ce; border-top: 3pt solid var(--domain); background: #fff;
  }
  .domain-head { padding-right: 0; margin-bottom: 3mm; }
  .domain-title { font-size: 13pt; }
  .resource-list { gap: 2mm; }
  .resource-row { background: color-mix(in srgb, var(--domain, #fff) 8%, #fff); border: 1px solid color-mix(in srgb, var(--domain, #ccc) 30%, #e3e8e6); border-radius: 2.5mm; padding: 2mm 3mm; break-inside: avoid; }
  .resource-open { padding: 0; }
  .resource-name { font-size: 11pt; }
  .resource-meta { font-size: 9pt; }
}

/* Aide : cartes PDF / nuage, détails */
.help-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.help-card { border: 1px solid var(--line, #dfe5e2); border-radius: 12px; padding: 14px 16px; background: #fff; }
.help-card h3 { margin: 0 0 8px; font-size: 15px; }
.help-card p { font-size: 14px; margin: 0 0 8px; }
.help-section code { background: #eef2f0; padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.help-section .hint { color: var(--muted); font-size: 13px; }
.backup-card .facts { margin: 6px 0; font-size: 14px; }
.help-more { margin-top: 10px; font-size: 14px; }
.help-more summary { cursor: pointer; font-weight: 600; }
.help-section .steps + .hint { margin-top: 12px; }
.help-cards + .facts { margin-top: 14px; }
