/* ============================================================
   Mesh Commander — Meshtastic-green console on deep slate
   Palette: Meshtastic Client Design Standards v1.4 (dark scheme)
   Type: Space Grotesk (UI) / JetBrains Mono (data)
   Signature motif: segmented LED bargraphs
   ============================================================ */

@font-face {
  font-family: "Space Grotesk";
  src: url("/static/fonts/space-grotesk-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/static/fonts/space-grotesk-latin-500-normal.woff2") format("woff2");
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/static/fonts/space-grotesk-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-display: swap;
}

:root {
  --bg: #0F1017;            /* Neutral 950 */
  --surface: #1A1B26;       /* Neutral 900 */
  --raised: #242533;        /* surfaceContainer */
  --line: #303245;          /* Neutral Variant 800 */
  --line-soft: #1D1E2B;     /* Neutral Variant 900 */
  --text: #ECEDF3;          /* Neutral 100 */
  --muted: #9698B0;         /* Neutral Variant 400 */
  --faint: #5C5E78;         /* Neutral Variant 600 */
  --accent: #67EA94;        /* Green 500 — Meshtastic brand accent */
  --accent-hi: #8FF0B2;     /* Green 400 */
  --accent-dim: rgba(103, 234, 148, 0.13);
  --ok: #3FB86D;            /* Green 600 — Success */
  --warn: #E8A33E;          /* Warning */
  --err: #E05252;           /* Error 500 */
  --info: #5C6BC0;          /* Info */
  --link: #9BA8E0;          /* Blue 400 — Link */
  --ui: "Space Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --rail-w: 76px;
  --topbar-h: 58px;
  --r: 10px;
  --r-sm: 7px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-dim); color: var(--accent-hi); }

button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- segmented LED bargraph (signature) ---------- */
.seg { display: inline-flex; gap: 2px; align-items: center; }
.seg i {
  width: 5px; height: 11px; border-radius: 1.5px;
  background: var(--line); flex: none;
}
.seg i.on { background: var(--accent); box-shadow: 0 0 5px rgba(103,234,148,.45); }
.seg.ok i.on { background: var(--ok); box-shadow: 0 0 5px rgba(63,184,109,.4); }
.seg.warn i.on { background: var(--warn); box-shadow: 0 0 5px rgba(232,163,62,.4); }
.seg.err i.on { background: var(--err); box-shadow: 0 0 5px rgba(224,82,82,.4); }
.seg-label {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-right: 6px;
}
.seg-val { font-family: var(--mono); font-size: 12.5px; color: var(--text); margin-left: 6px; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; height: 100dvh; }

.rail {
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 4px;
}
.rail .brand {
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  color: var(--accent); letter-spacing: .02em;
  padding: 8px 0 14px; text-align: center; line-height: 1.15;
}
.rail .brand small { display: block; color: var(--faint); font-weight: 400; font-size: 9px; letter-spacing: .18em; }
.navbtn {
  width: 60px; padding: 9px 0 7px; border: 0; background: transparent;
  border-radius: var(--r-sm); cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: background .12s, color .12s;
}
.navbtn svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.navbtn span { font-size: 11px; letter-spacing: .04em; }
.navbtn:hover { color: var(--text); background: var(--raised); }
.navbtn.active { color: var(--accent); background: var(--accent-dim); }
.rail .spacer { flex: 1; }

.main { display: flex; flex-direction: column; min-width: 0; }

/* ---------- topbar: the link faceplate ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px;
}
.linklamp {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--faint); flex: none;
}
.linklamp.connected { background: var(--ok); box-shadow: 0 0 8px rgba(63,184,109,.7); animation: lamp 2.4s ease-in-out infinite; }
.linklamp.connecting { background: var(--warn); animation: lampfast .7s ease-in-out infinite; }
.linklamp.error { background: var(--err); }
@keyframes lamp { 50% { opacity: .55; } }
@keyframes lampfast { 50% { opacity: .3; } }

.linkinfo { min-width: 0; }
.linkinfo .l1 { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linkinfo .l2 { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.topbar .meters { display: flex; gap: 18px; margin-left: auto; align-items: center; }
.topbar .user { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

.btn {
  background: var(--raised); border: 1px solid var(--line);
  color: var(--text); border-radius: var(--r-sm);
  padding: 7px 14px; cursor: pointer; font-size: 14.5px; font-weight: 500;
  transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0F1017; font-weight: 700; }
.btn.primary:hover { background: var(--accent-hi); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- content ---------- */
.content { flex: 1; overflow-y: auto; padding: 18px; }
.view { display: none; max-width: 1180px; margin: 0 auto; }
.view.active { display: block; }
.view-title { font-size: 21px; font-weight: 700; margin: 2px 0 14px; letter-spacing: .01em; }
.view-title small { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 10px; }

