/* ════════════════════════════════════════════════════════════════════════════
   Pi — Feuille de style. Système de design partagé avec phi.tmktools.com :
   mêmes jetons, mêmes composants ; accent cyan pour π (doré pour φ).
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Polices auto-hébergées ── */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/fonts/space-grotesk-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2');
}

/* ── Jetons (thème sombre par défaut, thème clair via data-theme) ── */
:root {
  --bg-deep: #0b0f14;
  --bg-panel: #111821;
  --bg-cell: #161f2a;
  --bg-input: #0d131b;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text-main: #e9edf2;
  --text-dim: #9aa6b5;
  --text-faint: #5f6b7a;
  --accent: #22d3ee;
  --accent-strong: #67e8f9;
  --accent-ink: #001217;
  --accent-soft: rgba(34, 211, 238, 0.12);
  --accent-glow: rgba(34, 211, 238, 0.35);
  --gold: #f5c451;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --focus: #8ab4ff;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);

  --font-display: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --transition: 160ms ease;

  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg-deep: #f6f4ee;
  --bg-panel: #ffffff;
  --bg-cell: #f3f0e7;
  --bg-input: #ffffff;
  --border-subtle: rgba(26, 31, 38, 0.12);
  --border-strong: rgba(26, 31, 38, 0.24);
  --text-main: #1a1f26;
  --text-dim: #4d5866;
  --text-faint: #7b8794;
  --accent: #0284a8;
  --accent-strong: #026a87;
  --accent-ink: #ffffff;
  --accent-soft: rgba(2, 132, 168, 0.12);
  --accent-glow: rgba(2, 132, 168, 0.25);
  --gold: #b07a00;
  --green: #15803d;
  --amber: #a66300;
  --red: #b91c1c;
  --red-soft: rgba(185, 28, 28, 0.1);
  --focus: #1d4ed8;
  --shadow: 0 10px 30px rgba(26, 31, 38, 0.12);

  color-scheme: light;
}

/* ── Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.55;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 45% at 15% 20%, var(--accent-soft) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 85% 70%, rgba(245, 196, 81, 0.05) 0%, transparent 55%);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
}

@media (min-width: 768px) {
  .app {
    padding: 2rem 2rem 3rem;
  }
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--accent-strong);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--transition);
}

.skip-link:focus {
  top: 1rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── En-tête ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  color: inherit;
  text-decoration: none;
}

.brand-icon {
  width: 46px;
  height: 46px;
  color: var(--accent);
  filter: drop-shadow(0 0 10px var(--accent-glow));
  flex-shrink: 0;
}

.brand-title {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 700;
}

.brand-accent {
  color: var(--accent);
  text-shadow: 0 0 18px var(--accent-glow);
}

.brand-tagline {
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* ── Badges d'état ── */
.badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.45rem 0.8rem;
  min-height: 2.25rem;
  border-radius: 999px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition);
}

a.badge:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.badge.on .dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: breathe 1.4s infinite;
}

.badge.ok .dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: breathe 2s infinite;
}

.badge.warn .dot {
  background: var(--amber);
}

@keyframes breathe {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.65); }
}

/* ── Présentation ── */
.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.25rem 1.75rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.hero-symbol {
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 12vw, 7.5rem);
  font-weight: 300;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent-glow);
  user-select: none;
}

.hero-text {
  min-width: 0;
  max-width: 100%;
}

.hero-title {
  font-size: clamp(1.25rem, 3vw, 1.7rem);
  margin-bottom: 0.5rem;
}

.hero-lead {
  color: var(--text-dim);
  max-width: 60ch;
  margin-bottom: 0.9rem;
}

.formula {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  max-width: 100%;
  box-sizing: border-box;
}

.formula-body {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
}

.formula sup {
  font-size: 0.7em;
  line-height: 0;
}

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  vertical-align: middle;
}

.frac .num {
  border-bottom: 1.5px solid currentColor;
  padding: 0 0.3rem 0.1rem;
  white-space: nowrap;
}

.frac .den {
  padding-top: 0.1rem;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }

  .hero-text {
    width: 100%;
  }

  .hero-lead {
    margin-left: auto;
    margin-right: auto;
  }

  /* La formule se réduit et se replie pour tenir dans la largeur du téléphone */
  .formula {
    width: 100%;
    font-size: clamp(0.62rem, 2.75vw, 0.95rem);
    padding: 0.55rem 0.5rem;
  }
}

/* ── Cartes ── */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

@media (min-width: 768px) {
  .card {
    padding: 1.6rem 1.75rem;
  }
}

