/* Monitoring — mise en page reprise de Chlocogram (barre du haut, onglets qui
   descendent sous le pouce sur téléphone, fenêtres en feuille, thème clair ou
   sombre), avec sa propre palette. */

:root {
  color-scheme: light;
  --bg: #f2f5fb;
  --surface: #ffffff;
  --surface-2: #e8eef8;
  --text: #15233b;
  --muted: #5c6b84;
  --line: #d4deee;
  --accent: #1b66d1;
  --ok: #1a8f4c;
  --warn: #b8620f;
  --danger: #c93a52;
  --grad: linear-gradient(45deg, #2fb4f0, #2563eb 55%, #1e3a8a);
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* courbes */
  --c-cpu: #2563eb;
  --c-mem: #8b5cf6;
  --c-temp: #e5484d;
  --c-power: #d99a00;
  --c-rx: #1a9f55;
  --c-tx: #e08a00;
  --c-read: #0aa5c2;
  --c-write: #db4f9b;
  --c-fan: #0f9f95;
  --c-swap: #d97706;
}
/* Mode sombre : choisi par theme.js (réglage « Auto », « Clair » ou « Sombre »). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a111e;
  --surface: #121c2e;
  --surface-2: #1a2740;
  --text: #e8eefb;
  --muted: #8d9cb6;
  --line: #24344f;
  --accent: #6cb2ff;
  --ok: #4ade80;
  --warn: #f0a04b;
  --danger: #ff7d8f;
  --grad: linear-gradient(45deg, #38bdf8, #3b82f6 55%, #2a4fb8);
  --c-cpu: #60a5fa;
  --c-mem: #a78bfa;
  --c-temp: #f87171;
  --c-power: #facc15;
  --c-rx: #4ade80;
  --c-tx: #fbbf24;
  --c-read: #22d3ee;
  --c-write: #f472b6;
  --c-fan: #2dd4bf;
  --c-swap: #fb923c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(900px 420px at 50% -160px, color-mix(in srgb, var(--accent) 16%, transparent), transparent) no-repeat var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo.big { font-size: 34px; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand img { flex: none; border-radius: 8px; }
.host-tag {
  flex: none;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.login-logo { display: block; margin: 0 auto 10px; border-radius: 20px; }

/* ---------- boutons et champs ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}
.btn.primary { border: 0; background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 12px; font-size: 13px; min-height: 34px; }
.btn.icon { padding: 7px 10px; line-height: 0; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:not(:disabled):hover { filter: brightness(1.06); }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.link-btn { font: inherit; font-size: 13px; color: var(--muted); background: none; border: 0; text-decoration: underline; cursor: pointer; }

input, textarea, select {
  font: inherit;
  font-size: 16px; /* en dessous, iOS zoome sur le champ */
  width: 100%;
  padding: 9px 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible, .btn:focus-visible, .tab:focus-visible, .row-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }

/* ---------- connexion ---------- */

.login-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 34px 26px;
  box-shadow: 0 20px 50px rgba(30, 58, 138, 0.14);
}
.login-card input { text-align: center; margin-bottom: 12px; }
.login-card .btn { width: 100%; padding: 12px; }
.tagline { color: var(--muted); margin: 6px 0 22px; }
.form-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; }

/* ---------- ossature ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }

/* Témoin de liaison : vert qui bat quand les relevés arrivent, gris sinon. */
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.live-dot.on { background: var(--ok); box-shadow: 0 0 8px color-mix(in srgb, var(--ok) 70%, transparent); animation: beat 1.8s ease-in-out infinite; }
@keyframes beat { 50% { opacity: 0.4; } }

.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 16px 0; max-width: 1100px; margin: 0 auto; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.tab svg { width: 18px; height: 18px; flex: none; }
.tab[aria-current="page"] { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: var(--accent); color: var(--accent); }

/* Sept onglets sur une ligne dès qu'ils sont en haut de l'écran. */
@media (min-width: 701px) and (max-width: 900px) {
  .tabs { gap: 4px; }
  .tab { padding: 7px 10px; }
}

main { max-width: 1100px; margin: 0 auto; padding: 14px 16px 60px; }

.net-error {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 9px 14px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  color: var(--warn);
  font-size: 13px;
  font-weight: 600;
}

.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; color: var(--accent); font-weight: 600; text-decoration: none; }
.view-title { margin: 0 0 12px; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }

