/* ─────────────────────────────────────────────────────
   LeCanardJaune — Design System « Liquid Glass »
   Inspiré de visionOS / iOS 26 Apple
   ───────────────────────────────────────────────────── */

/* ── Variables ──────────────────────────────────────── */
:root {
  --bg:           #05080f;
  --bg2:          #0a0e1a;
  --glass:        rgba(255, 255, 255, 0.06);
  --glass-hover:  rgba(255, 255, 255, 0.10);
  --glass-active: rgba(255, 255, 255, 0.14);
  --border:       rgba(255, 255, 255, 0.11);
  --border-bright:rgba(255, 255, 255, 0.22);
  --blur:         22px;

  --accent:   #34c9ff;   /* eau / cyan */
  --active:   #ff9f0a;   /* orange — équipement allumé */
  --success:  #32d74b;   /* vert iOS */
  --warning:  #ffd60a;   /* jaune */
  --danger:   #ff453a;   /* rouge */
  --muted:    rgba(255,255,255,0.38);

  --text:     rgba(255,255,255,0.92);
  --text-sub: rgba(255,255,255,0.48);

  --r:   20px;    /* border-radius standard */
  --r-sm: 12px;
  --r-lg: 28px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t:   0.22s;
  --t-slow: 0.55s;

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display',
          'Segoe UI', system-ui, sans-serif;

  /* Safe area iOS */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset & base ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 70% at 20% 10%, rgba(0,130,200,0.25) 0%, transparent 55%),
    radial-gradient(ellipse 70% 60% at 85% 85%, rgba(0,80,140,0.28) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 60% 40%, rgba(0,160,160,0.10) 0%, transparent 50%),
    radial-gradient(ellipse 100% 100% at 50% 50%, #05090f 0%, #020810 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Background image overlay (jour/nuit) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('../images/blue_background_abstract-wide.jpg');
  background-size: cover;
  background-position: center;
  opacity: 0.18;
  z-index: 0;
  transition: opacity 1.2s var(--ease);
  pointer-events: none;
}
body.night::before {
  background-image: url('../images/blue_background_abstract-wide.jpg');
  opacity: 0.10;
}

/* ── Utility — glass panel ──────────────────────────── */
.glass {
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  border: 1px solid var(--border);
  box-shadow:
    0 4px 24px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.10);
}
.glass-bright {
  background: rgba(255,255,255,0.09);
  backdrop-filter: blur(var(--blur)) saturate(200%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(200%);
  border: 1px solid var(--border-bright);
  box-shadow:
    0 8px 32px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 0 0 0.5px rgba(255,255,255,0.06);
}

/* ── Layout wrapper ──────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header bar ─────────────────────────────────────── */
.header {
  z-index: 100;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  margin-bottom: 8px;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  border-top: none;
  background: rgba(5, 8, 15, 0.62);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 20px rgba(0,0,0,0.4);
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}
.header-logo .duck { font-size: 1.5rem; }

/* Logo image canard */
.duck-logo {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(52,201,255,0.55));
}

/* Badge version */
.version-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--accent);
  background: rgba(52,201,255,0.12);
  border: 1px solid rgba(52,201,255,0.28);
  border-radius: 100px;
  padding: 2px 8px;
  flex-shrink: 0;
  align-self: center;
  margin-left: 2px;
}
.header-center {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
#last-update {
  font-size: 0.78rem;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

/* Satellite status dot */
.sat-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background var(--t), box-shadow var(--t);
  flex-shrink: 0;
}
.sat-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.sat-dot.offline { background: var(--danger);  box-shadow: 0 0 6px var(--danger); }

/* ── Section titles ──────────────────────────────────── */
.section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-sub);
  font-weight: 700;
  margin: 6px 4px 7px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(52,201,255,0.18) 0%, transparent 100%);
  border-radius: 1px;
}

/* ── Controls section ────────────────────────────────── */
.controls-section { flex-shrink: 0; }