.card-title {
  font-size: 1.1rem;
  margin-bottom: 0.9rem;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-head .card-title {
  margin-bottom: 0.25rem;
}

.card-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (max-width: 560px) {
  .card-actions {
    width: 100%;
  }

  .card-actions .btn {
    flex: 1 1 auto;
  }
}

/* ── Boutons ── */
.btn {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  min-height: 2.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:not(:disabled):active {
  transform: translateY(1px);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.45rem 0.8rem;
  min-height: 2.25rem;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:not(:disabled):hover {
  background: var(--accent-strong);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-cell);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-secondary.is-success {
  border-color: var(--green);
  color: var(--green);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border-subtle);
}

.btn-ghost:not(:disabled):hover {
  color: var(--text-main);
  border-color: var(--border-strong);
}

/* ── Bascule de thème ── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.1rem;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-icon {
  display: none;
  line-height: 1;
}

:root:not([data-theme='light']) .theme-icon-sun,
:root[data-theme='light'] .theme-icon-moon {
  display: inline;
}

/* ── Champs ── */
.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.field-input {
  width: 100%;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 0.6rem 0.85rem;
  min-height: 2.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-main);
}

.field-input::placeholder {
  color: var(--text-faint);
}

.field-input:focus {
  border-color: var(--accent);
  outline-offset: 0;
}

.field-help {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.45rem;
}

/* ── Compteur en direct ── */
.counter {
  margin-bottom: 1.1rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-cell);
  border: 1px solid var(--border-subtle);
  display: grid;
  gap: 0.15rem;
}

.counter-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.counter-value {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-shadow: 0 0 18px var(--accent-glow);
}

.counter-words {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: 0.02em;
  min-height: 1.4em;
}

.counter-words::first-letter {
  text-transform: uppercase;
}

/* ── Grille de décimales ── */
.digits {
  font-family: var(--font-mono);
  background: var(--bg-cell);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  max-height: 60vh;
  min-height: 12rem;
  overflow: auto;
  overscroll-behavior: contain;
}

.digits:empty::before {
  content: 'Connexion au fichier en cours… Les décimales apparaîtront ici en temps réel.';
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 0.85rem;
  display: block;
  text-align: center;
  padding-top: 4rem;
}

.pi-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-evenly;
  margin-bottom: 0.5rem;
}

.row-label {
  font-size: 0.62rem;
  color: var(--text-faint);
  width: 2.6rem;
  text-align: right;
  padding-right: 0.5rem;
  flex-shrink: 0;
  user-select: none;
  position: relative;
  top: -2px;
}

.row-label::before {
  content: '#';
  opacity: 0.5;
}

.pi-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.pi-digit {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  display: block;
  text-align: center;
  transition: opacity 0.1s ease, transform 0.15s ease;
}

.pi-digit.new {
  animation: popIn 0.22s ease both;
}

