/* structural tokens; every colour comes from themes.css */
:root {
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", "Fira Code", Menlo, Consolas, monospace;
  /* one label rail for specs + meters: every value starts at the same x */
  --label-w: 52px;
  --label-gap: 12px;
  --radius: 0px;
  --line-w: 1px;
  --card-shadow: none;
  --header-pad: 0px;
  --well: var(--well);
  --well-soft: var(--well-soft);
  --track-bg: var(--track-bg);
  --crt-opacity: 1;
  --speed: 0.18s;
}

* { box-sizing: border-box; }

/* `hidden` must win over any component display rule (e.g. .op-badge) */
[hidden] { display: none !important; }

/* ------------------------------------------------------------- theme switch */
.theme-slot { display: flex; align-items: center; }
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 25px;
  padding: 0 9px;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--dim);
  background: var(--panel);
  border: var(--line-w) solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color var(--speed), border-color var(--speed);
}
.theme-btn:hover { color: var(--green); border-color: var(--line-hot); }
.theme-btn .ico { width: 12px; height: 12px; vertical-align: 0; }
.theme-btn .theme-name { color: inherit; }

/* ---------------------------------------------------------------- icons */
/* every icon is inline SVG in currentColor — no emoji, no font glyphs */
.ico {
  width: 12px;
  height: 12px;
  display: inline-block;
  vertical-align: -2px;
  fill: currentColor;
  stroke: none;
  flex: none;
  pointer-events: none;
}
.vt .ico { width: 13px; height: 13px; vertical-align: 0; }
.bar .ico { width: 11px; height: 11px; vertical-align: -1px; }
.ghost-btn .ico, .btn .ico { vertical-align: -2px; }
.ghost-btn, .btn { white-space: nowrap;   border-radius: var(--radius);
}
.note-act .ico { width: 10px; height: 10px; vertical-align: 0; }

html, html { background-color: var(--bg); scrollbar-gutter: stable; color-scheme: var(--scheme, dark); }

body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 12% -8%, rgba(var(--green-deep-rgb), 0.10), transparent 60%),
    radial-gradient(900px 500px at 96% 4%, rgba(var(--magenta-rgb), 0.07), transparent 62%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 45%, var(--bg-3));
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#rain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.30;
  pointer-events: none;
  z-index: 0;
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    var(--well-soft) 3px,
    var(--well-soft) 4px
  );
  mix-blend-mode: multiply;
  opacity: calc(var(--crt-opacity) * 1);
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(120% 90% at 50% 0%, transparent 40%, rgba(0, 0, 0, 0.75) 100%);
  opacity: var(--crt-opacity);
}

.wrap {
  position: relative;
  z-index: 3;
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 24px 40px;
}

/* ------------------------------------------------------------------ hero */

.logo {
  font-size: 11px;
  line-height: 1.05;
  margin: 0 0 18px;
  color: var(--green);
  text-shadow: 0 0 14px rgba(var(--accent-rgb), 0.55), 0 0 2px rgba(var(--accent-rgb), 0.9);
  letter-spacing: 0;
  overflow: hidden;
  animation: flicker 7s infinite steps(1);
}

@keyframes flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.72; }
  98% { opacity: 1; }
  99% { opacity: 0.86; }
}

.prompt {
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.prompt .user { color: var(--magenta); }
.prompt .path { color: var(--cyan); }
.prompt .dim { color: var(--dimmer); }
.typed { color: var(--green); text-shadow: var(--glow); }
.caret { color: var(--green); animation: blink 1.05s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* operator-only chrome */
.hero { position: relative; }
.op-badge {
  position: absolute;
  top: 2px;
  right: 0;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--magenta);
  border: 1px solid rgba(var(--magenta-rgb), 0.45);
  padding: 2px 9px;
  box-shadow: 0 0 14px -6px var(--magenta);
  white-space: nowrap;
}
.op-badge::before { content: "●"; margin-right: 6px; font-size: 8px; vertical-align: 1px; }

.tagline {
  color: var(--dim);
  margin: 2px 0 34px;
  font-size: 13px;
  letter-spacing: 0.04em;
}
.tagline b { color: var(--ink); font-weight: 500; }
/* the tagline is filled in by the server; an empty one takes no space */
.tagline:empty { display: none; }

/* --------------------------------------------------------------- readout */

.readout {
  display: grid;
  /* one row of N equal columns, N from data-count */
  grid-template-columns: repeat(6, 1fr);
  border: var(--line-w) solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(6px);
  margin-bottom: 34px;
  position: relative;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}
/* built by JS; reserving the height keeps the page from jumping */
.readout:empty { min-height: 81px; }
.readout::before {
  /* lowercase, as the command is typed */
  content: "df -h /fleet";
  position: absolute;
  top: -9px;
  left: 14px;
  background: var(--bg);
  padding: 0 8px;
  font-size: 10px;
  color: var(--dimmer);
  letter-spacing: 0.1em;
}
.readout[data-count="5"] { grid-template-columns: repeat(5, 1fr); }
.readout[data-count="4"] { grid-template-columns: repeat(4, 1fr); }
.readout[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
.readout[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.ro {
  padding: 16px 14px 14px;
  border-right: 1px dashed var(--line);
  min-width: 0;
}
.ro:last-child { border-right: 0; }
.ro-k {
  display: block;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dimmer);
  margin-bottom: 6px;
}
.ro-v {
  display: block;
  font-size: 20px;
  color: var(--green);
  text-shadow: var(--glow);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ro-v small { font-size: 11px; color: var(--dim); text-shadow: none; }

/* ------------------------------------------------------------ sectionbar */

.sectionbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0 0 18px;
}
.sectionbar .bar { color: var(--green); }
.sectionbar .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.dim { color: var(--dimmer); }

/* search + view toggle */
.search {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--green);
  background: var(--well);
  border: var(--line-w) solid var(--line);
  padding: 5px 9px;
  width: 190px;
  min-width: 120px;
  transition: border-color 0.15s, box-shadow 0.15s, width 0.2s;
  border-radius: var(--radius);
}
.search::placeholder { color: var(--dimmer); letter-spacing: 0.1em; }
.search:focus {
  outline: none;
  border-color: var(--line-hot);
  width: 230px;
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.12);
}
.search::-webkit-search-cancel-button { filter: invert(0.7) sepia(1) hue-rotate(70deg) saturate(4); }

