/* L'ossature : la barre du haut, la liste et la scène, la barre du bas (cahier §3, « Trois mises en page »).
   La mise en page se règle sur body[data-view] : home, apps, new, app, hood, detail, account, gate.
   Trois sections : « Home » (une page seule, sans liste), « Apps » (la liste, et l'app ouverte ou le panneau
   « New app »), « Account ».

     moins de 720 px   la liste est la page ; l'app, une autre page. En bas, la navigation (Home, Apps, Account), toujours
                       la même et toujours là ; dans une app, le retour est en haut à gauche, à la place du logo,
                       et « More » en haut à droite. Les gestes d'une app vivent dans son contenu.
     720 à 1099 px     un rail de 264 px (lignes de 56 px), l'app à droite sur 640 px au plus
     1100 px et plus   la liste sur 360 px (lignes de 64 px), l'app sur 760 px au plus ; contenu plafonné à 1 200 px */

/* ---------------------------------------------------------------- la barre du haut */
.top-in{display:flex;align-items:center;gap:10px;height:48px;padding:0 16px}
.logo{display:inline-flex;align-items:center;min-height:44px;font:800 20px/1 var(--f-display);font-stretch:75%;letter-spacing:-.01em;color:var(--ink);text-decoration:none}
.top-mascot{display:block;margin-top:-2px}
/* Le retour et « More » de la barre du haut : au téléphone seulement, dans une app ouverte. */
.top-back,.top-acts{display:none}
@media (max-width:719px){
  /* Au téléphone, la mascotte de la barre est deux fois plus grande et regarde par-dessus la liste : seule sa
     tête dépasse, sur un semis de cellules. Pas un mot, huit pixels de plus. */
  .top-in{height:56px;overflow:hidden;background:linear-gradient(to right,var(--paper) 45%,transparent),
    linear-gradient(90deg,var(--paper) 10px,transparent 0) 0 0/12px 12px,linear-gradient(var(--paper) 10px,transparent 0) 0 0/12px 12px,var(--rule-strong)}
  .top-mascot{margin:-8px 20px 0 auto;align-self:flex-start}
  .top-mascot .mascot.x1,.top-mascot .mascot.x1 canvas,.top-mascot .mascot.x1 img{width:68px}
  /* Une app ouverte : le retour prend la place du logo, en haut à gauche ; « More », s'il y en a un, est à droite. */
  .top-in{padding:0 8px 0 16px}
  .top[data-back] .top-in{padding-left:6px}
  .top[data-back] .logo{display:none}
  .top[data-back] .top-in:has(.top-mascot[hidden]){background:none}      /* le semis est le décor de la mascotte : sans elle, rien */
  .top[data-back] .top-back{display:flex;min-width:0}
  .top[data-back] .top-acts{display:flex;margin-left:auto}
  .top-acts:empty{display:none}
  .top-mascot{margin-right:12px}
  .top-acts .btn{background:none}
  /* « Home » : le bandeau porte le nom, en grand ; la barre du haut s'efface. */
  body[data-view="home"] header.top{display:none}
}
.nav-top{display:none}

/* ---------------------------------------------------------------- la navigation : trois destinations, cinq au plus */
.nav-item{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:0 12px;border-radius:var(--r-touch);
  color:var(--mute);font-weight:500;text-decoration:none;-webkit-tap-highlight-color:transparent}
.nav-item .ico{width:24px;height:24px;image-rendering:pixelated;opacity:.55}
.nav-item[aria-current]{color:var(--ink);font-weight:600}
.nav-item[aria-current] .ico{opacity:1}

.bottom{position:fixed;left:0;right:0;bottom:0;z-index:6;display:none;align-items:center;min-height:var(--bar);
  padding:0 8px env(safe-area-inset-bottom);background:var(--paper);box-shadow:0 -8px 24px rgb(23 33 58 / .08)}   /* pas de filet : une ombre douce détache la barre */
.bottom .nav-item{flex:1 1 0;min-width:0;min-height:var(--bar);border-radius:0;flex-direction:row}
.bottom .nav-item span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bottom .nav-item[aria-current]{box-shadow:inset 0 3px 0 var(--ink)}
/* Avec cinq destinations, l'icône passe au-dessus du libellé : cinq entrées de 71 px tiennent à 390 px. */
.bottom .nav-item:nth-last-child(n+4),.bottom .nav-item:nth-last-child(n+4)~.nav-item{flex-direction:column;gap:2px;padding:0 2px;font-size:14px}
/* Sur un petit écran (et en français, « Accueil », « Compte »), l'icône passe aussi au-dessus : aucun libellé ne se coupe. */
@media (max-width:430px){.bottom .nav-item{flex-direction:column;gap:2px;padding:0 2px;font-size:13px}}
.main{display:block;padding-bottom:calc(var(--bar) + env(safe-area-inset-bottom) + 24px)}
.main:focus{outline:none}
body[data-view="gate"] .main{padding-bottom:32px}

