:root {
  --bg: #f5f6f8; --panel: #ffffff; --text: #1d2330; --muted: #667085; --line: #e3e6ec;
  --accent: #ea580c; --accent-soft: #fff1e8; --ok: #15803d; --ok-soft: #e7f6ec;
  --err: #b42318; --err-soft: #fdecea; --warn: #a15c07; --warn-soft: #fff6e0;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b1f27; --text: #e6e8ec; --muted: #98a1b2; --line: #2b313c;
    --accent: #fb923c; --accent-soft: #3a2416; --ok: #4ade80; --ok-soft: #14301f;
    --err: #f87171; --err-soft: #3a1717; --warn: #fbbf24; --warn-soft: #3a2e10;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted, small { color: var(--muted); }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
main.narrow { max-width: 420px; padding-top: 10vh; }

/* barre du haut */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px;
  padding: 0 18px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 700; text-decoration: none; color: var(--accent); }
.topbar nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.topbar nav a { text-decoration: none; padding: 7px 11px; border-radius: 7px; color: var(--muted); white-space: nowrap; }
.topbar nav a:hover { background: var(--bg); color: var(--text); }
.topbar nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sched { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.dot.off { background: var(--err); }
.dot.run { width: 13px; height: 13px; background: none; border: 2px solid var(--accent);
  border-right-color: transparent; animation: spin .8s linear infinite; }

/* indicateurs rotatifs */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; flex: none; width: 1em; height: 1em; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: spin .75s linear infinite; vertical-align: -.15em; }
.spin.lg { width: 34px; height: 34px; border-width: 3px; color: var(--accent); }
button:disabled { cursor: progress; opacity: .85; }
.waiting { display: none; align-items: center; gap: 14px; margin-top: 14px; padding: 16px;
  border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 14px; }
.waiting.show { display: flex; }
.waiting b { color: var(--text); display: block; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 20; display: flex; gap: 12px; align-items: center;
  max-width: calc(100vw - 32px); padding: 12px 14px; border-radius: var(--radius); background: var(--panel);
  border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0, 0, 0, .15); font-size: 14px;
  animation: toast-in .25s ease-out; }
.toast::before { content: "✓"; color: var(--ok); font-weight: 700; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .spin, .dot.run { animation-duration: 2.5s; }
  .toast { animation: none; }
}
.user { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 0; }
.user .me { text-decoration: none; padding: 5px 9px; border-radius: 7px; white-space: nowrap; }
.user .me:hover { background: var(--bg); }
.user .me.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 860px) { .sched, .user span { display: none; } .topbar { gap: 10px; } }