/* search + toggle wrap as one unit */
.fleet-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}
@media (max-width: 560px) {
  .fleet-tools {
    /* alone on its row: field left, toggle hard right */
    flex: 1 1 100%;
    justify-content: space-between;
  }
}

.viewtoggle { display: flex; gap: var(--vt-gap); }
.vt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* exact square, same height as the search field beside it */
  width: 25px;
  height: 25px;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1;
  background: transparent;
  color: var(--dimmer);
  border: var(--line-w) solid var(--line);
  cursor: pointer;
  transition: all 0.15s;
  border-radius: var(--radius);
}
/* both keep all four borders and touch: each stays an exact square */
.vt:hover { color: var(--ink); border-color: var(--line-hot); }
.vt.active {
  color: var(--bg);
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 12px -3px var(--green);
}

/* ------------------------------------------------------------------ grid */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.loading {
  color: var(--dim);
  padding: 48px 4px;
  grid-column: 1 / -1;
  text-align: center;
  max-width: 620px;
  margin-inline: auto;
}
.dots { animation: blink 1.2s steps(1) infinite; }

/* an empty fleet: the rack is drawn with the page's own characters, so every theme recolours it */
.empty { grid-column: 1 / -1; text-align: center; padding: 46px 4px 70px; }
.empty-art {
  display: inline-block;
  margin: 0 0 24px;
  font: inherit;
  font-size: 15px;
  /* tight rows: the bays read as slots and the frame's sides as lines, not as dashes */
  line-height: 1.16;
  letter-spacing: 0;
  text-align: left;
  /* the page's dim shade, not its faintest: in three themes that one is too pale to draw with */
  color: var(--dim);
}
/* the power light: the one thing moving on an otherwise idle page */
.empty-led { color: var(--amber); animation: pulse 2.6s ease-in-out infinite; }
.empty-fact,
.empty-note {
  margin: 0 auto;
  max-width: 56ch;
  font-size: 13px;
}
.empty-fact { color: var(--ink); font-size: 14px; }
.empty-note { margin-top: 6px; color: var(--dim); }
.empty-note a { color: var(--green); }

