/* Atelier — design system. Aucune ressource externe : polices système. */

:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --bg-sunken: #eef0f6;
  --bg-hover: #e9ecf5;
  --text: #161a23;
  --text-2: #4a5263;
  --text-3: #6b7385;
  --border: #d9dde8;
  --border-strong: #b9bfce;
  --primary: #3b5bdb;
  --primary-hover: #304ac2;
  --primary-soft: #e7ecff;
  --primary-text: #2c47b8;
  --on-primary: #ffffff;
  --success: #1f7a4a;
  --success-soft: #e3f5ea;
  --warning: #8a5300;
  --warning-soft: #fff3d6;
  --danger: #c0262d;
  --danger-soft: #fde7e8;
  --info-soft: #e6f1ff;
  --focus: #3b5bdb;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --shadow-md: 0 4px 12px rgb(16 24 40 / 8%), 0 2px 4px rgb(16 24 40 / 6%);
  --shadow-lg: 0 20px 40px rgb(16 24 40 / 18%);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --control-h: 44px;
  --content: 1120px;
  /* couleurs des catégories */
  --c-images: #7048e8; --c-pdf: #e03131; --c-media: #d6336c; --c-text: #1c7ed6;
  --c-files: #e8590c; --c-dev: #0c8599; --c-convert: #2f9e44; --c-utils: #5c7cfa;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1117; --bg-elev: #181b24; --bg-sunken: #12141b; --bg-hover: #232736;
    --text: #e8eaf0; --text-2: #b4bac8; --text-3: #8b92a3;
    --border: #2c3140; --border-strong: #434a5c;
    --primary: #7c93ff; --primary-hover: #95a8ff; --primary-soft: #232b4d; --primary-text: #a9b8ff; --on-primary: #0f1117;
    --success: #5fd394; --success-soft: #16301f; --warning: #f2c45a; --warning-soft: #33290f;
    --danger: #ff7b80; --danger-soft: #3a1a1d; --info-soft: #182a42; --focus: #95a8ff;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%); --shadow-md: 0 4px 14px rgb(0 0 0 / 45%); --shadow-lg: 0 20px 50px rgb(0 0 0 / 60%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1117; --bg-elev: #181b24; --bg-sunken: #12141b; --bg-hover: #232736;
  --text: #e8eaf0; --text-2: #b4bac8; --text-3: #8b92a3;
  --border: #2c3140; --border-strong: #434a5c;
  --primary: #7c93ff; --primary-hover: #95a8ff; --primary-soft: #232b4d; --primary-text: #a9b8ff; --on-primary: #0f1117;
  --success: #5fd394; --success-soft: #16301f; --warning: #f2c45a; --warning-soft: #33290f;
  --danger: #ff7b80; --danger-soft: #3a1a1d; --info-soft: #182a42; --focus: #95a8ff;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%); --shadow-md: 0 4px 14px rgb(0 0 0 / 45%); --shadow-lg: 0 20px 50px rgb(0 0 0 / 60%);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font);
  min-height: 100vh; overflow-x: hidden; overflow-wrap: break-word;
}
img, svg, video, canvas { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--s3); font-weight: 650; overflow-wrap: break-word; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 var(--s3); }
a { color: var(--primary-text); text-underline-offset: 2px; }
code, kbd, pre, .mono { font-family: var(--mono); font-size: 0.92em; }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--bg-elev); font-size: 0.8em; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--s3); top: -60px; z-index: 100; background: var(--primary); color: var(--on-primary); padding: var(--s2) var(--s4); border-radius: var(--radius-sm); }
.skip:focus { top: var(--s3); }

/* ---------- en-tête ---------- */
.top {
  position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
}
.top-inner { max-width: var(--content); margin: 0 auto; display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4); min-height: 64px; }
.brand { display: flex; align-items: center; gap: var(--s2); color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.15rem; flex-shrink: 0; border-radius: var(--radius-sm); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), #9c36b5); color: #fff; }
.brand-mark svg { width: 20px; height: 20px; }
.top-search { flex: 1; min-width: 0; max-width: 560px; margin-left: auto; position: relative; }
.top-search .input { padding-left: 42px; border-radius: 999px; background: var(--bg-sunken); }
.top-search > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.top-search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.top-actions { display: flex; gap: var(--s1); flex-shrink: 0; }
.home .top-search { visibility: hidden; }
.mobile-only { display: none !important; }

