:root {
  color-scheme: dark;
  --fond: #14161a;
  --cote: #1a1d22;
  --carte: #1e2127;
  --ligne: #2a2e36;
  --texte: #dfe2e7;
  --doux: #8c939e;
  --accent: #4fb39b;
  --accent-fonce: #2f7d6b;
  --erreur: #e8806f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--fond); color: var(--texte); }
body {
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  height: 100dvh;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.doux { color: var(--doux); }
.petit { font-size: 12px; }
.erreur { color: var(--erreur); min-height: 1.2em; margin: 4px 0 0; font-size: 13px; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; color: var(--texte); }

.principal {
  background: var(--accent-fonce);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 7px 14px;
}
.principal:hover { background: var(--accent); color: #0d1512; }
.lien { background: none; border: 0; color: var(--doux); padding: 6px 8px; text-align: left; border-radius: 6px; }
.lien:hover { color: var(--texte); background: #ffffff0d; }
input, textarea {
  width: 100%;
  background: var(--fond);
  border: 1px solid var(--ligne);
  border-radius: 6px;
  padding: 8px 10px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

/* Connexion / installation */
.ecran { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.carte {
  width: min(360px, 100%);
  background: var(--carte);
  border: 1px solid var(--ligne);
  border-radius: 10px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.carte h1 { margin: 0; font-size: 18px; font-weight: 600; }
.carte p { margin: 0; }
.carte label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--doux); }
#qr { align-self: center; border-radius: 6px; background: #fff; }

/* Panel */
#app { display: grid; grid-template-columns: 230px minmax(0, 1fr); height: 100dvh; }
#cote {
  background: var(--cote);
  border-right: 1px solid var(--ligne);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px calc(10px + env(safe-area-inset-bottom));
  min-height: 0;
  overflow-y: auto;
}
.marque { font-weight: 600; padding: 2px 8px 12px; }
#projets { display: flex; flex-direction: column; gap: 2px; }
.projet {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: none;
  border: 0;
  border-radius: 6px;
  padding: 8px;
  text-align: left;
}
.projet:hover { background: #ffffff0d; }
.projet.actif { background: #4fb39b1f; color: #fff; }
.point { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--doux); flex: none; }
.point.ouvert { background: var(--accent); border-color: var(--accent); }
#form-nouveau { display: flex; flex-direction: column; gap: 6px; padding: 6px 4px; }
#form-nouveau .ligne { display: flex; gap: 6px; }
.bas { margin-top: auto; display: flex; flex-direction: column; padding-top: 12px; border-top: 1px solid var(--ligne); }

main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#barre {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--ligne);
  min-height: 46px;
}
#barre h2 { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#statut { font-size: 12px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icone { display: none; background: none; border: 1px solid var(--ligne); border-radius: 6px; padding: 3px 9px; }
#vide { flex: 1; display: grid; place-items: center; padding: 20px; text-align: center; }
#terminal { flex: 1; min-height: 0; padding: 6px 0 2px 8px; background: #101215; }
#terminal .xterm { height: 100%; }
#terminal .xterm-viewport { overflow-y: hidden; }

#touches, #saisie { display: none; }
#touches button {
  flex: none;
  background: var(--carte);
  border: 1px solid var(--ligne);
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 13px;
  touch-action: manipulation;
}
#touches button:active { background: var(--accent-fonce); }
#saisie textarea { resize: none; max-height: 30dvh; font-size: 16px; }

@media (pointer: coarse) {
  #touches { display: flex; gap: 6px; padding: 6px 8px; overflow-x: auto; border-top: 1px solid var(--ligne); scrollbar-width: none; }
  #saisie { display: flex; gap: 6px; padding: 0 8px calc(8px + env(safe-area-inset-bottom)); align-items: flex-end; }
}
@media (max-width: 760px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #cote {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(80vw, 300px);
    z-index: 20;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
  }
  #app.menu-ouvert #cote { transform: none; }
  #voile { display: none; position: fixed; inset: 0; background: #0008; z-index: 10; }
  #app.menu-ouvert #voile { display: block; }
  .icone { display: inline-block; }
}
