:root {
  color-scheme: dark;
  --bg: #10161c;
  --bg-raise: #18222c;
  --line: #2c3c4c;
  --text: #e7eef4;
  --muted: #8ea3b5;
  --accent: #7dcec4;
  --accent-ink: #08312e;
  --local: #e39b2b;
  --network: #3db7e8;
  --telemetry: #b79af0;
  --playback: #ef7aa8;
  --idle: #6d8294;
  --linked: #3dbe86;
  --keyed: #e39b2b;
  --danger: #e15d5d;
  --heat: #c4473a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  --sans: "Segoe UI", "Liberation Sans", "DejaVu Sans", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: var(--sans);
  background:
    radial-gradient(1200px 400px at 10% -10%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 50%),
    var(--bg);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost, button.quiet {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
button.danger { background: var(--danger); color: white; }
dialog input, dialog select { width: 100%; }
.fav-tools input { width: 7rem; }
.fav-tools select { width: auto; max-width: 12rem; }
input, select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.25rem; letter-spacing: 0.02em; }
h2 { font-size: 1.1rem; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1.2rem 0.4rem;
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.tx-dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--idle);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--idle) 15%, transparent);
}
.tx-dot.live { background: var(--local); box-shadow: 0 0 0 4px color-mix(in srgb, var(--local) 20%, transparent); }
#site-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }
.top-actions, .node-nav, .fav-tools, .dialog-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.menu { position: relative; }
.menu > summary {
  list-style: none;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  user-select: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after {
  content: " ▾";
  font-size: 0.85em;
  opacity: 0.85;
}
.menu[open] > summary { filter: brightness(1.08); }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.3rem);
  min-width: 10.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.35rem;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 40;
}
.menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
}
.menu-item:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 18%, transparent); }
#login-btn { background: transparent; color: var(--text); border: 1px solid var(--line); }
.pill, .node-nav button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  color: var(--muted);
  background: var(--bg-raise);
  font-size: 0.82rem;
}
.legend .key, .legend-title { font-size: 0.78rem; cursor: default; user-select: none; }
.legend-title { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.legend .key::before {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  background: currentColor;
  vertical-align: -0.05rem;
}
.node-nav { padding: 0.4rem 1.2rem; }
.node-nav button.on { border-color: var(--accent); color: var(--text); }
.welcome, .banner { padding: 0.2rem 1.2rem; color: var(--muted); }
.banner { color: var(--local); }
.control {
  display: grid;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0.4rem 1.2rem 0.8rem;
  padding: 0.8rem 0.95rem;
  background: color-mix(in srgb, var(--bg-raise) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.ctl-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem 1.5rem; }
.ctl-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; }
.ctl-tools { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.control label.field { display: flex; flex-direction: column; gap: 0.3rem; }
.ctl-label { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
#local-node { min-width: 8rem; }
#target { width: calc(15ch + 1.3rem); letter-spacing: 0.03em; }
.ctl-options { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.82rem; color: var(--muted); }
.ctl-options label { display: flex; align-items: center; gap: 0.45rem; cursor: pointer; }
.ctl-options input { margin: 0; accent-color: var(--accent); }
.ctl-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.ctl-actions select { margin-left: auto; min-width: 11rem; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; border-left: 1px solid color-mix(in srgb, var(--accent-ink) 30%, transparent); }
.seg button:first-child { border-radius: 8px 0 0 8px; border-left: 0; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button:only-child { border-radius: 8px; }
.seg button.primary { font-weight: 600; }
.seg.danger button { background: var(--danger); color: white; border-left-color: rgb(0 0 0 / 0.25); }
.seg.danger button:first-child { border-left: 0; }
.control button:hover:not(:disabled) { filter: brightness(1.1); }
@media (max-width: 640px) {
  .ctl-actions select { margin-left: 0; flex: 1; }
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.9fr);
  gap: 1rem;
  padding: 0 1.2rem 1.2rem;
}
.panel, .card {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem;
  box-shadow: var(--shadow);
}
.nodes, .side { display: flex; flex-direction: column; gap: 0.8rem; }
.card header, .panel header, .fav-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; }
.muted { color: var(--muted); }
.small { font-size: 0.78rem; margin: 0.15rem 0 0.4rem; }
dialog.wide { width: min(46rem, 94vw); }
dialog.wider { width: min(64rem, 96vw); }
fieldset.scope { border: 1px solid var(--line); border-radius: 6px; padding: 0.3rem 0.8rem; margin: 0.4rem 0 0.6rem; }
fieldset.scope label { margin: 0.25rem 0; }
dialog label.inline { display: inline-flex; flex-direction: row; align-items: center; gap: 0.4rem; margin: 0 0 0.5rem; }
#sounds-node { width: auto; min-width: 8rem; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 50; pointer-events: none; }
.toast {
  background: var(--bg-raise);
  color: var(--text);
  border: 1px solid var(--accent);
  border-left-width: 4px;
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  box-shadow: var(--shadow);
  max-width: min(24rem, 90vw);
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in { from { transform: translateY(0.6rem); opacity: 0; } }
#alerts-nodes { margin-top: 0.3rem; }
.sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 0.8rem; margin-top: 0.6rem; }
.sys-card { border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.8rem; min-width: 0; }
.sys-card h3 { margin: 0 0 0.4rem; font-size: 0.95rem; }
.sys-card dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 0.7rem; margin: 0; font-size: 0.88rem; }
.sys-card dt { color: var(--muted); }
.sys-card dd { margin: 0; overflow-wrap: anywhere; }
.usage { margin: 0.35rem 0 0.55rem; font-size: 0.85rem; }
.usage-text { margin-bottom: 0.2rem; overflow-wrap: anywhere; }
.bar span.warm { background: #f3e14b; }
.bar span.hot { background: var(--danger); }
ul.services { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
ul.services li { padding: 0.15rem 0; }
.svc { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; margin-right: 0.45rem; }
.svc.up { background: #8fe388; }
.svc.down { background: var(--danger); }
pre.sys-pre { white-space: pre-wrap; font-size: 0.78rem; margin: 0; overflow-wrap: anywhere; }
.db-table { max-height: 55vh; overflow: auto; }
.db-table td:first-child { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; overflow-wrap: anywhere; }
#db-filter { flex: 1; width: auto; }
.db-table th, .db-table td { text-align: left; }
#tts-name { flex: 1; width: auto; min-width: 10rem; }
#sound-list td:last-child { text-align: right; white-space: nowrap; }
#sound-list button + button { margin-left: 0.3rem; }
.dvs-now { font-weight: 600; color: var(--linked); }
#dvs-modes { flex-wrap: wrap; }
#dvs-list { max-height: 22rem; overflow-y: auto; }
#dvs-list td:last-child { text-align: right; }
#dvs-list tr.dvs-current td { color: var(--linked); font-weight: 700; }
#dvs-custom { flex: 1; min-width: 12rem; }
.tabs { display: flex; gap: 0.4rem; border-bottom: 1px solid var(--line); padding-bottom: 0.5rem; }
.tabs button { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.tabs button.on { color: var(--text); border-color: var(--accent); }
.admin-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.8rem; margin-top: 0.6rem; }
.admin-actions button { width: 100%; }
.file-bar { display: flex; gap: 0.5rem; align-items: center; margin: 0.6rem 0; flex-wrap: wrap; }
.file-bar select { flex: 1; min-width: 10rem; }
#admin-text, pre.log {
  width: 100%;
  box-sizing: border-box;
  height: 55vh;
  font: 0.8rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem;
}
pre.log { overflow: auto; white-space: pre; margin: 0; }
#admin-backups { margin-bottom: 0.6rem; }
#admin-backup-list { max-height: 12rem; overflow: auto; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions button + button { margin-left: 0.3rem; }
pre.diff { height: auto; max-height: 30vh; margin-top: 0.5rem; }
pre.diff .add { color: var(--linked); }
pre.diff .del { color: var(--danger); }
pre.diff .hunk { color: var(--muted); }
.access-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 0.6rem 0; }
.access-fields { display: grid; grid-template-columns: 8rem 1fr 1fr; gap: 0.6rem; }
.schedule-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.6rem; }
.schedule-days { display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; margin: 0 0 0.4rem 1.6rem; }
.settings-parts { display: grid; gap: 0.3rem; margin: 0.4rem 0 0.6rem; }
.theme-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: 0.6rem; margin: 0.6rem 0; }
.theme-card { border: 1px solid var(--line); border-radius: 10px; padding: 0.4rem; display: grid; gap: 0.3rem; }
.theme-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.theme-card .row-actions { display: flex; flex-wrap: wrap; gap: 0.25rem; }
button.theme-pick {
  display: grid; gap: 0.35rem; width: 100%; text-align: left;
  background: transparent; color: var(--text); padding: 0.2rem;
}
.theme-preview {
  display: flex; align-items: center; justify-content: space-between; gap: 0.4rem;
  height: 3rem; padding: 0.4rem; border: 1px solid; border-radius: 8px;
}
.theme-preview-panel { flex: 1; height: 100%; border-radius: 5px; padding: 0 0.4rem; font-weight: 700; display: flex; align-items: center; }
.theme-preview-dots { display: grid; grid-template-columns: repeat(2, 0.7rem); gap: 0.2rem; }
.theme-preview-dots i { width: 0.7rem; height: 0.7rem; border-radius: 50%; }
.theme-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.4rem 0; }
.theme-colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.35rem 0.9rem; }
dialog label.theme-color { flex-direction: row; align-items: center; gap: 0.5rem; }
dialog label.theme-color input { width: 2.4rem; height: 1.8rem; padding: 0.1rem; flex: none; }
#theme-site h3, #theme-editor h3 { margin: 1rem 0 0.3rem; }
[data-panel="backup"] h3 { margin: 1rem 0 0.3rem; }
#settings-file { margin: 0.3rem 0 0.6rem; }
#schedule-list td.row-actions { white-space: normal; }
#schedule-list td.row-actions button { margin: 0.1rem 0 0.1rem 0.3rem; }
tr.paused td { opacity: 0.55; }
tr.paused td.row-actions { opacity: 1; }
@media (max-width: 640px) { .access-grid, .access-fields { grid-template-columns: 1fr; } }
#finder input[type="search"] { width: 100%; margin-top: 0.5rem; }
table.finder td.row-actions { white-space: nowrap; text-align: right; }
button.tiny { font-size: 0.72rem; padding: 0.15rem 0.45rem; margin-left: 0.2rem; }
button:disabled { opacity: 0.45; cursor: default; }
table.heard td:first-child { white-space: nowrap; }
table.heard td:last-child { white-space: nowrap; text-align: right; }
table.heard th:last-child { text-align: right; }
.tx {
  margin: 0.55rem 0;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  font-weight: 650;
}
.tx.local { background: color-mix(in srgb, var(--local) 22%, var(--bg)); color: var(--local); }
.tx.network { background: color-mix(in srgb, var(--network) 20%, var(--bg)); color: var(--network); }
.tx.telemetry { background: color-mix(in srgb, var(--telemetry) 22%, var(--bg)); color: var(--telemetry); }
.tx.playback { background: color-mix(in srgb, var(--playback) 20%, var(--bg)); color: var(--playback); }
.tx.idle { background: transparent; color: var(--muted); font-weight: 500; }
.status { text-align: center; font-size: 0.84rem; line-height: 1.45; margin: 0.2rem 0 0.6rem; }
.status .alert, .status .wx { font-weight: 700; }
.status .alert:first-child { text-decoration: underline; }
[data-theme="light"] .status .alert { filter: brightness(0.7) saturate(1.3); }
.status .temp { display: inline-block; padding: 0 0.35rem; border-radius: 4px; font-weight: 700; color: #111; }
.status .temp.ok { background: #8fe388; }
.status .temp.warm { background: #f3e14b; }
.status .temp.hot { background: #fa4c2d; }
.status .temp.unknown { background: var(--line); color: var(--text); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.35rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.75rem; cursor: pointer; }
tr.keyed td {
  background: color-mix(in srgb, var(--keyed) 24%, transparent);
  color: var(--keyed);
  font-weight: 650;
}
tr.keyed td.node { color: var(--keyed); font-weight: 700; }
tr.connecting td { color: var(--muted); }
tr.selected td { outline: 1px solid var(--accent); }
td.node { color: var(--accent); cursor: pointer; }
td.node.linked { color: var(--linked); font-weight: 700; }
.swatch {
  display: inline-block;
  min-width: 1.6rem;
  text-align: center;
  border-radius: 6px;
  padding: 0.05rem 0.25rem;
}
.swatch.web { background: #146c43; color: white; }
.swatch.up { background: #0f5132; color: #d8ffe8; }
.swatch.down { background: transparent; color: var(--muted); }
.map { width: 100%; height: 180px; margin-top: 0.4rem; }
.map text { fill: var(--text); font-size: 11px; }
.map .hub { fill: var(--accent); }
.map .peer { fill: var(--network); }
.map line { stroke: var(--line); }
.legend { display: flex; gap: 0.9rem; flex-wrap: wrap; align-items: center; padding: 0 1.2rem 1.4rem; }
.legend .local { color: var(--local); }
.legend .network { color: var(--network); }
.legend .telemetry { color: var(--telemetry); }
.legend .playback { color: var(--playback); }
.legend .heat { color: var(--heat); }
.legend .linked { color: var(--linked); }
.legend .keyed { color: var(--keyed); }
.voter { margin: 0.45rem 0 0.7rem; }
.bar { height: 0.7rem; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar span { display: block; height: 100%; background: var(--network); }
.bar.voted span { background: var(--linked); }
.bar.mix span { background: var(--telemetry); }
.bar.inactive span { background: var(--idle); }
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-raise);
  color: var(--text);
  padding: 1rem;
  min-width: min(420px, 92vw);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog label { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.55rem 0; }
dialog label.check { flex-direction: row; align-items: center; gap: 0.45rem; }
dialog label.check input { width: auto; }
.form-error { color: var(--danger); min-height: 1.1rem; font-size: 0.85rem; }
.hint { color: var(--muted); margin: 0.3rem 0 0.6rem; }
pre {
  white-space: pre-wrap;
  background: var(--bg);
  border-radius: 8px;
  padding: 0.7rem;
  max-height: 50vh;
  overflow: auto;
}
.user-row { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; padding: 0.3rem 0; border-bottom: 1px solid var(--line); }
.empty { color: var(--muted); padding: 0.8rem 0; }

.display-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0 0.8rem; }
#display-heard-rows { width: auto; }
body.hide-control #control,
body.hide-finder #finder,
body.hide-heard #heard,
body.hide-favorites #favorites,
body.hide-voters #voters,
body.hide-legend .legend,
body.hide-tx .card .tx,
body.hide-alerts .card .status .alert,
body.hide-alerts .card .status .wx,
body.hide-cpu .card .status .cpu,
body.hide-load .card .status .load,
body.hide-disk .card .status .disk,
body.hide-links .card table,
body.hide-map .card details,
body.hide-col-info .card table :is(th, td):nth-child(2),
body.hide-col-recv .card table :is(th, td):nth-child(3),
body.hide-col-connected .card table :is(th, td):nth-child(4),
body.hide-col-dir .card table :is(th, td):nth-child(5),
body.hide-col-state .card table :is(th, td):nth-child(6),
body.hide-col-mode .card table :is(th, td):nth-child(7) { display: none !important; }
body.hide-finder.hide-heard.hide-favorites .layout:not(:has(#voters:not([hidden]))),
body.hide-finder.hide-heard.hide-favorites.hide-voters .layout { grid-template-columns: 1fr; }
body.hide-finder.hide-heard.hide-favorites .layout:not(:has(#voters:not([hidden]))) .side,
body.hide-finder.hide-heard.hide-favorites.hide-voters .layout .side { display: none; }

body.touch button, body.touch input, body.touch select { min-height: 2.8rem; font-size: 1.05rem; }
body.touch .card, body.touch .panel { font-size: 1.05rem; }
body.touch table { font-size: 1rem; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .top { align-items: flex-start; }
}