.card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 16px;
}
.card + .card { margin-top: 14px; }
.card h3 {
  margin: 0 0 12px; font-size: 13px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .12em;
}

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- connect panel ---------- */
.connect-grid { display: grid; grid-template-columns: 1fr 340px; gap: 14px; }
.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: 5px;
}
.field input[type=text], .field input[type=password], .field input[type=number],
.field select, .field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 9px 11px; color: var(--text);
  font-family: var(--mono); font-size: 14.5px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); outline: none;
}
.field .hint { font-size: 12.5px; color: var(--faint); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: end; }
.row .field { flex: 1; margin-bottom: 0; }

.recent-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid transparent;
}
.recent-item:hover { background: var(--raised); border-color: var(--line); }
.recent-item .who { flex: 1; min-width: 0; }
.recent-item .who b { display: block; font-size: 14.5px; font-weight: 500; }
.recent-item .who span { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.recent-item .forget { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 15px; padding: 4px; }
.recent-item .forget:hover { color: var(--err); }

/* ---------- messages ---------- */
.msg-layout { display: grid; grid-template-columns: 230px 1fr; gap: 14px; height: calc(100dvh - var(--topbar-h) - 96px); align-items: stretch; }
.msg-layout > .card { height: 100%; min-height: 0; }
.chanlist { overflow-y: auto; }
.chan-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 11px; border: 0; background: transparent; text-align: left;
  border-radius: var(--r-sm); cursor: pointer; color: var(--muted); font-size: 14.5px;
}
.chan-item:hover { background: var(--raised); color: var(--text); }
.chan-item.active { background: var(--accent-dim); color: var(--accent-hi); font-weight: 500; }
.chan-item .idx { font-family: var(--mono); font-size: 11.5px; color: var(--faint); width: 22px; flex: none; }
.chan-item .unread {
  margin-left: auto; background: var(--accent); color: #0F1017;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  border-radius: 8px; padding: 1px 6px;
}
.chan-group { font-size: 11.5px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .12em; margin: 12px 11px 5px; }

.msg-pane { display: flex; flex-direction: column; min-width: 0; }
.msg-scroll { flex: 1; overflow-y: auto; padding: 4px 6px 12px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 76%; align-self: flex-start; }
.bubble.tx { align-self: flex-end; }
.bubble .meta { font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin: 0 4px 3px; display: flex; gap: 8px; }
.bubble.tx .meta { justify-content: flex-end; }
.bubble .body {
  background: var(--raised); border: 1px solid var(--line-soft);
  border-radius: 12px 12px 12px 4px; padding: 8px 12px; font-size: 15px;
  word-wrap: break-word;
}
.bubble.tx .body {
  background: var(--accent-dim); border-color: rgba(103,234,148,.25);
  border-radius: 12px 12px 4px 12px;
}
.bubble .sig { font-family: var(--mono); font-size: 11px; color: var(--faint); margin: 3px 4px 0; }
.ack { font-family: var(--mono); }
.ack.pending { color: var(--warn); }
.ack.delivered { color: var(--ok); }
.ack.failed { color: var(--err); }

.composer { display: flex; gap: 9px; padding-top: 10px; border-top: 1px solid var(--line-soft); align-items: end; }
.composer textarea {
  flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 11px; resize: none; height: 42px; max-height: 110px; font-size: 15px;
  font-family: var(--ui);
}
.composer textarea:focus { border-color: var(--accent); outline: none; }
.bytecount { font-family: var(--mono); font-size: 11.5px; color: var(--faint); align-self: center; width: 58px; text-align: right; }
.bytecount.over { color: var(--err); font-weight: 700; }

