/* Studio — feuille unique, sans dépendance externe. Clair/sombre selon le système. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1b1f24;
  --muted: #5d6673;
  --border: #dde1e6;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --garder: #1f7a4d;
  --garder-bg: #e3f4ea;
  --plus_tard: #a35d00;
  --plus_tard-bg: #fdf0dc;
  --ignorer: #6b7280;
  --ignorer-bg: #eceef1;
  --ia: #6941c6;
  --ia-bg: #f0eafc;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-size: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1e24;
    --surface-2: #232830;
    --text: #e8eaed;
    --muted: #9aa3ae;
    --border: #2e343d;
    --accent: #7c9cff;
    --accent-text: #0b1020;
    --garder: #5fd69a;
    --garder-bg: #15301f;
    --plus_tard: #f5b452;
    --plus_tard-bg: #36280f;
    --ignorer: #a6adb8;
    --ignorer-bg: #262b33;
    --ia: #b69cff;
    --ia-bg: #2a2140;
    --danger: #ff8a7a;
    --danger-bg: #3a1a17;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 1rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* En-tête */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 980px; margin: 0 auto; padding: .55rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.tabs { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.tab { padding: .4rem .7rem; border-radius: 999px; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.is-active { background: var(--accent); color: var(--accent-text); }
.count { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: .78rem; text-align: center; }
.tab.is-active .count { background: rgba(255, 255, 255, .25); color: inherit; }
.logout { margin: 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); font-family: inherit; font-size: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* Mise en page */
.page { max-width: 980px; margin: 0 auto; padding: 1.25rem 1rem 6rem; }
.intro { margin-bottom: 1rem; }
.notice { margin: .25rem 0 0; padding: .6rem .8rem; border-left: 3px solid var(--plus_tard); background: var(--plus_tard-bg); border-radius: 6px; font-size: .92rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 1rem 0; box-shadow: var(--shadow); }
.flash { padding: .6rem .8rem; border-radius: 8px; background: var(--garder-bg); color: var(--garder); font-weight: 500; }
.error { padding: .6rem .8rem; border-radius: 8px; background: var(--danger-bg); color: var(--danger); }
.error-inline { color: var(--danger); font-weight: 600; }
.warn { color: var(--plus_tard); font-size: .9rem; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.crumbs { font-size: .9rem; color: var(--muted); margin: 0 0 .75rem; }
.result-count { color: var(--muted); font-size: .9rem; margin: .5rem 0; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  min-height: 2.4rem; padding: .4rem .9rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-family: inherit; font-size: .95rem; font-weight: 500; line-height: 1.2; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-small { min-height: 2rem; padding: .25rem .65rem; font-size: .88rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-garder { color: var(--garder); background: var(--garder-bg); border-color: transparent; }
.btn-plus_tard { color: var(--plus_tard); background: var(--plus_tard-bg); border-color: transparent; }
.btn-ignorer { color: var(--ignorer); background: var(--ignorer-bg); border-color: transparent; }
.btn-ia { color: var(--ia); background: var(--ia-bg); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Formulaires */
label { display: block; font-size: .88rem; font-weight: 500; color: var(--muted); }
input[type=text], input[type=search], input[type=password], select, textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .5rem .65rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: inherit; font-size: 1rem; line-height: 1.45;
}
textarea { resize: vertical; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; }
.filters label { flex: 1 1 10rem; }
.filters .grow { flex: 3 1 14rem; }

/* Sélection multiple */
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .5rem .75rem; margin: .5rem 0 1rem; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.bulk-bar select { width: auto; display: inline-block; margin: 0; padding: .3rem .5rem; font-size: .88rem; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.select-all { display: inline-flex; align-items: center; gap: .35rem; color: var(--text); }
.bulk-count { color: var(--muted); font-size: .88rem; margin-right: auto; }
.bulk-bar.has-selection { position: sticky; bottom: .75rem; z-index: 15; border-style: solid; border-color: var(--accent); box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.bulk-bar.has-selection .bulk-count { color: var(--text); font-weight: 600; }

/* Cartes */
.cards { display: grid; gap: .9rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.card.is-garder { border-left-color: var(--garder); }
.card.is-plus_tard { border-left-color: var(--plus_tard); }
.card.is-ignorer { border-left-color: var(--ignorer); opacity: .82; }
.card.is-selected { outline: 2px solid var(--accent); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; margin: 0 0 .35rem; font-size: .85rem; }
.select input { width: 1.15rem; height: 1.15rem; margin: 0; vertical-align: middle; }
.source { font-weight: 600; }
.date { color: var(--muted); }
.badge { padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); }
.badge-garder { background: var(--garder-bg); color: var(--garder); }
.badge-plus_tard { background: var(--plus_tard-bg); color: var(--plus_tard); }
.badge-ignorer { background: var(--ignorer-bg); color: var(--ignorer); }
.card-title { font-size: 1.08rem; line-height: 1.35; margin: 0 0 .35rem; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--accent); text-decoration: underline; }
.ext { color: var(--muted); font-size: .85em; }
.summary { margin: 0 0 .4rem; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.reprises { margin: 0 0 .5rem; font-size: .82rem; color: var(--muted); }
.card-form { margin-top: .5rem; }
.usages { border: 0; margin: 0 0 .5rem; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.usages legend { font-size: .8rem; color: var(--muted); padding: 0; margin-bottom: .3rem; width: 100%; }
.chip { display: inline-flex; color: var(--text); font-weight: 500; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-block; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--border); font-size: .88rem; cursor: pointer; user-select: none; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.note textarea { font-size: .92rem; min-height: 2.6rem; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.contents { margin-top: .75rem; padding-top: .6rem; border-top: 1px solid var(--border); display: grid; gap: .45rem; }
.content-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; font-size: .9rem; }
.usage-name { font-weight: 600; min-width: 7.5rem; }
.dest { color: var(--muted); font-size: .8rem; flex-basis: 100%; }
form.inline { display: inline; margin: 0; }

/* États de contenu */
.state { display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--text); text-decoration: none; }
.state-a_approuver { background: var(--ia-bg); color: var(--ia); }
.state-modification_demandee { background: var(--plus_tard-bg); color: var(--plus_tard); }
.state-approuve { background: var(--garder-bg); color: var(--garder); }
.state-rejete { background: var(--ignorer-bg); color: var(--ignorer); }
.tag { display: inline-block; padding: .05rem .5rem; border-radius: 6px; background: var(--surface-2); font-size: .8rem; }

/* Listes */
.group { margin: 1.25rem 0; }
.rows { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.row { display: grid; gap: .15rem; padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.row:hover { border-color: var(--accent); }
.row-main { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row-meta { font-size: .85rem; }
.selection { margin: 0; }
.selection p { margin: .2rem 0; }
.note-text { white-space: pre-wrap; background: var(--surface-2); padding: .4rem .6rem; border-radius: 6px; }

/* Brouillon */
.draft-head { margin-bottom: .5rem; }
.draft-head h1 { margin: .4rem 0; }
.draft-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; }
.dest-line { font-size: .9rem; padding: .5rem .7rem; background: var(--surface-2); border-radius: 8px; }
.callout { padding: .6rem .8rem; border-radius: 8px; background: var(--plus_tard-bg); color: var(--text); }
.callout-ia { background: var(--ia-bg); }
.approval { padding: .7rem .9rem; border-radius: 8px; background: var(--garder-bg); margin: .75rem 0; }
.editor label { margin-bottom: .75rem; }
.editor textarea { min-height: 18rem; font-size: .98rem; line-height: 1.55; }
.action-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.action-list form { margin: 0; }
.change-request { margin-top: .9rem; display: grid; gap: .5rem; max-width: 40rem; }
.table-wrap { overflow-x: auto; }
.versions { width: 100%; border-collapse: collapse; font-size: .88rem; }
.versions th, .versions td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
pre.text { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: 1rem; line-height: 1.55; background: var(--surface-2); padding: .9rem; border-radius: 8px; }
.progress { padding: .7rem .9rem; border-radius: 8px; background: var(--ia-bg); color: var(--ia); font-weight: 500; }

/* Historique */
.subtabs { display: flex; gap: .5rem; margin-top: .5rem; }
.subtabs a { padding: .3rem .8rem; border-radius: 999px; text-decoration: none; color: var(--muted); border: 1px solid var(--border); }
.subtabs a.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
.timeline { list-style: none; margin: 1rem 0; }
.timeline li { display: grid; grid-template-columns: 11.5rem 1fr; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin: 1.5rem 0; }

/* Connexion */
.login-box { max-width: 24rem; margin: 3rem auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.login-box label { margin-bottom: .9rem; }

/* Téléphone */
@media (max-width: 640px) {
  .topbar-inner { gap: .5rem; padding: .5rem .75rem; }
  .tabs { order: 3; flex-basis: 100%; }
  .logout { margin-left: auto; }
  .page { padding: 1rem .75rem 7rem; }
  h1 { font-size: 1.3rem; }
  .card { padding: .8rem; }
  .actions .btn { flex: 1 1 auto; }
  .bulk-bar.has-selection { position: fixed; left: .5rem; right: .5rem; bottom: .5rem; margin: 0; }
  .timeline li { grid-template-columns: 1fr; gap: .1rem; }
  .usage-name { min-width: 0; flex-basis: 100%; }
  .versions thead { display: none; }
  .versions tr { display: block; padding: .5rem 0; border-bottom: 1px solid var(--border); }
  .versions td { display: inline; padding: 0 .4rem 0 0; border: 0; }
  .versions td:last-child { display: block; padding-top: .15rem; }
}
