/* The Flow and Instrument styles' live screen, after the app's pack_cards.dart, hero_paint.dart
   and cell_cards.dart. The heroes are painted on canvases (styles/classic.js). */
.cl .muted { color: var(--muted); }

/* Flow: the figure, the state and the liquid battery. */
.cl-flow { position: relative; padding: 4px 2px 8px; }
.cl-flow canvas.glow { position: absolute; inset: -24px; width: calc(100% + 48px); height: calc(100% + 48px); pointer-events: none; }
.cl-flow .fig { position: relative; display: flex; align-items: baseline; }
.cl-flow .big { font-size: 88px; line-height: 1; font-weight: 600; font-variant-numeric: tabular-nums; }
.cl-flow .pct { font-size: 28px; color: var(--muted); }
.cl-flow .state { position: relative; display: flex; align-items: center; gap: 2px; margin-top: 4px; color: var(--muted); }
.cl-flow.active .state { color: var(--accent-text); }
.cl-flow .bolt { display: inline-flex; color: var(--accent-text); }
.cl-flow .battery { position: relative; display: flex; align-items: center; margin-top: 14px; }
.cl-flow .shell { position: relative; flex: 1; height: 72px; padding: 4px; border: 2.5px solid var(--muted); border-radius: 14px; }
.cl-flow .shell canvas { display: block; width: 100%; height: 100%; }
.cl-flow .nub { width: 7px; height: 28px; margin-left: 3px; background: var(--muted); border-radius: 0 4px 4px 0; }
.cl-flow .watts-box { position: absolute; left: 4px; top: 4px; bottom: 4px; display: flex; align-items: center; justify-content: flex-end;
  padding-right: 10px; box-sizing: border-box; }
.cl-flow .watts { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--bg); white-space: nowrap; }
.cl-flow.active .watts { color: var(--on-accent); }
@media (max-width: 420px) { .cl-flow .big { font-size: 64px; } .cl-flow .pct { font-size: 22px; } .cl-flow .shell { height: 52px; } }

/* Instrument: the gauge, with the figure and the state inside it. */
.cl-arc { position: relative; height: 230px; }
.cl-arc canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cl-arc .mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 20px; }
.cl-arc .big { font-size: 72px; line-height: 1; font-weight: 600; font-variant-numeric: tabular-nums; }
.cl-arc .lines { margin-top: 8px; font-size: 13px; color: var(--muted); text-align: center; max-width: 62%; }
.cl-arc.active .lines { color: var(--accent-text); }

