:root {
  --fond: #10131a;
  --fond-2: #171b24;
  --fond-3: #1f2531;
  --trait: #2a3140;
  --texte: #e6e9ef;
  --texte-doux: #99a2b3;
  --azur: #4a9fd8;
  --azur-clair: #7cc0ec;
  --alerte: #e2725b;
  --ok: #5fb37a;
  --r: 10px;
  --vh: 100dvh;
  --vtop: 0px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Arimo, Arial, sans-serif;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  left: 0; right: 0;
  top: var(--vtop);
  height: var(--vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cache { display: none !important; }
.cache-vrai { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- écrans ---------- */
.ecran { display: none; flex: 1 1 auto; min-height: 0; flex-direction: column; }
.ecran.actif { display: flex; }

.centre {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.marque {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 0 18px;
  text-align: center;
  color: var(--texte);
}
.marque-petite { font-weight: 600; letter-spacing: 0.02em; }

/* ---------- barre du haut ---------- */
.barre-haut {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: var(--fond-2);
  border-bottom: 1px solid var(--trait);
  min-height: 46px;
}
.actions-haut { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cible {
  color: var(--texte-doux);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 34vw;
}

/* ---------- formulaires ---------- */
label {
  display: block;
  font-size: 13px;
  color: var(--texte-doux);
  margin-bottom: 5px;
}
input[type=text], input[type=password], input[type=number] {
  width: 100%;
  padding: 12px 12px;
  font-size: 16px; /* jamais moins : sinon iOS zoome */
  color: var(--texte);
  background: var(--fond-3);
  border: 1px solid var(--trait);
  border-radius: var(--r);
  outline: none;
}
input:focus { border-color: var(--azur); }
.champ { margin-bottom: 12px; }
.rangee { display: flex; gap: 10px; }
.rangee .grand { flex: 1 1 auto; }
.rangee .petit { flex: 0 0 92px; }
.avec-bouton { display: flex; gap: 8px; align-items: stretch; }
.avec-bouton input { flex: 1 1 auto; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--r);
  border: 1px solid transparent;
  color: var(--texte);
  background: var(--fond-3);
  padding: 10px 14px;
  min-height: 44px;
}
button:active { filter: brightness(1.25); }
button:disabled { opacity: 0.45; cursor: default; }

.primaire { background: var(--azur); color: #06121b; font-weight: 600; border-color: var(--azur); }
.large { width: 100%; padding: 14px; font-size: 17px; }
.fantome { background: transparent; border-color: var(--trait); color: var(--texte-doux); }
/* Une action irréversible ne doit jamais être celle qui saute aux yeux. */
.danger { background: transparent; border-color: var(--alerte); color: var(--alerte); }
.petit-bouton { padding: 7px 10px; min-height: 38px; font-size: 13px; }
.lien {
  background: none; border: none; color: var(--azur-clair);
  padding: 10px 4px; text-decoration: underline; min-height: 40px;
}

.aide { color: var(--texte-doux); font-size: 13px; margin: 6px 0 14px; }
.erreur { color: var(--alerte); font-size: 14px; min-height: 20px; margin: 8px 0 0; }
.etat { color: var(--texte-doux); font-size: 14px; min-height: 20px; margin: 8px 0 0; }

/* ---------- onglets ---------- */
.onglets { display: flex; gap: 4px; }
.onglet {
  background: transparent; border: none; color: var(--texte-doux);
  padding: 8px 12px; min-height: 38px; border-radius: 8px;
}
.onglet.actif { background: var(--fond-3); color: var(--texte); }

.vue { display: none; flex: 1 1 auto; min-height: 0; flex-direction: column; }
.vue.actif { display: flex; }

/* ---------- terminal ---------- */
#terminal {
  flex: 1 1 auto;
  min-height: 0;
  padding: 4px 2px 0 6px;
  background: #0b0e14;
  overflow: hidden;
}
.xterm .xterm-viewport { overscroll-behavior: contain; }

.barre-touches {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  background: var(--fond-2);
  border-top: 1px solid var(--trait);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.barre-touches::-webkit-scrollbar { display: none; }
.barre-touches { -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 22px), transparent 100%);
                 mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 22px), transparent 100%); }
.touche {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  font-size: 15px;
  background: var(--fond-3);
  border: 1px solid var(--trait);
  color: var(--texte);
  border-radius: 9px;
  user-select: none;
}
.touche.enfoncee {
  background: var(--azur);
  border-color: var(--azur);
  color: #06121b;
  font-weight: 600;
}

/* ---------- fichiers ---------- */
.volets { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.volet {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--trait);
}
/* Sur un téléphone, la machine distante prend la place ; l'appareil local
   se contente de ce qu'il lui faut. */
#volet-distant { flex: 1 1 auto; }
#volet-local { flex: 0 0 auto; max-height: 46%; }
.volet:last-child { border-bottom: none; }
.volet-haut {
  flex: 0 0 auto;
  padding: 8px 10px 6px;
  background: var(--fond-2);
  border-bottom: 1px solid var(--trait);
}
.volet-titre { font-size: 13px; color: var(--texte-doux); margin-bottom: 6px; }
.volet-outils { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.volet-outils::-webkit-scrollbar { display: none; }
.chemin {
  flex: 0 0 auto;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--texte-doux);
  background: var(--fond);
  border-bottom: 1px solid var(--trait);
  word-break: break-all;
}
.liste {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  list-style: none;
  margin: 0; padding: 0;
}
.liste li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-bottom: 1px solid rgba(42, 49, 64, 0.55);
  min-height: 52px;
}
.liste li.survol { background: rgba(74, 159, 216, 0.18); }
.entree-nom {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}
.entree-nom.dossier { color: var(--azur-clair); font-weight: 500; }
.entree-info {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--texte-doux);
  text-align: right;
  line-height: 1.3;
}
.entree-actions { flex: 0 0 auto; display: flex; gap: 5px; }
.mini {
  min-height: 34px; padding: 5px 8px; font-size: 12px;
  background: transparent; border: 1px solid var(--trait); color: var(--texte-doux);
}
/* Une action irréversible se distingue, sans pour autant attirer le doigt. */
.mini.danger { border-color: var(--alerte); color: var(--alerte); }
.depot {
  flex: 0 0 auto;
  margin: 10px;
  padding: 16px 12px;
  border: 1px dashed var(--trait);
  border-radius: var(--r);
  color: var(--texte-doux);
  font-size: 13px;
  text-align: center;
}
.depot.survol { border-color: var(--azur); color: var(--azur-clair); }
.vide { color: var(--texte-doux); font-size: 13px; padding: 14px; text-align: center; }

