/* Navette — une feuille, des jetons, aucun framework.
   Principes : neutre et calme, une seule couleur d'accent, des cibles de 44 px au doigt,
   le contenu (les photos) au premier plan. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #e1e4e9;
  --text: #14171c;
  --muted: #646b76;
  --accent: #2f5bea;
  --accent-hover: #2449c9;
  --accent-ink: #ffffff;
  --accent-soft: #e9eefd;
  --danger: #c93a2b;
  --danger-soft: #fbeceb;
  --success: #1c8a4c;
  --warning: #a86200;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(16 24 40 / 5%), 0 4px 16px rgb(16 24 40 / 6%);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13;
    --surface: #15181e;
    --surface-2: #1c2028;
    --border: #272c35;
    --text: #e9ebef;
    --muted: #979fac;
    --accent: #6f8dff;
    --accent-hover: #8aa2ff;
    --accent-ink: #0d0f13;
    --accent-soft: rgb(111 141 255 / 14%);
    --danger: #ff7a6b;
    --danger-soft: rgb(255 122 107 / 12%);
    --success: #4fd08a;
    --warning: #f0b25a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
@media (min-width: 720px) { body { font-size: 16px; } }
img, video, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.1rem; font-weight: 620; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.icon { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.mono { font-family: var(--mono); font-size: 0.9em; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spacer { flex: 1; }

/* --- Structure ------------------------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 680; font-size: 1.08rem; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; }
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 8px 16px 96px; }
.narrow { max-width: 640px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
footer.foot { text-align: center; padding: 24px 16px 32px; color: var(--muted); font-size: 0.8rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
@media (max-width: 520px) { .card { padding: 16px; } }

.hero { padding: 12px 0 20px; }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.1rem); }
.hero p { color: var(--muted); margin-top: 6px; }

/* --- Boutons et champs ------------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn.icon-only { width: 44px; padding: 0; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.92em; }
.btn.small.icon-only { width: 36px; padding: 0; }
.btn.block { width: 100%; }
.btn.big { min-height: 52px; font-size: 1.05em; }

label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 560; font-size: 0.92em; }
label.field .hint { font-weight: 400; color: var(--muted); }
.input, textarea.input, select.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
textarea.input { min-height: 76px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Contrôle segmenté (durées, formats) */
.segmented { display: flex; padding: 3px; gap: 3px; background: var(--surface-2); border-radius: var(--radius-sm); overflow-x: auto; }
.segmented button {
  flex: 1;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 560;
  font-size: 0.92em;
  cursor: pointer;
  white-space: nowrap;
}
.segmented button[aria-pressed='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Interrupteur */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; }
.switch input { appearance: none; flex: none; width: 42px; height: 24px; border-radius: 99px; background: var(--border); position: relative; cursor: pointer; transition: background 0.15s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgb(0 0 0 / 25%); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }
.switch span { display: flex; flex-direction: column; }
.switch small { color: var(--muted); }

details.options { border-top: 1px solid var(--border); padding-top: 12px; }
details.options summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; font-weight: 580; min-height: 36px; }
details.options summary::-webkit-details-marker { display: none; }
details.options summary .icon { transition: transform 0.15s; }
details.options[open] summary .icon { transform: rotate(90deg); }
details.options .stack { padding-top: 12px; }

/* --- Dépôt et liste d'envoi -------------------------------------------------------------------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 210px;
  padding: 24px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .disc { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.dropzone .disc .icon { width: 26px; height: 26px; }
.dropzone strong { font-size: 1.05em; }
.dropzone.compact { min-height: 0; padding: 14px; flex-direction: row; }
.dropzone.compact .disc { width: 36px; height: 36px; }
.dropzone.compact .disc .icon { width: 20px; height: 20px; }

.filelist { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.filelist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.filelist li:last-child { border-bottom: 0; }
.filelist .thumb { width: 40px; height: 40px; flex: none; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.filelist .thumb img { width: 100%; height: 100%; object-fit: cover; }
.filelist .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.filelist .meta .sub { color: var(--muted); font-size: 0.85em; }
.filelist .state { flex: none; color: var(--muted); font-size: 0.85em; font-variant-numeric: tabular-nums; }
.filelist .state.ok { color: var(--success); }
.filelist .state.err { color: var(--danger); }

.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 0.2s linear; }
.progress.thin { height: 3px; }
.progress.done > i { background: var(--success); }

.summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }

/* Lien de partage */
.share { display: flex; gap: 8px; align-items: stretch; }
.share .input { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); }
@media (max-width: 520px) { .share { flex-direction: column; } }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.banner.warn { background: var(--danger-soft); color: var(--danger); }
.banner .icon { margin-top: 2px; }

/* --- Page d'un transfert ------------------------------------------------------------------------ */