/* éléments communs */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--err-soft); color: var(--err); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; resize: vertical; }
button, .btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: var(--panel); border-radius: 7px; padding: 7px 12px; cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--err); }
button.link { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; }
button.sm, .btn.sm { padding: 3px 8px; font-size: 13px; }
form.inline { display: inline; margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.field input, label.field select, label.field textarea { color: var(--text); font-size: 15px; }
.stack { display: grid; gap: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tablewrap { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.pill.off { color: var(--muted); }
.tag { display: inline-flex; gap: 5px; align-items: center; padding: 1px 8px 1px 6px; border-radius: 99px;
  font-size: 12px; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); cursor: help; }
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 24px; }

/* articles */
.layout { display: grid; grid-template-columns: 250px 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }
.filters { position: sticky; top: 72px; }
.filters .stack { gap: 10px; }
.filters select, .filters input { width: 100%; }
.article { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); border-left: 3px solid var(--accent); }
.article.read { border-left-color: var(--line); }
.article.read h3 a { color: var(--muted); font-weight: 500; }
.article h3 { font-size: 16px; margin: 0 0 4px; }
.article h3 a { text-decoration: none; }
.article h3 a:hover { text-decoration: underline; }
.meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.meta a { color: var(--muted); }
.source { font-weight: 600; color: var(--text); }
.summary { margin: 8px 0; font-size: 14px; color: var(--text); opacity: .88; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.summary.full { display: block; }
.filters-toggle { display: none; }
@media (max-width: 860px) {
  .filters { position: static; }
  .filters-toggle { display: block; margin-bottom: 10px; }
  .filters:not(.open) .stack { display: none; }
  .filters:not(.open) { padding: 0; border: 0; background: none; box-shadow: none; margin: 0; }
}
.topbar nav { scrollbar-width: none; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.actions button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.article.archived { border-left-color: var(--muted); border-left-style: dashed; }
.archived-info { font-size: 13px; color: var(--muted); margin-top: 4px; }
.archived-info::before { content: "🗄 "; }
.article.leaving { opacity: 0; transform: translateX(24px); max-height: 0; padding-top: 0; padding-bottom: 0;
  margin-bottom: 0; overflow: hidden; transition: all .3s ease; }
.toast a, .toast button { color: var(--accent); font-weight: 600; }
.toast button { border: 0; background: none; padding: 0; cursor: pointer; text-decoration: underline; }
.note-box { margin-top: 8px; display: none; }
.note-box.open { display: block; }
.note-box .saved { font-size: 12px; color: var(--ok); }
.my-note { margin-top: 8px; padding: 8px 10px; background: var(--warn-soft); border-radius: 7px; font-size: 14px; white-space: pre-wrap; }
.others { margin-top: 8px; font-size: 13px; color: var(--muted); }
.others div { padding: 4px 0 0; white-space: pre-wrap; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pager a, .pager span { padding: 5px 11px; border-radius: 7px; border: 1px solid var(--line); text-decoration: none; background: var(--panel); }
.pager span.cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.start-steps { display: inline-grid; gap: 6px; text-align: left; margin: 4px auto 12px; color: var(--text); }
.start-steps li.done { color: var(--muted); text-decoration: line-through; }
.start-steps li.done::marker { content: "✓  "; color: var(--ok); }

/* flux : candidats de détection */
.candidates { display: grid; gap: 12px; margin-top: 14px; }
.cand { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.cand.valid { border-color: var(--ok); }
.cand.warn { border-color: var(--warn); }
.cand ul { margin: 6px 0; padding-left: 18px; font-size: 14px; }
.warnings { margin: 8px 0; padding: 8px 12px; border-radius: 7px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.warnings div::before { content: "⚠ "; }
.confirm { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; font-size: 14px; }
.url { font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all; }
.err-text { color: var(--err); font-size: 13px; }

/* thèmes */
.theme { border-top: 4px solid var(--c); }
.kw { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 9px; margin: 0 4px 6px 0;
  border-radius: 99px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; }
.kw.ex { background: var(--err-soft); color: var(--err); border-color: transparent; text-decoration: line-through; }
.kw .kw-meta { font-size: 11px; color: var(--muted); white-space: nowrap; }
.kw .kw-meta b { color: var(--text); font-weight: 600; }
.kw-help { margin: 6px 0 0; font-size: 12px; }
.kw button { border: 0; background: none; padding: 0 4px; color: var(--muted); font-size: 15px; line-height: 1; }
.kw button:hover { color: var(--err); }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.kw-box { border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; }
.kw-box > summary { display: flex; gap: 10px; align-items: baseline; padding: 10px 0; color: var(--text); }
.kw-box > summary b { font-size: 14px; }
.kw-box > summary::-webkit-details-marker { display: none; }
.kw-box > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; display: inline-block; }
.kw-box[open] > summary::before { transform: rotate(90deg); }
.kw-box > summary::after { content: "afficher"; margin-left: auto; font-size: 13px; color: var(--accent); }
.kw-box[open] > summary::after { content: "masquer"; }
.kw-box[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.kw-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.kw-tools input { min-width: 180px; }
.kw-count { font-size: 13px; white-space: nowrap; }
.kw-list { max-height: 320px; overflow-y: auto; padding-bottom: 6px; }
.kw[hidden] { display: none; }

/* liste déroulante filtrable (choix du responsable) */
.combo { position: relative; display: flex; }
.combo input { flex: 1; width: 100%; padding-right: 34px; }
.combo-toggle { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); border: 0; background: none;
  padding: 4px 8px; color: var(--muted); }
.combo-list { position: absolute; z-index: 15; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px;
  list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14); max-height: 240px; overflow-y: auto; color: var(--text); font-size: 14px; }
.combo-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.combo-list li.active { background: var(--accent-soft); color: var(--accent); }
.combo-list li.none { color: var(--muted); font-style: italic; }
.combo-list li.empty-choice { color: var(--muted); }
.combo-list li.empty { color: var(--muted); cursor: default; }
.combo-list mark { background: none; color: var(--accent); font-weight: 700; }
.kw mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
pre.log { white-space: pre-wrap; font-size: 13px; background: var(--bg); padding: 10px; border-radius: 7px; margin: 6px 0 0; max-height: 320px; overflow: auto; }
.switch { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 600; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

/* confirmation avant d'ouvrir un article */
.open-dialog { width: min(480px, calc(100vw - 32px)); padding: 20px 22px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); color: var(--text);
  box-shadow: 0 12px 40px rgba(16, 24, 40, .25); }
.open-dialog::backdrop { background: rgba(16, 24, 40, .45); }
.open-dialog h2 { margin: 0 0 10px; font-size: 18px; }
.open-dialog .open-title { font-weight: 600; margin: 0 0 8px; overflow-wrap: anywhere; }
.open-dialog .muted { margin: 0 0 12px; font-size: 14px; }
.count-bump { animation: count-bump .5s ease; }
@keyframes count-bump { 0% { background: rgba(234, 88, 12, .25); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .count-bump { animation: none; } }

@media (max-width: 640px) { .kw-add input[name=words] { flex: 1 1 100%; } }

/* mots-clés requis */
.kw.req { border-color: var(--accent); }
.kw-req { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 1px 4px; }