.transferts {
  flex: 0 0 auto;
  max-height: 34%;
  overflow-y: auto;
  border-top: 1px solid var(--trait);
  background: var(--fond-2);
  padding-bottom: env(safe-area-inset-bottom);
}
.transfert { padding: 9px 10px; border-bottom: 1px solid rgba(42,49,64,0.55); }
.transfert-haut { display: flex; align-items: center; gap: 10px; }
.transfert-nom { flex: 1 1 auto; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfert-pct { flex: 0 0 auto; font-size: 12px; color: var(--texte-doux); font-variant-numeric: tabular-nums; }
.jauge { height: 5px; background: var(--fond-3); border-radius: 3px; margin-top: 7px; overflow: hidden; }
.jauge span { display: block; height: 100%; background: var(--azur); width: 0; transition: width .15s linear; }
.transfert.fini .jauge span { background: var(--ok); }
.transfert.rate .jauge span { background: var(--alerte); }

/* ---------- boîtes ---------- */
.voile {
  position: fixed; inset: 0;
  background: rgba(6, 9, 14, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  z-index: 50;
}
.boite {
  background: var(--fond-2);
  border: 1px solid var(--trait);
  border-radius: 14px;
  padding: 18px;
  width: 100%;
  max-width: 460px;
  max-height: 84vh;
  overflow-y: auto;
}
.boite h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.boite p { margin: 0 0 10px; font-size: 14px; color: var(--texte-doux); }
.boite .fort { color: var(--texte); }
.boite input[type=text] { margin-bottom: 10px; }
.boite-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.boite-actions button { flex: 1 1 130px; }
.empreinte {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: var(--fond-3);
  border: 1px solid var(--trait);
  border-radius: 8px;
  padding: 9px 10px;
  margin: 6px 0 12px;
  word-break: break-all;
  color: var(--texte);
}
.avertissement {
  border-left: 3px solid var(--alerte);
  padding-left: 10px;
  color: var(--texte);
  font-size: 14px;
  margin-bottom: 12px;
}
.liste-appareils { list-style: none; padding: 0; margin: 0 0 12px; }
.liste-appareils li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--trait); font-size: 14px;
}
.liste-appareils li.confirmation { display: block; }
.liste-appareils .nom { flex: 1 1 auto; }

.liste-machines { list-style: none; padding: 0; margin: 0 0 12px; }
.liste-machines li { padding: 10px 0; border-bottom: 1px solid var(--trait); }
.liste-machines li:last-child { border-bottom: none; }
.machine-haut { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.machine-haut .nom {
  flex: 1 1 auto; min-width: 0; font-size: 15px; color: var(--texte);
  overflow-wrap: anywhere;
}
.liste-machines .empreinte { margin: 8px 0 4px; }
.boite .discret { font-size: 12px; margin: 0; }
.boite .note {
  font-size: 13px;
  border-left: 3px solid var(--trait);
  padding-left: 10px;
  margin: 12px 0 4px;
}

.bandeau {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--fond-3);
  border: 1px solid var(--trait);
  color: var(--texte);
  padding: 11px 16px;
  border-radius: 22px;
  font-size: 14px;
  max-width: 92vw;
  text-align: center;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.bandeau.alerte { border-color: var(--alerte); }

/* ---------- écrans larges ---------- */
@media (min-width: 860px) {
  .volets { flex-direction: row; }
  .volet, #volet-distant, #volet-local {
    flex: 1 1 50%;
    max-height: none;
    border-bottom: none;
    border-right: 1px solid var(--trait);
  }
  .volet:last-child { border-right: none; }
  .touche { min-width: 52px; }
  .barre-touches { -webkit-mask-image: none; mask-image: none; }
}

@media (prefers-color-scheme: light) {
  :root {
    --fond: #f5f6f8;
    --fond-2: #ffffff;
    --fond-3: #eceff3;
    --trait: #d5dae2;
    --texte: #1b2029;
    --texte-doux: #5c6675;
    --azur: #2b7fb8;
    --azur-clair: #1d6a9e;
    color-scheme: light;
  }
  #terminal { background: #ffffff; }
  .primaire { color: #ffffff; }
  .touche.enfoncee { color: #ffffff; }
}