.card {
  position: relative;
  border: var(--line-w) solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(7px);
  padding: 0 0 14px;
  transition: border-color 0.18s ease, box-shadow 0.25s ease, transform 0.18s ease;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.card:hover {
  border-color: var(--line-hot);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.08), 0 14px 40px -18px rgba(var(--accent-rgb), 0.35);
  transform: translateY(-2px);
}
.card.down { border-color: rgba(var(--down-rgb), 0.4); }
.card.down .status { color: var(--down); }

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.07), transparent 70%);
}
.card-name {
  font-size: 13px;
  color: var(--ink);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.card-name::before { content: "~/"; color: var(--dimmer); }

.status {
  font-size: 11px;
  color: var(--up);
  letter-spacing: 0.12em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.status.up .dot { animation: pulse 2.4s ease-in-out infinite; }
.status.down { color: var(--down); }
/* a down box is red and static, no blink */
.status.down .dot { animation: none; }
.status.unknown { color: var(--dimmer); }
/* linked to a system the hub no longer has: a fault, and static like a down box */
.status.error { color: var(--down); }
.status.error .dot { animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.card-sub {
  padding: 9px 14px 0;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.05em;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.card-sub .sep { color: var(--dimmer); }

.specs {
  margin: 11px 14px 0;
  display: grid;
  grid-template-columns: var(--label-w) 1fr;
  gap: 3px var(--label-gap);
  font-size: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}
.spec { display: contents; }
.specs dt { color: var(--dimmer); letter-spacing: 0.08em; }
.spec-ico { display: none; width: 11px; height: 11px; flex: none; }
/* grid view has no glyph column, but the OS mark is worth showing there too: it rides inside the value */
.os-inline { display: inline-block; width: 11px; height: 11px; vertical-align: -1.5px; margin-right: 4px; color: var(--dim); }
/* the cpu value carries a tip; the anchor is an inline span, since a <dd> stretches past the text */
.spec-tip { cursor: help; }
.spec-tip:hover { color: var(--ink); }
.specs dd { margin: 0; color: var(--ink); }
.specs dd .u { color: var(--dim); font-size: 11px; }

.meters { margin: 12px 14px 0; display: grid; gap: 6px; }
.meter {
  display: grid;
  grid-template-columns: var(--label-w) 1fr 34px;
  gap: 10px var(--label-gap);
  align-items: center;
  font-size: 11px;
}
.meter-k {
  color: var(--dimmer);
  letter-spacing: 0.08em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* segmented track + fill: fills the whole column, keeps the block-terminal look */
.meter-track {
  position: relative;
  height: 11px;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, rgba(var(--accent-rgb), 0.10) 0 5px, transparent 5px 8px),
    var(--track-bg);
  box-shadow: inset 0 0 0 1px var(--line);
}
.meter-track i {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  display: block;
  color: var(--green);
  background: repeating-linear-gradient(90deg, currentColor 0 5px, transparent 5px 8px);
  box-shadow: 0 0 12px -3px currentColor;
  transition: width 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), background-color 0.3s;
}
.meter.warn .meter-track i { color: var(--amber); }
.meter.crit .meter-track i { color: var(--red); }
.meter.off .meter-track i { width: 0 !important; }
.meter.off .meter-track { opacity: 0.45; }

.meter-v {
  color: var(--dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
  /* reserve room for "100%" so the track above never gets squeezed by the digits */
  width: 4.2ch;
  min-width: 4.2ch;
  overflow: hidden;
  white-space: nowrap;
}
.meter-track { min-width: 0; }
.meter.off .meter-k, .meter.off .meter-v { color: var(--dimmer); }

.card-foot {
  margin: 13px 14px 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--dim);
}
.renew { color: var(--dim); }
.renew.warn { color: var(--amber); }
.renew.crit { color: var(--red); text-shadow: 0 0 8px rgba(var(--red-rgb), 0.5); }
.price { color: var(--ink); }
.price .cyc { color: var(--dimmer); }

.card a.jump {
  color: var(--green);
  text-decoration: none;
  font-size: 11px;
  border: var(--line-w) solid var(--line);
  padding: 3px 8px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.card a.jump:hover {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: var(--line-hot);
  box-shadow: var(--glow);
}

.purpose {
  margin: 10px 14px 0;
  font-size: 11px;
  color: var(--dim);
  font-style: italic;
}

/* cpu + load share a row; cpu keeps the label column so its track aligns */
.meter-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; column-gap: 14px; }
.meter-pair .meter:first-child { grid-template-columns: var(--label-w) 1fr 4.2ch; }
.meter-pair .meter:last-child { grid-template-columns: 34px 1fr 5.4ch; }

/* grid view: cards stretch to the tallest, so the footer sinks to the bottom */
.grid:not(.list) .card {
  display: flex;
  flex-direction: column;
}
/* slack goes into a spacer before the footer: margin-top:auto collapses to 0 on a full card */
.grid:not(.list) .card::after {
  content: "";
  order: 1;
  flex: 1 1 auto;
}
.grid:not(.list) .card-foot {
  order: 2;
}

/* after the first paint, refreshes must not replay the entry animation */
.grid.stable .card { animation: none; }

/* ------------------------------------------------------------- list view */

.grid.list {
  grid-template-columns: 1fr;
  gap: 6px;
}
.grid.list .card {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) minmax(200px, 2fr);
  /* foot on its own third row */
  grid-template-areas:
    "top specs"
    "top meters"
    "foot foot";
  align-items: center;
  column-gap: 16px;
  padding: 8px 12px;
  row-gap: 4px;
  min-width: 0;
}
.grid.list .card > * { min-width: 0; }
.grid.list .card-top {
  grid-area: top;
  border-bottom: 0;
  padding: 0;
  background: none;
}
.grid.list .card-sub { display: none; }
.grid.list .purpose { display: none; }
/* two purpose slots: footer row in list view, above the specs in grid view */
.purpose-inline { display: none; color: var(--dim); font-size: 10px; letter-spacing: 0.02em; }
.grid.list .purpose-inline { display: inline; }
.grid.list .specs {
  grid-area: specs;
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
}
/* list view has no room for the words, so each field leads with its glyph */
.grid.list .spec {
  display: inline-flex;
  /* centre, not baseline: the glyph box is taller than the text's x-height */
  align-items: center;
  gap: 5px;
}
.grid.list .specs dt {
  /* the word stays for screen readers, out of the visual row */
  display: inline-flex;
  align-items: center;
  line-height: 0;
  font-size: 0;
  color: var(--dimmer);
}
.grid.list .spec-ico {
  display: inline-block;
  /* the glyph box sits 0.8px low against the line box on both rows */
  transform: translateY(-0.8px);
}
.grid.list .specs dd { color: var(--dim); font-size: 11px; }
.grid.list .spec-tip { display: inline; }
/* list view already leads with the glyph */
.grid.list .os-inline { display: none; }
.grid.list .spec:first-child dd { color: var(--ink); }
.grid.list .meters {
  grid-area: meters;
  margin: 0;
  display: flex;
  gap: 12px;
}
.grid.list .meter-pair { flex: 2 1 0; column-gap: 12px; }
.grid.list .meters > .meter { flex: 1 1 0; }
.grid.list .meter { grid-template-columns: 46px 1fr 30px; gap: 6px; font-size: 10px; }
.grid.list .meter-track { height: 8px; }
.grid.list .card-foot {
  grid-area: foot;
  margin: 0;
  padding: 0;
  border: 0;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-start;
  gap: 2px 10px;
  font-size: 10px;
}
.grid.list .card-foot + .card-foot { display: none; }

@media (max-width: 760px) {
  .grid.list .card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "specs"
      "foot"
      "meters";
    row-gap: 5px;
    min-width: 0;
  }
}

/* phones in list view: drop the bar, keep labels and numbers */
@media (max-width: 620px) {
  .grid.list .card {
    row-gap: 3px;
    padding: 7px 11px;
  }
  .grid.list .meters {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 12px;
    margin: 0;
  }
  .grid.list .meter-pair {
    display: flex;
    flex: 0 0 auto;
    gap: 12px;
    column-gap: 12px;
  }
  .grid.list .meters > .meter,
  .grid.list .meter-pair > .meter {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    font-size: 10px;
  }
  .grid.list .meter-track { display: none; }
  .grid.list .meter-k { width: auto; overflow: visible; }
  .grid.list .meter-v { min-width: 0; }
  .grid.list .card-top { gap: 8px; }
  .grid.list .card-name { font-size: 12px; }
  .grid.list .specs { gap: 1px 12px; }
  .grid.list .specs dd {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .grid.list .card-foot {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: flex-start;
    gap: 2px 10px;
    font-size: 10px;
  }
}

/* small beszel deep-link: only in list view (grid keeps the footer link) */
.ico-chart {
  fill: currentColor;
  display: inline-block;
  vertical-align: -1px;
  flex: none;
}
.jump .ico-chart { margin-right: 5px; }
.hub-mini .ico-chart { vertical-align: 0; }
.hub-mini { display: none; }
.grid.list .hub-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 15px;
  height: 15px;
  margin-left: 6px;
  font-size: 10px;
  line-height: 1;
  color: var(--green);
  border: var(--line-w) solid var(--line);
  text-decoration: none;
  opacity: 0.75;
  transition: opacity 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.grid.list .hub-mini:hover {
  opacity: 1;
  border-color: var(--line-hot);
  box-shadow: 0 0 10px -3px var(--green);
}


/* ------------------------------------------------------------------ yabs */
.yabs-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 16px;
  padding: 0 4px;
  font: inherit;
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--dim);
  background: transparent;
  border: var(--line-w) solid var(--line);
  cursor: pointer;
  opacity: 0.8;
  flex: none;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.yabs-mini:hover {
  opacity: 1;
  color: var(--green);
  border-color: var(--line-hot);
  box-shadow: 0 0 10px -3px var(--green);
}
.yabs-mini .count { font-size: 9px; color: inherit; opacity: 0.85; }
.yabs-mini .ico { width: 10px; height: 10px; vertical-align: 0; }

.modal.m-wide { width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 64px); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head .modal-title { margin-bottom: 10px; }
.modal-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* exact square, same size as the fleet view toggles */
  width: 25px;
  height: 25px;
  padding: 0;
  box-sizing: border-box;
  font: inherit;
  background: transparent;
  border: var(--line-w) solid var(--line);
  color: var(--dim);
  cursor: pointer;
  flex: none;
  transition: all 0.15s;
  border-radius: var(--radius);
}
.modal-x:hover { color: var(--magenta); border-color: var(--magenta); }