/* ---------- nodes ---------- */
.node-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.node-card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 13px 14px; }
.node-card.self { border-color: rgba(103,234,148,.4); }
.node-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.shortbadge {
  font-family: var(--mono); font-weight: 700; font-size: 14px;
  background: var(--raised); border: 1px solid var(--line);
  color: var(--accent); border-radius: 6px; padding: 5px 8px; flex: none;
  min-width: 46px; text-align: center;
}
.node-head .names { min-width: 0; flex: 1; }
.node-head .names b { display: block; font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-head .names span { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.node-meters { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }
.node-meters .mrow { display: flex; align-items: center; }
.node-foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.node-stats { display: flex; gap: 12px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; border: 1px solid var(--line); color: var(--muted); border-radius: 4px; padding: 1px 5px; }
.tag.mqtt { color: var(--info); border-color: rgba(92,107,192,.4); }

/* ---------- map (full-bleed below topbar, beside rail) ---------- */
.content.fullbleed { padding: 0; overflow: hidden; }
.content.fullbleed .view.active { max-width: none; margin: 0; height: 100%; }
#view-map { height: 100%; }
#map { height: 100%; background: var(--surface); }
.map-missing { padding: 40px; text-align: center; color: var(--muted); }
.leaflet-container { background: #0F1017; font-family: var(--ui); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--raised); color: var(--text);
  border: 1px solid var(--line); box-shadow: 0 6px 22px rgba(0,0,0,.5);
}
.leaflet-popup-content-wrapper { border-radius: var(--r-sm); }
.leaflet-popup-content a { color: var(--link); }
.leaflet-tooltip.nodetip {
  background: var(--raised); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-sm); font-family: var(--ui); font-size: 13.5px;
  box-shadow: 0 4px 14px rgba(0,0,0,.5); padding: 7px 10px;
}
.leaflet-tooltip.nodetip::before { display: none; }
.leaflet-bar a { background: var(--raised); color: var(--text); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--surface); color: var(--accent); }
.leaflet-control-attribution { background: rgba(15,16,23,.7) !important; color: var(--faint) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.nodepin {
  font-family: var(--mono); font-weight: 700; font-size: 12px;
  background: var(--surface); color: var(--accent);
  border: 1.5px solid var(--accent); border-radius: 6px; padding: 2px 5px;
  white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.6); cursor: pointer;
}

/* ---------- configure ---------- */
.cfg-layout { display: grid; grid-template-columns: 230px 1fr; gap: 14px; align-items: start; }
.cfg-form { max-width: 660px; }
.cfg-field { display: grid; grid-template-columns: 1fr 230px; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.cfg-field:last-of-type { border-bottom: 0; }
.cfg-field .fname { font-size: 14.5px; }
.cfg-field .fname code { font-family: var(--mono); font-size: 11.5px; color: var(--faint); display: block; }
.cfg-field input[type=text], .cfg-field input[type=number], .cfg-field select {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 7px 10px; font-family: var(--mono); font-size: 13.5px;
}
.cfg-field input:focus, .cfg-field select:focus { border-color: var(--accent); outline: none; }
.cfg-field.dirty .fname { color: var(--accent-hi); }

.toggle { position: relative; width: 42px; height: 23px; flex: none; justify-self: end; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle .tk {
  position: absolute; inset: 0; background: var(--line); border-radius: 12px;
  transition: background .14s; pointer-events: none;
}
.toggle .tk::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px;
  border-radius: 50%; background: var(--muted); transition: transform .14s, background .14s;
}
.toggle input:checked + .tk { background: var(--accent); }
.toggle input:checked + .tk::after { transform: translateX(19px); background: #0F1017; }
.toggle input:focus-visible + .tk { outline: 2px solid var(--accent); outline-offset: 2px; }

.savebar { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.savebar .note { font-size: 13px; color: var(--faint); }

/* ---------- channels ---------- */
.chan-row {
  display: grid; grid-template-columns: 40px 1fr auto auto; gap: 12px;
  align-items: center; padding: 13px 6px; border-bottom: 1px solid var(--line-soft);
}
.chan-row:last-child { border-bottom: 0; }
.chan-row .slot { font-family: var(--mono); font-size: 13px; color: var(--faint); }
.chan-row .cname b { font-size: 15px; }
.chan-row .cname span { font-family: var(--mono); font-size: 11.5px; color: var(--faint); display: block; }
.rolepill { font-family: var(--mono); font-size: 11px; letter-spacing: .07em; border-radius: 4px; padding: 2px 7px; }
.rolepill.PRIMARY { background: var(--accent-dim); color: var(--accent-hi); }
.rolepill.SECONDARY { background: rgba(92,107,192,.13); color: var(--info); }
.rolepill.DISABLED { background: var(--raised); color: var(--faint); }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(5,7,11,.72);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px;
}
.modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 20px; width: 480px; max-width: 100%;
  max-height: 88dvh; overflow-y: auto;
}
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- toast / traceroute ---------- */
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  background: var(--raised); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--r-sm); padding: 10px 14px; font-size: 14px; max-width: 360px;
  box-shadow: 0 6px 22px rgba(0,0,0,.45); animation: slidein .18s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

