:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --line: #e2e5ea;
  --text: #1b1f24;
  --muted: #5f6873;
  --faint: #8b939d;
  --accent: #2f6f4f;
  --accent-2: #3f8f66;
  --accent-soft: #e5f1ea;
  --ok: #2e8b57;
  --warn: #b7791f;
  --bad: #c0392b;
  --bad-soft: #fbeaea;
  --warn-soft: #fdf3e2;
  --cpu: #3b82c4;
  --mem: #8b5cc4;
  --gpu: #2f9e6e;
  --vram: #d08a2e;
  --side: #17211c;
  --side-text: #c9d4ce;
  --side-muted: #7f8f86;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111416;
    --panel: #181c1f;
    --panel-2: #1f2427;
    --line: #2b3135;
    --text: #e4e8eb;
    --muted: #a0a9b0;
    --faint: #6f7a82;
    --accent: #5fb88a;
    --accent-2: #74c89c;
    --accent-soft: #1d2e25;
    --bad-soft: #3a1f1d;
    --warn-soft: #3a2f1b;
    --side: #0c0f10;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { background: var(--panel-2); padding: 10px 12px; border-radius: 6px; overflow-x: auto; margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
[hidden] { display: none !important; }

/* ---- shell ---- */
:root { --top: 52px; }
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; padding: 16px 10px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 650; font-size: 15px; padding: 4px 8px 12px; }
.brand:hover { text-decoration: none; }
.brand svg { width: 26px; height: 26px; flex: none; }
.brand small { display: block; font-weight: 400; font-size: 11.5px; color: var(--side-muted); }
.side-section { display: flex; flex-direction: column; min-height: 0; }
.side-admin { margin-top: auto; padding-top: 12px; }
.side nav { display: flex; flex-direction: column; gap: 1px; }
.side nav a {
  color: var(--side-text); padding: 7px 10px; border-radius: 6px;
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.side nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.side nav a.on { background: rgba(255, 255, 255, .1); color: #fff; }
.side nav .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--side-muted); flex: none; }
.side nav .dot.up { background: #4cc38a; }
.side nav .dot.down { background: #e5534b; }
/* Dozens of nodes: the list scrolls on its own and the Admin links stay in view. */
.node-nav { max-height: min(50vh, 440px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--side-muted); padding: 14px 10px 4px; display: flex; justify-content: space-between; }
.nav-label a { color: inherit; }
.nav-label a:hover { color: #fff; text-decoration: none; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count {
  margin-left: auto; background: var(--accent-2); color: #fff; font-size: 11px; font-weight: 650;
  border-radius: 10px; padding: 0 7px; line-height: 18px; min-width: 18px; text-align: center;
}

.frame { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top);
  display: flex; align-items: stretch; gap: 16px; padding: 0 24px 0 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.tabs { display: flex; align-items: stretch; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: flex; align-items: center; gap: 7px; padding: 0 12px; white-space: nowrap;
  color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { margin-left: 0; }
.me { display: flex; align-items: center; gap: 12px; flex: none; }
.me a { color: var(--text); display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 200px; font-weight: 550; }
.me a:hover { text-decoration: none; }
.me button { color: var(--muted); }

.main { padding: 28px 32px 60px; max-width: 980px; width: 100%; }
.main.wide { max-width: 1400px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; } /* short pages: the top bar keeps its height */
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; gap: 4px; overflow: visible; }
  .brand { padding: 4px 6px; }
  .brand small { display: none; }
  .side-nodes { display: none; } /* the Nodes tab lists them */
  .side-admin { margin: 0 0 0 auto; padding: 0; }
  .side nav { flex-direction: row; overflow-x: auto; }
  .side nav a { white-space: nowrap; padding: 6px 9px; }
  .nav-label { display: none; }
  .topbar { padding: 0 8px; gap: 8px; }
  .tabs a { padding: 0 9px; }
  .me a .ellipsis { display: none; }
  .main { padding: 18px 16px 48px; }
}

/* ---- common blocks ---- */
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head h1 { margin: 0; }
.head .sub { color: var(--muted); margin-top: 3px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.panel + .panel, .panel + .grid, .grid + .panel, .grid + .grid { margin-top: 16px; }
.panel > h2:first-child { margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols-main { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
@media (max-width: 1000px) { .cols-main { grid-template-columns: 1fr; } }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: var(--accent-soft); border-color: transparent; color: var(--text); }
.flash.err, .error { background: var(--bad-soft); border-color: transparent; color: var(--text); }
.error { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.notice { background: var(--warn-soft); padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }

/* ---- forms ---- */
label { display: block; font-weight: 550; margin-bottom: 4px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=password], input[type=email], input[type=search], input[type=date], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
textarea.mono { font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }
.inline { display: inline; }
.btn, button {
  font: inherit; font-weight: 550; cursor: pointer; border-radius: 6px; padding: 7px 14px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; white-space: nowrap;
}
.btn:hover, button:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover, button.primary:hover { background: var(--accent-2); }
.btn.danger, button.danger { color: var(--bad); }
.btn.small, button.small { padding: 4px 10px; font-size: 12.5px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 400; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 140px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg a, .seg button { padding: 5px 11px; color: var(--muted); border: 0; border-radius: 0; background: var(--panel); font-weight: 500; }
.seg a + a, .seg button + button { border-left: 1px solid var(--line); }
.seg a.on, .seg button.on { background: var(--accent-soft); color: var(--text); }
.seg a:hover { text-decoration: none; background: var(--panel-2); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 550; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.panel.flush { padding: 4px 0; }
.panel.flush th:first-child, .panel.flush td:first-child { padding-left: 18px; }
.panel.flush th:last-child, .panel.flush td:last-child { padding-right: 18px; }
tbody tr:hover { background: var(--panel-2); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---- badges & avatars ---- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 10px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.badge.open { background: #e6eef8; color: #2c5d8f; }
.badge.in_progress { background: #efe7f8; color: #6a3fa0; }
.badge.blocked { background: var(--bad-soft); color: var(--bad); }
.badge.done { background: var(--accent-soft); color: var(--accent); }
.badge.urgent { background: var(--bad); color: #fff; }
.badge.high { background: var(--warn-soft); color: var(--warn); }
.badge.low { color: var(--faint); }
@media (prefers-color-scheme: dark) {
  .badge.open { background: #1c2a3a; color: #8db8e6; }
  .badge.in_progress { background: #2a2038; color: #c2a3ea; }
}
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 550; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status.up::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(46, 139, 87, .18); }
.status.down::before { background: var(--bad); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff;
  display: inline-grid; place-items: center; font-size: 11px; font-weight: 650; flex: none;
}
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }

/* ---- markdown ---- */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md table, .md blockquote { margin: 0 0 .7em; }
.md ul, .md ol { padding-left: 1.4em; }
.md blockquote { border-left: 3px solid var(--line); padding-left: 12px; color: var(--muted); }
.md code { background: var(--panel-2); padding: 1px 4px; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md table { width: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; }
.md img { max-width: 100%; }

/* ---- auth pages ---- */
body.bare { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth { width: 100%; max-width: 380px; }
.auth .panel { padding: 28px 28px 24px; }
.auth .brand { color: var(--text); justify-content: center; padding: 0 0 20px; font-size: 17px; }
.auth h1 { font-size: 18px; text-align: center; }
.auth .lead { color: var(--muted); text-align: center; margin: -4px 0 18px; }
.auth button.primary { width: 100%; justify-content: center; padding: 9px; margin-top: 4px; }
.code-input { font-family: var(--mono); font-size: 24px !important; letter-spacing: .35em; text-align: center; padding: 10px !important; }
.auth-foot { margin-top: 16px; text-align: center; font-size: 12.5px; color: var(--muted); }

/* ---- nodes ---- */
.nodes { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.node-card { display: flex; flex-direction: column; gap: 12px; }
.node-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.node-card h2 { margin: 0; font-size: 16px; }
.node-card h2 a { color: var(--text); }
.node-card .role { color: var(--muted); font-size: 12.5px; }
.node-card .err { font-size: 12px; color: var(--bad); overflow-wrap: anywhere; }
.meters { display: grid; gap: 9px; }
.meter { display: grid; grid-template-columns: 58px 1fr 92px; align-items: center; gap: 10px; font-size: 12.5px; }
.meter .name { color: var(--muted); }
.meter .val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 7px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .4s ease; }
.bar.cpu > i { background: var(--cpu); }
.bar.mem > i { background: var(--mem); }
.bar.gpu > i { background: var(--gpu); }
.bar.vram > i { background: var(--vram); }
.bar.disk > i { background: var(--faint); }
.bar > i.hot { background: var(--bad) !important; }
.gpu-row { border-top: 1px dashed var(--line); padding-top: 9px; display: grid; gap: 7px; }
.gpu-row .gname { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.facts b { color: var(--text); font-weight: 550; }
.spark { width: 100%; height: 38px; display: block; }
.legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin: 2px 0 6px; }
.tile .v small { font-size: 12.5px; font-weight: 400; color: var(--muted); }

.chart { position: relative; }
.chart svg { width: 100%; height: 220px; display: block; overflow: visible; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); white-space: nowrap;
}
.chart text { fill: var(--faint); font-size: 10.5px; }
.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.core { background: var(--panel-2); border-radius: 5px; padding: 5px 6px 6px; font-size: 11px; color: var(--muted); }
.core .bar { height: 4px; margin-top: 4px; }

/* ---- tickets ---- */
.ticket-title { font-weight: 550; color: var(--text); }
.ticket-meta { font-size: 12px; color: var(--muted); }
.timeline { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.comment { display: grid; grid-template-columns: 26px 1fr; gap: 10px; }
.comment .body { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.comment .who { padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); background: var(--panel-2); border-radius: var(--radius) var(--radius) 0 0; }
.comment .who b { color: var(--text); }
.comment .md { padding: 10px 12px; }
.event { font-size: 12.5px; color: var(--muted); padding-left: 36px; position: relative; }
.event::before { content: ""; position: absolute; left: 11px; top: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.side-fields .field { margin-bottom: 10px; }
.progress { height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); }

/* ---- chat ---- */
.chat { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 0; height: calc(100vh - 56px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.chat-side { border-right: 1px solid var(--line); padding: 12px 8px; overflow-y: auto; background: var(--panel-2); }
.chat-side h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 8px 4px; font-weight: 600; }
.chat-side a { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px; color: var(--text); }
.chat-side a:hover { background: var(--panel); text-decoration: none; }
.chat-side a.on { background: var(--accent-soft); font-weight: 600; }
.chat-side a.unread { font-weight: 650; }
.chat-side details { margin: 10px 8px; font-size: 12.5px; }
.chat-side details input { margin: 6px 0; }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.chat-head h1 { font-size: 16px; margin: 0; }
.chat-head .topic { color: var(--muted); font-size: 12.5px; }
.msgs { flex: 1; overflow-y: auto; padding: 12px 18px; display: flex; flex-direction: column; }
.msg { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 6px 0; }
.msg .avatar { width: 30px; height: 30px; }
.msg .meta { font-size: 12.5px; color: var(--muted); }
.msg .meta b { color: var(--text); margin-right: 6px; }
.msg.cont { padding-top: 0; }
.msg.cont .avatar, .msg.cont .meta { visibility: hidden; height: 0; }
.composer { border-top: 1px solid var(--line); padding: 10px 14px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 200px; height: 42px; }
.composer .hint { font-size: 11.5px; color: var(--faint); }
@media (max-width: 860px) {
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat-side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 180px; }
  .msgs { max-height: 60vh; }
}

/* ---- vault ---- */
.secret { font-family: var(--mono); background: var(--panel-2); padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 36px; }
.secret.masked { color: var(--faint); letter-spacing: .2em; }
.kind { font-size: 11.5px; color: var(--muted); }
.danger-zone { border-color: var(--bad-soft); }
.danger-zone summary { cursor: pointer; color: var(--bad); font-weight: 550; }
.temp-pw { font-family: var(--mono); font-size: 18px; background: var(--panel-2); padding: 10px 14px; border-radius: 6px; user-select: all; display: inline-block; margin: 6px 0; }

.gap-top { margin-top: 16px; }
.lg-cpu { background: var(--cpu); }
.lg-mem { background: var(--mem); }
.lg-gpu { background: var(--gpu); }
.lg-vram { background: var(--vram); }
.ms-row + .ms-row { margin-top: 14px; }
.ms-row .panel-head { margin-bottom: 5px; }
.overdue { color: var(--bad); font-weight: 550; }
.recent-msg { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 6px 0; }
.recent-msg + .recent-msg { border-top: 1px solid var(--line); }
.recent-msg a { overflow-wrap: anywhere; }
.gap-xs { margin-top: 6px; }
.center { text-align: center; display: block; padding: 6px 0; }
.grow { flex: 1; min-width: 0; }
.main:has(.chat) { padding: 16px; max-width: none; } /* the same gap on every side of the chat window */
.chat { height: calc(100vh - var(--top) - 32px); } /* 16px above and below */
.grid > .panel + .panel, .nodes > .panel + .panel { margin-top: 0; }
.tile .v { margin-bottom: 0; }
.tile .s { font-size: 12px; color: var(--muted); margin-bottom: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .bar { margin-top: 6px; }

/* ---- node access ---- */
.access-node .hostkey { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.access-node .hostkey .muted { margin-right: 8px; }
table.logins td { vertical-align: middle; }
.sub-row td { padding-top: 0; }
.sub-row:hover { background: none; }
.err-text { overflow-wrap: anywhere; max-width: 360px; }
.keyline { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11.5px; margin-top: 8px; }
details.menu { display: inline-block; position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { background: var(--panel-2); }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 320px; text-align: left; white-space: normal;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.menu-body label { margin-top: 2px; }
.menu-body input, .menu-body select { margin-bottom: 8px; }
.menu-body hr { margin: 12px 0; }
.menu-body p { margin: 0 0 8px; }
label.check { display: flex; align-items: center; gap: 6px; font-weight: 400; margin: 4px 0 8px; }
label.check input { width: auto; margin: 0; }
details.add-login { margin-top: 12px; }
details.add-login > summary { cursor: pointer; color: var(--accent); font-weight: 550; }

/* ---- brand ---- */
:root { --side: #072124; --brand-ink: #072124; }
@media (prefers-color-scheme: dark) { :root { --side: #051618; --brand-ink: #cfe8de; } }
.brand svg.logo { width: 30px; height: 30px; color: #d9efe6; }
.auth .brand svg.logo { color: var(--brand-ink); width: 34px; height: 34px; }

/* ---- avatars ---- */
img.avatar { object-fit: cover; background: var(--panel-2); }
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }
.avatar-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.avatar-row input[type=file] { width: auto; }
.who-cell { display: flex; align-items: center; gap: 10px; }

/* ---- chat: files, deleting, vault links ---- */
.msg-main { min-width: 0; }
.msg-del { visibility: hidden; margin-left: 8px; padding: 0 6px; font-size: 11.5px; font-weight: 500; border: 0; background: none; color: var(--faint); }
.msg-del:hover { color: var(--bad); background: none; }
.msg:hover .msg-del { visibility: visible; }
.msg.cont .meta { visibility: visible; height: auto; }
.msg.cont .meta b, .msg.cont .meta .ts { display: none; }
.msg.cont .meta { position: absolute; right: 18px; margin-top: -2px; }
.msg { position: relative; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.att-img img { display: block; max-width: min(360px, 100%); max-height: 280px; border-radius: 8px; border: 1px solid var(--line); }
.att-file { display: inline-flex; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--text); max-width: 100%; }
.att-file::before { content: ""; width: 14px; height: 17px; flex: none; border: 1.5px solid var(--muted); border-radius: 2px 6px 2px 2px; }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.composer-tools { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.composer-tools .hint { margin-left: 4px; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 2px 4px 2px 10px; font-size: 12.5px; max-width: 280px; }
.chip span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x { border: 0; background: none; padding: 0 6px; font-size: 15px; line-height: 1; color: var(--muted); }
.chat-main.dragging { outline: 2px dashed var(--accent); outline-offset: -6px; }
.vault-picker { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; background: var(--panel); }
.vault-results { display: flex; flex-direction: column; max-height: 200px; overflow-y: auto; margin: 6px 0; }
.vault-result { justify-content: space-between; border: 0; border-radius: 6px; background: none; font-weight: 450; }
.md a[href^="/vault/"] { display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; border-radius: 10px; background: var(--accent-soft); font-weight: 550; text-decoration: none; }
.md a[href^="/vault/"]::before { content: ""; width: 10px; height: 10px; border: 2px solid currentColor; border-radius: 50%; box-shadow: 5px 0 0 -3px currentColor; margin-right: 4px; }

/* ---- idle sign-out warning ---- */
.idle-toast { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; gap: 12px; align-items: center; max-width: 420px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }

/* ---- nodes list ---- */
.head input.node-filter { width: 240px; }
table.node-list td { vertical-align: middle; }
table.node-list tr.offline td:nth-child(n+3) { opacity: .5; }
table.node-list td:first-child { min-width: 150px; }
.w-bar { width: 14%; min-width: 110px; }
.w-gpu { width: 22%; min-width: 170px; }
.cell-bar { font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-bar .bar { height: 5px; margin-top: 3px; }
.gpu-cell { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.gpu-cell + .gpu-cell { margin-top: 6px; }
/* A narrow list (next to the map, or on a phone): each node becomes a card. */
.nodes-list-col { container: nodelist / inline-size; min-width: 0; }
@container nodelist (max-width: 860px) {
  table.node-list thead { display: none; }
  table.node-list, table.node-list tbody { display: block; }
  table.node-list tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 20px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
  table.node-list tr:last-child { border-bottom: 0; }
  table.node-list td { display: block; border: 0; padding: 0 !important; text-align: left; min-width: 0; }
  table.node-list td:first-child { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  table.node-list td.node-st { grid-column: 1 / -1; }
  table.node-list td.node-actions { grid-column: 1 / -1; }
  table.node-list td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 2px; }
  table.node-list tr[hidden] { display: none; }
}

/* ---- node access: collapsible blocks, nothing clipped ---- */
details.access-node { padding: 0; }
details.access-node + details.access-node, details.access-node + .panel { margin-top: 10px; }
details.access-node > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 13px 18px; border-radius: var(--radius);
}
details.access-node > summary::-webkit-details-marker { display: none; }
details.access-node > summary:hover { background: var(--panel-2); }
details.access-node > summary h2 { margin: 0; }
details.access-node[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.access-flags { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.chev { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; flex: none; margin-right: 2px; }
details[open] > summary .chev { transform: rotate(45deg); }
.access-body { padding: 10px 18px 16px; }
.access-addr { margin-bottom: 4px; overflow-wrap: anywhere; }
.access-node .hostkey { padding-top: 4px; }
table.logins td, table.keys td { vertical-align: middle; }
table.keys td.mono { word-break: break-all; min-width: 180px; }
@media (max-width: 760px) {
  table.logins thead, table.keys thead { display: none; }
  table.logins, table.logins tbody, table.logins tr, table.logins td,
  table.keys, table.keys tbody, table.keys tr, table.keys td { display: block; width: 100%; }
  table.logins tr, table.keys tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.logins td, table.keys td { border: 0; padding: 3px 0; text-align: left; }
  .menu-body { width: min(320px, calc(100vw - 48px)); left: 0; right: auto; }
}

/* ---- presence ---- */
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; flex: none; }
.who { display: flex; align-items: center; gap: 4px; padding-right: 12px; border-right: 1px solid var(--line); height: 28px; }
.who-av, .av-wrap { position: relative; display: inline-flex; flex: none; }
.who-av:hover { text-decoration: none; opacity: .85; }
.who-av .avatar { width: 26px; height: 26px; font-size: 11px; }
.pdot { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--panel); background: var(--faint); }
.chat-side .pdot { border-color: var(--panel-2); }
.pdot.online { background: #2fb36d; }
.pdot.idle { background: #e0a030; }
.pdot.offline { background: var(--panel); box-shadow: inset 0 0 0 2px var(--faint); }
.plabel.online { color: var(--ok); }
.plabel.idle { color: var(--warn); }
.plabel.offline { color: var(--muted); }
.chat-side a .av-wrap { margin-right: 2px; }

/* ---- notifications ---- */
.bell { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--muted); }
.bell:hover, details[open] > .bell, .bell.on { background: var(--panel-2); color: var(--text); }
.bell .count { position: absolute; top: 1px; right: -3px; margin: 0; font-size: 10.5px; line-height: 16px; min-width: 16px; padding: 0 4px; background: var(--bad); }
.notif-menu .menu-body.notif-body { width: min(390px, calc(100vw - 24px)); padding: 0; top: calc(100% + 8px); overflow: hidden; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.notif-list { max-height: min(60vh, 460px); overflow-y: auto; }
.notif-list .empty { padding: 22px 0; }
.notif-all { display: block; text-align: center; padding: 9px; border-top: 1px solid var(--line); font-size: 12.5px; }
.notif-offer { padding: 10px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--line); font-size: 12.5px; }
.push-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.push-row > span { flex: 1 1 180px; }
.push-row.on > span { color: var(--ok); font-weight: 550; }
.push-row.denied > span, .push-row.unsupported > span { color: var(--warn); }
.push-state { margin: 6px 0 8px; }
.notif-item { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--line); }
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--panel-2); text-decoration: none; }
.notif-item.unread { background: var(--accent-soft); }
.notif-item.unread .ni-title { font-weight: 650; }
.ni-main { display: flex; flex-direction: column; min-width: 0; }
.ni-title { overflow-wrap: anywhere; }
.ni-body { color: var(--muted); font-size: 12.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.ni-time { color: var(--faint); font-size: 11.5px; white-space: nowrap; padding-top: 2px; }
.ni-kind { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; background: var(--faint); }
.ni-kind::before { content: "•"; }
.k-dm.ni-kind { background: #6a5acd; } .k-dm.ni-kind::before { content: "@"; }
.k-channel.ni-kind { background: var(--accent-2); } .k-channel.ni-kind::before { content: "#"; }
.k-ticket.ni-kind { background: #3b82c4; } .k-ticket.ni-kind::before { content: "✓"; }
.k-node.ni-kind { background: var(--bad); } .k-node.ni-kind::before { content: "!"; }
.notif-cols { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 1000px) { .notif-cols { grid-template-columns: minmax(0, 1fr); } }
.device-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
label.check.opt { align-items: flex-start; }
label.check.opt input { margin-top: 3px; }
label.check.opt .hint { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
#settings h3 { margin: 12px 0 6px; }
#settings h2 + h3 { margin-top: 4px; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.toast { display: flex; gap: 8px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent-2);
  border-radius: var(--radius); padding: 10px 8px 10px 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); animation: toast-in .2s ease-out; }
.toast.k-node { border-left-color: var(--bad); }
.toast.k-ticket { border-left-color: #3b82c4; }
.toast.k-dm { border-left-color: #6a5acd; }
.toast a { flex: 1; min-width: 0; color: var(--text); display: flex; flex-direction: column; }
.toast a:hover { text-decoration: none; }
.toast a span { color: var(--muted); font-size: 12.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.toast-x { border: 0; background: none; color: var(--faint); font-size: 16px; line-height: 1; padding: 0 4px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.offer-card { position: fixed; right: 16px; bottom: 16px; z-index: 61; width: min(360px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.offer-card span { color: var(--muted); font-size: 13px; }
.offer-card .actions { margin-top: 4px; }
@media (max-width: 860px) {
  .who { display: none; }
  .top-right { gap: 6px; }
  /* live.js sets top from the bell's position */
  .notif-menu .menu-body.notif-body { position: fixed; left: 8px; right: 8px; width: auto; }
}

/* ---- messages button (header) ---- */
.msg-btn { position: relative; display: grid; place-items: center; width: 44px; height: 40px; border-radius: 10px; color: var(--muted); border: 1px solid var(--line); background: var(--panel); }
.msg-btn:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.msg-btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.msg-btn:has(.count:not([hidden])) { color: var(--accent); }
.msg-btn .count { position: absolute; top: -8px; right: -9px; margin: 0; box-sizing: border-box; min-width: 22px; height: 22px; line-height: 18px; font-size: 11.5px; padding: 0 5px; border: 2px solid var(--panel); }

/* ---- files: picker, cards, My files ---- */
.file-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.file-pick .btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.file-pick .hint { font-size: 12px; color: var(--muted); }
.file-pick .pending-files { flex: 1 1 100%; margin: 2px 0 0; }
form.dragging { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 6px; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
/* No overflow: hidden on the card: its "…" menu must be able to stick out. */
.fcard { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); min-width: 0; }
.fthumb { display: block; aspect-ratio: 4 / 3; background: var(--panel-2); overflow: hidden; border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
.fbtns .menu-body { width: 270px; left: 0; right: auto; }
.fthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ficon { display: grid; place-items: center; text-decoration: none !important; }
.ficon span { font: 700 13px/1 var(--mono); letter-spacing: .04em; color: var(--muted); border: 2px solid var(--faint); border-radius: 4px 12px 4px 4px; padding: 14px 8px; min-width: 52px; text-align: center; background: var(--panel); }
.fmeta { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px 4px; min-width: 0; }
.fname { color: var(--text); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fbtns { display: flex; gap: 12px; align-items: center; padding: 2px 10px 9px; margin-top: auto; flex-wrap: wrap; }
.danger-link { color: var(--bad) !important; }
button.saved { color: var(--ok) !important; }
.comment-files { padding: 0 12px 12px; }
.comment-files .file-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.my-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.fcard.big .fbtns { padding-top: 6px; }
.upload-panel p { margin: 10px 0 0; }
.upload-panel form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.upload-panel .file-pick { flex: 1 1 320px; }

/* ticket side panel */
.side-file { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.side-file:first-of-type { border-top: 0; }
.sf-thumb { width: 38px; height: 38px; border-radius: 6px; overflow: hidden; background: var(--panel-2); display: grid; place-items: center; flex: none; }
.sf-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sf-thumb.ficon span { font-size: 9px; padding: 4px 3px; min-width: 0; border-width: 1.5px; border-radius: 2px 6px 2px 2px; }
.sf-main { display: flex; flex-direction: column; min-width: 0; }
.sf-main a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.side-files form { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }

/* chat attachments: save button */
.atts { align-items: flex-start; }
.att { position: relative; display: inline-flex; max-width: 100%; }
.att-save { position: absolute; top: 6px; right: 6px; padding: 2px 9px; font-size: 11.5px; font-weight: 600; border: 0; border-radius: 10px;
  background: rgba(10, 16, 18, .72); color: #fff; opacity: 0; transition: opacity .12s; }
.att:hover .att-save, .att-save:focus-visible, .att-save.saved { opacity: 1; }
.att-save.saved { background: var(--ok); color: #fff !important; }
.att .att-file { padding-right: 64px; }
@media (hover: none) { .att-save { opacity: 1; } }

/* chat: shared photos, files and links */
.chat-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.shared-menu > summary { display: inline-flex; align-items: center; gap: 5px; }
.shared-menu .menu-body.shared-body { left: 0; right: auto; width: min(480px, calc(100vw - 32px)); padding: 10px; }
.shared-tabs { display: flex; margin-bottom: 8px; }
.shared-tabs button { flex: 1; border: 0; border-radius: 0; background: none; padding: 6px 8px; font-weight: 550; color: var(--muted); }
.shared-tabs button.on { color: var(--text); background: var(--accent-soft); }
.shared-tabs button span { color: var(--faint); font-weight: 400; margin-left: 2px; }
.shared-list { max-height: min(62vh, 520px); overflow-y: auto; }
.shared-photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.shared-photos figure { margin: 0; min-width: 0; }
.shared-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; background: var(--panel-2); }
.shared-photos figcaption { display: flex; flex-direction: column; font-size: 11px; margin-top: 3px; line-height: 1.35; }
.shared-photos figcaption .link { font-size: 11px; margin-right: 8px; }
.shared-row { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; padding: 8px 2px; border-top: 1px solid var(--line); }
.shared-row:first-child { border-top: 0; }
.sr-main { display: flex; flex-direction: column; min-width: 0; }
.sr-main > a { display: flex; flex-direction: column; min-width: 0; color: var(--text); overflow-wrap: anywhere; }
.sr-url { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-btns { display: flex; gap: 12px; }
.link-ico { font-size: 17px; color: var(--accent); }
.msg.hl { animation: msg-hl 2.4s ease-out; border-radius: 6px; }
@keyframes msg-hl { 0%, 30% { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); } 100% { background: transparent; box-shadow: 0 0 0 6px transparent; } }
.newer-note { display: block; text-align: center; padding: 6px; background: var(--accent-soft); font-weight: 550; font-size: 12.5px; border-top: 1px solid var(--line); }
.newer-link { font-weight: 550; }
.push-hint { color: var(--warn); margin: 8px 0 0; }

/* ---- chat: the list scrolls inside the box; the message box always stays in view ---- */
.chat { grid-template-rows: minmax(0, 1fr); }
.chat-main, .msgs { min-height: 0; }
@media (max-width: 860px) { .chat { grid-template-rows: auto; } }

/* ---- chat: bubbles; your own messages on the right ---- */
.msg-main { display: flex; flex-direction: column; align-items: flex-start; }
.msg .md { display: inline-block; max-width: min(720px, 100%); margin-top: 2px; padding: 7px 12px; background: var(--panel-2); border-radius: 4px 14px 14px 14px; overflow-wrap: anywhere; }
.msg.cont .md { border-radius: 14px; }
.msg .md pre { background: var(--panel); }
.msg .md code { background: rgba(127, 127, 127, .16); }
.msg.mine { grid-template-columns: minmax(0, 1fr); }
.msg.mine > .avatar { display: none; }
.msg.mine .msg-main { position: relative; justify-self: end; align-items: flex-end; max-width: min(720px, 88%); }
.msg.mine .md { background: var(--accent-soft); border-radius: 14px 4px 14px 14px; text-align: left; }
.msg.mine.cont .md { border-radius: 14px; }
.msg.mine .md a[href^="/vault/"] { background: var(--panel); }
.msg.mine .meta b { display: none; }
.msg.mine .msg-del { margin-left: 6px; }
.msg.mine .atts { justify-content: flex-end; }
/* on follow-up messages only the Delete button shows, left of the bubble */
.msg.mine.cont .meta { right: calc(100% + 2px); top: 50%; transform: translateY(-50%); margin: 0; }

/* ---- photo overlay ---- */
html.lb-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(5, 10, 12, .92); display: flex; flex-direction: column; color: #e9eef0; }
.lightbox[hidden] { display: none !important; }
.lb-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap; }
.lb-title { display: flex; flex-direction: column; min-width: 0; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-caption, .lb-count { font-size: 12.5px; color: #9fb0b5; }
.lb-caption:not(:empty) + .lb-count:not(:empty)::before { content: " · "; }
.lb-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.lb-btn { background: rgba(255, 255, 255, .1); color: #fff; border: 0; border-radius: 7px; padding: 6px 11px; font-size: 13px; font-weight: 550; cursor: pointer; }
.lb-btn:hover { background: rgba(255, 255, 255, .2); text-decoration: none; }
.lb-btn.saved { background: var(--ok); }
.lb-close { font-size: 20px; line-height: 1; padding: 4px 11px 6px; }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 8px 16px; }
.lb-stage img { max-width: calc(100% - 110px); max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); background: #111; }
.lb-nav { flex: none; width: 46px; height: 64px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .08); color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }
.lb-nav:hover { background: rgba(255, 255, 255, .18); }
@media (max-width: 700px) {
  .lb-stage { position: relative; padding: 0 0 12px; }
  .lb-stage img { max-width: 100%; }
  .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 54px; background: rgba(0, 0, 0, .45); z-index: 1; }
  .lb-prev { left: 6px; } .lb-next { right: 6px; }
}

/* ---- tabs inside a page (node page) ---- */
.page-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -4px 0 18px; overflow-x: auto; }
.page-tabs a { padding: 9px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.page-tabs a:hover { color: var(--text); text-decoration: none; }
.page-tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.access-overview td { vertical-align: middle; }

/* ---- nodes page: list + map ---- */
.nodes-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 44%); gap: 16px; align-items: start; }
.nodes-map-col { position: sticky; top: calc(var(--top) + 16px); }
.map-panel { padding: 0; overflow: hidden; }
.world-map { height: calc(100vh - var(--top) - 150px); min-height: 340px; }
.map-foot { padding: 9px 14px; border-top: 1px solid var(--line); }
.map-foot a { font-weight: 550; }
@media (max-width: 1100px) {
  .nodes-layout { grid-template-columns: minmax(0, 1fr); }
  .nodes-map-col { position: static; order: -1; }
  .world-map { height: 340px; min-height: 0; }
}
.node-place { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pin { width: 9px; height: 9px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--accent); display: inline-block; margin: 0 2px; }
table.node-list tr.map-hl, table.node-list tr.map-hl:hover { background: var(--accent-soft); }

/* ---- map ---- */
:root { --map-sea: #dfe9ec; --map-land: #f8faf9; --map-border: #b9c6c9; --map-road-a: #e2a15a; --map-road-b: #e4c795; --map-road-c: #e6d4b4; --map-place: #3a4648; --map-place-dot: #66767a; }
@media (prefers-color-scheme: dark) { :root { --map-sea: #0d1719; --map-land: #1d2a2c; --map-border: #34474a; --map-road-a: #a36f3b; --map-road-b: #6f6448; --map-road-c: #4a4a3e; --map-place: #cdd8d9; --map-place-dot: #95a6a9; } }
.map { position: relative; overflow: hidden; background: var(--map-sea); touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.map.dragging { cursor: grabbing; }
.map-svg { width: 100%; height: 100%; display: block; }
.map-sea { fill: var(--map-sea); }
.map-land path { fill: var(--map-land); stroke: var(--map-border); stroke-width: .7; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.map-roads, .map-places { pointer-events: none; }
.map-roads path { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.map-roads .rd-a { stroke: var(--map-road-a); stroke-width: 2.2; }
.map-roads .rd-b { stroke: var(--map-road-b); stroke-width: 1.5; }
.map-roads .rd-c { stroke: var(--map-road-c); stroke-width: 1; }
.map-places circle { fill: var(--map-place-dot); stroke: var(--map-land); stroke-width: 1.2; }
.map-places text { font: 500 11px system-ui, -apple-system, "Segoe UI", sans-serif; fill: var(--map-place); paint-order: stroke; stroke: var(--map-land); stroke-width: 3px; stroke-linejoin: round; }
.map-places .cap text { font-weight: 650; }
.map-places .cap circle { fill: var(--map-land); stroke: var(--map-place); stroke-width: 1.6; }
.map-mk { cursor: pointer; }
.map-mk .halo { fill: transparent; }
.map-mk .dot { fill: var(--faint); stroke: #fff; stroke-width: 2; }
.map-mk.up .dot { fill: #2fb36d; }
.map-mk.down .dot { fill: var(--bad); }
.map-mk.pick .dot { fill: var(--accent); }
.map-mk.hl .halo { fill: rgba(47, 179, 109, .22); stroke: #2fb36d; stroke-width: 1.5; }
.map-mk.hl .dot { r: 8; }
.map-mk .lbl { font: 600 12px system-ui, -apple-system, "Segoe UI", sans-serif; fill: var(--text); paint-order: stroke; stroke: var(--map-land); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.map-mk.off { display: none; }
.map-ctrls { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 4px; }
.map-btn { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.map-btn svg { display: block; }
/* Bigger map: the window. */
.map.map-full { position: fixed; inset: 0; z-index: 45; width: auto; height: auto; min-height: 0; border-radius: 0; border: 0; }
body.map-full-open { overflow: hidden; }
body.map-full-open .nodes-map-col { position: static; } /* sticky would keep it under the header */
.map-btn:hover { background: var(--panel-2); }
.map-credit { position: absolute; right: 4px; bottom: 3px; font-size: 9.5px; line-height: 1; color: var(--muted); opacity: .75; pointer-events: none; }
.map-tip { position: absolute; z-index: 2; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .15); max-width: 220px; }

/* ---- host card ---- */
.card-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 24px; }
.card-groups h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 6px; }
.pre-line { white-space: pre-line; }
.mini-map { height: 230px; border-radius: 6px; }
.pick-map { height: 360px; border-radius: 6px; border: 1px solid var(--line); cursor: crosshair; }
.pick-map.dragging { cursor: grabbing; }
details.card-edit > summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.card-edit h3 { font-size: 13px; margin-bottom: 8px; }

/* ---- calls (the call window itself: call.css) ---- */
.call-btns { display: flex; gap: 6px; margin-left: auto; }
.call-btns button { display: inline-flex; align-items: center; gap: 5px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #2fb36d; box-shadow: 0 0 0 3px rgba(47, 179, 109, .22); flex: none; animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 50% { box-shadow: 0 0 0 6px rgba(47, 179, 109, .08); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.call-banner { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 7px 10px 7px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; }
.call-banner button { margin-left: auto; }
.msg.call-msg { display: block; }
.call-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: 4px auto; width: fit-content; max-width: 100%; padding: 6px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); font-size: 13px; }
.call-line .call-ico { display: inline-flex; color: var(--muted); }
.call-line.live { border-color: var(--accent-2); background: var(--accent-soft); }
.call-line.live .call-ico { color: var(--accent); }
.call-line button { padding: 2px 12px; }
.call-pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent); max-width: 240px; }
.call-pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ring-box { position: fixed; top: 16px; right: 16px; z-index: 80; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.ring-card { background: var(--panel); border: 1px solid var(--accent-2); border-radius: 12px; padding: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, .25); animation: ring-in .2s ease-out; }
@keyframes ring-in { from { transform: translateY(-8px); opacity: 0; } }
.ring-top { display: flex; align-items: center; gap: 12px; }
.ring-av { width: 42px; height: 42px; font-size: 15px; }
.ring-main { display: flex; flex-direction: column; min-width: 0; }
.ring-actions { display: flex; gap: 8px; margin-top: 12px; }
.ring-actions button { flex: 1; }
.ring-actions .ring-no { color: #fff; background: var(--bad); border-color: var(--bad); }
.k-call.ni-kind { background: #d0612e; } .k-call.ni-kind::before { content: "☎"; }
.toast.k-call { border-left-color: #d0612e; }
@media (max-width: 860px) {
  .call-btns button { padding: 4px 8px; }
  .call-pill { max-width: 150px; }
}

/* ---- chat: replies, read statuses, emoji ---- */
.msg-act { visibility: hidden; margin-left: 8px; padding: 0 6px; font-size: 11.5px; font-weight: 500; border: 0; background: none; color: var(--faint); }
.msg-act:hover { color: var(--accent); background: none; }
.msg:hover .msg-act, .msg.show-act .msg-act, .msg.show-act .msg-del { visibility: visible; }
.msg.mine .msg-act { margin-left: 6px; }
.reply-quote { display: flex; flex-direction: column; max-width: min(520px, 100%); margin: 3px 0 1px; padding: 3px 10px; border-left: 3px solid var(--accent-2); border-radius: 4px; background: rgba(127, 127, 127, .09); color: var(--muted); font-size: 12.5px; line-height: 1.4; text-decoration: none; }
.reply-quote:hover { background: rgba(127, 127, 127, .16); text-decoration: none; }
.reply-quote b { color: var(--text); font-weight: 600; }
.reply-quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-quote.gone { border-left-color: var(--line); font-style: italic; cursor: default; }
.msg.mine .reply-quote { align-self: flex-end; }
.reply-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding: 5px 6px 5px 10px; border-left: 3px solid var(--accent-2); border-radius: 6px; background: var(--panel-2); font-size: 12.5px; }
.reply-bar .rb-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.reply-bar .rb-main span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.read-status { margin-top: 2px; font-size: 11.5px; color: var(--faint); }
.read-status.seen { color: var(--accent); }
.read-marks { grid-column: 1 / -1; justify-self: end; display: flex; gap: 3px; margin-top: 2px; }
.read-marks .avatar { width: 16px; height: 16px; font-size: 7.5px; }
.msg .md.jumbo { background: none; padding: 0; font-size: 40px; line-height: 1.2; }

/* ---- code boxes (codeblock.go; colours in code.css) ---- */
.code-box { margin: 4px 0 8px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); max-width: 100%; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 6px 3px 10px; border-bottom: 1px solid var(--line); background: var(--panel-2); font-size: 11.5px; }
.code-lang { color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.code-copy { padding: 1px 9px; font-size: 11.5px; font-weight: 500; }
.code-copy.copied { color: var(--accent); border-color: var(--accent-2); }
.code-box pre.chroma { margin: 0; padding: 9px 12px; overflow-x: auto; background: none; font: 12.5px/1.5 var(--mono); tab-size: 4; }
.md .code-box pre code, .msg .md .code-box code { background: none; padding: 0; white-space: pre; }
.msg .md:has(.code-box) { display: block; width: min(720px, 100%); }
.msg .md .code-box { background: var(--panel); }

/* ---- emoji ---- */
.composer .grow { position: relative; }
.emoji-btn { font-size: 15px; line-height: 1; padding: 3px 8px; }
.emoji-panel { position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 30; width: min(360px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
.emoji-cats { display: flex; gap: 2px; }
.emoji-cat { flex: 1; padding: 4px 0; border: 0; background: none; font-size: 17px; line-height: 1; border-radius: 6px; }
.emoji-cat:hover { background: var(--panel-2); }
.emoji-grid { height: 260px; overflow-y: auto; }
.emoji-grid h4 { position: sticky; top: 0; margin: 0; padding: 4px 2px; background: var(--panel); font-size: 11.5px; font-weight: 600; color: var(--muted); }
.emoji-set { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); }
.emoji-cell { padding: 0; height: 34px; border: 0; background: none; font-size: 21px; line-height: 1; border-radius: 6px; }
.emoji-cell:hover, .emoji-cell:focus-visible { background: var(--panel-2); }
.emoji-suggest { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 30; display: flex; flex-direction: column; min-width: 240px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.sugg { display: flex; align-items: center; gap: 10px; justify-content: flex-start; padding: 4px 8px; border: 0; background: none; font-weight: 450; font-size: 13px; border-radius: 6px; }
.sugg.on, .sugg:hover { background: var(--accent-soft); }
.sugg-e { font-size: 18px; width: 22px; text-align: center; }
@media (hover: none) { .msg-act, .msg-del { padding: 2px 8px; } }

/* ---- chat: editing ---- */
.edited-tag { font-size: 11px; color: var(--faint); margin: 1px 4px 0; }
.msg.editing .md { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.edit-bar { border-left-color: var(--warn); }

/* ---- private groups ---- */
.ch-mark { display: inline-flex; align-items: center; justify-content: center; width: 13px; color: var(--muted); flex: none; }
.chat-head h1 { display: inline-flex; align-items: center; gap: 6px; }
.chat-side .new-channel .pick-people { display: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px 2px; margin: 0 0 8px; max-height: 180px; overflow-y: auto; }
.chat-side .new-channel form:has([name=private]:checked) .pick-people { display: block; }
.pick-people legend { font-size: 11.5px; color: var(--muted); padding: 0 4px; }
.pick-people label.check { margin: 3px 0; }
.members-menu > summary { display: inline-flex; align-items: center; gap: 5px; }
.leave-group { margin: 0; }
.leave-group button { display: inline-flex; align-items: center; gap: 5px; }
.members-menu .menu-body.members-body { left: 0; right: auto; width: min(320px, calc(100vw - 32px)); }
.member-list { list-style: none; margin: 0 0 10px; padding: 0; max-height: 260px; overflow-y: auto; }
.member-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.member-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-list form { margin: 0; }
.member-add { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.member-add select { flex: 1; margin: 0; }
.members-body .hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* ---- users page: access ---- */
.access-fields .module-list { padding-left: 22px; margin: -2px 0 6px; }
.access-fields .module-list label.check { margin: 2px 0 6px; }
.role-list { max-width: 260px; white-space: normal; margin-top: 3px; }
/* Phones: one card per person (the table can't scroll sideways: its menus must stick out). */
@media (max-width: 760px) {
  table.users thead { display: none; }
  table.users, table.users tbody, table.users tr, table.users td { display: block; width: 100%; }
  table.users tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.users td { border: 0; padding: 3px 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  table.users td.right { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 6px; }
  table.users .role-list { max-width: none; }
}
.table-wrap.has-menus { overflow: visible; } /* the Access… menus open below the row */

/* ---- My links ---- */
.link-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.link-add input[name=url] { flex: 2 1 260px; margin: 0; }
.link-add input[name=title] { flex: 1 1 180px; margin: 0; }
.link-list { padding: 0; }
.link-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.link-row:last-child { border-bottom: 0; }
.link-ico { flex: none; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.link-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.link-title { font-weight: 600; overflow-wrap: anywhere; }
.link-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row .menu-body { right: 0; left: auto; }

/* ---- reactions ---- */
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.msg.mine .reacts { justify-content: flex-end; }
.react { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; min-height: 24px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); color: var(--text); font-size: 14px; line-height: 1; cursor: pointer; }
.react span { font-size: 12px; font-weight: 600; color: var(--muted); }
.react:hover { border-color: var(--faint); }
.react.mine { border-color: var(--accent); background: var(--accent-soft); }
.react.mine span { color: var(--text); }
.react-bar { position: absolute; z-index: 30; display: flex; gap: 2px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.react-bar[hidden] { display: none; }
.react-bar button { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: none; font-size: 19px; line-height: 1; cursor: pointer; }
.react-bar button:hover { background: var(--panel-2); transform: scale(1.12); }
.react-bar .rb-more { font-size: 18px; color: var(--muted); }
.emoji-panel.for-react { outline: 2px solid var(--accent); }
.link-pick { position: absolute; z-index: 30; width: min(380px, calc(100vw - 16px)); padding: 6px 10px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.link-pick[hidden] { display: none; }
.link-pick .lp-row { display: flex; gap: 10px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); }
.link-pick .lp-head { padding: 2px 0 6px; }
.link-pick .lp-url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

/* ---- chat: action icons, your times on the right, search ---- */
.msg .meta { display: flex; align-items: center; gap: 6px; min-height: 22px; }
.msg .meta b { margin-right: 0; }
.msg .meta .acts { display: inline-flex; align-items: center; gap: 1px; }
.msg-act, .msg-del { display: inline-grid; place-items: center; width: 24px; height: 22px; margin: 0; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--faint); cursor: pointer; }
.msg .meta .msg-act:hover { background: var(--panel-2); color: var(--accent); }
.msg .meta .msg-del:hover { background: var(--panel-2); color: var(--bad); }
.msg-act.saved { visibility: visible; color: var(--ok); }
.msg.mine .meta { flex-direction: row-reverse; } /* the time at the right edge, the icons left of it */
.msg.mine .msg-act, .msg.mine .msg-del { margin-left: 0; }
@media (hover: none) { .msg-act, .msg-del { width: 30px; height: 28px; padding: 0; } }

.chat-search { display: flex; align-items: center; gap: 6px; margin: 0 4px 8px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--faint); }
.chat-search:focus-within { border-color: var(--accent); }
.chat-search input { flex: 1; min-width: 0; margin: 0; padding: 7px 0; border: 0; background: none; box-shadow: none; outline: none; font-size: 13px; }
.chat-main.searching .msgs { display: none; }
.search-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.search-panel[hidden] { display: none; }
.sp-head { display: flex; align-items: center; gap: 10px; padding: 8px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sp-head .seg button { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-head .chip-x { margin-left: auto; }
.sp-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 12px; }
.sp-hit { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.sp-hit:hover { background: var(--panel-2); text-decoration: none; }
.sp-hit + .sp-hit { border-top: 1px solid var(--line); }
.sp-meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); }
.sp-meta b { color: var(--text); font-weight: 600; }
.sp-text { margin-top: 2px; font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sp-text mark { background: rgba(240, 190, 60, .35); color: inherit; border-radius: 2px; padding: 0 1px; }
.sp-more { display: block; margin: 10px auto 0; }

/* ---- "Add to vault" on selected text ---- */
.vq-btn { position: absolute; z-index: 40; display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); box-shadow: 0 4px 14px rgba(0, 0, 0, .2); cursor: pointer; }
.vq-btn:hover { border-color: var(--accent); color: var(--accent); }
.vq-btn[hidden], .vq-pop[hidden], .vq-pop [hidden] { display: none; }
.vq-pop { position: absolute; z-index: 41; width: min(300px, calc(100vw - 16px)); display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .22); }
.vq-head { display: flex; align-items: center; justify-content: space-between; }
.vq-pop input { margin: 0; }
.vq-kind { align-self: flex-start; }
.vq-preview { overflow-wrap: anywhere; }
.vq-preview:empty { display: none; }
.vq-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vq-msg.bad, .vq-pop .link.danger { color: var(--bad); }

/* ---- Slack ---- */
.slack-side { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.slack-chip svg { margin-right: 4px; }
.slack-menu .menu-body { width: min(340px, 86vw); }
.slack-mirrors { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.slack-ws-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.slack-links { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.slack-links li { display: flex; align-items: center; gap: 10px; }
.slack-add { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 6px 0; }
.slack-add label { display: grid; gap: 4px; font-size: 13px; flex: 1 1 180px; min-width: 0; }
.slack-add select { width: 100%; }
.slack-manifest { max-height: 320px; overflow: auto; font-size: 12px; margin: 8px 0; }
.slack-steps { padding-left: 20px; display: grid; gap: 6px; }

/* ---- the chat app (app.go): only the chat, under a slim bar ---- */
body.app .app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-top { align-items: center; padding: 0 16px; }
.app-brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 15px; font-weight: 500; white-space: nowrap; }
.app-brand:hover { text-decoration: none; }
.app-brand svg.logo { width: 26px; height: 26px; color: var(--brand-ink); flex: none; }
.app-brand b { font-weight: 700; }
.app-main { max-width: none; }
.app-me > summary { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; font-weight: 550; max-width: 220px; }
.app-me .menu-body > a { display: block; padding: 4px 0; }
.app-me .menu-body form { margin-top: 4px; }
.app-push:empty { display: none; }
.app-push .push-row { flex-wrap: wrap; }
/* Saving to My files or links and the vault live in the console, not here. */
body.app [data-save], body.app [data-save-link], body.app [data-save-links], body.app #vault-pick { display: none !important; }
.install-card { z-index: 62; }
.device-lost { z-index: 63; }
@media (max-width: 520px) { .app-me > summary .ellipsis { display: none; } }
.install-card button, .device-lost button { align-self: flex-start; }

/* ---- terminal windows (static/terminal.js): float over every console page ---- */
.tw { position: fixed; z-index: 30; display: flex; flex-direction: column; min-width: 0; background: #0f1214; color: #dfe6ea;
  border: 1px solid #2c3438; border-radius: 10px; overflow: hidden; box-shadow: 0 16px 44px rgba(0, 0, 0, .32), 0 2px 6px rgba(0, 0, 0, .18); }
.tw.tw-top { border-color: #3d5a4b; box-shadow: 0 20px 56px rgba(0, 0, 0, .42), 0 2px 8px rgba(0, 0, 0, .2); }
.tw.tw-min { visibility: hidden; pointer-events: none; }
.tw.tw-max { border-radius: 0; border-width: 0 0 0 1px; }
.tw.tw-moving { user-select: none; }
.tw-bar { flex: none; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 4px 0 11px; background: #1a1f22;
  font-size: 12.5px; cursor: grab; user-select: none; touch-action: none; }
.tw.tw-top .tw-bar { background: #1f2d27; }
.tw.tw-moving .tw-bar { cursor: grabbing; }
.tw.tw-max .tw-bar { cursor: default; }
.tw-title { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; }
.tw-title > svg { width: 15px; height: 15px; flex: none; color: #7fbf9c; }
.tw-title b { font-weight: 600; }
.tw-as { color: #9aa8b0; white-space: nowrap; }
.tw-as select { height: 24px; padding: 0 22px 0 6px; font-size: 12px; color: #dfe6ea; background-color: #262e32; border: 1px solid #3a4448; border-radius: 5px; cursor: pointer; }
.tw-state { font-size: 11.5px; color: #8c9aa2; white-space: nowrap; }
.tw-btns { display: flex; gap: 2px; flex: none; }
.tw-b { width: 28px; height: 26px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: #b8c4ca; }
.tw-b:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.tw-b.x:hover { background: #c0392b; }
.tw-b svg { width: 15px; height: 15px; }
.tw-body { position: relative; flex: 1; min-height: 0; padding: 6px 4px 6px 10px; }
.tw-term { width: 100%; height: 100%; }
.tw-note { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 8px 10px; font-size: 12.5px; background: #1d2427; border: 1px solid #36424a; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); }
.tw-note span { flex: 1 1 200px; }
.tw-note button:not(.primary) { background: #262e32; border-color: #3a4448; color: #dfe6ea; }
.tw-grip { position: absolute; right: 0; bottom: 0; z-index: 6; width: 16px; height: 16px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 55%, #5c6a71 55%, #5c6a71 62%, transparent 62%, transparent 74%, #5c6a71 74%, #5c6a71 81%, transparent 81%); }
.tw.tw-max .tw-grip { display: none; }

/* The task bar: one button per terminal window of this tab. */
.tw-dock { position: fixed; left: 220px; right: 0; bottom: 0; z-index: 39; height: 40px; display: flex; align-items: center; gap: 6px;
  padding: 0 12px; background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(16, 24, 32, .05); overflow-x: auto; }
.tw-chip { flex: none; display: inline-flex; align-items: center; gap: 6px; max-width: 240px; height: 28px; padding: 0 10px; font-size: 12.5px; font-weight: 500;
  color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; }
.tw-chip svg { width: 14px; height: 14px; flex: none; color: var(--muted); }
.tw-chip.on { background: var(--accent-soft); border-color: var(--accent); }
.tw-chip.on svg { color: var(--accent); }
.tw-chip.min { color: var(--muted); border-style: dashed; background: transparent; }
.tw-chip-user { color: var(--muted); font-weight: 400; }
.tw-chip .dot, .tw-bar .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--faint); }
.tw-chip .dot.up { background: #2fb36d; }
.tw-chip .dot.down { background: var(--bad); }
.tw-chip .dot.wait { background: var(--warn); }
body.has-dock .main { padding-bottom: 100px; }
body.has-dock .main:has(.chat) { padding-bottom: 16px; }
body.has-dock .chat { height: calc(100vh - var(--top) - 32px - 40px); }
body.has-dock :is(.toasts, .idle-toast, .offer-card) { bottom: 56px; }
@media (max-width: 860px) { .tw-dock { left: 0; } }
@media (max-width: 700px) { .tw { border-radius: 0; border-width: 1px 0 0; } .tw-state { display: none; } .tw-b[data-a="max"] { display: none; } }

/* ---- the chat app on a phone (app.go, chatapp.js): the list of chats and a
   conversation are two screens, like WhatsApp. Only at chat.host.garden. ---- */
.chat-back, .row-last, .row-time { display: none; }
body.app .app-row .row-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.app .app-row .row-side { margin-left: auto; display: flex; align-items: center; }
body.app .chat-pick { margin: auto; }
@media (max-width: 860px) {
  body.app .main:has(.chat) { padding: 0; }
  body.app .chat { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); border: 0; border-radius: 0; }
  body.app .chat:not(.chat-list-only) .chat-side, body.app .chat.chat-list-only .chat-main { display: none; }
  /* A conversation fills the screen under its own header, with the back arrow. */
  body.app:has(.chat:not(.chat-list-only)) .app-top { display: none; }
  body.app .chat:not(.chat-list-only) { height: 100vh; height: 100dvh; }
  body.app .msgs { max-height: none; padding: 10px 12px; }
  body.app .chat-head { padding: 8px 12px 8px 6px; }
  body.app .chat-title { flex-wrap: nowrap; gap: 6px; }
  body.app .chat-title h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
  body.app .chat-title .btn.small, body.app .chat-title button.small { font-size: 0; gap: 0; padding: 7px; }
  body.app .chat-title .faint { display: none; }
  body.app .chat-head .topic { padding-left: 34px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.app .chat-back { display: inline-flex; align-items: center; padding: 4px; border-radius: 50%; color: var(--text); flex: none; }
  body.app .chat-back:hover { background: var(--panel-2); text-decoration: none; }
  body.app .composer .hint { display: none; }
  /* The message box in one line, like WhatsApp: emoji, the text (growing as
     you type), a paperclip, and a round send button. */
  body.app .composer { padding: 6px 8px max(6px, env(safe-area-inset-bottom)); gap: 6px; align-items: flex-end; }
  body.app .composer .grow { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 2px 4px; }
  body.app .composer .grow > * { flex: 1 1 100%; }
  body.app .composer .composer-tools { display: contents; }
  body.app .composer .grow > textarea { order: 2; flex: 1 1 0; min-width: 0; height: 44px; min-height: 44px; max-height: 140px; padding: 11px 14px; border-radius: 22px; line-height: 1.35; resize: none; }
  body.app .composer .emoji-btn { order: 1; height: 44px; padding: 0 6px; border: 0; background: none; font-size: 22px; }
  /* Their words stay for screen readers (font-size 0); flex keeps the empty text beside the icon, not above it. */
  body.app .composer-tools label.btn { order: 3; width: 40px; height: 44px; margin: 0; padding: 0; border: 0; background: none; font-size: 0; line-height: 0; display: flex; align-items: center; justify-content: center; }
  body.app .composer-tools label.btn::before, body.app .composer > button.primary::before {
    content: ""; width: 22px; height: 22px; background: var(--muted);
    -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
  }
  body.app .composer-tools label.btn::before { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m21.4 11.1-9.2 9.2a6 6 0 0 1-8.5-8.5l9.2-9.2a4 4 0 0 1 5.7 5.7l-9.2 9.2a2 2 0 0 1-2.8-2.8l8.5-8.5'/%3E%3C/svg%3E"); }
  body.app .composer > button.primary { flex: none; width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 0; line-height: 0; display: flex; align-items: center; justify-content: center; }
  /* The arrow's weight is on its left: moved 2px right so it looks centred. */
  body.app .composer > button.primary::before { background: #fff; transform: translateX(2px); --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M3.4 20.4 21 12 3.4 3.6l2.3 7.2 8.8 1.2-8.8 1.2z'/%3E%3C/svg%3E"); }
  /* Editing a message: a tick instead of the arrow. */
  body.app .composer:has(#edit-bar:not([hidden])) > button.primary::before { transform: none; --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
  /* The list: big rows with the newest message and its time. */
  body.app .chat-side { max-height: none; border: 0; padding: 8px 6px 24px; background: var(--panel); }
  body.app .chat-side a.app-row { padding: 9px 8px; gap: 12px; }
  body.app .app-row .avatar { width: 46px; height: 46px; font-size: 16px; }
  body.app .app-row .ch-mark { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--panel-2); color: var(--muted); font-size: 18px; }
  body.app .app-row .pdot { width: 12px; height: 12px; }
  body.app .app-row .row-main { display: flex; flex-direction: column; gap: 2px; }
  body.app .app-row .row-name { font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; }
  body.app .app-row .row-last { display: block; color: var(--muted); font-size: 13.5px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
  body.app .app-row .row-side { flex-direction: column; align-items: flex-end; gap: 5px; align-self: stretch; justify-content: center; }
  body.app .app-row .row-time { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
  body.app .app-row.unread .row-time { color: var(--accent); font-weight: 600; }
  body.app .app-row .count { margin: 0; }
  body.app .chat-side a.on { background: none; font-weight: inherit; }
  body.app .chat-side > a[href^="/chat/dm/"] { padding: 9px 8px; gap: 12px; font-size: 15.5px; }
  body.app .chat-side > a[href^="/chat/dm/"] .avatar { width: 46px; height: 46px; font-size: 16px; }
  /* Searching from the list: the results take the screen. */
  body.app .chat.chat-list-only.searching { grid-template-rows: auto minmax(0, 1fr); }
  body.app .chat.chat-list-only.searching .chat-main { display: flex; }
  body.app .chat.chat-list-only.searching .chat-side { padding-bottom: 0; }
  body.app .chat.chat-list-only.searching .chat-side > :not(.chat-search) { display: none; }
  body.app .chat.chat-list-only .chat-pick { display: none; }
}
/* Touch screens (phones, also sideways, and tablets): no keyboard hints under the chat app's message box. */
@media (pointer: coarse) { body.app .composer .hint { display: none; } }