.yabs-tabscroll { position: relative; margin-bottom: 12px; }
/* the rule sits on the tab row: the tabs touch it */
.yabs-tabs {
  display: flex;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  border-bottom: 1px solid var(--line);
  padding-right: 4px;
}
.ytab-menuwrap { position: absolute; top: 0; bottom: 0; right: 0; z-index: 20; border-bottom: 1px solid var(--line); background: var(--panel-solid); }
.ytab-more {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 100%;
  padding: 0 8px;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink);
  opacity: 0.62;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  cursor: pointer;
  transition: all 0.15s;
}
.ytab-more:hover,
.ytab-more[aria-expanded="true"] { opacity: 1; color: var(--green); }
.ytab-more .ytab-more-count { font-size: 9px; color: var(--green); }
.ytab-menu {
  position: absolute;
  top: calc(100% + 1px);
  right: 0;
  z-index: 30;
  min-width: 190px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--panel-solid);
  border: var(--line-w) solid var(--line-hot);
  box-shadow: 0 12px 30px -12px #000;
  display: grid;
  scrollbar-width: thin;
  border-radius: var(--radius);
}
.ytab-menu::-webkit-scrollbar { width: 4px; }
.ytab-menu::-webkit-scrollbar-thumb { background: var(--line-hot); }
.ytab-item {
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
  padding: 6px 10px;
  background: transparent;
  color: var(--ink);
  border: 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ytab-item:hover { background: rgba(var(--accent-rgb), 0.08); color: var(--green); }
.ytab-item.active { color: var(--green); }
.ytab-mark { color: var(--dimmer); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }

.yabs-tabs {
  display: flex;
  gap: 2px;
  width: max-content;
  min-width: 100%;
  border-bottom: 1px solid var(--line);
}
.ytab-btn {
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  padding: 5px 9px;
  background: transparent;
  color: var(--ink);
  opacity: 0.62;
  border: 1px solid transparent;
  border-bottom: 0;
  cursor: pointer;
  flex: none;
  transition: all 0.15s;
}
.ytab-btn:hover { opacity: 1; color: var(--ink); border-color: var(--line); }
.ytab-btn.active { opacity: 1; color: var(--green); border-color: var(--line-hot); background: rgba(var(--accent-rgb), 0.06); }
.ytab-btn .dotpulse {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--green);
  vertical-align: 1px;
  box-shadow: 0 0 6px var(--green);
}

.yabs-body {
  height: clamp(240px, 52vh, 500px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  font-size: 11.5px;
}
.yabs-raw {
  margin: 0;
  padding: 0 2px 2px 0;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre;
  overflow-x: auto;
  max-height: 62vh;
}
.yabs-raw::-webkit-scrollbar { width: 6px; height: 6px; }
.yabs-raw::-webkit-scrollbar-thumb { background: var(--line-hot); }

/* ---------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--scrim);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.15s;
}
.modal-backdrop.open { opacity: 1; }
/* the confirm dialog can open above the yabs viewer, so it stacks higher */
#modal.modal-backdrop { z-index: 120; }
.modal {
  width: min(430px, calc(100vw - 32px));
  background: var(--panel-solid);
  border: var(--line-w) solid var(--line-hot);
  box-shadow: 0 0 30px -16px var(--green), inset 0 0 0 1px rgba(var(--accent-rgb), 0.06);
  padding: 18px 20px;
  transform: translateY(6px);
  transition: transform 0.15s;
  border-radius: var(--radius);
}
.modal-backdrop.open .modal { transform: none; }
.modal-title {
  margin: 0 0 8px;
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
}
.modal-body { margin: 0 0 16px; font-size: 12px; line-height: 1.55; color: var(--dim); }
.modal-body strong { color: var(--ink); font-weight: 400; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* keeps its height when there is nothing to delete, so the modal never resizes */
.modal-actions.off { visibility: hidden; }

/* keeps its height with zero runs, so the modal never resizes */
.yabs-tabs { min-height: 25px; }


.yabs-empty {
  margin: auto;
  padding: 20px;
  text-align: center;
  display: grid;
  gap: 7px;
  justify-items: center;
}
.yabs-empty-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}
.yabs-empty-sub {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--dimmer);
  max-width: 30ch;
  line-height: 1.6;
}
.yabs-empty-mark { color: var(--line-hot); opacity: 0.9; }
/* public credit — always visible, unlike the operator footer */
.foot-credit {
  margin-top: 34px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--dimmer);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}