.tr-route { font-family: var(--mono); font-size: 13.5px; line-height: 1.9; }
.tr-route .hop { color: var(--accent); }

/* ---------- tables (users) ---------- */
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 11.5px; font-weight: 700; color: var(--faint);
  text-transform: uppercase; letter-spacing: .1em; padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
table.list td { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); font-size: 14.5px; }
table.list td.mono { font-size: 13px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 18px; }
.login-card {
  width: 380px; max-width: 100%; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 30px 28px;
}
.login-card .mark {
  font-family: var(--mono); font-weight: 700; color: var(--accent);
  font-size: 17px; letter-spacing: .02em; margin-bottom: 2px;
}
.login-card .mark small { display: block; color: var(--faint); font-weight: 400; font-size: 10px; letter-spacing: .22em; margin-top: 2px; }
.login-card .lampline { display: flex; gap: 4px; margin: 16px 0 20px; }
.login-card .lampline i { height: 3px; flex: 1; background: var(--line); border-radius: 2px; }
.login-card .lampline i:nth-child(-n+3) { background: var(--accent); box-shadow: 0 0 6px rgba(103,234,148,.5); }
.login-err { background: rgba(224,82,82,.12); border: 1px solid rgba(224,82,82,.4); color: var(--err); border-radius: var(--r-sm); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }

/* ---------- responsive ---------- */
.bottomnav { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--line);
    z-index: 50; padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
  }
  .bottomnav .navbtn { flex: 1; width: auto; padding: 6px 0 4px; }
  .content { padding: 13px 12px calc(76px + env(safe-area-inset-bottom)); }
  .connect-grid, .cfg-layout { grid-template-columns: 1fr; }
  .msg-layout { grid-template-columns: 1fr; height: auto; }
  .msg-pane { height: calc(100dvh - var(--topbar-h) - 250px); min-height: 320px; }
  .chanlist { max-height: 140px; }
  .topbar .meters .seg-label { display: none; }
  .topbar .user { display: none; }
  .bubble { max-width: 88%; }
  .cfg-field { grid-template-columns: 1fr; gap: 6px; }
  .toggle { justify-self: start; }
  .content.fullbleed { padding: 0 0 calc(64px + env(safe-area-inset-bottom)); }
  .chan-row { grid-template-columns: 30px 1fr auto; }
  .chan-row .roles-col { display: none; }
  .node-filters { flex-wrap: wrap; }
  .pkt-wrap { overflow-x: auto; }
}

/* ---------- brand logo ---------- */
.rail .brand img, .login-card .mark img { display: block; width: 44px; height: 44px; margin: 0 auto 6px; }
.login-card .mark img { width: 56px; height: 56px; }

/* ---------- avatars / node circles ---------- */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 12px;
  background: var(--raised); color: var(--text); border: 1.5px solid var(--line);
  overflow: hidden; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }
.topbar .userbox { display: flex; align-items: center; gap: 9px; }

/* ---------- chat bubbles: node-color tint (dimmed), text stays onSurface ---------- */
.msg-row { display: flex; gap: 9px; align-items: flex-end; }
.msg-row.tx { justify-content: flex-end; }
.msg-row .avatar { margin-bottom: 16px; cursor: pointer; }
.bubble .body { position: relative; }
.bubble.rx .body {
  background: color-mix(in srgb, var(--node-color, var(--raised)) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--node-color, var(--line)) 35%, var(--line-soft));
}
.bubble .meta .who { color: var(--node-color, var(--muted)); font-weight: 700; cursor: pointer; }
.bubble .react-btn {
  position: absolute; top: -10px; right: -8px; display: none;
  background: var(--raised); border: 1px solid var(--line); border-radius: 10px;
  font-size: 11px; padding: 1px 7px; cursor: pointer; color: var(--muted);
}
.bubble:hover .react-btn { display: block; }
.bubble .react-btn:hover { color: var(--accent); border-color: var(--accent); }
.reactions { display: flex; gap: 4px; margin: 3px 4px 0; flex-wrap: wrap; }
.reaction {
  background: var(--raised); border: 1px solid var(--line); border-radius: 10px;
  font-size: 13px; padding: 1px 7px; cursor: default;
}
.reaction .cnt { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 3px; }
.emoji-pick {
  display: flex; gap: 4px; flex-wrap: wrap; position: absolute; z-index: 70;
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.55);
}
.emoji-pick button { background: none; border: 0; font-size: 18px; padding: 4px 6px; cursor: pointer; border-radius: 5px; }
.emoji-pick button:hover { background: var(--accent-dim); }
.chan-item .ro { font-family: var(--mono); font-size: 10px; color: var(--info); border: 1px solid rgba(92,107,192,.4); border-radius: 4px; padding: 0 4px; margin-left: 6px; }

