/* The web monitor's layout. Colours come from themes.css (the app's colour sets); each style
   below sets its lettering and shapes the way the app's style does. */
:root {
  --font-sys: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-ui: var(--font-sys);
  --font-title: var(--font-ui);
  --font-num: var(--font-ui);
  --title-weight: 600;
  --title-spacing: 0;
  --radius: 16px;
  --card-border: 0 solid transparent;
  --card-clip: none;
  --btn-radius: 20px;
  color-scheme: dark;
}
:root[data-mode="light"] { color-scheme: light; }

/* ---- styles: lettering and shapes (app_style.dart, buildTheme) ---- */
:root[data-style="panel"] { --font-title: 'Oswald', var(--font-sys); --font-num: 'Oswald', var(--font-sys); --title-weight: 500; --title-spacing: .06em; --radius: 10px; }
:root[data-style="cyber"] {
  --font-ui: 'Exo2', var(--font-sys); --font-title: 'Exo2', sans-serif; --font-num: 'JetBrainsMono', monospace;
  --title-weight: 800; --title-spacing: .07em; --radius: 0; --card-border: 1px solid var(--line);
  --card-clip: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  --btn-radius: 0;
}
:root[data-style="terminal"] {
  --font-ui: 'PixelifySans', monospace; --font-title: 'PixelifySans', monospace; --font-num: 'PixelifySans', monospace;
  --title-weight: 400; --radius: 0; --card-border: 1px solid var(--line); --btn-radius: 0;
}
:root[data-style="cockpit"] {
  --font-ui: 'RobotoCondensed', var(--font-sys); --font-title: 'RobotoCondensed', sans-serif; --font-num: 'RobotoMono', monospace;
  --title-weight: 700; --title-spacing: .04em; --radius: 6px; --card-border: 1px solid #0006; --btn-radius: 4px;
}
:root[data-style="workbench"] {
  --font-ui: 'RobotoCondensed', var(--font-sys); --font-title: 'RobotoCondensed', sans-serif; --font-num: 'ShareTechMono', monospace;
  --title-weight: 700; --title-spacing: .04em; --radius: 10px; --card-border: 1px solid var(--line); --btn-radius: 6px;
}
:root[data-style="plain"] { --font-title: var(--font-ui); --title-weight: 800; --radius: 0; --card-border: 2.5px solid var(--fg); --btn-radius: 0; }
:root[data-style="instrument"] { --radius: 16px; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 15px; line-height: 1.4;
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}
:root[data-style="terminal"][data-mode="dark"] body { text-shadow: 0 0 4px color-mix(in srgb, var(--fg) 45%, transparent); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-text); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--warn); }
.accent { color: var(--accent-text); }
/* The Bridge tab's firmware update: the offer and Install, or the wait while it updates. */
.fw-update { margin-top: 12px; }
.fw-update .row { justify-content: space-between; flex-wrap: wrap; }
.fw-update progress { width: 100%; accent-color: var(--accent); }
.danger { color: var(--danger); }

/* ---- frame ---- */
/* header.top, not .top: a bare .top also styled the split-flap's top halves (above the
   folding card, so the new number showed before the flip). */