.foot-credit .credit-author { color: var(--dim); }
.foot-credit .credit-sep { color: var(--line-hot); }
.foot-credit a { color: var(--dim); text-decoration: none; border-bottom: 1px dotted var(--line-hot); transition: color 0.15s; }
.foot-credit a:hover { color: var(--green); }
.foot-credit .ico { width: 9px; height: 9px; vertical-align: 0; }

/* ---------------------------------------------------------------- footer */

.foot { margin-top: 48px; border-top: 1px solid var(--line); padding-top: 18px; }
.foot-links { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.ghost-btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--green);
  background: var(--well);
  text-decoration: none;
  border: var(--line-w) solid var(--line);
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: var(--radius);
}
.ghost-btn:hover { border-color: var(--line-hot); background: rgba(var(--accent-rgb), 0.1); box-shadow: var(--glow); }
.small { font-size: 11px; margin: 4px 0; }

.mode-badge {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.16em;
  padding: 2px 7px;
  border: var(--line-w) solid var(--amber);
  color: var(--amber);
  text-transform: uppercase;
  vertical-align: middle;
}
.mode-badge.err { border-color: var(--red); color: var(--red); }

/* interactive bits */
:focus-visible { outline: 1px dashed var(--green); outline-offset: 3px; }

/* ---------------------------------------------------------------- tooltips */
.tip,
.meter.has-tip { cursor: help; }
.meter.has-tip:hover .meter-k { color: var(--ink); }
.meter.has-tip:hover .meter-track { box-shadow: inset 0 0 0 1px var(--line-hot); }

.tippy-box[data-theme~="bsp"] {
  background: var(--tip-bg);
  color: var(--tip-ink, var(--ink));
  border: var(--line-w) solid var(--line-hot);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  box-shadow: 0 0 26px -8px rgba(var(--accent-rgb), 0.65);
}
.tippy-box[data-theme~="bsp"] .tippy-content { padding: 7px 10px; }
.tippy-box[data-theme~="bsp"] .tippy-arrow { color: var(--line-hot); }

/* the arrow anchors to the padding box; a framed theme needs it pushed out by a border-width */
.tippy-box[data-theme~="bsp"][data-placement^="top"] > .tippy-arrow {
  margin-bottom: calc(var(--tip-nudge, var(--line-w)) * -1);
}
.tippy-box[data-theme~="bsp"][data-placement^="bottom"] > .tippy-arrow {
  margin-top: calc(var(--tip-nudge, var(--line-w)) * -1);
}
.tippy-box[data-theme~="bsp"][data-placement^="left"] > .tippy-arrow {
  margin-right: calc(var(--tip-nudge, var(--line-w)) * -1);
}
.tippy-box[data-theme~="bsp"][data-placement^="right"] > .tippy-arrow {
  margin-left: calc(var(--tip-nudge, var(--line-w)) * -1);
}
.tippy-box[data-theme~="bsp"] .tip-dim { color: var(--dim); font-size: 10px; margin-top: 3px; }

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

@media (max-width: 900px) {
  /* flex, not grid (a short last row leaves empty tracks); row separators are border-TOP */
  .readout,
  .readout[data-count] { display: flex; flex-wrap: wrap; }
  .ro { flex: 1 1 calc(100% / 3); border-top: 1px dashed var(--line); }
  .ro:nth-child(-n + 3) { border-top: 0; }
  .ro:nth-child(3n) { border-right: 0; }
}

@media (max-width: 620px) {
  .wrap { padding: 26px 14px 60px; }
  .logo { font-size: 7px; }
  .grid { grid-template-columns: 1fr; }
  .ro { flex-basis: calc(100% / 2); }
  /* two per row here: the 900px rule exempting tiles 1-3 is undone for the third tile */
  .ro:nth-child(-n + 2) { border-top: 0; }
  .ro:nth-child(n + 3) { border-top: 1px dashed var(--line); }
  /* row ends here are every 2nd tile: undo the 900px rule that strips the divider after tile 3 */
  .ro:nth-child(3n) { border-right: 1px dashed var(--line); }
  .ro:nth-child(2n) { border-right: 0; }
  .ro-v { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #rain { display: none; }
}

/* =========================================================
   admin console
   ========================================================= */

.admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
/* fleet panel tools: node picker + search, both inside the panel */
.console-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  flex-wrap: wrap;
}
.console-tools #node-count { margin-left: auto; }
.node-pick {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--green);
  background: var(--well);
  border: var(--line-w) solid var(--line);
  padding: 5px 8px;
  border-radius: var(--radius);
  max-width: 260px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.node-pick:focus {
  outline: none;
  border-color: var(--line-hot);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.12);
}
.node-pick option { background: var(--panel-solid); color: var(--ink); }
.console-tools .search { width: 200px; }
.console-tools .search:focus { width: 240px; }
@media (max-width: 620px) {
  .console-tools .search { flex: 1 1 100%; width: auto; }
  .console-tools .search:focus { width: auto; }
  .console-tools #node-count { margin-left: 0; }
  .node-pick { max-width: none; flex: 1 1 auto; }
}

/* a node chosen from the dropdown flashes once, so the eye finds it */
.nodeform.picked {
  outline: 2px solid var(--line-hot);
  outline-offset: 3px;
  transition: outline-color 0.4s ease;
}

.searchbar { display: flex; align-items: center; gap: 12px; margin: -8px 0 18px; }
.searchbar .search { width: 260px; }
.searchbar .search:focus { width: 320px; }
.admin-title { font-size: 15px; color: var(--green); text-shadow: var(--glow); letter-spacing: 0.1em; margin: 0 0 6px; }
.admin-sub { font-size: 12px; color: var(--dim); margin: 0; }