/* ── Gauges section ──────────────────────────────────── */
.gauges-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* scroll sur mobile si les jauges dépassent, fixe sur desktop */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Controls grid ───────────────────────────────────── */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}
@media (min-width: 600px) {
  .controls-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Device card */
.device-card {
  border-radius: var(--r);
  padding: 12px 10px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: default;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.device-card:active { transform: scale(0.97); }

.device-card.on {
  background: rgba(255, 159, 10, 0.12);
  border-color: rgba(255, 159, 10, 0.35);
  box-shadow:
    0 4px 24px rgba(255, 159, 10, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 0 0.5px rgba(255, 159, 10, 0.2);
}

.device-icon {
  font-size: 2rem;
  line-height: 1;
  opacity: 0.85;
}
.device-name {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-sub);
}

/* Power ring button */
.power-ring {
  width: 54px; height: 54px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: var(--text-sub);
  font-size: 1.3rem;
  cursor: pointer;
  transition:
    background var(--t) var(--ease),
    border-color var(--t) var(--ease),
    color var(--t) var(--ease),
    box-shadow var(--t) var(--ease),
    transform var(--t) var(--ease);
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.power-ring:active { transform: scale(0.92); }
.power-ring.on {
  background: rgba(255, 159, 10, 0.22);
  border-color: var(--active);
  color: var(--active);
  box-shadow: 0 0 16px rgba(255, 159, 10, 0.4), inset 0 0 8px rgba(255,159,10,0.1);
  animation: pulse-glow 2.4s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(255,159,10,0.35), inset 0 0 8px rgba(255,159,10,0.08); }
  50%       { box-shadow: 0 0 22px rgba(255,159,10,0.55), inset 0 0 12px rgba(255,159,10,0.15); }
}

/* Mode pill (Auto/Manu) */
.mode-pill {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: var(--text-sub);
  cursor: pointer;
  transition: background var(--t), border-color var(--t), color var(--t);
  -webkit-tap-highlight-color: transparent;
}
.mode-pill.auto {
  background: rgba(52, 201, 255, 0.14);
  border-color: rgba(52, 201, 255, 0.38);
  color: var(--accent);
}

/* ── Full Auto badge (header) ────────────────────────── */
.fullauto-badge {
  display: none;  /* caché par défaut */
  align-items: center;
  gap: 5px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--success);
  background: rgba(50, 215, 75, 0.12);
  border: 1px solid rgba(50, 215, 75, 0.28);
  border-radius: 100px;
  padding: 3px 10px;
  flex-shrink: 0;
  animation: badge-pulse 2.5s ease-in-out infinite;
}
.fullauto-badge.active { display: flex; }
.fullauto-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 5px var(--success);
  flex-shrink: 0;
}
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

.gauges-grid {
  display: grid;
  /* répartition automatique selon la largeur disponible — min 100px par jauge */
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  grid-auto-rows: auto;
  gap: 8px;
  padding-bottom: 8px;
}