.cats-bar { border-bottom: 1px solid var(--border); background: var(--bg-elev); }
.cats-bar ul { list-style: none; margin: 0 auto; padding: 0 var(--s4); max-width: var(--content); display: flex; gap: var(--s1); overflow-x: auto; scrollbar-width: thin; }
.cats-bar a { display: flex; align-items: center; gap: 6px; padding: 10px 12px; color: var(--text-2); text-decoration: none; white-space: nowrap; font-size: 0.93rem; border-bottom: 2px solid transparent; }
.cats-bar a:hover { color: var(--text); }
.cats-bar a[aria-current="page"] { color: var(--primary-text); border-bottom-color: var(--primary); font-weight: 600; }
.cats-bar svg { width: 16px; height: 16px; }

main { max-width: var(--content); margin: 0 auto; padding: var(--s5) var(--s4) var(--s7); outline: none; }
main:focus, main:focus-visible { outline: none; }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--control-h); padding: 0 var(--s4); border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; text-align: center; line-height: 1.25; max-width: 100%;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-lg { min-height: 52px; padding: 0 var(--s5); font-size: 1.05rem; border-radius: var(--radius); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: 0.92rem; }
.btn-icon { width: var(--control-h); padding: 0; flex-shrink: 0; }
.chip { white-space: nowrap; }
.btn-icon.btn-sm { width: 36px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.btn-row.end { justify-content: flex-end; }
@media (max-width: 480px) { .btn-row.stack > .btn { flex: 1 1 100%; } }

/* ---------- formulaires ---------- */
.input, .select, .textarea {
  width: 100%; min-height: var(--control-h); padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--text); font: inherit;
}
.textarea { min-height: 160px; resize: vertical; font-family: var(--mono); font-size: 0.92rem; line-height: 1.45; }
.textarea.prose { font-family: var(--font); font-size: 1rem; }
.select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); outline: none; }
.input[aria-invalid="true"] { border-color: var(--danger); }
input[type="color"].input { padding: 4px; width: 64px; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-weight: 600; font-size: 0.95rem; }
.field .hint { color: var(--text-3); font-size: 0.86rem; }
.field-row { display: flex; gap: var(--s2); align-items: center; }
.field-row > .input { flex: 1; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: var(--s4); }
.fields .full { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; min-height: 32px; padding-top: 4px; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--primary); flex-shrink: 0; }
.check .muted { font-weight: 400; }
.range-wrap { display: flex; gap: var(--s3); align-items: center; }
.range-wrap input[type="range"] { flex: 1; accent-color: var(--primary); min-height: 32px; }
.range-wrap output { min-width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

/* choix segmentés (boutons radio) */
.seg { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.seg legend { font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; padding: 0; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--bg-elev); cursor: pointer; font-size: 0.95rem; font-weight: 550; }
.seg input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg label:hover span { border-color: var(--primary); }

details.advanced { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
details.advanced > summary { cursor: pointer; padding: var(--s3) var(--s4); font-weight: 600; list-style: none; display: flex; align-items: center; gap: var(--s2); min-height: var(--control-h); }
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
details.advanced[open] > summary::before { transform: rotate(45deg); }
details.advanced > .fields { padding: 0 var(--s4) var(--s4); }

/* ---------- cartes / sections ---------- */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s5); box-shadow: var(--shadow-sm); min-width: 0; }
@media (max-width: 560px) { .card { padding: var(--s4); border-radius: var(--radius); } main { padding: var(--s4) var(--s3) var(--s7); } }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s5); }
.muted { color: var(--text-3); }
.small { font-size: 0.88rem; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--bg-sunken); color: var(--text-2); max-width: 100%; }
.badge.local { padding: 4px 10px; }
.badge.local { background: var(--success-soft); color: var(--success); }
.badge svg { width: 13px; height: 13px; }