.rowbtns { display: flex; gap: 8px; flex-wrap: wrap; }

/* visibility checklist: tick what the public page may show */
.vislist { display: grid; gap: 2px; }
.visrow {
  display: grid;
  grid-template-columns: auto minmax(140px, 0.9fr) 2fr;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: var(--line-w) solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.visrow:hover { border-color: var(--line); background: var(--well); }
.visrow input { accent-color: var(--green); width: 13px; height: 13px; margin: 0; cursor: pointer; }
/* matches the field labels above (muted, uppercase); a ticked row lifts to ink */
.vislabel {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--dim);
  text-transform: uppercase;
}
.visrow:has(input:checked) .vislabel { color: var(--ink); }
.vishint {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  text-transform: none;
  letter-spacing: 0;
}
@media (max-width: 620px) {
  .visrow { grid-template-columns: auto 1fr; }
  .vishint { grid-column: 2; }
}

/* logo source switch — two states, one visible field */
.modebar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.radio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: var(--dim);
  cursor: pointer;
}
.radio input {
  appearance: none;
  width: 12px;
  height: 12px;
  margin: 0;
  border: var(--line-w) solid var(--line-hot);
  border-radius: calc(var(--radius) / 2);
  background: transparent;
  cursor: pointer;
}
.radio input:checked {
  border-color: var(--green);
  box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 6px var(--green);
}
.radio:hover { color: var(--ink); }

/* the preview is the real art, drawn by the server with the same renderer */
.logo-preview {
  margin: 0;
  padding: 14px;
  font-size: 11px;
  line-height: 1.05;
  color: var(--green);
  background: var(--well);
  border: var(--line-w) solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow-x: auto;
  white-space: pre;
  tab-size: 4;
}
.logo-preview:empty { display: none; }
html[data-theme="paper"] .logo-preview { color: var(--ink); }

/* border always present (transparent when idle): marking the current page must not nudge neighbours */
.console-nav { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.navlink {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 25px;
  padding: 0 9px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  text-decoration: none;
  color: var(--dim);
  border: var(--line-w) solid transparent;
  border-radius: var(--radius);
  transition: color var(--speed), border-color var(--speed);
}
.navlink:hover { color: var(--green); border-color: var(--line); }
.navlink[aria-current="page"] { color: var(--ink); border-color: var(--line-hot); }
.navlink .ico { width: 10px; height: 10px; }
.btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: transparent;
  color: var(--green);
  border: var(--line-w) solid var(--line);
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--line-hot); background: rgba(var(--accent-rgb), 0.1); box-shadow: var(--glow); }
.btn:disabled { opacity: 0.45; cursor: progress; box-shadow: none; background: transparent; }
.btn.danger { color: var(--red); border-color: rgba(var(--red-rgb), 0.35); }
.btn.danger:hover { background: rgba(var(--red-rgb), 0.12); border-color: var(--red); box-shadow: none; }
.btn.primary { border-color: var(--line-hot); }

.panel {
  border: var(--line-w) solid var(--line);
  background: var(--panel);
  padding: 16px;
  margin-bottom: 18px;
  position: relative;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}
.panel::before {
  content: attr(data-title);
  position: absolute;
  top: -9px;
  left: 12px;
  background: var(--bg);
  padding: 0 8px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.kv { display: flex; gap: 10px; font-size: 12px; margin: 4px 0; flex-wrap: wrap; }
.kv span:first-child { color: var(--dimmer); min-width: 96px; }
/* tooltip sections: one per volume, so a multi-disk host stays readable */
.tip-sec + .tip-sec {
  margin-top: 7px;
  padding-top: 7px;
  border-top: var(--line-w) solid var(--line);
}
.tip-name {
  display: block;
  margin-bottom: 2px;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  color: var(--dimmer);
}

.kvlink {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--green);
  text-decoration: none;
  border-bottom: 1px dotted var(--line-hot);
  transition: color var(--speed), border-color var(--speed);
}
.kvlink:hover { color: var(--ink); border-bottom-color: var(--green); }
.kvlink .ico { width: 10px; height: 10px; }

.hintbox {
  border-left: 2px solid var(--amber);
  background: rgba(var(--amber-rgb), 0.07);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--amber);
  margin-top: 12px;
  white-space: pre-wrap;
  border-radius: var(--radius);
}
.hintbox code { color: var(--ink); }

.nodeform {
  border: var(--line-w) solid var(--line);
  background: var(--panel);
  padding: 14px 16px 16px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}
.nodeform.dirty { border-color: var(--amber); }
/* no dead space under the final card in the fleet list */
.nodeform:last-child { margin-bottom: 0; }
.nf-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.nf-title { font-size: 13px; color: var(--ink); flex: 1; }
.nf-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dimmer); }
.field input, .field select, .field textarea {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--well);
  border: var(--line-w) solid var(--line);
  padding: 7px 8px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field select option,
.field select optgroup {
  background-color: var(--panel-solid);
  color: var(--ink);
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--line-hot);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.15);
}
.field.wide { grid-column: 1 / -1; }
.field textarea { min-height: 62px; resize: vertical; }
.field.check { flex-direction: row; align-items: center; gap: 8px; white-space: nowrap; }
.field.check input { width: auto; flex: none; }
.field.check label { text-transform: none; letter-spacing: 0; font-size: 11px; color: var(--dim); white-space: nowrap; }