.transfer-head { display: flex; flex-direction: column; gap: 6px; padding: 8px 0 18px; }
.transfer-head .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 0.9em; }
.transfer-head .facts span { display: inline-flex; align-items: center; gap: 6px; }
.transfer-head .facts .icon { width: 16px; height: 16px; }
.message { white-space: pre-wrap; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 8px; }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 99px; background: var(--surface); color: var(--muted);
  font: inherit; font-size: 0.9em; font-weight: 560; cursor: pointer; white-space: nowrap;
}
.chip b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.chip[aria-pressed='true'] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip[aria-pressed='true'] b { color: var(--bg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 4px; } }
.tile {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2);
  border: 0; padding: 0; cursor: pointer; color: var(--muted); -webkit-tap-highlight-color: transparent;
}
@media (max-width: 520px) { .tile { border-radius: 4px; } }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; }
.tile .ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px; font-size: 0.75em; text-align: center; }
.tile .ph .icon { width: 28px; height: 28px; }
.tile .ph .ellipsis { max-width: 100%; }
.tile .badge {
  position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 99px; background: rgb(0 0 0 / 58%); color: #fff; font-size: 0.72em; font-weight: 600;
}
.tile .badge .icon { width: 13px; height: 13px; }
.tile .done { position: absolute; right: 6px; top: 6px; width: 20px; height: 20px; border-radius: 50%; background: rgb(0 0 0 / 50%); color: #fff; display: grid; place-items: center; }
.tile .done .icon { width: 13px; height: 13px; }
.tile .check {
  position: absolute; left: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff; background: rgb(0 0 0 / 25%); display: none; place-items: center; color: #fff;
}
.tile .check .icon { width: 14px; height: 14px; opacity: 0; }
.selecting .tile .check { display: grid; }
.tile[aria-selected='true'] .check { background: var(--accent); border-color: var(--accent); }
.tile[aria-selected='true'] .check .icon { opacity: 1; }
.tile[aria-selected='true'] img, .tile[aria-selected='true'] video { transform: scale(0.9); border-radius: 8px; }
.tile img, .tile video { transition: transform 0.15s; }
.tile .bar { position: absolute; left: 0; right: 0; bottom: 0; }

.docs { margin-top: 24px; }
.docs h2 { margin-bottom: 8px; }
.docs .filelist { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 14px; }

.actionbar {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px;
  width: min(560px, calc(100% - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 10px 40px rgb(0 0 0 / 22%);
}
.actionbar .count { font-weight: 600; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .icon { width: 40px; height: 40px; }

/* --- Visionneuse ---------------------------------------------------------------------------------- */

.viewer { position: fixed; inset: 0; z-index: 50; background: #050506; color: #fff; display: flex; flex-direction: column; touch-action: none; }
.viewer .vbar { display: flex; align-items: center; gap: 4px; padding: max(8px, env(safe-area-inset-top)) 8px 8px; position: absolute; top: 0; left: 0; right: 0; z-index: 2; background: linear-gradient(rgb(0 0 0 / 65%), transparent); }
.viewer .vbar .title { flex: 1; min-width: 0; padding: 0 8px; }
.viewer .vbar .title small { display: block; opacity: 0.7; }
.viewer .btn { color: #fff; background: transparent; border-color: transparent; }
.viewer .btn:hover { background: rgb(255 255 255 / 12%); }
.viewer .stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.viewer .track { display: flex; width: 100%; height: 100%; will-change: transform; }
.viewer .slide { flex: 0 0 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: relative; }
.viewer .slide img, .viewer .slide video { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.viewer .slide .ph { display: flex; flex-direction: column; align-items: center; gap: 12px; opacity: 0.8; text-align: center; padding: 24px; }
.viewer .slide .ph .icon { width: 48px; height: 48px; }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 52px; height: 52px; border-radius: 50%; background: rgb(255 255 255 / 10%); }
.viewer .nav.prev { left: 12px; }
.viewer .nav.next { right: 12px; }
@media (hover: none) { .viewer .nav { display: none; } }
.viewer .spinner { position: absolute; width: 32px; height: 32px; border: 3px solid rgb(255 255 255 / 25%); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.menu { position: absolute; right: 8px; top: 56px; z-index: 3; min-width: 230px; padding: 6px; border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--border); }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu small { margin-left: auto; color: var(--muted); }
.menu .danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* --- Dialogue, notifications ------------------------------------------------------------------- */

dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 20px; width: min(440px, calc(100% - 32px)); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(0 0 0 / 45%); }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

.toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 24px)); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-weight: 520; animation: rise 0.2s ease-out; pointer-events: auto; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* --- Gestion --------------------------------------------------------------------------------------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi small { color: var(--muted); display: block; }
.kpi strong { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.gauge { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; }
.gauge i { display: block; height: 100%; background: var(--accent); }
.gauge i.warn { background: var(--warning); }
.gauge i.bad { background: var(--danger); }
.table { width: 100%; border-collapse: collapse; font-size: 0.92em; }
.table th { text-align: left; font-weight: 560; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
@media (max-width: 640px) {
  .table thead { display: none; }
  .table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .table td { border: 0; padding: 0; }
  .table td.hide-sm { display: none; }
  .table td.title-cell { grid-column: 1; }
  .table td.actions-cell { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  .table .num { text-align: left; }
}
.bars { display: flex; align-items: flex-end; gap: 3px; height: 64px; }
.bars i { flex: 1; background: var(--accent-soft); border-top: 2px solid var(--accent); min-height: 2px; border-radius: 3px 3px 0 0; }

/* Petits écrans : les icônes suffisent là où la place manque. */
@media (max-width: 520px) {
  #selectBtn .label, .docs .btn .label, #addBtn .label { display: none; }
  #selectBtn, .docs .btn.small { width: 36px; padding: 0; }
  .transfer-head h1 { font-size: 1.35rem; }
}
label.field > span:first-child { display: flex; gap: 6px; align-items: baseline; }