/* ---------- nodes: filter bar + clickable cards ---------- */
.node-filters { display: flex; gap: 9px; margin-bottom: 13px; align-items: center; }
.node-filters input[type=text], .node-filters select {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 7px 10px; color: var(--text); font-family: var(--mono); font-size: 13.5px;
}
.node-filters input[type=text] { flex: 1; max-width: 280px; }
.node-filters label.chk { display: flex; gap: 6px; align-items: center; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.node-card { cursor: pointer; transition: border-color .12s; }
.node-card:hover { border-color: var(--node-color, var(--accent)); }
.node-card .shortbadge { color: var(--node-color, var(--accent)); border-color: color-mix(in srgb, var(--node-color, var(--line)) 50%, var(--line)); }

/* ---------- node detail page ---------- */
.node-page-head { display: flex; gap: 18px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.node-page-head .devimg {
  width: 110px; height: 110px; object-fit: contain; flex: none;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 10px;
}
.node-page-head .names h2 { margin: 0; font-size: 23px; }
.node-page-head .names .sub { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.node-page-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 14px; align-items: start; }
@media (max-width: 980px) { .node-page-grid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; font-size: 14.5px; }
.kv dt { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .07em; padding-top: 1px; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 13.5px; }
.dm-pane { display: flex; flex-direction: column; height: 480px; }
.keywarn {
  background: rgba(232,163,62,.1); border: 1px solid rgba(232,163,62,.4);
  color: var(--warn); border-radius: var(--r-sm); padding: 8px 12px; font-size: 13.5px; margin-bottom: 9px;
}
.backlink { background: none; border: 0; color: var(--link); cursor: pointer; font-size: 14px; padding: 0; margin-bottom: 10px; }
.backlink:hover { text-decoration: underline; }

/* ---------- packets table ---------- */
.pkt-filters { display: flex; gap: 9px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.pkt-filters input[type=text], .pkt-filters select {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 7px 10px; color: var(--text); font-family: var(--mono); font-size: 13.5px;
}
table.pkt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.pkt th {
  text-align: left; font-size: 11.5px; font-weight: 700; color: var(--faint);
  text-transform: uppercase; letter-spacing: .08em; padding: 7px 8px;
  border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; user-select: none;
}
table.pkt th:hover { color: var(--accent); }
table.pkt th.sorted { color: var(--accent); }
table.pkt td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
table.pkt td.summary { white-space: normal; max-width: 320px; overflow: hidden; text-overflow: ellipsis; font-family: var(--ui); font-size: 13.5px; }
table.pkt tr:hover td { background: var(--raised); }
.pkt-pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.portpill { font-family: var(--mono); font-size: 10.5px; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--muted); }
.portpill.enc { color: var(--warn); border-color: rgba(232,163,62,.4); }

/* ---------- account page ---------- */
.account-grid { display: grid; grid-template-columns: 360px 1fr; gap: 14px; align-items: start; }
@media (max-width: 860px) { .account-grid { grid-template-columns: 1fr; } }
.avatar-row { display: flex; gap: 16px; align-items: center; }
a { color: var(--link); }

/* ---------- multiline message text (item 3) ---------- */
.bubble .body .msgtext { white-space: pre-wrap; }

/* ---------- node-stats icons (item 4) ---------- */
.node-stats svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; vertical-align: -2px; }
.node-stats span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- role icons (item 6) ---------- */
.roleicon { display: inline-flex; color: var(--node-color, var(--muted)); }
.roleicon svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; }

/* ---------- channels header row + color-coded UP/DOWN (item 9) ---------- */
.chan-row.chan-head {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--faint); border-bottom: 1px solid var(--line); padding: 6px 4px;
}
.chan-row.chan-head .cname, .chan-row.chan-head span { font-family: var(--ui); }
.chan-row:nth-child(even):not(.chan-head) { background: rgba(255,255,255,.015); }
.tag.up { color: var(--ok); border-color: rgba(63,184,109,.5); background: rgba(63,184,109,.08); }
.tag.down { color: var(--info); border-color: rgba(92,107,192,.5); background: rgba(92,107,192,.08); }
.tag.off { color: var(--faint); border-color: var(--line-soft); opacity: .55; }

/* ---------- logout icon (item 10) ---------- */
.topbar a.logout { display: inline-flex; color: var(--muted); }
.topbar a.logout:hover { color: var(--err); }
.topbar a.logout svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; }