/* spend-currency panel: the two rate sources, and the manual-rates modal */
/* status text and its action sit together; only the modal's buttons go right */
.fxrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fxmodal {
  width: min(560px, 92vw);
  max-height: 84vh;
  padding: 18px;
  font-family: var(--mono);
  color: var(--ink);
  background: var(--panel-solid);
  border: var(--line-w) solid var(--line);
}
.fxmodal::backdrop { background: rgba(0, 0, 0, 0.62); }
.fxmodal-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
}
.fxgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin: 12px 0;
  max-height: 46vh;
  overflow-y: auto;
}
.fxrate { display: flex; flex-direction: column; gap: 3px; }
.fxrate span { font-size: 10px; letter-spacing: 0.1em; color: var(--dimmer); }
.fxrate input {
  width: 100%;
  padding: 6px 7px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--well);
  border: var(--line-w) solid var(--line);
}
/* the pinned base cell: same box as an input, but nothing to focus or select */
.fxval {
  padding: 6px 7px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dimmer);
  background: var(--well);
  border: var(--line-w) solid var(--line);
  cursor: default;
  user-select: none;
}
.fxrate input:focus { outline: none; border-color: var(--line-hot); }
.fxmodal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* private notes: existing ones are read-only items with stamps, one input for new */
/* yabs block in the console: one compact line, panel on demand */
/* ---------------------------------------------- beszel details + overrides */
.spec-toggle {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 4px 7px;
  background: transparent;
  color: var(--dim);
  border: var(--line-w) solid var(--line);
  cursor: pointer;
  transition: all 0.15s;
}
.spec-toggle:hover { color: var(--green); border-color: var(--line-hot); }
.spec-toggle.open { color: var(--green); border-color: var(--line-hot); }
.spec-toggle .sp-flag {
  margin-left: 6px;
  padding: 1px 5px;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--accent);
  border: var(--line-w) solid var(--line-hot);
}
.spec-panel {
  margin-top: 9px;
  padding: 11px 12px;
  border: var(--line-w) solid var(--line);
  background: var(--well);
}
.sp-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 20px; }
.sp-h {
  margin: 0 0 7px;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
}
.sp-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--dim);
  padding: 2px 0;
}
.sp-row > span:first-child { color: var(--dimmer); flex: none; }
/* last synced specs: nothing left to refresh them until a system is linked again */
.sp-row.dim, .sp-row.dim > span:first-child { color: var(--dimmer); }
.sp-val { text-align: right; overflow-wrap: anywhere; }
.sp-over { display: grid; gap: 7px; align-content: start; }
.sp-note { margin: 2px 0 0; font-size: 10px; color: var(--dimmer); line-height: 1.5; }
@media (max-width: 760px) {
  .sp-cols { grid-template-columns: minmax(0, 1fr); }
}

.yabs-bar { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.yabs-bar .note-act { white-space: nowrap; flex: none; }
.yabs-bar .note-act[disabled] { opacity: 0.35; cursor: default; }
.yabs-bar .note-act[disabled]:hover { color: var(--dim); border-color: var(--line); }
.yabs-count { font-size: 10px; letter-spacing: 0.06em; color: var(--dimmer); white-space: nowrap; }
.yabs-adder { margin-top: 8px; display: grid; gap: 8px; }
.yabs-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.yabs-input { width: 100%; min-height: 96px; font-size: 10.5px; resize: vertical; }
.yabs-date { width: 150px; }
.notes { display: grid; gap: 7px; margin-bottom: 8px; }
.notes:empty { display: none; }
.note-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  border: var(--line-w) solid var(--line);
  border-left: 2px solid var(--line-hot);
  background: var(--well-soft);
  padding: 8px 10px;
}
.note-main { flex: 1; min-width: 0; }
.note-body {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.note-edit { width: 100%; min-height: 46px; font-size: 11.5px; }
.note-side { display: flex; align-items: center; gap: 8px; flex: none; }
.note-when {
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--dimmer);
  white-space: nowrap;
}
.note-act {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 4px 7px;
  background: transparent;
  color: var(--dim);
  border: var(--line-w) solid var(--line);
  cursor: pointer;
  transition: all 0.15s;
}
.note-act:hover { color: var(--green); border-color: var(--line-hot); }
.note-act.danger:hover { color: var(--magenta); border-color: var(--magenta); }
.note-new { display: flex; gap: 8px; align-items: flex-start; }
.note-new-text { flex: 1; min-height: 46px; font-size: 11.5px; }
.note-new [data-act="add-note"] { flex: none; }

.login-wrap { max-width: 400px; margin: 12vh auto 0; }
.login-wrap .panel { padding: 22px; }

.login-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
  margin: 18px 0 7px;
}
.login-row { display: flex; gap: 8px; align-items: stretch; }
.login-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--green);
  background: var(--well);
  border: var(--line-w) solid var(--line);
  padding: 9px 11px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-row input::placeholder { color: var(--dimmer); letter-spacing: 0.16em; }
.login-row input:focus {
  outline: none;
  border-color: var(--line-hot);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.15), 0 0 18px -6px rgba(var(--accent-rgb), 0.55);
}
.login-row .btn { white-space: nowrap; }
.err { color: var(--red); font-size: 12px; margin-top: 10px; min-height: 16px; }
/* a code the runtime does not recognise, flagged while it is being typed */
.nodeform input.bad { border-color: var(--red); }

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-solid);
  border: var(--line-w) solid var(--line-hot);
  color: var(--green);
  padding: 9px 16px;
  font-size: 12px;
  letter-spacing: 0.06em;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 10;
  box-shadow: 0 0 22px -6px rgba(var(--accent-rgb), 0.6);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --------------------------------------------------------------- settings */
.settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 14px;
  align-items: end;
}
/* outside the field grid, so it needs the grid's 12px gap, not the 2px token */
.settings-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.settings-hint { font-size: 10px; letter-spacing: 0.06em; color: var(--dim); }

