:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3eee6;
  --text: #2a2420;
  --muted: #7a6f66;
  --border: #e8e0d5;
  --accent: #c2512f;
  --accent-hover: #a9441f;
  --accent-soft: #f8e3da;
  --accent-text: #ffffff;
  --ok: #2f7d4f;
  --ok-soft: #e0f0e5;
  --warn: #9a5b00;
  --warn-soft: #fbedd5;
  --err: #b3261e;
  --err-soft: #f9e0de;
  --topbar: rgba(250, 247, 242, .85);
  --shadow: 0 1px 2px rgba(42, 36, 32, .05), 0 6px 20px rgba(42, 36, 32, .06);
  --avatar-l: 52%;
  --radius: 18px;
  --tabbar: 64px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161311;
    --surface: #211d1a;
    --surface-2: #2b2622;
    --text: #f4eee8;
    --muted: #a89d93;
    --border: #38312b;
    --accent: #f0866a;
    --accent-hover: #f59c84;
    --accent-soft: #3d2620;
    --accent-text: #1a1210;
    --ok: #6fcf97;
    --ok-soft: #1e3326;
    --warn: #f2b65a;
    --warn-soft: #3a2c15;
    --err: #ff8a80;
    --err-soft: #3d1f1d;
    --topbar: rgba(22, 19, 17, .85);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --avatar-l: 45%;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* --- Barre du haut + onglets --------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand img { border-radius: 9px; }
.brand span { font: 600 21px/1 var(--serif); letter-spacing: -.01em; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--tabbar); color: var(--muted); text-decoration: none; font-size: 10.5px; font-weight: 600;
  letter-spacing: -.01em; min-width: 0;
}
.tab span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 1px; }
.tab .ic { width: 24px; height: 24px; }
.tab .avatar { --size: 26px; font-size: 13px; }
.tab.active { color: var(--accent); }
.tab.active .avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

@media (min-width: 760px) {
  /* Le flou est réservé à l'ordinateur : sur mobile il servirait de repère à la barre d'onglets
     "position: fixed", qui se retrouverait collée en haut au lieu du bas de l'écran. */
  .topbar {
    background: var(--topbar);
    -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  }
  .tabs {
    position: static; display: flex; gap: 4px; background: none; border: 0; padding: 0;
  }
  .tab {
    flex-direction: row; height: 40px; padding: 0 14px; border-radius: 999px; font-size: 15px; gap: 8px;
    color: var(--text);
  }
  .tab .ic { width: 19px; height: 19px; }
  .tab:hover { background: var(--surface-2); }
  .tab.active { background: var(--accent-soft); color: var(--accent); }
  .tab.account { margin-left: 8px; padding-left: 6px; }
  .tab.active .avatar { box-shadow: none; }
}

/* --- Mise en page ------------------------------------------------------------------- */
.page {
  max-width: 720px; margin: 0 auto;
  padding: 24px 16px calc(var(--tabbar) + 32px + env(safe-area-inset-bottom));
}
.page.wide { max-width: 1200px; }
@media (min-width: 760px) { .page { padding-bottom: 56px; padding-top: 32px; } }
.page-head { margin-bottom: 20px; }
.page-head h1 { font: 600 32px/1.15 var(--serif); letter-spacing: -.02em; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 650; margin-bottom: 14px; }
.card-title .ic { color: var(--accent); }
.icon-bubble {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent);
}