/* ---------- cartes ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.card {
  min-width: 0;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}
.card.wide, .cards > .span { grid-column: 1 / -1; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-head h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.card-head .value { font-weight: 700; font-variant-numeric: tabular-nums; }
.card > .muted:last-child { margin: 6px 0 0; }

.status { display: flex; align-items: center; gap: 12px; }
.status-icon { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; color: #fff; background: var(--ok); }
.status-icon.warning { background: var(--warn); }
.status-icon.critical { background: var(--danger); }
.status h2 { margin: 0; font-size: 18px; }
.status p { margin: 0; }

.alert-row { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.alert-row:first-child { border-top: 0; padding-top: 0; }
.alert-row:last-child { padding-bottom: 0; }
.alert-row strong { display: block; font-size: 14px; }
.dot { flex: none; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.warning, .dot.starting { background: var(--warn); }
.dot.critical, .dot.error, .dot.failed, .dot.down, .dot.degraded { background: var(--danger); }
.dot.info { background: var(--accent); }

/* ---------- jauges et barres ---------- */

.gauges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.gauge svg { width: 68px; height: 68px; display: block; margin: 0 auto; }
.gauge .track { fill: none; stroke: var(--surface-2); stroke-width: 7; }
.gauge .arc { fill: none; stroke: var(--ok); stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray 0.4s ease; }
.gauge .arc.warning { stroke: var(--warn); }
.gauge .arc.critical { stroke: var(--danger); }
.gauge .arc.power { stroke: var(--c-power); }
.gauge text { fill: var(--text); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gauge .caption { margin-top: 4px; font-size: 11px; color: var(--muted); }

.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width 0.4s ease; }
.bar > span.warning { background: var(--warn); }
.bar > span.critical { background: var(--danger); }
.bar > span.plain { background: var(--accent); }

