/* Inflow Radar - application styles. Dark, map-first, responsive. */

:root {
  --bg: #0a0d12;
  --surface: #10151d;
  --surface-2: #171d28;
  --surface-3: #1f2733;
  --line: #262f3d;
  --text: #e6ecf3;
  --muted: #8d99ab;
  --accent: #5fd4c4;
  --accent-ink: #052520;
  --amber: #ffd166;
  --danger: #ff6b6b;
  --ok: #57d08a;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--font);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h2, h3 { margin: 0; }
kbd {
  font: 11px/1 var(--font);
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
}
code { font-size: 12px; color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
}

/* ------------------------------------------------------------ top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-width: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  user-select: none;
}
.brand-dot { fill: var(--amber); }
.brand-name { color: var(--text); font-size: 15px; }

.search { position: relative; flex: 0 1 240px; min-width: 150px; }
.search input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 32px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); }
.search input::-webkit-search-cancel-button { filter: invert(0.6); }
.search-icon { position: absolute; left: 8px; top: 8px; color: var(--muted); pointer-events: none; }
.search-icon .icon { width: 18px; height: 18px; }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: max(100%, 300px);
  max-height: min(60vh, 420px);
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 30;
}
.sr-head { padding: 6px 8px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.sr-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  text-align: left;
}
.sr-item:hover, .sr-item.is-active { background: var(--surface-3); }
.sr-item .icon { width: 16px; height: 16px; color: var(--muted); flex: none; }
.sr-main { flex: 1; min-width: 0; }
.sr-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-title b { color: var(--accent); font-weight: 650; margin-right: 6px; }
.sr-detail { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-save { flex: none; border: 0; background: none; color: var(--muted); padding: 4px; border-radius: 6px; display: flex; }
.sr-save:hover { color: var(--amber); background: var(--surface); }
.sr-note { padding: 8px; color: var(--muted); font-size: 12.5px; }

.row2 { display: contents; }

.site-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  white-space: nowrap;
  flex: none;
}
.site-pill:hover { border-color: var(--muted); }
.site-pill-id { font-weight: 700; color: var(--accent); letter-spacing: 0.03em; }
.site-pill-name { color: var(--muted); max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.site-pill-x { color: var(--muted); font-size: 17px; line-height: 1; }

.products { display: flex; gap: 2px; padding: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; flex: none; }
.chip {
  height: 28px;
  min-width: 40px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.03em;
}
.chip:hover { color: var(--text); background: var(--surface-3); }
.chip.is-active { background: var(--accent); color: var(--accent-ink); }
.chip.is-missing:not(.is-active) { opacity: 0.45; }

.tilt { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; flex: none; }
select {
  height: 34px;
  padding: 0 26px 0 10px;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238d99ab' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 9px center;
  border: 1px solid var(--line);
  border-radius: 8px;
  appearance: none;
  -webkit-appearance: none;
  max-width: 100%;
}
select:disabled { opacity: 0.5; }

.spacer { flex: 1; }

.seg { display: flex; padding: 2px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; flex: none; }
.seg button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-weight: 600;
}
.seg button:hover { color: var(--text); }
.seg button.is-active { background: var(--surface-3); color: var(--accent); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}
.icon-btn:hover { border-color: var(--muted); }
.icon-btn.is-active { color: var(--accent); border-color: var(--accent); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon { display: block; }

/* ------------------------------------------------------------ stage / panes */

.stage { position: relative; min-height: 0; overflow: hidden; }

.panes { position: absolute; inset: 0; display: grid; gap: 2px; background: #000; }
.panes.layout-1 { grid-template: 1fr / 1fr; }
.panes.layout-2 { grid-template: 1fr / 1fr 1fr; }
.panes.layout-4 { grid-template: 1fr 1fr / 1fr 1fr; }

.pane { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
.map { position: absolute; inset: 0; }

.pane-label {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  max-width: calc(100% - 16px);
  padding: 4px 9px;
  background: rgba(10, 13, 18, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 7px;
  backdrop-filter: blur(6px);
  pointer-events: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pane-title { font-weight: 700; letter-spacing: 0.02em; }
.pane-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.pane-value { color: var(--accent); font-weight: 600; }
.pane-value:empty, .pane-sub:empty { display: none; }

.pane-msg {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  max-width: min(80%, 360px);
  padding: 9px 14px;
  background: rgba(10, 13, 18, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-align: center;
  pointer-events: none;
}
.pane-msg.is-error { border-color: rgba(255, 107, 107, 0.55); color: #ffd0d0; }

.legend {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: min(300px, calc(100% - 110px));
  display: flex;
  align-items: flex-start;
  gap: 2px;
  padding: 5px 8px 3px 0;
  background: rgba(10, 13, 18, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 7px;
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.legend-bar { flex: 1; min-width: 0; width: 100%; height: 30px; display: block; }
.legend-units { font-size: 10.5px; color: var(--muted); line-height: 13px; min-width: 16px; }

.crosshair {
  position: absolute;
  left: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
  pointer-events: none;
  background:
    linear-gradient(#fff, #fff) center / 18px 1.5px no-repeat,
    linear-gradient(#fff, #fff) center / 1.5px 18px no-repeat;
  filter: drop-shadow(0 0 1.5px #000) drop-shadow(0 0 1.5px #000);
  opacity: 0.9;
}

.readout {
  position: absolute;
  left: 8px;
  bottom: 60px;
  min-width: 190px;
  max-width: min(320px, calc(100% - 16px));
  padding: 8px 11px;
  background: rgba(13, 17, 24, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  z-index: 3;
}
.ro-values { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-bottom: 4px; }
.ro-value { display: flex; align-items: baseline; gap: 6px; }
.ro-value small { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; }
.ro-value b { font-size: 17px; font-weight: 650; }
.ro-value b.is-none { color: var(--muted); font-weight: 500; font-size: 14px; }
.ro-line { color: var(--muted); font-size: 12px; }
.ro-line span { color: var(--text); }

.spc-legend {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 210px;
  padding: 9px 11px;
  background: rgba(13, 17, 24, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  z-index: 2;
  font-size: 12.5px;
}
.stage.panel-open .spc-legend { right: 340px; }
.stage.alert-open .readout { left: 378px; }
.spc-title { font-weight: 650; margin-bottom: 2px; }
.spc-meta { color: var(--muted); font-size: 11.5px; margin-bottom: 6px; }
.spc-row { display: flex; align-items: center; gap: 8px; padding: 1.5px 0; }
.spc-swatch { width: 16px; height: 11px; border-radius: 2px; border: 1.5px solid; flex: none; }
.spc-swatch.is-hatched { background: repeating-linear-gradient(45deg, transparent 0 2px, rgba(255, 255, 255, 0.7) 2px 3px) !important; border-style: dashed; }

.toasts {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(92%, 460px);
  z-index: 40;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 8px 8px 13px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}
.toast-error { border-left-color: var(--danger); }
.toast-ok { border-left-color: var(--ok); }
.toast-action { border: 0; background: none; color: var(--accent); font-weight: 650; padding: 2px 4px; white-space: nowrap; }
.toast-close { border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 5px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ------------------------------------------------------------ side panels */

.side-panel, .alert-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 330px;
  max-width: 100%;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 20;
  overscroll-behavior: contain;
}
.side-panel { right: 0; border-left: 1px solid var(--line); }
.alert-panel { left: 0; width: 370px; border-right: 1px solid var(--line); }

.panel-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
.panel-head h2 { font-size: 15px; font-weight: 650; }

.side-panel section { padding: 12px 14px 14px; border-bottom: 1px solid var(--line); }
.side-panel h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 9px; font-weight: 650; }

.field { display: flex; align-items: center; gap: 10px; margin: 7px 0; min-width: 0; }
.field-label { flex: 0 0 96px; color: var(--muted); font-size: 12.5px; }
.field select, .field input[type="range"] { flex: 1; min-width: 0; }
.field output { width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.field-row { display: flex; gap: 8px; align-items: flex-end; margin: 7px 0; }
.field-row .field { flex-direction: column; align-items: stretch; gap: 3px; margin: 0; }
.field-row .field-label { flex: none; font-size: 11.5px; }
.grow { flex: 1; min-width: 0; }

input[type="text"], input[type="date"], input[type="time"] {
  height: 34px;
  width: 100%;
  padding: 0 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}
input[type="range"] { accent-color: var(--accent); height: 24px; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }

.check { display: flex; align-items: center; gap: 9px; margin: 8px 0; cursor: pointer; }
.check kbd { margin-left: auto; }
.check.small { margin: 4px 0; font-size: 13px; }
.sub-checks { display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 4px 25px; }
.sub-checks.is-disabled { opacity: 0.45; pointer-events: none; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 2px; }

.btn {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: none; color: var(--accent); border-style: dashed; }
.btn.wide { width: 100%; margin-top: 8px; white-space: normal; height: auto; min-height: 34px; padding: 7px 10px; }
.btn.small { height: 26px; padding: 0 9px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; margin-top: 8px; }

.place-list, .pal-list { list-style: none; margin: 0 0 8px; padding: 0; }
.place-list li, .pal-list li { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.place-list .place-go { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 4px 0; display: flex; gap: 8px; align-items: center; }
.place-list .place-go:hover { color: var(--amber); }
.place-list .place-go span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-list .icon { width: 16px; height: 16px; color: var(--amber); flex: none; }
.mini-btn { border: 0; background: none; color: var(--muted); padding: 4px; border-radius: 6px; display: flex; }
.mini-btn:hover { color: var(--danger); background: var(--surface-2); }
.place-empty { color: var(--muted); font-size: 12.5px; padding: 2px 0 6px; }
.pal-name { flex: 1; min-width: 0; }
.pal-name b { display: inline-block; width: 38px; }
.pal-name span { color: var(--muted); font-size: 12px; }
.pal-name span.is-custom { color: var(--accent); }

.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); }

/* alert detail */
.alert-card { padding: 12px 14px 16px; border-bottom: 1px solid var(--line); }
.alert-event { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 650; }
.alert-dot { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.alert-headline { color: var(--muted); margin: 5px 0 8px; font-size: 13px; }
.alert-meta { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 12.5px; margin-bottom: 8px; }
.alert-meta dt { color: var(--muted); }
.alert-meta dd { margin: 0; }
.alert-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.alert-tag { padding: 2px 8px; border-radius: 99px; background: var(--surface-3); font-size: 12px; }
.alert-text { white-space: pre-wrap; font-size: 13px; line-height: 1.5; margin: 0 0 10px; overflow-wrap: anywhere; }
.alert-sub { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 10px 0 4px; font-weight: 650; }
.alert-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
}
.alert-list-item:hover { background: var(--surface-2); }
.alert-list-item div { min-width: 0; }
.alert-list-item small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-back { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 600; }

/* ------------------------------------------------------------ timeline */

.timeline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  min-width: 0;
  z-index: 5;
}
.tl-controls { display: flex; gap: 4px; flex: none; }
.icon-btn.play { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.icon-btn.play:hover { filter: brightness(1.08); }

.tl-track {
  flex: 1;
  min-width: 80px;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 2px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  border-radius: 8px;
}
.tl-cell {
  position: relative;
  flex: 1;
  min-width: 3px;
  height: 12px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
  transition: height 0.1s;
}
.tl-cell i { position: absolute; inset: 0 auto 0 0; width: 0; background: #4b596d; }
.tl-cell.is-ready i { width: 100% !important; background: #5f7088; }
.tl-cell.is-partial i { width: 100% !important; background: #47566b; }
.tl-cell.is-error i { width: 100% !important; background: rgba(255, 107, 107, 0.6); }
.tl-cell.is-loading { background: repeating-linear-gradient(110deg, var(--surface-3) 0 6px, #252e3c 6px 12px); }
.tl-cell.is-current { height: 22px; }
.tl-cell.is-current i { background: var(--accent) !important; }
.tl-cell.is-current.is-error i { background: var(--danger) !important; }
.tl-cell.is-live { outline: 1px solid rgba(87, 208, 138, 0.75); outline-offset: 1px; }
.tl-cell.is-live.is-loading { background: var(--surface-3); }
.tl-cell.is-live.is-loading i { background: rgba(87, 208, 138, 0.45); }
.tl-empty { color: var(--muted); font-size: 12.5px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tl-live {
  flex: none;
  max-width: 220px;
  color: var(--ok);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-live.is-delayed { color: var(--amber); }
.tl-info { flex: none; text-align: right; line-height: 1.2; font-variant-numeric: tabular-nums; min-width: 86px; }
.tl-time { font-weight: 650; font-size: 15px; }
.tl-sub { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.tl-sub.is-stale { color: var(--amber); }
.tl-speed { flex: none; height: 34px; }

.badge {
  flex: none;
  height: 24px;
  padding: 0 9px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
}
.badge.is-live { color: var(--ok); border-color: rgba(87, 208, 138, 0.5); }
.badge.is-live::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--ok); vertical-align: 1px; }
.badge.is-archive { color: var(--amber); border-color: rgba(255, 209, 102, 0.5); }

/* ------------------------------------------------------------ MapLibre tweaks */

.maplibregl-map { font: inherit; }
.maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(16, 21, 29, 0.85); color: var(--muted); margin: 0 6px 6px 0; }
.maplibregl-ctrl-attrib a { color: var(--text); }
.maplibregl-ctrl-attrib-button { filter: invert(0.85); }
.maplibregl-ctrl-attrib.maplibregl-compact-show { max-width: min(420px, 80vw); font-size: 11px; }
.maplibregl-canvas { outline: none; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1080px) {
  .brand-name { display: none; }
  .site-pill-name { display: none; }
}

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; row-gap: 7px; gap: 8px; padding-left: 10px; padding-right: 10px; }
  .search { flex: 1 1 120px; min-width: 0; }
  .spacer, .topbar > .seg { display: none; }
  .row2 {
    display: flex;
    align-items: center;
    gap: 8px;
    order: 10;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .row2::-webkit-scrollbar { display: none; }
  .tilt span { display: none; }

  .timeline { flex-wrap: wrap; row-gap: 6px; gap: 8px; padding-left: 10px; padding-right: 10px; }
  .tl-track { order: -1; flex: 1 0 100%; height: 30px; }
  .tl-info { flex: 1; text-align: left; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
  .tl-live { order: 5; flex: 1 0 100%; max-width: none; }
  .tl-sub { overflow: hidden; text-overflow: ellipsis; }

  .side-panel { width: min(100%, 380px); }
  .stage.panel-open .spc-legend { right: 10px; }
  .spc-legend { width: 180px; font-size: 12px; }

  /* Alert details become a bottom sheet. */
  .alert-panel {
    top: auto;
    left: 0;
    right: 0;
    width: auto;
    max-height: 62%;
    border-right: 0;
    border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
  }
  .readout, .stage.alert-open .readout { bottom: 54px; left: 8px; }
}

@media (max-width: 860px) and (orientation: portrait) {
  .panes.layout-2 { grid-template: 1fr 1fr / 1fr; }
}

@media (max-width: 520px) {
  .pane-label { font-size: 12.5px; padding: 3px 7px; }
  .panes.layout-4 .legend, .panes.layout-2 .legend { width: calc(100% - 16px); }
  .panes.layout-4 .legend-units { display: none; }
  .readout { left: 6px; right: 6px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