.step { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.step h2 { margin: 0; font-size: 1.08rem; }

/* ---------- accueil ---------- */
.hero { text-align: center; padding: var(--s6) 0 var(--s5); }
.hero h1 { font-size: clamp(1.7rem, 1.2rem + 2.2vw, 2.6rem); margin-bottom: var(--s2); }
.hero p { color: var(--text-2); font-size: 1.08rem; margin-bottom: var(--s5); }
.hero-search { position: relative; max-width: 640px; margin: 0 auto; }
.hero-search .input { min-height: 60px; font-size: 1.12rem; padding-left: 54px; border-radius: 999px; box-shadow: var(--shadow-md); border-color: var(--border); }
.hero-search > svg { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--text-3); }
.quick { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); margin-top: var(--s4); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-2); text-decoration: none; font-size: 0.93rem; font-weight: 550; }
.chip:hover { border-color: var(--primary); color: var(--primary-text); }
.chip svg { width: 16px; height: 16px; }
.privacy-note { display: flex; gap: var(--s2); justify-content: center; align-items: center; color: var(--success); font-weight: 600; font-size: 0.95rem; margin-top: var(--s4); }
.privacy-note svg { width: 18px; height: 18px; flex-shrink: 0; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin: var(--s6) 0 var(--s3); flex-wrap: wrap; }
.section-title h2 { margin: 0; font-size: 1.25rem; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: var(--s3); }
.cat-card { display: flex; gap: var(--s3); align-items: center; padding: var(--s4); border-radius: var(--radius-lg); background: var(--bg-elev); border: 1px solid var(--border); text-decoration: none; color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .12s, transform .12s, box-shadow .12s; min-width: 0; }
.cat-card:hover { border-color: var(--cat, var(--primary)); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.cat-card strong { display: block; font-size: 1.05rem; }
.cat-card span.muted { font-size: 0.88rem; }
.cat-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; color: var(--cat, var(--primary)); background: color-mix(in srgb, var(--cat, var(--primary)) 14%, transparent); }
.cat-icon svg { width: 26px; height: 26px; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: var(--s3); }
.tool-card { position: relative; display: flex; gap: var(--s3); padding: var(--s4); padding-right: 52px; border-radius: var(--radius); background: var(--bg-elev); border: 1px solid var(--border); color: var(--text); text-decoration: none; min-height: 88px; transition: border-color .12s, box-shadow .12s; min-width: 0; }
.tool-card:hover { border-color: var(--cat, var(--primary)); box-shadow: var(--shadow-md); }
.tool-card .t-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; color: var(--cat, var(--primary)); background: color-mix(in srgb, var(--cat, var(--primary)) 13%, transparent); }
.tool-card .t-icon svg { width: 22px; height: 22px; }
.tool-card .t-body { min-width: 0; }
.tool-card strong { display: block; font-size: 1rem; margin-bottom: 2px; }
.tool-card .t-desc { color: var(--text-3); font-size: 0.88rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fav-btn { position: absolute; top: 8px; right: 8px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: var(--text-3); cursor: pointer; display: grid; place-items: center; }
.fav-btn:hover { background: var(--bg-hover); color: #e8a400; }
.fav-btn[aria-pressed="true"] { color: #e8a400; }
.fav-btn svg { width: 20px; height: 20px; }
.empty { text-align: center; padding: var(--s6) var(--s4); color: var(--text-3); border: 2px dashed var(--border); border-radius: var(--radius-lg); }

/* résultats de recherche */
.search-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; max-height: min(70vh, 520px); overflow-y: auto; text-align: left; }
.search-results a { display: flex; gap: var(--s3); align-items: center; padding: 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; min-width: 0; }
.search-results a[aria-selected="true"], .search-results a:hover { background: var(--bg-hover); }
.search-results .t-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--cat); background: color-mix(in srgb, var(--cat) 13%, transparent); flex-shrink: 0; }
.search-results .t-icon svg { width: 18px; height: 18px; }
.search-results .r-body { min-width: 0; flex: 1; }
.search-results .r-body strong { display: block; }
.search-results .r-body span { color: var(--text-3); font-size: 0.86rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results .none { padding: var(--s4); color: var(--text-3); text-align: center; }

/* ---------- page d'outil ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.9rem; color: var(--text-3); margin-bottom: var(--s3); }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs svg { width: 14px; height: 14px; }
.tool-head { display: flex; gap: var(--s4); align-items: flex-start; margin-bottom: var(--s5); }
.tool-head .cat-icon { width: 56px; height: 56px; border-radius: 16px; }
.tool-head .cat-icon svg { width: 30px; height: 30px; }
.tool-head h1 { margin-bottom: 4px; }
.tool-head p { color: var(--text-2); margin: 0 0 var(--s2); max-width: 70ch; }
.tool-head .head-main { flex: 1; min-width: 0; }
.tool-head .fav-btn { position: static; flex-shrink: 0; border: 1px solid var(--border); width: var(--control-h); height: var(--control-h); }
@media (max-width: 560px) { .tool-head .cat-icon { display: none; } }

.tool-layout { display: grid; gap: var(--s4); }

/* zone de dépôt */
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s2); text-align: center;
  padding: var(--s6) var(--s4); border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--bg-sunken); transition: border-color .12s, background .12s;
}
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop .drop-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.drop .drop-icon svg { width: 28px; height: 28px; }
.drop strong { font-size: 1.08rem; }
.drop.compact { padding: var(--s4); flex-direction: row; flex-wrap: wrap; }
.drop.compact .drop-icon { display: none; }
.drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* liste de fichiers */
.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s2) var(--s3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); min-height: 64px; }
.file-row.dragging { opacity: .5; }
.file-row.drop-target { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.file-thumb { width: 48px; height: 48px; border-radius: var(--radius-sm); background: var(--bg-sunken); display: grid; place-items: center; overflow: hidden; color: var(--text-3); flex-shrink: 0; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb svg { width: 22px; height: 22px; }
.file-info { min-width: 0; }
.file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.file-meta { color: var(--text-3); font-size: 0.86rem; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.file-actions { display: flex; gap: 2px; align-items: center; }
.file-status { font-size: 0.86rem; font-weight: 600; }
.file-status.ok { color: var(--success); }
.file-status.err { color: var(--danger); }
.files-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); flex-wrap: wrap; }
@media (max-width: 480px) {
  .file-row { grid-template-columns: auto minmax(0, 1fr); }
  .file-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* barres d'avancement */
.progress { height: 8px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; border: 1px solid var(--border); }
.progress > div { height: 100%; width: 0; background: var(--primary); border-radius: inherit; transition: width .2s; }
.progress.indeterminate > div { width: 35%; animation: indet 1.2s ease-in-out infinite; }
.progress.ok > div { background: var(--success); }
.progress.err > div { background: var(--danger); }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) { .progress.indeterminate > div { animation: none; width: 100%; opacity: .5; } * { transition: none !important; } }

/* alertes */
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--radius); border: 1px solid transparent; }
.alert svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }
.alert p:last-child { margin-bottom: 0; }
.alert.info { background: var(--info-soft); }
.alert.success { background: var(--success-soft); color: var(--success); }
.alert.success .alert-body { color: var(--text); }
.alert.warn { background: var(--warning-soft); }
.alert.warn > svg { color: var(--warning); }
.alert.error { background: var(--danger-soft); }
.alert.error > svg { color: var(--danger); }
.alert-body { min-width: 0; flex: 1; }
.alert details { margin-top: 6px; font-size: 0.86rem; color: var(--text-2); }
.alert details pre { white-space: pre-wrap; max-height: 200px; overflow: auto; }