@keyframes popIn {
  from { opacity: 0.5; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.pi-digit.latest {
  z-index: 10;
  animation: latestPulse 0.55s ease forwards;
}

@keyframes latestPulse {
  0% { transform: scale(1.18); filter: brightness(1.5) saturate(1.3); }
  100% { transform: scale(1); filter: brightness(1) saturate(1); }
}

/* Une couleur par chiffre (identité visuelle historique de π) */
.v0 { color: #60a5fa; }
.v1 { color: #34d399; }
.v2 { color: #a78bfa; }
.v3 { color: #f472b6; }
.v4 { color: #fb923c; }
.v5 { color: #facc15; }
.v6 { color: #4ade80; }
.v7 { color: #38bdf8; }
.v8 { color: #e879f9; }
.v9 { color: #f87171; }

:root[data-theme='light'] .v0 { color: #1d4ed8; }
:root[data-theme='light'] .v1 { color: #047857; }
:root[data-theme='light'] .v2 { color: #6d28d9; }
:root[data-theme='light'] .v3 { color: #be185d; }
:root[data-theme='light'] .v4 { color: #c2410c; }
:root[data-theme='light'] .v5 { color: #a16207; }
:root[data-theme='light'] .v6 { color: #15803d; }
:root[data-theme='light'] .v7 { color: #0369a1; }
:root[data-theme='light'] .v8 { color: #a21caf; }
:root[data-theme='light'] .v9 { color: #b91c1c; }

.pi-rank {
  font-size: 0.5rem;
  color: var(--text-faint);
  line-height: 1;
  margin-top: 0.15rem;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}

.pi-cell:hover .pi-rank {
  color: var(--accent);
}

.pi-cell:hover .pi-digit {
  transform: scale(1.35);
  z-index: 5;
}

.century-rule {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.6rem 0;
  opacity: 0.8;
}

.century-rule .line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.5;
}

.century-rule .text {
  font-size: 0.62rem;
  color: var(--accent);
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.search-glow {
  animation: searchPulse 1.8s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes searchPulse {
  0%, 100% { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
  50% { background: var(--accent-glow); box-shadow: 0 0 0 3px var(--accent-glow); }
}

/* ── Outils d'exploration (grille de panneaux) ── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.tool {
  background: var(--bg-cell);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tool h3 {
  font-size: 0.95rem;
  color: var(--accent);
}

.tool-out {
  font-size: 0.85rem;
  color: var(--text-dim);
  min-height: 2rem;
}

.tool-out strong {
  color: var(--text-main);
}

.tool-out .bigDigit {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  margin-left: 0.3rem;
  vertical-align: middle;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
}

.tool-out .search-pos {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  background: none;
  border: none;
  padding: 0;
  font: inherit;
}

.tool-out .search-pos:hover,
.tool-out .bigDigit:hover {
  color: var(--gold);
}

/* Distribution */
.dist-row {
  display: grid;
  grid-template-columns: 1.1rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.dist-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

.dist-track {
  height: 5px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
}

.dist-fill {
  height: 100%;
  border-radius: 999px;
  background: currentColor;
  transition: width 0.3s ease;
}

.dist-count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  min-width: 4ch;
  text-align: right;
}

/* Snapshots */
.snapshot-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 15rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.snapshot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.4rem 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.snapshot-row .n {
  color: var(--accent);
  font-weight: 700;
}

.snapshot-row .unit {
  color: var(--text-dim);
  font-size: 0.68rem;
  margin-left: auto;
}

/* Infos fichier */
.file-info {
  font-size: 0.85rem;
  color: var(--text-dim);
  display: grid;
  gap: 0.25rem;
}

.file-info .val {
  color: var(--text-main);
  font-weight: 600;
  font-family: var(--font-mono);
}

/* ── Pédagogie & à propos ── */
.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.knowledge-item {
  background: var(--bg-cell);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.knowledge-item h3 {
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.knowledge-item p {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.about-list {
  padding-left: 1.2rem;
  color: var(--text-dim);
  font-size: 0.92rem;
  display: grid;
  gap: 0.5rem;
}

.about-list strong {
  color: var(--text-main);
}

/* ── Pied de page ── */
.footer {
  text-align: center;
  padding: 2rem 0 0.5rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-faint);
}

/* ── Notifications ── */
.toast-box {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  z-index: 999;
  pointer-events: none;
  align-items: flex-end;
}

.toast {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow);
  transform: translateY(12px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: auto;
  max-width: min(24rem, 100%);
  overflow-wrap: anywhere;
}

.toast.on {
  transform: translateY(0);
  opacity: 1;
}

.toast-ok { border-color: var(--green); color: var(--green); }
.toast-error { border-color: var(--red); color: var(--red); }
.toast-info { border-color: var(--accent); color: var(--accent); }

/* ── Bandeau de mise à jour ── */
.update-banner {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: calc(100% - 2.5rem);
  font-size: 0.9rem;
}

.update-actions {
  display: flex;
  gap: 0.5rem;
}

/* ── Dernière décimale (bandeau flottant) ── */
.last-digit {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease;
  z-index: 998;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.6rem 1.1rem;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: calc(100% - 2.5rem);
}

.last-digit.on {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.last-digit-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.last-digit-value {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
}

.last-digit-rank {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ── Page de statut ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.metric {
  background: var(--bg-cell);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.metric-label {
  color: var(--text-dim);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: clamp(1.05rem, 2.5vw, 1.5rem);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.metric-sub {
  min-height: 1.25rem;
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-top: 0.4rem;
}

.route {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0 0.8rem;
}

.node {
  width: 2.9rem;
  height: 2.9rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-cell);
  border: 1px solid var(--border-subtle);
  font-size: 1.2rem;
}

.node.ok {
  border-color: var(--green);
  box-shadow: 0 0 18px rgba(74, 222, 128, 0.25);
}

.node.warn {
  border-color: var(--amber);
}

.line {
  position: relative;
  height: 0.55rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-input);
}

.line > i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--accent));
  transform-origin: left;
  transition: transform 0.6s ease, background 0.3s;
}

.line.stale > i {
  background: linear-gradient(90deg, var(--amber), var(--red));
}

.route-labels {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  color: var(--text-dim);
  font-size: 0.78rem;
  text-align: center;
}

.route-labels strong {
  display: block;
  color: var(--text-main);
  font-size: 0.85rem;
  margin-bottom: 0.12rem;
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 600;
}

.state::before {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.state.stale {
  color: var(--amber);
}

.updated {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

@media (max-width: 575.98px) {
  .route {
    grid-template-columns: auto 1fr auto;
    gap: 0.45rem;
  }

  .route .line:last-of-type {
    display: none;
  }

  .route .node:last-child {
    grid-column: 3;
  }

  .route-labels {
    font-size: 0.67rem;
  }
}

/* ── Divers ── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