/* Gauge card — carrée */
.gauge-card {
  border-radius: var(--r);
  padding: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.gauge-card svg.arc {
  width: 100%;
  height: 100%;
  display: block;
}

/* Arc track (fond gris) */
.arc-track {
  stroke: rgba(255,255,255,0.09);
  stroke-width: 7;
  stroke-linecap: round;
  fill: none;
}
/* Arc fill (valeur) — stroke-dashoffset pour compat iOS Safari */
.arc-fill {
  stroke-linecap: round;
  fill: none;
  stroke-width: 7;
  /* pathLength="1" dans le SVG : dasharray normalisé à 1 */
  stroke-dasharray: 1;
  stroke-dashoffset: 1;           /* 1 = vide, 0 = plein */
  transition: stroke-dashoffset var(--t-slow) var(--ease);
  -webkit-transition: stroke-dashoffset var(--t-slow) var(--ease);
}
/* Graduated ticks on arc */
.arc-ticks { stroke: rgba(255,255,255,0.12); stroke-width: 1.5; fill: none; }

/* Value / Unit / Label dans le SVG */
.g-val-svg {
  font-size: 20px;
  font-weight: 700;
  fill: rgba(255,255,255,0.92);
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.g-unit-svg {
  font-size: 9px;
  fill: rgba(255,255,255,0.45);
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.g-lbl-svg {
  font-size: 10px;
  fill: rgba(255,255,255,0.52);
  font-family: var(--font);
  font-weight: 500;
}

/* (conservés pour compatibilité) */
.g-val  { font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; }
.g-unit { font-size: 0.65rem; color: var(--text-sub); text-transform: uppercase; }
.g-lbl  { font-size: 0.72rem; color: var(--text-sub); font-weight: 500; }

/* Gauge min/max labels */
.arc-minmax {
  font-size: 8px;
  fill: rgba(255,255,255,0.3);
  font-family: var(--font);
}

/* ── Preferences modal ───────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  opacity: 0;
  transition: opacity var(--t) var(--ease);
  pointer-events: none;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, calc(-50% + 24px));
  z-index: 201;
  width: min(92vw, 500px);
  max-height: min(88vh, 740px);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition:
    opacity var(--t) var(--ease),
    transform var(--t) var(--ease);
  pointer-events: none;
  overflow: hidden;
}
.modal.open {
  opacity: 1;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 20px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-footer button { flex: 1; }

/* Prefs sections */
.prefs-section {
  margin-bottom: 22px;
}
.prefs-section h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-sub);
  font-weight: 600;
  margin-bottom: 10px;
}

/* Timer row */
.timer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.timer-row label {
  font-size: 0.75rem;
  color: var(--text-sub);
  width: 34px;
  flex-shrink: 0;
}
.timer-row input[type="time"] {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font);
  padding: 6px 10px;
  text-align: center;
  appearance: none;
  -webkit-appearance: none;
  color-scheme: dark;
  cursor: pointer;
}
.timer-row input[type="time"]:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(52, 201, 255, 0.06);
}
.timer-sep {
  color: var(--text-sub);
  font-size: 0.8rem;
  flex-shrink: 0;
}
.timer-remove {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255,67,58,0.3);
  background: rgba(255,67,58,0.08);
  color: var(--danger);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--t);
  -webkit-tap-highlight-color: transparent;
}
.timer-remove:hover { background: rgba(255,67,58,0.18); }

/* Badge "↪ 00h" affiché quand stop < start */
.timer-midnight {
  display: none;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(52, 201, 255, 0.12);
  border: 1px solid rgba(52, 201, 255, 0.3);
  border-radius: 6px;
  padding: 2px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.timer-midnight.visible { display: inline-flex; align-items: center; gap: 3px; }

/* Créneau en conflit avec un autre */
.timer-row.conflict {
  border-color: rgba(255, 69, 58, 0.6);
  background: rgba(255, 69, 58, 0.07);
}
.timer-row.conflict input[type="time"] {
  border-color: rgba(255, 69, 58, 0.45);
}

.add-timer-btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--r-sm);
  border: 1px dashed rgba(52, 201, 255, 0.3);
  background: rgba(52, 201, 255, 0.05);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t), border-color var(--t);
  -webkit-tap-highlight-color: transparent;
}
.add-timer-btn:hover { background: rgba(52, 201, 255, 0.10); border-color: rgba(52, 201, 255, 0.5); }

/* Prefs input fields */
.pref-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.pref-field > label:not(.toggle) {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text);
}
.pref-field input[type="number"] {
  width: 80px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.92rem;
  font-family: var(--font);
  padding: 6px 10px;
  text-align: right;
  appearance: none;
  -webkit-appearance: none;
}
.pref-field input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}
.pref-field .unit {
  font-size: 0.78rem;
  color: var(--text-sub);
  width: 28px;
}

/* iOS-style toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 12px; }
.toggle-label { flex: 1; font-size: 0.85rem; color: var(--text); }
.toggle-hint {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 32px;
  text-align: right;
}
.pref-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 4px 0 0;
  line-height: 1.4;
}
.toggle {
  position: relative;
  flex: none;            /* ne grandit ni ne rétrécit */
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  height: 28px;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  display: block;
  width: 100%; height: 100%;
  border-radius: 100px;
  background: rgba(255,255,255,0.15);
  cursor: pointer;
  transition: background var(--t);
}
.toggle input:checked + .toggle-track { background: var(--success); }
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: transform var(--t) var(--ease);
}
.toggle input:checked + .toggle-track::after { transform: translateX(20px); }

/* ── Buttons ──────────────────────────────────────────── */
.btn-primary {
  padding: 11px 20px;
  border-radius: var(--r-sm);
  border: none;
  background: var(--accent);
  color: #000;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity var(--t), transform var(--t);
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { opacity: 0.8; transform: scale(0.98); }

.btn-secondary {
  padding: 11px 20px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--t);
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
}
.btn-secondary:hover { background: var(--glass-hover); }

