/* Communauté — étagère partagée à durée limitée : chaque titre porte sa date de fin.
   Une colonne de 960 px, des fiches à liseré d'état. Direction visuelle : ecrans/commun.md.
   Polices système seulement (le CSP de l'app refuse toute police externe). Aucune animation.
   Contours : --line sépare (1,4:1, décoratif), --ctl délimite un contrôle (3:1 au moins, G48). */
:root {
  --bg: #f3f5f9; --surface: #ffffff; --raise: #eef1f6; --line: #d5dbe4; --ctl: #7f8a99;
  --fg: #141a23; --muted: #556070;
  --accent: #3451d1; --accent-ink: #ffffff; --accent-soft: #e6eafb;
  --ok: #1d7a4d; --warn: #8a5a00; --bad: #b3261e;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-data: ui-monospace, "SF Mono", "Cascadia Mono", "DejaVu Sans Mono", monospace;
  --r: 8px; --tap: 44px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117; --surface: #161b24; --raise: #1d2430; --line: #2c3542; --ctl: #647083;
    --fg: #e7ebf2; --muted: #9aa6b6;
    --accent: #8aa4ff; --accent-ink: #0b1020; --accent-soft: #1e2744;
    --ok: #4cc38a; --warn: #e8b04a; --bad: #ff8577;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1117; --surface: #161b24; --raise: #1d2430; --line: #2c3542; --ctl: #647083;
  --fg: #e7ebf2; --muted: #9aa6b6;
  --accent: #8aa4ff; --accent-ink: #0b1020; --accent-soft: #1e2744;
  --ok: #4cc38a; --warn: #e8b04a; --bad: #ff8577;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 1rem/1.5 var(--font-ui); }
h1, h2, h3 { text-wrap: balance; line-height: 1.25; margin: 0; }
h1 { font-size: 1.375rem; font-weight: 650; }
h2 { font-size: 1.0625rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: .875em; }
.tnum { font-variant-numeric: tabular-nums; }   /* phrase qui contient des chiffres : police du texte, chiffres alignés */
.muted { color: var(--muted); font-size: .9375rem; }
.eyebrow { font-size: .8125rem; color: var(--muted); font-weight: 600; }
.skip { position: absolute; left: 16px; top: -100px; z-index: 10; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: var(--r); }
.skip:focus { top: 8px; }

/* ---------- entête */
header { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); }
.bar-inner { max-width: 960px; margin: 0 auto; padding: 8px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.brand { font-weight: 700; letter-spacing: .01em; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 22px; height: 22px; color: var(--accent); flex: none; }
#tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
#tabs button { white-space: nowrap; min-height: var(--tap); background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 0 12px; font-weight: 550; }
#tabs button:hover, .subtabs button:hover { color: var(--fg); background: none; }
#tabs button[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9375rem; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- mise en page */
main { max-width: 960px; margin: 0 auto; padding-block: 20px 32px; padding-inline: 16px; display: grid; gap: 16px; }
main > section { display: grid; gap: 16px; min-width: 0; }
.view-head { display: grid; gap: 4px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.narrow { width: 100%; max-width: 420px; margin: 24px auto 0; }

/* ---------- formulaires */
label { display: grid; gap: 6px; font-size: .9375rem; font-weight: 550; }
input, select { width: 100%; min-height: var(--tap); padding: 8px 12px; font: inherit; font-weight: 400; color: var(--fg); background: var(--bg); border: 1px solid var(--ctl); border-radius: var(--r); }
input:hover, select:hover { border-color: var(--muted); }
.search { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.search select { width: auto; }
@media (max-width: 560px) { .search { grid-template-columns: 1fr 1fr; } .search input { grid-column: 1 / -1; } }
button { font: inherit; min-height: var(--tap); padding: 0 16px; border-radius: var(--r); border: 1px solid var(--ctl); background: var(--surface); color: var(--fg); cursor: pointer; font-weight: 550; }
button:hover { background: var(--raise); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: currentColor; background: none; }
button.danger:hover { background: var(--raise); }
button.quiet { border-color: transparent; background: none; color: var(--muted); }
button.quiet:hover { color: var(--fg); background: var(--raise); }
button:disabled { cursor: not-allowed; color: var(--muted); background: var(--raise); border-color: var(--line); filter: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }   /* titres focalisés par le script au changement de vue */
.err { color: var(--bad); font-weight: 550; }
.err:empty { display: none; }

/* ---------- bandeau d'annonce */
.banner { padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); border-left: 4px solid var(--warn); background: var(--surface); font-weight: 550; }
.banner.bad { border-left-color: var(--bad); }
.banner.ok { border-left-color: var(--ok); }

/* ---------- résultats de recherche : une liste, l'affiche en vignette (une affiche absente ne laisse pas de grand vide) */
.search-msg:empty { display: none; }
.results { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.results li + li { border-top: 1px solid var(--line); }
.result { width: 100%; display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 14px; padding: 8px 16px; border: 0; border-radius: 0; background: none; text-align: left; font-weight: 400; }
.results li:first-child .result { border-radius: var(--r) var(--r) 0 0; }
.results li:last-child .result { border-radius: 0 0 var(--r) var(--r); }
.result .cap { display: grid; gap: 2px; min-width: 0; }
.result .cap strong { font-weight: 600; overflow-wrap: anywhere; }
.thumb { width: 48px; aspect-ratio: 2 / 3; object-fit: cover; display: block; border-radius: 4px; background: var(--raise); }
.thumb.ph { border: 1px solid var(--line); }

/* ---------- choix des liens */
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 0; min-width: 0; }
legend { padding: 0 0 8px; font-weight: 600; }
.link { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px; padding: 10px 4px; min-height: var(--tap); border-top: 1px solid var(--line); font-weight: 400; cursor: pointer; }
.link:first-of-type { border-top: 0; }
.link input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--accent); }
.link .meta { min-width: 0; overflow-wrap: anywhere; display: grid; gap: 4px; }
.link .line { display: block; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { white-space: nowrap; font-size: .75rem; font-weight: 700; letter-spacing: .03em; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); background: var(--raise); }
.tag.fr { color: var(--accent); border-color: currentColor; background: var(--accent-soft); }
.tag.st { font-weight: 550; letter-spacing: 0; }
.tag.warn { color: var(--warn); border-color: currentColor; background: none; cursor: help; }
.tag.flagtag { display: inline-flex; align-items: center; gap: 3px; padding: 2px 4px; background: none; }
.flag { display: block; border-radius: 2px; flex: none; }
.maybe { color: var(--warn); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.filters { display: grid; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.frow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.flabel { font-size: .8125rem; color: var(--muted); font-weight: 600; min-width: 4.5rem; }
.chipbtn { min-height: 36px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; font-weight: 550; }
.chipbtn .flag { width: 20px; height: 13px; }
.chipbtn .count { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chipbtn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chipbtn[aria-pressed="true"] .count { color: var(--accent); }
.legend { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; }
details.codes summary { cursor: pointer; color: var(--muted); font-size: .875rem; padding: 12px 0; }
.empty { display: grid; gap: 8px; justify-items: start; }
.warn-text { color: var(--warn); }
.release { color: var(--muted); font-size: .8125rem; overflow-wrap: anywhere; }
.files { overflow-wrap: anywhere; }
.small { font-size: .8125rem; }
.legend { font-size: .875rem; }
.season { max-width: 280px; }
.dlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dlist li { display: grid; gap: 4px; padding-left: 10px; border-left: 2px solid var(--line); font-weight: 400; }
details.jd summary { cursor: pointer; color: var(--muted); font-weight: 400; font-size: .8125rem; min-height: 24px; }
details.jd[open] summary { margin-bottom: 6px; }
details.jd .dlist { min-width: 16rem; }
.link .size { color: var(--muted); }
.link.off { cursor: not-allowed; color: var(--muted); }
.link.off .why { grid-column: 2 / -1; color: var(--bad); font-size: .875rem; font-weight: 550; }

/* ---------- fiches de titre (mes titres) : deux lignes, le liseré code l'état, rien d'autre */
.jobs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.job { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--r); padding: 10px 14px; min-width: 0; }
.job[data-state="run"] { border-left-color: var(--accent); }
.job[data-state="wait"] { border-left-color: var(--muted); }
.job[data-state="ready"] { border-left-color: var(--ok); }
.job[data-state="failed"] { border-left-color: var(--bad); }
.job .thumb { width: 40px; align-self: start; }
.job .info { display: grid; gap: 4px; min-width: 0; }
.job h3 { overflow-wrap: anywhere; }
.job .err { font-weight: 400; font-size: .9375rem; }
.facts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.progress { display: grid; grid-template-columns: minmax(80px, 240px) auto; align-items: center; gap: 10px; }
.progress .num { white-space: nowrap; }
.job .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: .875rem; font-weight: 600; color: var(--muted); }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state.run { color: var(--accent); }
.state.ready { color: var(--ok); }
.state.failed { color: var(--bad); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: .8125rem; color: var(--muted); white-space: nowrap; }
.chip.due { color: var(--fg); }
.chip.soon { color: var(--warn); border-color: currentColor; }
.notice { padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--warn); color: var(--warn); font-weight: 600; }