.meter { margin: 10px 0; }
.meter:first-child { margin-top: 0; }
.meter:last-child { margin-bottom: 0; }
.meter-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; font-size: 14px; }
.meter-head .value { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter .muted { margin: 4px 0 0; }

.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 10px; }
.core { font-size: 11px; }
.core-head { display: flex; justify-content: space-between; margin-bottom: 3px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- courbes ---------- */

.chart { display: block; width: 100%; height: 80px; }
.chart.tall { height: 150px; }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .area { stroke: none; opacity: 0.16; }
.c-cpu { stroke: var(--c-cpu); fill: var(--c-cpu); }
.c-mem { stroke: var(--c-mem); fill: var(--c-mem); }
.c-temp { stroke: var(--c-temp); fill: var(--c-temp); }
.c-power { stroke: var(--c-power); fill: var(--c-power); }
.c-rx { stroke: var(--c-rx); fill: var(--c-rx); }
.c-tx { stroke: var(--c-tx); fill: var(--c-tx); }
.c-read { stroke: var(--c-read); fill: var(--c-read); }
.c-write { stroke: var(--c-write); fill: var(--c-write); }
.c-fan { stroke: var(--c-fan); fill: var(--c-fan); }
.c-swap { stroke: var(--c-swap); fill: var(--c-swap); }
.c-faint { opacity: 0.4; }
.chart .line.c-cpu, .chart .line.c-mem, .chart .line.c-temp, .chart .line.c-power, .chart .line.c-rx,
.chart .line.c-tx, .chart .line.c-read, .chart .line.c-write, .chart .line.c-fan, .chart .line.c-swap { fill: none; }

.chart-frame { display: flex; gap: 8px; }
.chart-frame .y-axis { display: flex; flex-direction: column; justify-content: space-between; text-align: right; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-frame .plot { flex: 1; min-width: 0; }
.x-axis { display: flex; justify-content: space-between; margin-top: 3px; font-size: 11px; color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.legend .c-cpu, .legend .c-mem, .legend .c-temp, .legend .c-power, .legend .c-rx, .legend .c-tx,
.legend .c-read, .legend .c-write, .legend .c-fan, .legend .c-swap { fill: none; stroke: none; }
.legend .c-cpu i { background: var(--c-cpu); } .legend .c-mem i { background: var(--c-mem); }
.legend .c-temp i { background: var(--c-temp); } .legend .c-power i { background: var(--c-power); }
.legend .c-rx i { background: var(--c-rx); } .legend .c-tx i { background: var(--c-tx); }
.legend .c-read i { background: var(--c-read); } .legend .c-write i { background: var(--c-write); }
.legend .c-fan i { background: var(--c-fan); } .legend .c-swap i { background: var(--c-swap); }

/* ---------- listes ---------- */

.list { border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.list + .list, .list + .section-title, .card + .section-title, .cards + .section-title { margin-top: 16px; }
.section-title { margin: 0 4px 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.section-note { margin: 6px 4px 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); min-width: 0; }
.row:first-child { border-top: 0; }
.row .dot { margin-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-main > div, .row-main > strong { overflow-wrap: anywhere; }
.row-main strong { font-weight: 600; }
.row-side { flex: none; text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.row.top { align-items: flex-start; }
.row.top .dot { margin-top: 7px; }
/* Ligne entière cliquable (menu Système, services, processus). */
.row-link { width: 100%; font: inherit; color: inherit; text-align: left; text-decoration: none; background: none; border: 0; border-top: 1px solid var(--line); cursor: pointer; touch-action: manipulation; }
.row-link:first-child { border-top: 0; }
.row-link::after { content: "›"; flex: none; color: var(--muted); font-size: 20px; line-height: 1; }
.row-link:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.row-icon { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }
.row-icon svg { width: 18px; height: 18px; }

/* Paire « libellé … valeur ». */
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 9px 14px; border-top: 1px solid var(--line); }
.kv:first-child { border-top: 0; }
.kv > span:first-child { flex: none; max-width: 55%; }
.kv > span:last-child { color: var(--muted); text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.pill { flex: none; display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.warning { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill.critical { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.pill.info { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 46px; }
.empty h2 { color: var(--text); margin: 10px 0 6px; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toolbar > * { flex: 1 1 140px; min-width: 0; }
.toolbar .segmented, .toolbar > .wide { flex: 1 1 100%; }
/* Variante sur une seule ligne, qui défile au besoin (au-dessus du terminal). */
.toolbar.strip { flex-wrap: nowrap; overflow-x: auto; margin-bottom: 8px; scrollbar-width: none; }
.toolbar.strip::-webkit-scrollbar { display: none; }
.toolbar.strip > * { flex: none; width: auto; }
.toolbar.strip select { padding: 5px 10px; border-radius: 999px; font-size: 14px; }

.log-line { padding: 8px 14px; border-top: 1px solid var(--line); }
.log-line:first-child { border-top: 0; }
.log-head { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.log-head .dot { margin-top: 0; width: 7px; height: 7px; }
.log-text { margin: 2px 0 0; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-line.error .log-text { color: var(--danger); }
pre.log-file { margin: 0; padding: 12px 14px; font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- fenêtres ---------- */

dialog { color: var(--text); border: 0; padding: 0; }
dialog::backdrop { background: rgba(8, 14, 28, 0.7); }

.sheet { width: min(680px, 100vw); max-width: 100vw; max-height: min(92vh, 100dvh); border-radius: 20px; background: var(--surface); }
.sheet[open] { display: flex; flex-direction: column; }
.sheet-head { padding: 18px 20px 8px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.sheet-head p { margin: 2px 0 0; }
/* « auto » et non 0 comme base : sur Safari, une zone défilante de base 0 dans
   un parent sans hauteur fixe s'écrase à zéro (leçon de Chlocogram). */
.sheet-body { overflow-y: auto; padding: 8px 20px; flex: 1 1 auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.sheet-body .list { margin-bottom: 14px; }
.sheet-head, .sheet-foot { flex: none; }
@media (max-width: 600px) {
  /* Sur téléphone, la fenêtre prend tout l'écran : la place ne manque jamais. */
  .sheet { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .sheet-head { padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
}
.sheet-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 20px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.sheet-foot .btn:first-child { margin-right: auto; }

.alert { width: min(360px, calc(100vw - 32px)); padding: 24px 22px; border-radius: 22px; background: var(--surface); text-align: center; }
.alert h2 { margin: 0 0 6px; font-size: 18px; }
.alert p { margin: 6px 0; }
.alert pre { margin: 10px 0; padding: 10px; border-radius: 10px; background: var(--surface-2); font-family: var(--mono); font-size: 12px; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
.alert .btn { width: 100%; margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: #13213b;
  color: #fff;
  font-size: 14px;
}

.banner { display: flex; align-items: stretch; max-width: 1068px; margin: 12px auto 0; border-radius: var(--radius); background: var(--grad); color: #fff; }
.banner button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.banner-main { flex: 1; padding: 11px 14px; text-align: left; font-weight: 600; }
.banner-close { padding: 0 14px; font-size: 20px; }
@media (max-width: 1100px) { .banner { margin-inline: 16px; } }

.app-section { padding: 6px 0 16px; border-bottom: 1px solid var(--line); }
.app-section:last-child { border-bottom: 0; }
.app-section h3 { margin: 10px 0 6px; font-size: 15px; }
.app-section p { margin: 6px 0; }
.app-section ol { margin: 8px 0; padding-left: 22px; }
.app-section li { margin: 6px 0; }
.app-section .ok { font-weight: 600; color: var(--ok); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.segmented { display: flex; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.segmented button {
  flex: 1;
  font: inherit;
  font-weight: 600;
  padding: 8px 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); }
.segmented.compact { display: inline-flex; }
.segmented.compact button { flex: none; padding: 5px 12px; font-size: 13px; }

/* ---------- terminal ---------- */

.terminal { display: flex; flex-direction: column; height: calc(var(--vvh, 100dvh) - var(--chrome, 150px)); min-height: 260px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: var(--surface); }
.term-screen { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px; background: #0b1020; color: #e6edf7; font-family: var(--mono); font-size: 12.5px; line-height: 1.45; }
.term-hint { color: #8391ab; white-space: pre-wrap; }
.term-entry { margin-bottom: 14px; }
.term-cmd { font-weight: 700; white-space: pre-wrap; overflow-wrap: anywhere; }
.term-cmd .prompt { color: #4ade80; }
.term-out { margin: 3px 0 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; color: #d5deed; -webkit-user-select: text; user-select: text; }
.term-note { margin-top: 3px; color: #fbbf24; }
.term-note.bad { color: #ff8a98; }
.term-note.quiet { color: #8391ab; }
.term-run { color: #8391ab; }
.term-run::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #4ade80; animation: beat 1s ease-in-out infinite; }

.term-strip { flex: none; display: flex; gap: 6px; overflow-x: auto; padding: 6px 10px; background: var(--surface-2); scrollbar-width: none; }
.term-strip::-webkit-scrollbar { display: none; }
.term-strip button { flex: none; font: inherit; font-family: var(--mono); font-size: 12.5px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; touch-action: manipulation; white-space: nowrap; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; }
.term-strip.keys button { min-width: 34px; min-height: 34px; padding: 4px 8px; border-radius: 8px; font-size: 15px; }
.term-strip button:disabled { opacity: 0.5; }

.term-input { flex: none; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.term-prompt { margin-bottom: 4px; color: var(--ok); font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere; }
.term-form { display: flex; gap: 8px; }
.term-form input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 16px; }
.term-form .btn { flex: none; width: 44px; height: 44px; padding: 0; font-size: 20px; line-height: 1; }

/* ---------- assistant (onglet IA) ---------- */

.ai-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 92%; padding: 9px 13px; border-radius: 16px; overflow-wrap: anywhere; }
.ai-msg.user { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 5px; white-space: pre-wrap; }
.ai-msg.bot { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 5px; -webkit-user-select: text; user-select: text; }
.ai-msg.bot > :first-child { margin-top: 0; }
.ai-msg.bot > :last-child { margin-bottom: 0; }
.ai-msg h4 { margin: 12px 0 4px; font-size: 15px; }
.ai-msg p { margin: 6px 0; }
.ai-msg ul, .ai-msg ol { margin: 6px 0; padding-left: 20px; }
.ai-msg li { margin: 3px 0; }
.ai-msg code { font-family: var(--mono); font-size: 0.9em; padding: 1px 4px; border-radius: 5px; background: color-mix(in srgb, var(--text) 9%, transparent); }
.ai-code { margin: 6px 0; padding: 9px 11px; border-radius: 10px; background: #0b1020; color: #d5deed; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-tool { align-self: stretch; font-size: 13px; color: var(--muted); }
.ai-tool summary { cursor: pointer; overflow-wrap: anywhere; }
.ai-tool-label { font-weight: 600; }
.ai-mark { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--muted); }
.ai-mark.ok { background: var(--ok); }
.ai-mark.bad { background: var(--danger); }
.ai-mark.run { background: var(--accent); animation: beat 1s ease-in-out infinite; }
.ai-approval { align-self: stretch; padding: 12px 14px; border-radius: var(--radius); border: 2px solid var(--warn); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); }
.ai-approval.decided { border: 1px solid var(--line); background: var(--surface); }
.ai-approval p { margin: 6px 0; }
.ai-approval .ok { color: var(--ok); font-weight: 600; }
.ai-approval .panel-actions .btn { flex: 1; }
.ai-note { align-self: center; font-size: 12px; color: var(--muted); text-align: center; }
.ai-note.bad { color: var(--danger); }
.ai-note.working::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--accent); animation: beat 1s ease-in-out infinite; }
.ai-intro h2 { margin: 4px 0 6px; font-size: 18px; }
.ai-intro p { margin: 6px 0; }
.ai-intro ul { margin: 8px 0; padding-left: 20px; }
.ai-intro li { margin: 6px 0; }
.ai-quota { flex: none; padding: 4px 12px; text-align: center; font-size: 12px; }
.ai-box .term-form input { font-family: inherit; }

/* ---------- backup ---------- */

.backup .panel-actions + .section-title, .backup .section-note + .section-title { margin-top: 16px; }
.dot.off { background: var(--line); }
/* Case à cocher sur toute la ligne (le style général des libellés ne vaut pas ici). */
.row.check { margin: 0; font-size: inherit; font-weight: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.row.check input { flex: none; width: 22px; height: 22px; margin: 0; padding: 0; accent-color: var(--accent); }
.card .segmented { margin-top: 12px; }
.card .segmented + .muted { margin: 8px 2px 0; }
.card + .list { margin-top: 8px; }
.card.notice { margin-bottom: 16px; border-color: var(--warn); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); }
.card.notice p { margin: 6px 0; }
.fold { margin-top: 8px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.fold + .section-title { margin-top: 16px; }
.fold > summary { padding: 10px 14px; font-size: 13px; color: var(--muted); cursor: pointer; touch-action: manipulation; }
.fold > .list { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
/* Reste sous le pouce tant qu'il y a des modifications à enregistrer. */
.save-bar { position: sticky; bottom: 12px; z-index: 4; display: flex; align-items: center; gap: 8px; margin: 14px 0 16px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--surface); box-shadow: 0 6px 22px rgba(8, 14, 28, 0.22); }
.save-bar .grow { flex: 1; min-width: 0; font-size: 14px; }
.save-bar .form-error { margin: 2px 0 0; }

.lock-card { max-width: 380px; margin: 30px auto; text-align: center; }
.lock-card .big { font-size: 44px; }
.lock-card h2 { margin: 6px 0; }
.lock-card form { margin-top: 14px; }
.lock-card input { text-align: center; margin-bottom: 10px; }
.lock-card .btn { width: 100%; }

/* ---------- ergonomie : tout sous le pouce ---------- */

@media (display-mode: standalone) {
  body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
  .btn, .tab, .row-link { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
}

@media (max-width: 700px) {
  .topbar { padding-inline: 12px; }
  .logo { font-size: 20px; }
  main { padding: 12px 12px calc(96px + env(safe-area-inset-bottom, 0px)); }
  .cards { grid-template-columns: 1fr; }
  .view-title { font-size: 20px; }
  /* Sur téléphone, la navigation descend en bas de l'écran. */
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    justify-content: space-around;
    gap: 0;
    max-width: none;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .tab { flex: 1; flex-direction: column; gap: 1px; padding: 4px 0; border: 0; border-radius: 12px; font-size: 11px; }
  .tab svg { width: 24px; height: 24px; }
  .tab[aria-current="page"] { background: none; }
  body > .toast { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  .gauge svg { width: 62px; height: 62px; }
  /* Le terminal occupe tout l'écran restant : pas de marge sous lui à faire défiler. */
  body[data-view="terminal"] main, body[data-view="ia"] main { padding-bottom: 0; }
  .save-bar { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .tab { font-size: 10.5px; }
  /* Clavier ouvert : la barre d'onglets cède sa place à la saisie. */
  body.keyboard .tabs { display: none; }
  body.keyboard main { padding-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot.on, .term-run::before { animation: none; }
  .bar > span, .gauge .arc { transition: none; }
}
