/* Homelab Drive — feuille de style
   Direction : un instrument pour une machine qu'on possède.
   Les faits machine (chemins, octets, dates, hôtes) sont en monospace ;
   le langage humain est en sans-serif. L'ambre ne sert qu'à l'activité disque. */

:root {
  --bg: #0d0e10;
  --surface: #161719;
  --raised: #1e1f22;
  --hover: #26282b;
  --line: #2c2e31;
  --line-soft: #212326;
  --text: #f1f1f2;
  --muted: #92969c;
  --faint: #6b6e74;

  --accent: #ffffff;
  --on-accent: #0d0e10;
  --accent-soft: rgba(255, 255, 255, 0.09);
  --accent-line: rgba(255, 255, 255, 0.26);
  --activity: #f1f1f2;
  --ok: #b9bbbf;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.13);

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Mono", Menlo, Consolas, monospace;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --rail: 252px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --raised: #ffffff;
  --hover: #ececee;
  --line: #dcdcde;
  --line-soft: #e8e8ea;
  --text: #131416;
  --muted: #5d6067;
  --faint: #8a8d94;

  --accent: #131416;
  --on-accent: #ffffff;
  --accent-soft: rgba(19, 20, 22, 0.06);
  --accent-line: rgba(19, 20, 22, 0.22);
  --activity: #131416;
  --ok: #4a4d52;
  --danger: #c9282d;
  --danger-soft: rgba(201, 40, 45, 0.09);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

/* Le display des classes ci-dessous l'emporterait sinon sur [hidden]. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono, .num {
  font-family: var(--mono);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.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;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------------------------------------------------------------- boutons */

button, .btn {
  font: inherit;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--hover); border-color: var(--faint); text-decoration: none; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); opacity: 0.88; }

.btn-danger { color: var(--danger); border-color: transparent; background: var(--danger-soft); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }

.icon-btn {
  padding: 6px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  border-radius: var(--r-sm);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--text); }

svg.i { width: 16px; height: 16px; flex: none; stroke-width: 1.7; }

/* ---------------------------------------------------------------- champs */

input[type="text"], input[type="password"], input[type="search"], input[type="number"], select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  width: 100%;
}
[data-theme="light"] input, [data-theme="light"] select { background: var(--surface); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--faint); }

label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}

/* ---------------------------------------------------------------- shell */

.shell {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* -------- rail ---------------------------------------------------------- */

.rail {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
}
.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
}
.brand-name { font-weight: 600; letter-spacing: -0.015em; }
.brand-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  letter-spacing: 0.02em;
}

.rail-actions { padding: 0 12px 12px; }
.btn-new { width: 100%; justify-content: center; padding: 10px; font-weight: 600; }

.nav { padding: 4px 8px; display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  padding: 14px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  cursor: pointer;
  border: 0; background: none; width: 100%; text-align: left;
  font-weight: 500;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item .count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--faint); }

.tree { padding: 0 8px 8px; overflow-y: auto; flex: 1; min-height: 0; }
.tree-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: var(--r-sm);
  color: var(--muted); cursor: pointer; font-size: 13px;
}
.tree-item:hover { background: var(--hover); color: var(--text); }
.tree-item.drop { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.tree-caret { display: grid; place-items: center; width: 16px; height: 16px; color: var(--faint); }
.tree-caret svg { transition: transform 0.15s ease; }
.tree-item.open > .tree-caret svg { transform: rotate(90deg); }
.tree-children { margin-left: 11px; border-left: 1px solid var(--line-soft); padding-left: 4px; }

/* -------- signature : la barre de montage ------------------------------- */

.mount {
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  display: grid;
  gap: 7px;
}
.mount-line { display: flex; align-items: center; gap: 7px; }
.mount-host { color: var(--muted); }
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); flex: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
body.busy .dot {
  background: var(--activity);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: pulse 1.05s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

.gauge {
  height: 5px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
}
.gauge-mine { background: var(--accent); }
.gauge-other { background: var(--faint); opacity: 0.5; }
.gauge-fill { transition: width 0.4s ease; }
.mount-legend { display: flex; justify-content: space-between; gap: 8px; }

/* -------- zone principale ---------------------------------------------- */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.search {
  position: relative;
  flex: 1;
  max-width: 520px;
}
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 34px; border-radius: 999px; }
.kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px; color: var(--faint);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
}
.search input:focus ~ .kbd { display: none; }