/* résultats */
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.result-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
.result-row .file-thumb { width: 64px; height: 64px; cursor: zoom-in; border: 0; padding: 0; }
.result-row .file-thumb.static { cursor: default; }
.saving { color: var(--success); font-weight: 650; }
.saving.worse { color: var(--warning); }
@media (max-width: 560px) {
  .result-row { grid-template-columns: auto minmax(0, 1fr); }
  .result-row .file-actions { grid-column: 1 / -1; }
  .result-row .file-actions .btn { flex: 1; }
}
.summary { display: flex; flex-wrap: wrap; gap: var(--s4); align-items: center; justify-content: space-between; }
.stat-list { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--text-3); font-size: 0.85rem; }

pre.output { margin: 0; padding: var(--s4); border-radius: var(--radius); background: var(--bg-sunken); border: 1px solid var(--border); white-space: pre-wrap; max-height: 480px; overflow: auto; font-size: 0.9rem; }

/* comparaison avant / après */
.compare { position: relative; overflow: hidden; border-radius: var(--radius); background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0/20px 20px; user-select: none; touch-action: pan-y; max-height: 75vh; }
.compare img { display: block; width: 100%; height: auto; max-height: 75vh; object-fit: contain; }
.compare .after { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--pos, 50%)); }
.compare .after img { height: 100%; }
.compare .divider { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 3px; background: #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 30%); transform: translateX(-50%); pointer-events: none; }
.compare .lbl { position: absolute; top: 10px; padding: 3px 10px; border-radius: 999px; background: rgb(0 0 0 / 60%); color: #fff; font-size: 0.82rem; font-weight: 600; }
.compare .lbl.l { left: 10px; } .compare .lbl.r { right: 10px; }
.compare-range { width: 100%; accent-color: var(--primary); }

/* boîtes de dialogue */
dialog.modal { border: 0; padding: 0; border-radius: var(--radius-lg); background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-lg); width: min(960px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
dialog.modal::backdrop { background: rgb(10 12 20 / 55%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-elev); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 1.05rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: var(--s4); }
.modal-body img.preview, .modal-body video, .modal-body audio { display: block; margin: 0 auto; max-height: 72vh; }
.modal-body iframe { width: 100%; height: 72vh; border: 0; border-radius: var(--radius-sm); background: #fff; }

/* notifications */
#toasts { position: fixed; bottom: var(--s4); left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: var(--s2); width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); border-radius: var(--radius); background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); animation: toastIn .18s ease-out; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* outils navigateur : deux colonnes entrée / sortie */
.io { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: var(--s4); }
.io .field { min-width: 0; }
.io-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; min-height: 36px; }
.io-head label, .io-head .label { font-weight: 600; }
.kv { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 6px var(--s4); margin: 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.big-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: var(--s3); }
.big-stats div { background: var(--bg-sunken); border-radius: var(--radius); padding: var(--s3) var(--s4); }
.big-stats b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.big-stats span { color: var(--text-3); font-size: 0.88rem; }
.table-wrap { overflow: auto; max-height: 480px; border: 1px solid var(--border); border-radius: var(--radius); }
table.data { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
table.data th, table.data td { border-bottom: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; max-width: 420px; }
table.data th { position: sticky; top: 0; background: var(--bg-sunken); font-weight: 650; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.diff { font-family: var(--mono); font-size: 0.9rem; white-space: pre-wrap; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s3); max-height: 560px; overflow: auto; }
.diff .add { background: color-mix(in srgb, var(--success) 22%, transparent); }
.diff .del { background: color-mix(in srgb, var(--danger) 22%, transparent); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.diff .line { display: block; padding: 0 6px; border-radius: 3px; }
mark { background: color-mix(in srgb, #ffd43b 60%, transparent); color: inherit; border-radius: 2px; }
.swatch { width: 100%; aspect-ratio: 3 / 1; border-radius: var(--radius); border: 1px solid var(--border); }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 92px), 1fr)); gap: var(--s2); }
.swatches button { border: 1px solid var(--border); border-radius: var(--radius-sm); min-height: 64px; cursor: pointer; font: inherit; font-size: 0.78rem; font-family: var(--mono); display: flex; align-items: flex-end; padding: 6px; }
.qr-out { display: grid; place-items: center; background: var(--bg-sunken); border-radius: var(--radius); padding: var(--s4); min-height: 240px; }
.qr-out svg, .qr-out img, .qr-out canvas { width: min(100%, 320px); height: auto; background: #fff; border-radius: 6px; }

/* rognage */
.crop-stage { position: relative; display: inline-block; max-width: 100%; touch-action: none; user-select: none; line-height: 0; }
.crop-stage img { max-width: 100%; max-height: 65vh; display: block; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgb(0 0 0 / 50%), 0 0 0 1px rgb(0 0 0 / 50%); cursor: move; }
.crop-box .h { position: absolute; width: 22px; height: 22px; background: #fff; border: 2px solid var(--primary); border-radius: 50%; transform: translate(-50%, -50%); }
.crop-box .h.nw { left: 0; top: 0; cursor: nwse-resize; } .crop-box .h.ne { left: 100%; top: 0; cursor: nesw-resize; }
.crop-box .h.sw { left: 0; top: 100%; cursor: nesw-resize; } .crop-box .h.se { left: 100%; top: 100%; cursor: nwse-resize; }
.crop-wrap { text-align: center; overflow: hidden; }

/* pages PDF (organisation visuelle) */
.pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 150px), 1fr)); gap: var(--s3); list-style: none; margin: 0; padding: 0; }
.page-tile { position: relative; border: 2px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); padding: var(--s2); display: flex; flex-direction: column; gap: 6px; align-items: center; cursor: grab; min-width: 0; }
.page-tile.sel { border-color: var(--primary); }
.page-tile.removed { opacity: .35; }
.page-tile.removed .page-img { filter: grayscale(1); }
.page-tile.drop-target { border-color: var(--primary); border-style: dashed; }
.page-img { width: 100%; aspect-ratio: 1 / 1.3; display: grid; place-items: center; overflow: hidden; background: var(--bg-sunken); border-radius: 6px; }
.page-img img { max-width: 100%; max-height: 100%; box-shadow: var(--shadow-sm); transition: transform .15s; background: #fff; }
.page-tile .p-num { font-weight: 650; font-size: 0.88rem; }
.page-tile .file-actions { justify-content: center; flex-wrap: wrap; }

/* pied de page */
.foot { max-width: var(--content); margin: 0 auto; padding: var(--s5) var(--s4) var(--s6); color: var(--text-3); font-size: 0.88rem; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); justify-content: space-between; border-top: 1px solid var(--border); }
.foot a { color: var(--text-2); }