/* ---------- jauges (sans animation) */
.meter { height: 8px; background: var(--raise); border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; background: var(--accent); }
.meter.q > i { background: var(--ok); }
.meter.q.high > i { background: var(--warn); }
.meter.q.full > i { background: var(--bad); }
.quota { display: grid; gap: 8px; }
.quota .row { justify-content: space-between; }

/* ---------- bibliothèque partagée */
.shelf { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.shelf li { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); }
.shelf li:first-child { border-top: 0; }
.shelf strong { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }

/* ---------- administration */
.subtabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.subtabs button { white-space: nowrap; background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 0 12px; }
.subtabs button[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.subtabs .count, #tabs .count { margin-left: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 7px; font-size: .8125rem; }
.spread { justify-content: space-between; }
h2.eyebrow { font-size: .8125rem; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat { display: grid; gap: 6px; }
.stat b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
caption { text-align: left; padding: 0 0 8px; font-weight: 600; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { color: var(--muted); font-weight: 600; font-size: .8125rem; white-space: nowrap; }
tbody th { font-weight: 600; min-width: 8rem; max-width: 22rem; overflow-wrap: break-word; }
td input { width: 88px; display: inline-block; }
td button { white-space: nowrap; }
td.n { font-family: var(--font-data); font-variant-numeric: tabular-nums; white-space: nowrap; }
.set { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.set label { align-content: start; }
.set label .small { font-weight: 400; }

/* ---------- confirmation */
dialog { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--fg); padding: 20px; width: min(420px, calc(100vw - 32px)); }
/* fenêtre de choix des liens : en-tête et bouton Télécharger toujours visibles, la liste défile entre les deux */
dialog.sheet { padding: 0; width: min(760px, calc(100vw - 32px)); max-width: none; max-height: min(88vh, 960px); }
dialog.sheet[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 1.125rem; overflow-wrap: anywhere; }
.sheet-body { overflow-y: auto; padding: 12px 16px; display: grid; gap: 12px; align-content: start; }
.sheet-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; background: var(--surface); }
@media (max-width: 560px) {
  dialog.sheet { width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--r) var(--r) 0 0; border-bottom: 0; }
  .link { grid-template-columns: auto 1fr; }
  .link .size { grid-column: 2; }
}
dialog::backdrop { background: rgb(0 0 0 / .55); }
dialog form { display: grid; gap: 12px; }
dialog form .row { margin-top: 4px; }

/* téléphone : deux lignes d'en-tête au plus (marque et compte, puis onglets) ; les boutons d'une fiche passent dessous */
@media (max-width: 560px) {
  .bar-inner { gap: 0 12px; flex-wrap: wrap; }
  .brand { flex: none; }
  .who { margin-left: auto; }
  .who span { display: none; }   /* le nom du compte cède la place : « Se déconnecter » reste sur une ligne */
  .who button { padding: 0 8px; white-space: nowrap; }
  #tabs { order: 3; flex: 1 0 100%; margin-inline: -6px; }
  #tabs button { padding: 0 6px; font-size: .9375rem; }
  .job { grid-template-columns: 40px 1fr; padding: 10px 12px; }
  .job .acts { grid-column: 1 / -1; justify-content: flex-start; }
  .job .acts button { padding: 0 10px; font-size: .9375rem; }
  .progress { grid-template-columns: 1fr auto; }
  .result { padding: 8px 12px; }
}

/* Comptes (admin) : l'échéance du lien ne se coupe pas. */
.nowrap { white-space: nowrap; }
th .small { font-weight: 400; }
/* Formulaires d'accès : aide sous le champ, champ en lecture seule visiblement figé. */
.field { display: grid; gap: 4px; }
.field p { margin: 0; }
label .small { font-weight: 400; }
input[readonly] { background: var(--surface); border-color: var(--line); color: var(--muted); }
/* Comptes : boutons du tableau dans la police de l'interface, pas celle des chiffres. */
td.n button { font-family: var(--font-ui); }
@media (max-width: 560px) { .subtabs { flex-wrap: wrap; } }