/* le bouton generique impose un padding : on le neutralise pour centrer les initiales */
.avatar {
  width: 30px; height: 30px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0;
  background: var(--accent-soft); color: var(--text);
  font-weight: 600; font-size: 11.5px; line-height: 1;
  letter-spacing: 0.02em; text-indent: 0.02em;
  border: 1px solid var(--accent-line);
  cursor: pointer;
  flex: none;
}
.avatar:hover { background: var(--hover); border-color: var(--faint); }

/* -------- barre de chemin ---------------------------------------------- */

.pathbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  flex-wrap: wrap;
}
.crumbs {
  display: flex; align-items: center; gap: 2px;
  font-family: var(--mono); font-size: 13px;
  flex-wrap: wrap; min-width: 0;
}
.crumb {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  padding: 4px 7px; border-radius: var(--r-sm); font: inherit;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb:hover { background: var(--hover); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 600; }
.crumb.drop { background: var(--accent-soft); color: var(--text); }
.crumb-sep { color: var(--faint); user-select: none; }

.view-toggle { display: flex; gap: 2px; padding: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
.view-toggle button { border: 0; background: none; padding: 5px 8px; color: var(--muted); }
.view-toggle button.on { background: var(--raised); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
[data-theme="light"] .view-toggle button.on { background: var(--hover); }

/* -------- rangée d'actions (par défaut / sélection) --------------------- */

.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.selcount {
  font-weight: 600;
  color: var(--text);
  padding-right: 2px;
  white-space: nowrap;
}

/* -------- liste --------------------------------------------------------- */

.files {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px 120px;
  min-height: 0;
  scrollbar-width: thin;
}
.files::-webkit-scrollbar { width: 10px; }
.files::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 3px solid var(--bg); }

.thead {
  display: grid;
  grid-template-columns: 1fr 110px 170px 92px;
  gap: 12px;
  padding: 0 12px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 2;
  font-weight: 600;
}
.thead button {
  border: 0; background: none; color: inherit; font: inherit;
  text-transform: inherit; letter-spacing: inherit; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.thead button:hover { color: var(--text); background: none; }
.thead .sorted { color: var(--text); }

.row {
  display: grid;
  grid-template-columns: 1fr 110px 170px 92px;
  gap: 12px;
  align-items: center;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: default;
  user-select: none;
}
.row + .row { margin-top: 1px; }
.row:hover { background: var(--surface); }
.row.selected { background: var(--accent-soft); border-color: var(--accent-line); }
.row.drop { background: var(--accent-soft); border-color: var(--accent); }
.row.cut { opacity: 0.5; }
.row.menu-open, .tile.menu-open { background: var(--hover); border-color: var(--line); }

.row-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-name .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-name .label b { font-weight: 500; }

.thumb {
  width: 30px; height: 30px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--raised);
  color: var(--muted);
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb svg { width: 17px; height: 17px; }
.k-folder { color: var(--text); }
.k-image, .k-video, .k-audio, .k-pdf, .k-archive,
.k-text, .k-doc, .k-sheet, .k-slide { color: var(--muted); }

.tags { display: inline-flex; gap: 5px; margin-left: 2px; color: var(--faint); }
.tags svg { width: 13px; height: 13px; }
.tags .star { color: var(--text); }
.tags .shared { color: var(--text); }

.cell { color: var(--muted); font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; opacity: 0; }
.row:hover .row-actions, .row.selected .row-actions { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }

/* -------- grille -------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
  padding-top: 4px;
}
.tile {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  overflow: hidden;
  cursor: default;
  user-select: none;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.tile:hover { border-color: var(--faint); }
.tile.selected { border-color: var(--accent); background: var(--accent-soft); }
.tile.drop { border-color: var(--accent); background: var(--accent-soft); }
.tile-preview {
  height: 104px;
  display: grid; place-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  overflow: hidden;
}
.tile-preview img { width: 100%; height: 100%; object-fit: cover; }
.tile-preview svg { width: 34px; height: 34px; stroke-width: 1.4; }
.tile-meta { padding: 8px 10px; }
.tile-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.tile-sub { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-top: 2px; }

/* -------- états --------------------------------------------------------- */

.empty {
  text-align: center;
  padding: 72px 20px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
  margin-top: 12px;
  background: radial-gradient(120% 90% at 50% 0%, var(--surface), transparent 70%);
}
.empty h3 { margin: 0 0 6px; color: var(--text); font-weight: 600; letter-spacing: -0.01em; }
.empty p { margin: 0 0 18px; }
.empty .mono { display: block; margin-top: 14px; font-size: 11px; color: var(--faint); }

.skeleton { display: grid; gap: 3px; padding-top: 10px; }
.skeleton div {
  height: 44px; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface), var(--hover), var(--surface));
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* -------- dépôt de fichiers -------------------------------------------- */

.dropveil {
  position: absolute; inset: 0; z-index: 40;
  display: none; place-items: center;
  background: rgba(10, 11, 12, 0.86);
  backdrop-filter: blur(3px);
  border: 2px dashed var(--accent);
  border-radius: var(--r-lg);
  margin: 8px;
}
[data-theme="light"] .dropveil { background: rgba(244, 244, 245, 0.9); }
body.dragging .dropveil { display: grid; }
.dropveil-inner { text-align: center; }
.dropveil-inner svg { width: 40px; height: 40px; color: var(--text); margin-bottom: 10px; }
.dropveil strong { display: block; font-size: 17px; letter-spacing: -0.01em; }

/* -------- transferts ---------------------------------------------------- */

.dock {
  position: fixed;
  right: 20px; bottom: 20px;
  width: 330px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  z-index: 60;
  overflow: hidden;
}
.dock[hidden] { display: none; }
.dock-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 600;
}
.dock-list { max-height: 240px; overflow-y: auto; }
.dock-item { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.dock-item:last-child { border-bottom: 0; }
.dock-top { display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.dock-top .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-top .pct { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--activity); width: 0; transition: width 0.15s linear; }
.dock-item.done .bar span { background: var(--accent); }
.dock-item.error .bar span { background: var(--danger); }
.dock-item.error .pct { color: var(--danger); }

/* -------- panneau de détails ------------------------------------------- */

.details {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 320px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 55;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  display: flex; flex-direction: column;
}
.details.open { transform: none; }
.details-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.details-body { padding: 16px; overflow-y: auto; }
.details-preview {
  height: 168px; border-radius: var(--r); background: var(--bg);
  display: grid; place-items: center; overflow: hidden; margin-bottom: 16px;
  border: 1px solid var(--line-soft);
}
.details-preview img { width: 100%; height: 100%; object-fit: contain; }
.details-preview svg { width: 46px; height: 46px; color: var(--muted); stroke-width: 1.3; }
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 8px 10px; font-size: 12.5px; align-items: baseline; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 11.5px; word-break: break-all; }

/* -------- menu du compte ------------------------------------------------ */

.usermenu-wrap { position: relative; }
.usermenu {
  position: absolute;
  right: 0; top: 40px;
  min-width: 232px;
}
.usermenu-head { padding: 8px 10px 6px; font-size: 12.5px; }
.usermenu-head .mono { font-size: 10.5px; word-break: break-all; }
.usermenu form { display: block; }
.usermenu form button { width: 100%; }

/* -------- menu contextuel ---------------------------------------------- */

.menu {
  position: fixed; z-index: 80;
  min-width: 208px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 5px;
}
.menu[hidden] { display: none; }
.menu button {
  display: flex; width: 100%; align-items: center; gap: 10px;
  padding: 7px 9px; border: 0; background: none; border-radius: var(--r-sm);
  color: var(--text); font-size: 13px; text-align: left;
}
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu button .short { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }

/* -------- modales ------------------------------------------------------- */

.overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(8, 9, 10, 0.74);
  display: grid; place-items: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }
[data-theme="light"] .overlay { background: rgba(19, 20, 22, 0.4); }

.modal {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.16s ease;
}
.modal.wide { width: min(720px, 100%); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.modal-head { padding: 16px 18px 0; }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.modal-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 16px 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--line); background: var(--bg);
}
[data-theme="light"] .modal-foot { background: var(--hover); }

.share-link {
  display: flex; gap: 8px; align-items: center;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 10px; margin-bottom: 14px;
}
.share-link code { flex: 1; font-family: var(--mono); font-size: 11.5px; word-break: break-all; color: var(--text); }

.list-rows { display: grid; gap: 4px; max-height: 340px; overflow-y: auto; }
.list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg);
}
[data-theme="light"] .list-row { background: var(--surface); }
.list-row .grow { min-width: 0; }
.list-row .sub { font-family: var(--mono); font-size: 11px; color: var(--faint); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip {
  font-family: var(--mono); font-size: 10.5px;
  padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.chip.warn { color: var(--text); border-color: var(--accent-line); }
.chip.ok { color: var(--muted); border-color: var(--accent-line); }

/* -------- aperçu -------------------------------------------------------- */

.viewer {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(8, 9, 10, 0.95);
  display: flex; flex-direction: column;
}
.viewer[hidden] { display: none; }
.viewer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; color: #e6eaf2;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.viewer-head .name { font-weight: 500; }
.viewer-head .icon-btn { color: rgba(230, 234, 242, 0.65); }
.viewer-head .icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.viewer-stage {
  flex: 1;
  min-height: 0;
  padding: 20px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overscroll-behavior: contain;
}
/* « safe » évite que le haut et la gauche deviennent inatteignables au zoom */
@supports (justify-content: safe center) {
  .viewer-stage { align-items: safe center; justify-content: safe center; }
}
.viewer-stage::-webkit-scrollbar { width: 12px; height: 12px; }
.viewer-stage::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18); border-radius: 10px; border: 3px solid transparent;
  background-clip: content-box;
}

.viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-sm); }
.viewer-stage img { border-radius: var(--r-sm); flex: none; }
.viewer-stage img.fit { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.viewer-stage img.zoomed { max-width: none; max-height: none; cursor: grab; }
.viewer-stage img.zoomed.grabbing { cursor: grabbing; }
.viewer-stage iframe { width: 100%; height: 100%; border: 0; border-radius: var(--r-sm); background: #fff; }
.viewer-stage pre {
  width: 100%; align-self: stretch; margin: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
  color: var(--text); white-space: pre; tab-size: 2;
}
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08); color: #fff; border: 0;
  display: grid; place-items: center;
}
.viewer-nav:hover { background: rgba(255, 255, 255, 0.18); }
.viewer-nav.prev { left: 16px; }
.viewer-nav.next { right: 16px; }
.viewer-empty { color: rgba(230, 234, 242, 0.6); text-align: center; }

/* zoom de l'aperçu */
.zoombar { display: flex; align-items: center; gap: 2px; }
.zoom-level {
  min-width: 72px;
  padding: 5px 8px;
  font-size: 11.5px;
  background: transparent;
  border-color: transparent;
  color: rgba(230, 234, 242, 0.75);
}
.zoom-level:hover { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: transparent; }

/* -------- toasts -------------------------------------------------------- */

.toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 9px 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  animation: rise 0.16s ease;
  pointer-events: auto;
  max-width: 90vw;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
.toast button { padding: 2px 8px; font-size: 12px; }

/* -------- connexion ----------------------------------------------------- */

.auth {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(70% 55% at 50% -8%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.auth-card {
  width: min(392px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.auth-head { padding: 28px 28px 4px; }
.auth-head .brand-mark { width: 36px; height: 36px; margin-bottom: 16px; }
.auth-head h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.auth-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.auth-body { padding: 22px 28px 24px; }
.auth-body button[type="submit"] { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }
.auth-foot {
  padding: 12px 28px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.alert {
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--r-sm); padding: 9px 12px; font-size: 13px; margin-bottom: 16px;
}

/* -------- page de partage public --------------------------------------- */

.public {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.public-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.public-main { flex: 1; width: min(880px, 100%); margin: 0 auto; padding: 28px 20px 60px; }
.public-hero {
  display: flex; align-items: center; gap: 16px;
  padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); margin-bottom: 22px; flex-wrap: wrap;
}
.public-hero .thumb { width: 48px; height: 48px; }
.public-hero .thumb svg { width: 26px; height: 26px; }
.public-hero h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.015em; word-break: break-word; }
.public-preview {
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface); margin-bottom: 22px;
}
.public-preview img, .public-preview video { display: block; width: 100%; max-height: 70vh; object-fit: contain; background: var(--bg); }
.public-preview iframe { display: block; width: 100%; height: 74vh; border: 0; background: #fff; }
.public-list { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.public-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
}
.public-row:last-child { border-bottom: 0; }
.public-row:hover { background: var(--surface); }
.public-foot { text-align: center; padding: 24px; color: var(--faint); font-family: var(--mono); font-size: 11px; }

/* -------- page d'erreur ------------------------------------------------- */

.errpage { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; text-align: center; }
.errpage .code { font-family: var(--mono); font-size: 56px; font-weight: 600; color: var(--text); letter-spacing: -0.03em; }
.errpage h1 { margin: 6px 0 10px; font-size: 18px; font-weight: 600; }
.errpage p { color: var(--muted); margin: 0 0 20px; }

/* -------- responsive ---------------------------------------------------- */

.rail-toggle { display: none; }

@media (max-width: 700px) {
  .pathbar .lbl { display: none; }
  .pathbar button { padding: 7px 9px; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: 268px; z-index: 70;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  body.rail-open .rail { transform: none; }
  body.rail-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 65;
  }
  .rail-toggle { display: inline-flex; }
  .thead, .row { grid-template-columns: 1fr 84px 44px; }
  .thead .col-date, .row .col-date { display: none; }
  .details { width: 100%; }
  .dock { right: 12px; left: 12px; width: auto; }
  .files { padding: 0 12px 120px; }
  .topbar, .pathbar { padding-left: 12px; padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