/* ------------------------------------------------------- onboarding (settings) */
/* deliberately unlike the other panels: a one-off action with an accent border, a kicker and its own row */
.onboard {
  border-color: rgba(var(--accent-rgb), 0.4);
  background:
    linear-gradient(115deg, rgba(var(--accent-rgb), 0.07), transparent 55%),
    var(--panel);
}
.onboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.onboard-text { min-width: 0; flex: 1 1 320px; }
.onboard-kicker {
  margin: 0 0 6px;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}
.onboard-title {
  margin: 0 0 8px;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text);
}
.onboard-copy { margin: 0; font-size: 12.5px; line-height: 1.65; color: var(--dim); }
.onboard-note {
  margin: 14px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--line-hot);
  font-size: 11px;
  line-height: 1.5;
  color: var(--dimmer);
}
.onboard-note code { color: var(--accent); }
.onboard-btn { flex: 0 0 auto; }

/* ------------------------------------------------------------------- wizard */
/* the modal is a column: header + steps stay put, the active step scrolls */
/* fixed height: the modal must not resize between steps */
.modal.wiz {
  width: min(560px, calc(100vw - 32px));
  height: min(86vh, 560px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.wiz-head { flex: 0 0 auto; }
.wiz-sub { margin: 0 0 4px; }

.wiz-steps {
  display: flex;
  gap: 6px;
  margin: 14px 0 16px;
  padding: 0;
  list-style: none;
  flex: 0 0 auto;
}
.wiz-steps li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dimmer);
  border-top: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
}
.wiz-steps li span {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border: 1px solid var(--line-hot);
  border-radius: 50%;
  font-size: 8.5px;
}
.wiz-steps li.on { color: var(--accent); border-top-color: var(--accent); }
.wiz-steps li.on span { color: var(--accent); border-color: var(--accent); }
.wiz-steps li.done { color: var(--dim); }
.wiz-steps li.done span { color: var(--dim); border-color: var(--line-hot); }

.wiz-step {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-right: 4px;
}
.wiz-step::-webkit-scrollbar { width: 8px; }
.wiz-step::-webkit-scrollbar-thumb { background: var(--line-hot); border-radius: 8px; }

.wiz-copy { margin: 0 0 14px; font-size: 12.5px; line-height: 1.6; color: var(--dim); }
.wiz-copy code, .wiz-copy b { color: var(--accent); font-size: 12px; }
.wiz-label {
  display: block;
  margin: 0 0 6px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
}
.wiz-step input:not([type="checkbox"]),
.wiz-step select {
  width: 100%;
  margin-bottom: 14px;
  padding: 9px 11px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg);
  border: var(--line-w) solid var(--line);
  border-radius: var(--radius);
}
.wiz-step input:focus,
.wiz-step select:focus { outline: none; border-color: var(--accent); }
.wiz-step select { cursor: pointer; }

/* a checkbox is a checkbox: no form width */
.wiz-step input[type="checkbox"] {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* helper lines carry a rule down the left, set apart from the fields */
.wiz-aside {
  margin: -4px 0 14px;
  padding: 1px 0 1px 10px;
  border-left: 2px solid var(--line-hot);
  font-size: 11px;
  line-height: 1.5;
  color: var(--dimmer);
}
.wiz-aside code { color: var(--dim); }
/* result bar: green, tick first, sits at the top of the modal once the work is done */
.wiz-alert {
  flex: 0 0 auto;
  margin: 10px 0 0;
  padding: 7px 11px;
  font-size: 11.5px;
  line-height: 1.45;
  border-radius: var(--radius);
  border: 1px solid var(--line-hot);
  color: var(--dim);
}
.wiz-alert.success {
  color: var(--up);
  border-color: rgba(var(--up-rgb), 0.5);
  background: rgba(var(--up-rgb), 0.09);
}
.wiz-alert.success b { color: var(--up); font-weight: 600; }
.wiz-alert.loading { color: var(--dim); background: var(--bg); }
.wiz-tick { color: var(--up); font-weight: 700; margin-right: 2px; }
/* three pulsing dots while the hub is being written to */
.wiz-dots::after {
  content: "";
  animation: wiz-dots 1.1s steps(4, end) infinite;
}
@keyframes wiz-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}
.wiz-who {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: 10.5px;
  color: var(--accent);
}
.wiz-count { margin: 8px 0 0; font-size: 10.5px; color: var(--dimmer); }
.wiz-count b { font-weight: 400; color: var(--dim); }

.wiz-pw { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.wiz-pw input { margin-bottom: 0; }
.wiz-pw .wiz-link { flex: 0 0 auto; }

.wiz-systems-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.wiz-systems-head .wiz-label { margin: 0; }
.wiz-search { margin-bottom: 8px !important; }
.wiz-list {
  flex: 1 1 auto;
  min-height: 96px;
  overflow-y: auto;
  border: var(--line-w) solid var(--line);
  border-radius: var(--radius);
}
.wiz-sys {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.wiz-sys:last-child { border-bottom: 0; }
.wiz-sys:hover { background: rgba(var(--accent-rgb), 0.06); }
.wiz-sys-name { flex: 1 1 auto; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiz-sys-meta { flex: 0 0 auto; font-size: 10px; color: var(--dimmer); }
.wiz-empty { margin: 12px; }
.wiz-count { margin: 8px 0 0; }

.wiz-env {
  margin: 0 0 12px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--accent);
  background: var(--bg);
  border: var(--line-w) solid var(--line-hot);
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-all;
}

.wiz-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: auto 0 2px;
  padding-top: 14px;
  flex: 0 0 auto;
}
.wiz-hint { font-size: 10.5px; color: var(--dimmer); display: block; margin-top: 6px; }
.wiz-link {
  padding: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  background: none;
  border: 0;
  border-bottom: 1px dotted var(--line-hot);
  cursor: pointer;
}
.wiz-link:hover { color: var(--accent); border-bottom-color: var(--accent); }
#wiz-err-1, #wiz-err-2, #wiz-err-3 { margin: 0 0 10px; }