/* Le retour : un signe et le nom de ce qu'on retrouve, discret. « More » : son mot. */
.back{font-weight:500;color:var(--ink);gap:6px;display:inline-flex;align-items:center;min-height:44px;padding:0 10px;border-radius:var(--r-touch);text-decoration:none}
.back .word{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:20ch}

/* ---------------------------------------------------------------- la ligne de panne, dans le flux */
.net{margin:8px 16px 0;padding:10px 12px;border-radius:var(--r-touch);background:var(--ink);color:var(--paper);font-size:14px}

/* ---------------------------------------------------------------- la liste */
.list,.scene{min-width:0}
.rows>.row{display:flex;align-items:center;gap:8px;min-height:72px;padding:0 16px 0 0;border-radius:var(--r-touch)}
.rows>.row+.row{margin-top:4px}   /* pas de filet entre deux apps : de l'espace */
.row-link{flex:1 1 auto;min-width:0;display:flex;align-items:center;gap:12px;min-height:72px;padding:8px 4px 8px 16px;color:var(--ink);text-decoration:none;-webkit-tap-highlight-color:transparent}
.row-link:focus-visible{outline-offset:-3px;border-radius:var(--r-touch)}
.row-text{min-width:0;display:grid;gap:1px}
.row-name{font:700 18px/1.25 var(--f-display);font-stretch:75%;overflow-wrap:anywhere;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}
.row-state{display:flex;align-items:center;gap:8px;font-size:14px;line-height:1.4;color:var(--mute)}
.row.needs .row-state{color:var(--ink)}
.row-line{font-size:14px;line-height:1.4}
.row-line.mute{color:var(--mute)}
.row-line.strong{color:var(--alert);font-weight:600}
/* La flèche d'une ligne : un signe, sans fond ; sur une ligne au fond marqué, son survol se détache encore. */
.row-out{flex:none}
.row .icon-btn:hover{background:var(--sunk-hover)}
/* Une app détruite le dit quatre secondes, à sa place, puis se replie. */
.row.destroyed{pointer-events:none}
.row.destroyed .glyph{opacity:.4}
.row.destroyed .row-name{text-decoration:line-through;color:var(--mute)}
.row.gone{min-height:0;height:0;overflow:hidden;border:0;opacity:0;transition:height .2s,opacity .2s}
.find-tool{padding:8px 16px 4px;display:grid;gap:6px}
.find{font-family:var(--f-text)}
.row .ghost{flex:1;padding:16px}
.row:has(.ghost),.row:has(.broke){padding:0 16px}

/* Au bout de la liste : « New app » (ou, à la limite du compte, la ligne qui le dit). */
.hint{padding:16px 16px 8px;display:grid;gap:8px;justify-items:start}
/* Un exemple du panneau « New app » : un titre, une ligne de description, et le signe « copier ». La ligne se touche :
   elle ouvre l'agent connecté avec le prompt (jamais affiché), ou le copie ; le signe, à droite, copie et devient la coche. */