.prose-block { max-width: 75ch; }
.prose-block h2 { margin-top: var(--s5); }
.prose-block li { margin-bottom: 6px; }
.md-preview { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s4); overflow: auto; max-height: 560px; }
.md-preview pre { background: var(--bg-sunken); padding: var(--s3); border-radius: var(--radius-sm); overflow: auto; }
.md-preview table { border-collapse: collapse; }
.md-preview td, .md-preview th { border: 1px solid var(--border); padding: 4px 8px; }
.md-preview img { max-width: 100%; }
.md-preview [align=right] { text-align: right; } .md-preview [align=center] { text-align: center; }
.md-preview blockquote { border-left: 4px solid var(--border-strong); margin: 0; padding-left: var(--s3); color: var(--text-2); }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- menu latéral (téléphone) ---------- */
dialog.drawer {
  margin: 0; padding: 0; border: 0; height: 100dvh; max-height: 100dvh; width: min(320px, 86vw); max-width: none;
  background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-lg);
  display: none; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) env(safe-area-inset-left);
}
dialog.drawer[open] { display: flex; animation: drawerIn .18s ease-out; }
dialog.drawer::backdrop { background: rgb(10 12 20 / 50%); }
@keyframes drawerIn { from { transform: translateX(-100%); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s2) var(--s2) var(--s2) var(--s4); min-height: 60px; border-bottom: 1px solid var(--border); }
.drawer-nav { padding: var(--s2); flex: 1; }
.drawer-title { margin: var(--s4) var(--s3) var(--s1); font-size: 0.78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.drawer-link {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 48px; padding: 0 var(--s3); border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font: inherit; font-weight: 550; text-decoration: none; text-align: left; cursor: pointer;
}
.drawer-link:hover { background: var(--bg-hover); }
.drawer-link[aria-current="page"] { background: var(--primary-soft); color: var(--primary-text); }
.drawer-link .d-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; color: var(--cat, var(--text-2)); background: color-mix(in srgb, var(--cat, var(--text-3)) 13%, transparent); }
.drawer-link .d-icon svg { width: 19px; height: 19px; }
.drawer-link .d-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-link .d-count { color: var(--text-3); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.drawer-foot { padding: var(--s2); border-top: 1px solid var(--border); }

/* barre d'action fixe (téléphone) */
.action-bar { display: none; }

/* ---------- téléphone ---------- */
@media (max-width: 720px) {
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }
  .cats-bar { display: none; }
  .top-inner { gap: var(--s1); padding: var(--s1) var(--s2); padding-left: max(var(--s2), env(safe-area-inset-left)); padding-right: max(var(--s2), env(safe-area-inset-right)); min-height: 56px; }
  .brand { font-size: 1.1rem; }
  .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
  .top-actions { margin-left: auto; }
  .home #search-btn { display: none !important; }

  /* recherche : cachée derrière la loupe, puis sur toute la largeur de l'en-tête */
  .top-search { display: none; position: absolute; inset: 0; max-width: none; margin: 0; padding: var(--s2); background: var(--bg-elev); align-items: center; gap: var(--s1); z-index: 2; }
  .top.search-open .top-search { display: flex; }
  .top.search-open .top-search .input { flex: 1; }
  .top-search > svg { left: 22px; }
  .top-search kbd { display: none; }
  .top-search .search-results { left: var(--s2); right: var(--s2); max-height: calc(100dvh - 90px); }

  main { padding: var(--s3) var(--s3) var(--s6); padding-left: max(var(--s3), env(safe-area-inset-left)); padding-right: max(var(--s3), env(safe-area-inset-right)); }
  .crumbs { display: none; }
  h1 { font-size: 1.45rem; }

  /* accueil */
  .hero { padding: var(--s4) 0 var(--s2); }
  .hero h1 { font-size: 1.55rem; }
  .hero p { font-size: 0.98rem; margin-bottom: var(--s4); }
  .hero-search .input { min-height: 52px; font-size: 1rem; padding-left: 48px; }
  .hero-search > svg { left: 17px; }
  .quick { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; margin: var(--s3) calc(-1 * var(--s3)) 0; padding: 2px var(--s3) var(--s1); scrollbar-width: none; }
  .quick::-webkit-scrollbar { display: none; }
  .quick .chip { flex-shrink: 0; }
  .privacy-note { font-size: 0.86rem; font-weight: 550; text-align: left; }
  .section-title { margin: var(--s5) 0 var(--s2); }
  .section-title h2 { font-size: 1.1rem; }
  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .cat-card { flex-direction: column; align-items: flex-start; gap: var(--s2); padding: var(--s3); border-radius: var(--radius); }
  .cat-card strong { font-size: 0.98rem; }
  .cat-card .cat-icon { width: 40px; height: 40px; border-radius: 12px; }
  .cat-card .cat-icon svg { width: 22px; height: 22px; }
  .cat-desc { display: none; }

  /* listes d'outils : lignes compactes */
  .tool-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .tool-card { min-height: 64px; padding: var(--s3); padding-right: 48px; align-items: center; }
  .tool-card .t-icon { width: 36px; height: 36px; border-radius: 10px; }
  .tool-card .t-icon svg { width: 20px; height: 20px; }
  .tool-card strong { font-size: 0.97rem; }
  .tool-card .t-desc { -webkit-line-clamp: 1; font-size: 0.85rem; }
  .fav-btn { top: 50%; transform: translateY(-50%); }

  /* page d'outil */
  .tool-head { gap: var(--s2); margin-bottom: var(--s3); }
  .tool-head h1 { font-size: 1.3rem; }
  .tool-head p { font-size: 0.95rem; margin-bottom: var(--s2); }
  .tool-head .fav-btn { transform: none; width: 40px; height: 40px; }
  .badge.local { font-size: 0.75rem; }
  .tool-layout { gap: var(--s3); }
  .card { padding: var(--s3); border-radius: var(--radius); }
  .step { margin-bottom: var(--s1); }
  .step h2 { font-size: 1rem; }
  .drop { padding: var(--s4) var(--s3); gap: var(--s1); }
  .drop .drop-icon { width: 44px; height: 44px; }
  .drop .drop-icon svg { width: 22px; height: 22px; }
  .drop strong { font-size: 1rem; }
  .file-row { grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s2); padding: 6px var(--s2); min-height: 56px; }
  .file-row .file-actions { grid-column: auto; }
  .file-thumb { width: 42px; height: 42px; }
  .seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seg span { width: 100%; justify-content: center; text-align: center; padding: 6px 10px; min-height: 44px; line-height: 1.2; }
  .fields { gap: var(--s3); }
  .result-row { padding: var(--s2); gap: var(--s2); }
  .result-row .file-thumb { width: 56px; height: 56px; }
  .stat b { font-size: 1.1rem; }

  .action-bar:not([hidden]) {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    padding: var(--s2) var(--s3) max(var(--s2), env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg-elev) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgb(16 24 40 / 8%);
  }
  .action-bar .btn { flex: 1; }
  .btn-row.stack { align-items: stretch; }
  body.has-action-bar { padding-bottom: 76px; }
  body.has-action-bar #toasts { bottom: 84px; }

  .foot { padding: var(--s4) var(--s3) max(var(--s5), env(safe-area-inset-bottom)); flex-direction: column; }
  dialog.modal { width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 0; margin: 0; height: 100dvh; }
}

/* écran tactile : pas de glisser-déposer ni de Ctrl+V, un seul gros bouton */
@media (pointer: coarse) {
  .drop .drop-title, .drop .drop-or, .drop .drop-paste { display: none; }
  .drop { padding: var(--s4) var(--s3); }
  .drop .btn { min-height: 52px; width: min(100%, 360px); font-size: 1.05rem; }
}
