/* Twin — système visuel validé (paralleles/05_pwa_twin.md). Thème sombre
   seulement. Ambre = action humaine, bleu = système. Angles de 2 à 4 px,
   boutons « touche mécanique » à bordure basse plus foncée. Aucune règle ici
   ne charge de ressource tierce : la CSP les refuserait. */

@font-face { font-family: "Pixelify Sans"; font-weight: 500; font-display: swap; src: url("/fonts/pixelify-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Pixelify Sans"; font-weight: 700; font-display: swap; src: url("/fonts/pixelify-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 400; font-display: swap; src: url("/fonts/space-grotesk-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 500; font-display: swap; src: url("/fonts/space-grotesk-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 600; font-display: swap; src: url("/fonts/space-grotesk-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url("/fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --bg: #0A0B0E;
  --card: #14161D;
  --card-on: #1B1E27;
  --line: #222530;
  --fg: #E8EAF0;
  --muted: #8A90A2;
  --amber: #E8B84A;
  --amber-dk: #A9801F;
  --blue: #2F7BFF;
  --blue-dk: #1D4FB8;
  --blue-lt: #8FB8FF;
  --green: #3DDC84;
  --green-dk: #1E8F4E;
  --red: #FF4D5E;
  --red-dk: #B3253A;
  --grey: #3A3F4E;
  --pixel: "Pixelify Sans", ui-monospace, monospace;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --body: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pad: 20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

/* ── Base, pensée mobile d'abord ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--fg);
  font: 400 15px/1.45 var(--body);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
/* Colonne unique, 480 px au plus, centrée sur grand écran. */
.shell {
  width: 100%; max-width: 480px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding-left: var(--safe-l); padding-right: var(--safe-r);
}
main { flex: 1; display: flex; flex-direction: column; min-width: 0; padding-bottom: 12px; }
h1, h2, h3, p { margin: 0; }
a { color: var(--blue-lt); }
img, canvas, svg { max-width: 100%; }
canvas.px { image-rendering: pixelated; image-rendering: crisp-edges; display: block; flex: none; }
svg.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; }
svg.ic.lg { width: 24px; height: 24px; stroke-width: 2.4; }
svg.ic.xl { width: 30px; height: 30px; stroke-width: 2.6; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue-lt); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.mono { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.error { color: var(--red); }
.pixel { font-family: var(--pixel); font-weight: 700; }

/* ── En-tête ── */
.top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(16px + var(--safe-t)) var(--pad) 16px;
  border-bottom: 1px solid var(--line);
}
.logo { width: 20px; height: 20px; flex: none; background: var(--blue); box-shadow: inset -4px -4px 0 var(--blue-dk); }
.brand { font-family: var(--pixel); font-weight: 700; font-size: 22px; line-height: 1; }
.top .stamp { margin-left: auto; letter-spacing: 0; font-size: 12px; font-weight: 400; }
.top .key.icon { margin-left: 8px; }
.top .stamp + .key.icon { margin-left: 12px; }
.top > .brand + .key.icon { margin-left: auto; }

.title-row { display: flex; align-items: center; gap: 12px; padding: 18px var(--pad) 14px; }
.title-row h1 { font-family: var(--pixel); font-weight: 700; font-size: 26px; line-height: 1.1; }
.count {
  margin-left: auto; font-family: var(--pixel); font-weight: 700; font-size: 16px;
  padding: 3px 9px; border-radius: 2px; background: var(--card); color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line);
}
.count.on { background: var(--amber); color: var(--bg); box-shadow: none; }
.count.neutral { color: var(--fg); }

/* ── Touches mécaniques ── */
button, .key {
  font: 600 15px/1.2 var(--body); color: var(--fg); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 2px;
}
button:active:not(:disabled), .key:active { transform: translateY(2px); border-bottom-width: 1px; margin-bottom: 2px; }
button:disabled { opacity: .5; cursor: default; }
.key.icon { width: 44px; min-height: 44px; height: 44px; padding: 0; }
/* Ambre réservé à Parler et Valider ; les autres actions principales sont bleues. */
.key.amber, button.ok {
  background: var(--amber); color: var(--bg); border: none; border-bottom: 4px solid var(--amber-dk);
  font-family: var(--pixel); font-weight: 700; font-size: 16px;
}
button.primary {
  background: var(--blue); color: var(--bg); border: 1px solid var(--blue-dk); border-bottom-width: 4px;
  font-family: var(--pixel); font-weight: 700; font-size: 16px;
}
button.ko { font-family: var(--pixel); font-weight: 700; font-size: 16px; border-bottom-width: 4px; }
button.danger { color: var(--red); }
.key.big { width: 100%; min-height: 56px; font-size: 20px; gap: 10px; }
.key.filter { min-height: 40px; padding: 0 10px; font: 500 11px/1 var(--mono); letter-spacing: 1px; }
.key.filter[aria-pressed="true"] { background: var(--blue); border-color: var(--blue-dk); color: var(--bg); }

/* ── Blocs pixel (un seul élément chacun, pas une grille) ── */
.blk { width: 16px; height: 16px; flex: none; background: var(--blue); box-shadow: inset -3px -3px 0 var(--blue-dk); }
.blk.lg { width: 24px; height: 24px; box-shadow: inset -5px -5px 0 var(--blue-dk); }
.blk.amber { background: var(--amber); box-shadow: inset -3px -3px 0 var(--amber-dk); }
.blk.lg.amber { box-shadow: inset -5px -5px 0 var(--amber-dk); }
.blk.lblue { background: var(--blue-lt); box-shadow: inset -3px -3px 0 var(--blue); }
.blk.lg.lblue { box-shadow: inset -5px -5px 0 var(--blue); }
.blk.grey { background: var(--grey); box-shadow: inset -3px -3px 0 var(--line); }
.blk.lg.grey { box-shadow: inset -5px -5px 0 var(--line); }

.badge {
  flex: none; font-family: var(--pixel); font-weight: 700; font-size: 14px; line-height: 1.2;
  padding: 3px 8px; border-radius: 2px; background: var(--bg); color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line); white-space: nowrap;
}
.badge.urgent { background: var(--amber); color: var(--bg); box-shadow: none; }
.badge.sm { font-size: 12px; padding: 1px 6px; }

/* ── Accueil ── */
.hello { display: flex; align-items: center; gap: 18px; padding: 24px var(--pad); }
.hello h1 { font-family: var(--pixel); font-weight: 700; font-size: 28px; line-height: 1; }
.talk { padding: 0 var(--pad) 24px; }
.week { border-top: 1px solid var(--line); flex: 1; }
.week h2 { padding: 14px var(--pad) 10px; }
.week ul { list-style: none; margin: 0; padding: 0; }
.line {
  display: flex; align-items: center; gap: 12px; padding: 14px var(--pad);
  background: var(--card); border-top: 1px solid var(--line); min-width: 0;
}
.txt { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.txt .t { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.txt .mono { letter-spacing: .5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── À valider ── */
.reqs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.reqs > li { background: var(--card); border-bottom: 1px solid var(--line); }
.reqs .head {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px var(--pad);
  min-height: 0; background: transparent; border: none; border-radius: 0;
  text-align: left; font: inherit; color: inherit;
}
.reqs .head:active { transform: none; margin: 0; }
.reqs .head:disabled { opacity: 1; cursor: default; }
/* Parti sans confirmation (executed_unconfirmed) : point ambre carré à côté du ✓. */
.reqs .alert-dot { flex: none; width: 8px; height: 8px; background: var(--amber); box-shadow: inset -2px -2px 0 var(--amber-dk); }
.reqs .body { display: flex; flex-direction: column; gap: 10px; padding: 0 var(--pad) 16px; }
.reqs .acts { display: flex; gap: 10px; }
.reqs .acts .ok { flex: 1; min-height: 48px; }
.reqs .acts .ko { min-height: 48px; }
.dest { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
pre.text, .quote {
  margin: 0; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--bg); border: 1px solid var(--line); border-radius: 2px;
  font: 400 14px/1.45 var(--body); color: var(--fg);
}
.kv { margin: 0; padding: 12px; list-style: none; background: var(--bg); border: 1px solid var(--line); border-radius: 2px; font-size: 14px; overflow-wrap: anywhere; }

/* ── Sujets ── */
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 var(--pad) 14px; }
.grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px;
  margin: 0 var(--pad); background: var(--line); border: 1px solid var(--line);
}
.grid button {
  flex-direction: column; gap: 6px; padding: 12px 4px 10px; min-height: 100px; min-width: 0;
  background: var(--card); border: none; border-radius: 0;
}
.grid button:active { transform: none; margin: 0; }
.grid button[aria-pressed="true"] { background: var(--card-on); box-shadow: inset 0 -3px 0 var(--blue); }
.grid .nm {
  font-size: 12px; font-weight: 600; line-height: 1.2; text-align: center; color: var(--fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.detail {
  margin: 14px var(--pad) 0; padding: 14px; display: flex; flex-direction: column; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-left: 2px solid var(--blue); border-radius: 2px;
}
.detail .nm { font-family: var(--pixel); font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
.detail .ex { font-size: 14px; overflow-wrap: anywhere; }
.empty { padding: 24px var(--pad); color: var(--muted); }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }

/* ── Navigation v2 : trois pages glissables (shell.ts) ──
   Positions de repos ici ; le trajet qui suit le doigt passe par l'API Web
   Animations (motion.ts), jamais par un attribut style. */
main:has(> .twin) { padding-bottom: 0; }
.twin { position: relative; flex: 1; height: 100vh; height: 100dvh; overflow: clip; }
.pager { position: absolute; inset: 0; overflow: clip; touch-action: pan-y; transition: filter .42s cubic-bezier(.2,.8,.2,1); }
.track { display: flex; width: 300%; height: 100%; transform: translateX(-33.3333%); will-change: transform; }
.track.at-0 { transform: none; }
.track.at-2 { transform: translateX(-66.6667%); }
.pane {
  width: calc(100% / 3); height: 100%; flex: none; min-width: 0;
  display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  padding-top: calc(22px + var(--safe-t));
}
.dots {
  position: absolute; left: 0; right: 0; top: calc(10px + var(--safe-t)); z-index: 2;
  display: flex; justify-content: center; gap: 4px; pointer-events: none; transition: opacity .2s;
}
.dots span { width: 4px; height: 4px; background: var(--grey); transition: width .3s cubic-bezier(.2,.8,.2,1), background .3s; }
.dots span.on { width: 10px; background: var(--fg); }
.twin.sheet-open .pager { filter: brightness(.55); }
.twin.sheet-open .dots { opacity: 0; }

/* Accueil */
.bare { background: transparent; border: none; min-height: 44px; }
.bare:active:not(:disabled) { transform: none; margin: 0; border: none; }
.home-top { display: flex; align-items: center; gap: 6px; padding: 8px 12px 10px; border-bottom: 1px solid var(--line); }
.home-top .key.icon { width: 44px; }
.home-top .brand { padding: 0 6px; font-size: 20px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.pane .week { flex: none; }
.pane .hello { padding-top: 28px; }
.composer { display: flex; align-items: center; gap: 8px; padding: 10px 12px calc(16px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--bg); }
.home-composer { margin-top: auto; position: sticky; bottom: 0; }
.field, .composer input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 12px; font: 400 15px/1.2 var(--body);
  background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 2px;
}
.field { color: var(--muted); cursor: text; }
.field::placeholder, .composer input::placeholder { color: var(--muted); }
.key.sq { width: 52px; height: 52px; min-height: 52px; padding: 0; flex: none; }

/* Feuille conversation */
.sheet {
  position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column;
  background: var(--bg); box-shadow: 0 -1px 0 var(--line); transform: translateY(100%);
}
.sheet.open { transform: none; }
.grab {
  display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none;
  padding: calc(14px + var(--safe-t)) var(--pad) 12px; border-bottom: 1px solid var(--line);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.handle { width: 36px; height: 4px; background: var(--grey); border-radius: 2px; }
.grab .brand { margin-top: 14px; font-size: 18px; }
.mic.on { animation: blink 1.6s steps(2, end) infinite; }
.face-wrap { display: flex; justify-content: center; flex: none; padding: 16px 0 4px; transition: padding .3s cubic-bezier(.2,.8,.2,1); }
.sheet.voice .face-wrap { padding: 28px 0 16px; }
canvas.face { width: 133px; height: 133px; transition: width .3s cubic-bezier(.2,.8,.2,1), height .3s cubic-bezier(.2,.8,.2,1); }
.sheet.voice canvas.face { width: 178px; height: 178px; }
canvas.bars { display: block; flex: none; width: 172px; height: 32px; margin: 0 auto; image-rendering: pixelated; }
.rise { animation: rise .25s ease-out; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 16px var(--pad) 12px; }
.msgs > :first-child { margin-top: auto; }
.msgs p {
  max-width: 85%; padding: 10px 12px; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 2px;
}
.msgs .from-me { align-self: flex-end; max-width: 80%; }
.msgs .from-twin { align-self: flex-start; border-left: 2px solid var(--blue); }
.msgs .from-twin.wait { text-transform: none; }
.sheet-status { padding: 0 var(--pad) 8px; font-size: 13px; color: var(--amber); }
.sheet-status:empty { display: none; }
.controls { display: flex; justify-content: center; align-items: center; gap: 28px; flex: none; padding: 6px var(--pad) calc(32px + var(--safe-b)); }
.controls .key.round { width: 60px; height: 60px; padding: 0; border-bottom-width: 4px; }
.controls .key.round[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--muted); }
.hangup {
  width: 72px; height: 72px; padding: 0; background: var(--red); color: var(--bg);
  border: none; border-bottom: 5px solid var(--red-dk); border-radius: 4px;
}

/* Menu ☰ des sessions et feuille Réglages */
button.scrim { flex: 1; min-height: 0; padding: 0; background: rgba(10, 11, 14, .6); border: none; border-radius: 0; cursor: pointer; }
button.scrim:active { transform: none; margin: 0; }
.drawer { position: absolute; inset: 0; z-index: 3; display: flex; }
.drawer nav {
  width: 290px; max-width: 80%; height: 100%; flex: none; overflow-y: auto;
  padding: calc(52px + var(--safe-t)) 0 28px; background: #0F1116; border-right: 1px solid var(--line);
  animation: slidein .28s cubic-bezier(.2,.8,.2,1);
}
.sessions h2 { padding: 14px var(--pad) 6px; }
.sessions h2:first-child { padding-top: 0; }
.session {
  display: block; width: 100%; min-height: 44px; padding: 11px var(--pad); text-align: left;
  background: transparent; border: none; border-radius: 0; color: #B8BDC9; font: 400 14px/1.3 var(--body);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.session:active:not(:disabled) { transform: none; margin: 0; background: var(--card); border: none; }
.session[aria-busy="true"] { color: var(--muted); }
.settings { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; justify-content: flex-end; }
.settings .scrim { position: absolute; inset: 0; }
.settings .panel {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 10px 0 calc(20px + var(--safe-b)); background: #0F1116; border-top: 1px solid var(--line);
  animation: slideup .3s cubic-bezier(.2,.8,.2,1);
}
.settings .handle { align-self: center; }
.settings h2 { padding: 4px var(--pad) 0; }

/* ── Écrans de gestion : chat, appareils, secrets, enrôlement, connexion ── */
.page { display: flex; flex-direction: column; gap: 12px; padding: 0 var(--pad) 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 2px;
  padding: 14px; display: flex; flex-direction: column; gap: 8px; overflow-wrap: anywhere; min-width: 0;
}
.card h3 { font-size: 15px; font-weight: 600; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
label { display: flex; flex-direction: column; gap: 6px; font: 500 11px/1.3 var(--mono); letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 10px; text-transform: none; letter-spacing: 0; font: 400 14px/1.4 var(--body); color: var(--fg); }
input, textarea {
  font: 400 16px/1.4 var(--body); width: 100%; min-width: 0; padding: 10px 12px; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-radius: 2px;
  text-transform: none; letter-spacing: 0;
}
input:focus, textarea:focus { outline: none; border-color: var(--blue); }
input[type="checkbox"] { width: 20px; height: 20px; flex: none; accent-color: var(--amber); }
textarea { min-height: 6em; resize: vertical; }
.notice { border-left: 2px solid var(--amber); padding-left: 10px; font-size: 14px; }
.secret { font-family: var(--mono); font-size: 14px; word-break: break-all; }
.code { font-family: var(--pixel); font-weight: 700; font-size: 28px; letter-spacing: .12em; color: var(--fg); }
.dot { width: 8px; height: 8px; flex: none; background: var(--green); }
.dot.off { background: var(--grey); }
.menu { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.menu a {
  display: flex; align-items: center; gap: 12px; padding: 16px var(--pad); min-height: 56px;
  color: var(--fg); text-decoration: none; background: var(--card); border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.menu a.out { color: var(--red); }
.menu .mono { margin-left: auto; }
.center { display: flex; flex-direction: column; gap: 10px; padding: calc(48px + var(--safe-t)) var(--pad) 24px; }
.center .row { gap: 14px; }
.center .logo { width: 36px; height: 36px; box-shadow: inset -7px -7px 0 var(--blue-dk); }
.center .brand { font-size: 36px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