.ex-row{display:flex;align-items:center;gap:6px;width:100%;min-height:56px;padding:0 4px 0 0;border-radius:var(--r-touch);background:var(--sunk);color:var(--ink)}
.ex-row:hover{background:var(--sunk-hover)}
.ex-main{appearance:none;flex:1 1 auto;min-width:0;align-self:stretch;display:flex;align-items:center;margin:0;padding:10px 0 10px 14px;border:0;border-radius:var(--r-touch);
  background:none;color:inherit;font:inherit;text-align:left;text-decoration:none;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.ex-text{flex:1 1 auto;min-width:0;display:grid;gap:2px}
.ex-title{font-weight:600;line-height:1.35}
.ex-about{font-size:14px;line-height:1.4;color:var(--mute)}
.ex-copy{appearance:none;flex:none;display:grid;place-items:center;width:44px;height:44px;margin:0;padding:0;border:0;border-radius:var(--r-touch);background:none;color:inherit;
  cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.ex-pill{display:inline-grid;place-items:center;min-width:32px;min-height:32px;border-radius:8px;background:var(--paper)}
.ex-pill>span{grid-area:1/1;display:inline-flex;align-items:center}
.ex-copy .res{visibility:hidden}
.ex-copy.done .lbl{visibility:hidden}
.ex-copy.done .res{visibility:visible}
.ex-manual{max-height:240px;overflow:auto}
.prompts{width:100%;text-align:left}
.prompts>li+li{margin-top:8px}
.copyrow{display:flex;align-items:center;gap:8px;min-width:0}
.say{flex:1 1 auto;min-width:0;display:block;padding:11px 12px;border-radius:var(--r-touch);background:var(--sunk);font:400 14px/1.55 var(--f-mono);overflow-wrap:anywhere}
.prompt{color:var(--mute)}

/* « New app » : le panneau qui dit comment naît une app. Une colonne centrée, la même derrière le bouton de la liste
   et à l'accueil d'un compte sans app (la liste s'efface alors, un semis de points derrière : gate.css). */
body[data-empty] .list{display:none}
/* « Home » : le nom est déjà dans le bandeau, en grand ; la barre du haut garde sa place sans le redire. */
body[data-view="home"] .logo{visibility:hidden}
.newapp{max-width:672px;margin:0 auto;padding:40px 16px 24px;display:grid;justify-items:center;gap:12px;text-align:center}
.newapp>*{min-width:0;max-width:100%}
.newapp-title{font-size:24px;font-weight:700;line-height:1.2;margin-top:8px}
.newapp .btn{margin:4px 0}

/* ---------------------------------------------------------------- au téléphone : une vue à la fois */
@media (max-width:719px){
  body:not([data-view="apps"]) .list{display:none}
  /* « Apps » : la liste seule. Sans aucune app, la liste s'efface et le panneau « New app » tient la page. */
  body[data-view="apps"]:not([data-empty]) .scene{display:none}
  /* La navigation du bas est là sur toutes les vues, app ouverte comprise ; pas sur les pages seules. */
  body[data-view]:not([data-view="gate"]) #bottom{display:flex}
}

/* ---------------------------------------------------------------- 720 px et plus : le fil et la scène côte à côte */
@media (min-width:720px){
  :root{--bar:0px}
  html{scroll-padding-top:72px}
  header.top{position:sticky;top:0;z-index:5;background:var(--paper)}
  .top-in{height:56px;padding:0 24px}
  .nav-top{display:flex;gap:4px;margin-left:auto}
  .bottom{display:none}
  .main{padding-bottom:48px}
  .frame{display:grid;grid-template-columns:264px minmax(0,1fr);align-items:start}
  .list{position:sticky;top:56px;max-height:calc(100vh - 56px);overflow-y:auto;padding:8px 0 24px 12px;overscroll-behavior:contain}
  .scene{padding:16px 32px 0;max-width:704px}
  body[data-view="account"] .frame,body[data-view="home"] .frame,body[data-view="gate"] .frame,body[data-empty] .frame{display:block}
  body[data-view="account"] .list,body[data-view="home"] .list,body[data-view="gate"] .list{display:none}
  body[data-empty][data-view="apps"] .scene{max-width:none;padding:0}
  body[data-view="home"] .scene{margin:0 auto;max-width:904px}
  .newapp{padding-top:56px}
  /* Le rail : des lignes de 56 px (glyphe 32, nom, état, la flèche) ; la sélection est marquée. */
  .rows>.row{min-height:56px;padding:0;border-bottom:0;border-radius:var(--r-touch)}
  .rows>.row+.row{margin-top:2px}
  .row-link{min-height:56px;padding:6px 4px 6px 10px;border-radius:var(--r-touch)}
  /* L'app ouverte, la ligne survolée : un fond sur toute la ligne, flèche comprise. Ni barre ni pastille sur le bord. */
  .rows>.row:has(.row-link:hover),.rows>.row:has([aria-current]){background:var(--sunk)}
  .row-name{font-size:16px}
  .row .glyph{width:32px;height:32px}
  .row-out{margin-right:2px}
  .find-tool{padding:0 0 8px}
  .hint{padding:16px 10px 8px}
}
@media (min-width:1100px){
  .top-in,.frame{max-width:1200px;margin:0 auto}
  .frame{grid-template-columns:360px minmax(0,1fr)}
  .scene{max-width:840px;padding:20px 40px 0}
  body[data-view="home"] .scene{max-width:1040px}
  .rows>.row{min-height:64px}
  .row-link{min-height:64px;padding:8px 10px}
  .row .glyph{width:40px;height:40px}
  .row-name{font-size:18px}
  .row-out{margin-right:6px}
}

/* Un compte qui utilise des apps sans en créer : son compte est sa seule page, la navigation s'efface (shell.js, setUser). */
body[data-user] .nav{display:none !important}
body[data-user] .main{padding-bottom:48px}