/* The figures. */
.cl-metrics { padding: 14px 0; text-align: center; }
.cl-metrics .row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cl-metrics .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cl-metrics .v.active { color: var(--accent-text); }
.cl-metrics .k { font-size: 12px; color: var(--muted); }
.cl-metrics .cap { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* Cells. */
.cl-cells-head { display: flex; justify-content: space-between; color: var(--muted); padding: 0 4px 8px; }
.cl-cells-head .delta { font-variant-numeric: tabular-nums; }
.cl-cells-head .delta.bad { color: var(--danger-soft); }
.cl-cells { container-type: inline-size; }
.cl-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
/* Four tiles a row where there is room (440 px), two otherwise. */
@container (min-width: 440px) { .cl-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cl-tile { padding: 12px 12px 10px; background: var(--card); border-radius: 14px; border: 1.5px solid var(--card); transition: border-color .3s; --c: var(--accent); }
.cl-tile .name { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-tile .v { margin-top: 2px; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cl-tile .bar { margin-top: 6px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.cl-tile .bar i { display: block; height: 100%; min-width: 4px; border-radius: 2px; transition: width .5s cubic-bezier(.33, 1, .68, 1);
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 80%, #000), var(--c)); }
.cl-tile.over, .cl-tile.under { border-color: var(--danger); --c: var(--danger); }
.cl-tile.over .name, .cl-tile.under .name { color: var(--danger-soft); }
.cl-tile.low { border-color: var(--warn); --c: var(--warn); }
.cl-tile.low .name { color: var(--warn); }
.cl-tile.high .name { color: var(--fg); }
.cl-bars .cl-cells-head { padding: 0 0 10px; }
.cl-bars .trip-line { height: 1.5px; background: color-mix(in srgb, var(--danger) 70%, transparent); }
.cl-bars .bars { display: flex; align-items: flex-end; height: 110px; }
.cl-bars .bars > div { flex: 1; height: 100%; display: flex; align-items: flex-end; padding: 0 6px; }
.cl-bars.dense .bars > div { padding: 0 2px; }
.cl-bars .bars i { --c: var(--accent); display: block; width: 100%; border-radius: 6px; transition: height .5s cubic-bezier(.33, 1, .68, 1);
  background: linear-gradient(to top, color-mix(in srgb, var(--c) 55%, transparent), var(--c)); }
.cl-bars.dense .bars i { border-radius: 3px; }
.cl-bars .bars i.over, .cl-bars .bars i.under { --c: var(--danger); }
.cl-bars .bars i.low { --c: var(--warn); }
.cl-bars .labels { display: flex; margin-top: 6px; }
.cl-bars .labels span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cl-bars.dense .labels span { font-size: 10px; }
.cl-bars .labels span.over { color: var(--danger-soft); }
.cl-bars .minmax { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }

/* While charging: the bar's stripes move forward at 18 px/s. */
.cl-charging .head { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.cl-charging .stops { font-size: 12px; text-align: right; }
.cl-charging .bar { height: 10px; margin: 8px 0; border-radius: 5px; background: var(--line); overflow: hidden; --c: var(--accent); }
.cl-charging.close .bar { --c: var(--warn); }
.cl-charging .bar i { display: block; height: 100%; min-width: 10px; border-radius: 5px; transition: width .6s cubic-bezier(.33, 1, .68, 1);
  background: repeating-linear-gradient(-60deg, transparent 0 11px, #ffffff29 11px 20px) 0 0 / 44px 10px,
    linear-gradient(90deg, color-mix(in srgb, var(--c) 80%, #000), var(--c));
  animation: clStripes 1.22s linear infinite; }
@keyframes clStripes { to { background-position: 22px 0, 0 0; } }
.cl-charging .line { font-size: 13px; }
.cl-charging.close .line { color: var(--warn); }
.cl-charging .note { margin-top: 4px; font-size: 11px; color: var(--muted); }

.cl-temps .row { display: flex; align-items: center; gap: 6px; text-align: center; }
.cl-temps .row > div { flex: 1; }
.cl-temps .icon { color: var(--muted); display: inline-flex; }
.cl-temps .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cl-temps .k { font-size: 12px; color: var(--muted); }

/* The protection banner glows out once when it appears (1.4 s). */
.cl-trip { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border-radius: 16px; background: var(--danger-bg); color: var(--danger-text); }
.reveal.open .cl-trip { animation: clGlow 1.4s ease-out both; }
@keyframes clGlow { from { box-shadow: 0 0 6px 0 color-mix(in srgb, var(--danger) 55%, transparent); }
  to { box-shadow: 0 0 28px 10px transparent; } }
.cl-trip .icon { font-size: 18px; line-height: 1.2; }
.cl-trip .title { font-weight: 600; font-size: 16px; }
.cl-trip .detail { opacity: .8; }

/* A balancing cell: a soft band of light sweeps across it (1.8 s), so it reads as busy. */
.cl-tile { position: relative; overflow: hidden; }
.cl-tile.bal::before { content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: 12.5px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 16%, transparent), transparent) no-repeat;
  background-size: 55% 100%; animation: clSweepX 1.82s linear infinite; }
.cl-tile.bal .name::after { content: ' ⚖'; color: var(--accent-text); }
@keyframes clSweepX { from { background-position: -120% 0; } to { background-position: 220% 0; } }
.cl-bars .bars i { position: relative; overflow: hidden; }
.cl-bars .bars i.bal { --c: var(--accent-text); }
.cl-bars .bars i.bal::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top, transparent, #ffffff59, transparent) no-repeat; background-size: 100% 55%;
  animation: clSweepY 1.82s linear infinite; animation-delay: var(--d, 0s); }
@keyframes clSweepY { from { background-position: 0 220%; } to { background-position: 0 -120%; } }