header.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
header.top h1 {
  margin: 0; flex: 1; font-family: var(--font-title); font-weight: var(--title-weight); letter-spacing: var(--title-spacing);
  font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.icon-btn {
  background: none; border: 1px solid transparent; border-radius: var(--btn-radius); padding: 6px 10px; cursor: pointer;
  color: var(--fg); min-height: 36px;
}
.icon-btn:hover { border-color: var(--line); }
.btn {
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: var(--btn-radius); padding: 9px 18px;
  font-weight: 600; cursor: pointer; min-height: 40px;
}
.btn.ghost { background: none; color: var(--accent-text); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }
:root[data-style="cyber"] .btn { clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }

.card {
  background: var(--card); border-radius: var(--radius); border: var(--card-border); clip-path: var(--card-clip);
  padding: 14px 16px;
}
.card h2 {
  margin: 0 0 8px; font-size: 14px; font-weight: 500; color: var(--muted); font-family: var(--font-title);
  letter-spacing: var(--title-spacing);
}
:root[data-style="cyber"] .card h2, :root[data-style="cockpit"] .card h2, :root[data-style="workbench"] .card h2 { text-transform: uppercase; font-size: 12px; }
:root[data-style="plain"] .card h2 { color: var(--fg); font-weight: 800; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stack > * + * { margin-top: 12px; }

.banner { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; background: var(--danger-bg); color: var(--danger-text); }
.banner.info { background: var(--card); color: var(--fg); border: 1px solid var(--line); }

/* ---- sign in ---- */
.signin { max-width: 380px; margin: 8vh auto 0; }
.signin label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
.signin input, .field {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: calc(var(--btn-radius) / 2);
}
.signin .btn { width: 100%; margin-top: 18px; }
.signin .switch { margin: 14px 0 0; text-align: center; }
.signin .switch a { color: var(--accent-text, var(--accent)); }

/* ---- battery list ---- */
.bat-row { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.bat-row:hover { outline: 1px solid var(--line); }
.badge {
  font-family: var(--font-title); font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 8px;
  border: 1.5px solid var(--line); color: var(--accent-text); min-width: 54px; text-align: center;
}
.bat-row .name { font-weight: 600; font-size: 17px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.on { background: var(--accent); }

/* ---- tabs ---- */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: 0; padding: 10px 16px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent;
  font-family: var(--font-title); letter-spacing: var(--title-spacing);
}
.tabs button.on { color: var(--fg); border-bottom-color: var(--accent); }
:root[data-style="terminal"] .tabs button.on, :root[data-style="plain"] .tabs button.on { background: var(--accent); color: var(--on-accent); }

/* ---- live ---- */
.live { display: grid; gap: 12px; grid-template-columns: minmax(260px, 360px) 1fr; }
@media (max-width: 760px) { .live { grid-template-columns: 1fr; } }
.hero { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 300px; }
.hero svg { width: 100%; max-width: 300px; height: auto; display: block; }
.hero .state { margin-top: 6px; font-family: var(--font-title); letter-spacing: var(--title-spacing); }
.figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.fig .label { color: var(--muted); font-size: 12px; }
.fig .value { font-family: var(--font-num); font-size: 26px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.fig .value small { font-size: 14px; color: var(--muted); margin-left: 3px; }
:root[data-style="plain"] .fig .value { font-weight: 800; font-size: 30px; }
:root[data-style="cockpit"] .fig .value { color: var(--accent); }
:root[data-style="cockpit"][data-mode="dark"] .fig .value { background: #0b0c0d; padding: 2px 8px; border-radius: 3px; }
:root[data-style="workbench"] .fig .value { background: color-mix(in srgb, var(--bg) 60%, #000); padding: 2px 8px; border-radius: 4px; color: var(--accent-text); }
:root[data-style="workbench"][data-mode="light"] .fig .value { background: #c9d3b4; color: #1e2b12; }
:root[data-style="cyber"][data-mode="dark"] .fig .value { color: var(--accent); text-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent); }

.lamps { display: flex; gap: 10px; flex-wrap: wrap; }
.lamp { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--btn-radius); }
.lamp i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); display: inline-block; }
.lamp.on i { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.lamp.off i { background: var(--danger); }
:root[data-style="terminal"] .lamp i, :root[data-style="plain"] .lamp i { border-radius: 0; box-shadow: none; }

.prot li { color: var(--danger); }
.prot ul { margin: 4px 0 0; padding-left: 18px; }

.cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.cell { border: 1px solid var(--line); border-radius: calc(var(--radius) / 2); padding: 6px 8px; position: relative; overflow: hidden; }
.cell .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); }
.cell.min { border-color: var(--warn); }
.cell.max { border-color: var(--accent); }
.cell .n { font-size: 11px; color: var(--muted); }
.cell .v { font-family: var(--font-num); font-size: 17px; font-variant-numeric: tabular-nums; }
.cellstats { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.temps { display: flex; gap: 10px; flex-wrap: wrap; }
.temps .t { font-family: var(--font-num); font-size: 20px; border: 1px solid var(--line); border-radius: var(--btn-radius); padding: 4px 12px; }
.faded { opacity: .45; filter: grayscale(.6); }

/* ---- history ---- */
.ranges { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.ranges button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chart svg { width: 100%; height: 180px; display: block; }
.chart .readout { min-height: 20px; font-family: var(--font-num); font-size: 13px; color: var(--muted); }

/* ---- bridge ---- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--font-num); }

/* ---- look dialog ---- */
.sheet-bg { position: fixed; inset: 0; background: #0008; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet { max-width: 520px; width: 100%; max-height: 90vh; overflow: auto; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-bottom: 14px; }
.choices button { padding: 10px; border: 1.5px solid var(--line); background: var(--bg); border-radius: calc(var(--radius) / 2); cursor: pointer; }
.choices button.on { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }

/* ---- the hero per style ---- */
.term-bar { font-family: 'PixelifySans', monospace; font-size: clamp(13px, 3.4vw, 22px); white-space: pre; max-width: 100%; overflow: hidden; }
.cursor { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }
.nixie { font-family: 'BarlowCondensed', sans-serif; font-weight: 300; font-size: 112px; line-height: 1; color: var(--accent);
  text-shadow: 0 0 6px var(--accent), 0 0 22px color-mix(in srgb, var(--accent) 70%, transparent); }
:root[data-mode="light"] .nixie { text-shadow: none; }
.plain-soc { font-size: 96px; font-weight: 800; line-height: 1; }
.plain-bar { width: 100%; height: 26px; border: 3px solid var(--fg); margin-top: 12px; }
.plain-bar > div { height: 100%; background: var(--fg); }

/* ---- motion shared by the styles (the app's motion.dart and motion_widgets.dart) ---- */
/* A card that opens and closes: height and fade, 320 ms in (easeOutCubic), 260 ms out (easeInCubic). */
.reveal { display: grid; grid-template-rows: 0fr; opacity: 0; visibility: hidden;
  transition: grid-template-rows .26s cubic-bezier(.32, 0, .67, 0), opacity .26s, visibility 0s .26s, margin .26s; }
.reveal.open { grid-template-rows: 1fr; opacity: 1; visibility: visible;
  transition: grid-template-rows .32s cubic-bezier(.33, 1, .68, 1), opacity .32s, visibility 0s, margin .32s; }
.reveal > * { overflow: hidden; min-height: 0; }
.live > .span { grid-column: 1 / -1; }
.live > .reveal:not(.open) { margin-bottom: -12px; }
/* A new tab fades in and grows from 0.985 (220 ms). */
.tab-body { animation: tabIn .22s cubic-bezier(.33, 1, .68, 1); }
@keyframes tabIn { from { opacity: 0; transform: scale(.985); } }
/* Charts draw in from the left over 900 ms; the neon and screen styles glow in the dark and
   mark the latest reading. */
.chart .plot { position: relative; }
.chart .trace { animation: drawIn .9s cubic-bezier(.33, 1, .68, 1) both; }
@keyframes drawIn { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.chart .glow { display: none; opacity: .18; }
.chart .end-dot { display: none; position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: var(--accent); animation: dotIn .3s .9s both; }
@keyframes dotIn { from { opacity: 0; transform: scale(.4); } }
:root[data-mode="dark"]:is([data-style="cyber"], [data-style="terminal"], [data-style="cockpit"]) .chart .glow { display: inline; }
:root:is([data-style="cyber"], [data-style="terminal"], [data-style="cockpit"]) .chart .end-dot { display: block; }
:root[data-style="cyber"] .chart .end-dot, :root[data-style="terminal"] .chart .end-dot { border-radius: 0; }
/* Motion off (the system, the viewer, or the Plain style): everything holds still. */
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after {
  animation: none !important; transition: none !important; }
/* A closed card's animations wait. */
.reveal:not(.open) * { animation-play-state: paused !important; }
[hidden] { display: none !important; }
.banner progress { display: block; width: 100%; margin-bottom: 6px; accent-color: var(--accent); }