/* Icon glass button (header) */
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  transition: background var(--t), transform var(--t);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.icon-btn:hover  { background: var(--glass-hover); }
.icon-btn:active { transform: scale(0.92); }

/* ── Save toast ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,30,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-bright);
  border-radius: 100px;
  padding: 10px 20px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s var(--ease);
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { color: var(--success); }
.toast.error   { color: var(--danger); }

/* ── Loading skeleton ─────────────────────────────────── */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.7; }
}
.skeleton { animation: skeleton-pulse 1.8s ease-in-out infinite; }

/* ── Scrollbar global ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

/* ── Landscape sur téléphone (hauteur réduite) ─────── */
@media (orientation: landscape) and (max-height: 520px) {
  #app { flex-direction: row; align-items: stretch; gap: 10px; padding: 0 8px; }
  .header { border-radius: 0 var(--r-lg) var(--r-lg) 0; border-bottom: none; border-right: 1px solid var(--border); flex-direction: column; width: 100px; flex-shrink: 0; margin-bottom: 0; margin-right: 0; writing-mode: horizontal-tb; justify-content: center; padding: 8px; }
  .header-center, .header-right { flex-direction: column; }
  .controls-section { flex-shrink: 0; width: 110px; display: flex; flex-direction: column; justify-content: center; }
  .controls-grid { grid-template-columns: repeat(2, 1fr); }
  .gauges-section { flex: 1; min-height: 0; }
  /* auto-fill gère déjà les colonnes en mode paysage */
  .gauges-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}

/* ── Petit mobile ─────────────────────────────────────── */
@media (max-width: 380px) {
  .g-val-svg { font-size: 16px; }
  .gauges-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 5px; }
  .device-card { padding: 8px 6px 8px; }
  .power-ring { width: 42px; height: 42px; }
}

/* ── Power icon SVG inline ─────────────────────────────── */
.power-icon { pointer-events: none; }

/* ── Modal chart ───────────────────────────── */
#modal-chart {
  width: min(760px, 96vw);
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
}
.chart-toolbar {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px;
  flex-shrink: 0;
}
.chart-tool-btn {
  flex: 1;
  padding: 7px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-sub);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t), transform var(--t);
  -webkit-tap-highlight-color: transparent;
}
.chart-tool-btn:hover {
  background: rgba(52,201,255,0.08);
  color: var(--text);
}
.chart-tool-btn.active {
  background: rgba(52,201,255,0.14);
  border-color: rgba(52,201,255,0.5);
  color: var(--accent);
}
.chart-modal-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 16px 16px;
}
.chart-hint {
  margin: 0 4px 10px;
  color: var(--text-sub);
  font-size: 0.78rem;
  line-height: 1.35;
}
.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 180px;
}
.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.chart-wrap.zoom-mode canvas {
  cursor: crosshair;
}
.chart-selection {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(52,201,255,0.14);
  border: 1px solid rgba(52,201,255,0.55);
  border-radius: 10px;
  pointer-events: none;
  display: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  font-size: 0.85rem;
  letter-spacing: .04em;
}
.chart-no-data {
  text-align: center;
  color: var(--text-sub);
  font-size: 0.85rem;
  padding: 24px 0;
  margin: 0;
}

@media (max-width: 560px) {
  #modal-chart {
    width: min(96vw, 760px);
  }

  .chart-toolbar {
    flex-direction: column;
    gap: 6px;
    padding: 0 14px 10px;
  }

  .chart-tool-btn {
    width: 100%;
    flex: 0 0 auto;
    padding: 10px 0;
    font-size: 0.82rem;
  }

  .chart-modal-body {
    padding: 0 12px 12px;
  }

  .chart-hint {
    margin: 0 2px 8px;
    font-size: 0.75rem;
  }
}

@media (max-width: 380px) {
  .chart-tool-btn {
    padding: 9px 0;
    font-size: 0.78rem;
  }
}
/* Rend les gauge-cards cliquables */
.gauge-card {
  cursor: pointer;
}
.gauge-card:active {
  opacity: 0.8;
}