/* --- Boutons et champs ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent;
  font: inherit; font-size: 16px; font-weight: 650; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-text); transition: background .15s, transform .1s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.98); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.secondary:hover { background: var(--border); }
.btn.ghost { background: none; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--err-soft); color: var(--err); }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px; flex: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.danger { color: var(--err); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-size: 14px; font-weight: 600; }
.input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; font: inherit; font-size: 16px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; margin: 4px 0 18px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.form-error { color: var(--err); font-size: 14px; margin: -4px 0 12px; }

.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px;
  background: var(--accent-soft); color: var(--text); font-size: 15px;
}
.notice .ic { color: var(--accent); margin-top: 2px; }
.notice.ok { background: var(--ok-soft); }
.notice.ok .ic { color: var(--ok); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }

.avatar {
  --size: 40px;
  width: var(--size); height: var(--size); border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; font-weight: 700; font-size: calc(var(--size) * .42);
  background: hsl(var(--hue, 20) 55% var(--avatar-l)); color: #fff;
}

.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .25s; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; margin: 12px 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

details { margin-top: 12px; font-size: 14px; }
details summary { cursor: pointer; font-weight: 600; }
details ul { margin: 8px 0 0; padding-left: 18px; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px;
  font-size: 15px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.2); transition: all .25s;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--err); color: #fff; }
@media (min-width: 760px) { .toast { bottom: 32px; } }

dialog {
  border: 0; border-radius: var(--radius); padding: 24px; width: min(420px, calc(100% - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(20, 15, 12, .5); }
dialog h2 { font: 600 22px/1.2 var(--serif); margin-bottom: 6px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* --- Connexion ------------------------------------------------------------------------ */
.auth {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(60rem 30rem at 10% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(40rem 30rem at 110% 110%, var(--warn-soft), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 24px; }
.auth-logo img { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 10px 30px rgba(194, 81, 47, .3); }
.auth-logo h1 { font: 600 34px/1.1 var(--serif); margin-top: 16px; letter-spacing: -.02em; }
.auth-logo p { margin: 6px 0 0; color: var(--muted); }

/* --- Dépôt ----------------------------------------------------------------------------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; cursor: pointer;
  padding: 44px 20px; border-radius: 24px; border: 2px dashed var(--border); background: var(--surface);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { font-size: 18px; margin-top: 10px; }
.dz-icon {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); box-shadow: 0 10px 24px rgba(194, 81, 47, .28);
}
.dz-icon .ic { width: 32px; height: 32px; }
.share-option {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  padding: 16px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}
.share-option .icon-bubble { transition: background .2s, color .2s; }
.share-option:not(.on) .icon-bubble { background: var(--surface-2); color: var(--muted); }
.share-option strong { display: block; }
.share-option small { color: var(--muted); font-size: 14px; }
.share-option > span:nth-child(2) { flex: 1; min-width: 0; }
button.share-option { width: 100%; font: inherit; color: var(--text); text-align: left; }
.share-option small { display: block; overflow-wrap: anywhere; }
.dest-select {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 15px; color: var(--text);
  padding: 6px 30px 6px 10px; border-radius: 10px; border: 1px solid var(--border); background-color: var(--bg);
  appearance: none; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 15px top 55%, right 10px top 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: background .2s;
  pointer-events: none;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.progress-head h2 { font-size: 17px; }
.upload-list { list-style: none; margin: 16px 0 0; padding: 0; }
.upload-list li { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.upload-list .thumb {
  width: 48px; height: 48px; border-radius: 10px; background: var(--surface-2); overflow: hidden;
  display: grid; place-items: center; color: var(--muted);
}
.upload-list .thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-list .name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 6px; }
.upload-list .bar { height: 5px; }

/* --- Transferts --------------------------------------------------------------------------- */
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.pc-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; } /* sinon un long chemin élargit la page */
.pc {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); transition: border-color .15s, background .15s;
}
.pc.selected { border-color: var(--accent); background: var(--accent-soft); }
.pc.offline { cursor: default; opacity: .6; }
.pc input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; flex: none; }
.pc-main { flex: 1; min-width: 0; }
.pc-name { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.pc-meta { display: block; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.pc-actions { display: flex; gap: 6px; flex: none; }
.dest-list { display: grid; gap: 6px; max-height: 50vh; overflow-y: auto; }
.add-pc { margin-top: 14px; }
.add-pc summary { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); list-style: none; }
.add-pc summary::-webkit-details-marker { display: none; }
.add-pc summary .ic { width: 18px; height: 18px; }
.add-pc ol { margin: 12px 0 8px; padding-left: 20px; display: grid; gap: 10px; font-size: 15px; }
.add-pc code { font-size: 14px; }

/* Choix dans une liste (destination d'un déplacement, mode de copie) */
.dest {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); font-size: 15px;
}
.dest input { accent-color: var(--accent); margin: 0; flex: none; }
.dest .ic { color: var(--accent); width: 18px; height: 18px; }
.dest:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Choix des fichiers à copier */
.pick-dialog { width: min(640px, calc(100% - 24px)); padding: 20px; }
.pick-modes { display: grid; gap: 8px; margin: 14px 0; }
.pick-modes .dest { align-items: flex-start; }
.pick-modes input { margin-top: 3px !important; }
.pick-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tree {
  max-height: 48vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); padding: 4px 0; font-size: 14px;
}
.tree-row { display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 0; min-height: 36px; }
.tree-row:hover { background: var(--surface-2); }
.tree-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.tree-row .ic { width: 17px; height: 17px; flex: none; color: var(--muted); }
.tree-row .ic.folder { color: var(--accent); }
.tree-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.tree-row .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tree-toggle {
  width: 26px; height: 26px; flex: none; display: grid; place-items: center; border: 0; background: none;
  color: var(--muted); cursor: pointer; border-radius: 6px; transition: transform .15s;
}
.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle .ic { width: 16px; height: 16px; }
.tree-spacer { width: 26px; flex: none; }
.tree-empty { padding: 16px; text-align: center; color: var(--muted); }

.direction {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  padding: 16px; border-radius: 16px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
  transition: border-color .15s, background .15s;
}
.direction:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.direction:disabled { opacity: .45; cursor: not-allowed; }
.direction .flow { display: flex; align-items: center; gap: 6px; color: var(--accent); flex: none; }
.direction .flow .ic:nth-child(2) { width: 16px; height: 16px; color: var(--muted); }
.direction strong { display: block; }
.direction small { color: var(--muted); font-size: 14px; }

/* --- Famille ------------------------------------------------------------------------------- */
.member { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.member:first-child { border-top: 0; padding-top: 0; }
.member:last-child { padding-bottom: 0; }
.member-main { flex: 1; min-width: 0; }
.member-name { font-weight: 650; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.member-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.member-actions { display: flex; gap: 6px; }
.member .badge { white-space: normal; }
@media (max-width: 480px) {
  .member { flex-wrap: wrap; }
  .member-actions { width: 100%; padding-left: 54px; }
}
.credentials {
  margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  font-size: 15px; display: grid; gap: 4px;
}
.credentials code { font-size: 16px; font-weight: 700; user-select: all; }

/* --- Corbeille ---------------------------------------------------------------------------- */
.crumbs-simple { margin-bottom: 6px; font-size: 14px; }
.crumbs-simple a { color: var(--muted); text-decoration: none; }
.crumbs-simple a:hover { color: var(--accent); }
.trash-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.trash-list { padding: 8px 16px; }
.trash-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.trash-item:first-child { border-top: 0; }
.trash-thumb {
  width: 56px; height: 56px; border-radius: 10px; overflow: hidden; flex: none; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
}
.trash-thumb img { width: 100%; height: 100%; object-fit: cover; }
.trash-main { flex: 1; min-width: 160px; }
.trash-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) { .trash-item .member-actions { width: 100%; padding-left: 68px; } }

.profile { display: flex; align-items: center; gap: 16px; }
.profile .avatar { --size: 64px; }
.profile h2 { font: 600 24px/1.2 var(--serif); }
