:root {
  /* Dark "explorer" theme — ported from the sites-monorepo explorer design.
     Token names are unchanged from the previous light theme so all page markup
     and JS keep working; only the values (and a handful of component rules)
     changed. A few tokens were added for the elevated/deep surfaces the design
     uses. Fonts stay on a system monospace stack — an embedded node UI must not
     depend on external font CDNs (offline nodes, privacy). */
  --bg: #0a0a0a;                          /* page background */
  --bg-elev: #1a1a1a;                     /* elevated surface (table headers, chips) */
  --card: #121212;                        /* card / panel surface */
  --card-deep: #050505;                   /* deep surface (stat cards) */
  --fg: #e6e6e6;                          /* body text */
  --fg-pure: #ffffff;                     /* headings / emphasis */
  --muted: #8a8a8a;                       /* secondary / labels */
  --line: #2b2b2b;                        /* borders / hairlines */
  --line-soft: rgba(212, 212, 212, 0.10); /* faint chrome hairlines */
  --accent: #ff7300;                      /* brand orange (interactive) */
  --brand: #ff6900;                       /* brand orange (marks) */
  --accent-weak: rgba(255, 115, 0, 0.14); /* orange wash (hover fills) */
  --good: #46c46a;
  --bad: #f0564a;
  --warn: #d1a017;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must always win over our display rules. Without
   this an element with class="stack" hidden would still render because the
   class selector ties with [hidden] on specificity and wins on source order. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--brand); color: var(--bg); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

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

/* Default link styling — inline data links (table cells, kv values) read as
   near-body text with an orange underline. Chrome elements (nav tabs, sub-nav,
   brand wordmark, full-card click targets) opt out via the rule below. */
a, a:visited {
  color: var(--fg-pure);
  text-decoration: underline;
  text-decoration-color: rgba(255, 115, 0, 0.45);
  text-underline-offset: 2px;
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.brand .home, .brand .home:visited,
.nav-tab, .nav-tab:visited,
.nav-link, .nav-link:visited,
a.card, a.card:visited,
a.stat-card, a.stat-card:visited,
.pill, .pill:visited {
  color: inherit;
  text-decoration: none;
}

header {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: grid;
  grid-template-columns: max-content max-content 1fr max-content;
  align-items: center;
  gap: 1.25rem;
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 0.5rem; }
.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-pure);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
/* Brand mark — a small orange hexagon echoing the explorer design's dot motif. */
.brand h1::before {
  content: "";
  width: 12px;
  height: 13px;
  background: var(--brand);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  flex: none;
}
.brand .home { color: inherit; text-decoration: none; }
.brand .home:hover h1 { color: var(--accent); }
.nav-primary {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.nav-tab {
  font-size: 0.85rem;
  padding: 0.3rem 0;
  text-decoration: none;
  color: var(--fg);
  opacity: 0.55;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  text-transform: capitalize;
  transition: opacity 120ms, color 120ms;
}
.nav-tab:hover { opacity: 1; color: var(--fg-pure); }
.nav-tab-active {
  opacity: 1;
  color: var(--fg-pure);
}
/* Active top-level tab gets the orange hexagon dot from the design. */
.nav-tab-active::before {
  content: "";
  width: 8px;
  height: 9px;
  background: var(--accent);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  flex: none;
}
.meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  justify-self: end;
}
.meta .net, .meta .ver { color: var(--muted); white-space: nowrap; }
.status { color: var(--muted); }
.status.ok { color: var(--accent); }
.status.err { color: var(--bad); }
/* .manifest (api link) — orange chrome accent, no underline. */
.meta .manifest, .meta .manifest:visited { color: var(--accent); text-decoration: none; }
.meta .manifest:hover { color: var(--brand); text-decoration: underline; }

.nav-secondary {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: var(--bg);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  overflow-x: auto;
}
.nav-link {
  font-size: 0.8rem;
  padding: 0.7rem 0.6rem;
  text-decoration: none;
  color: var(--fg);
  opacity: 0.5;
  white-space: nowrap;
  text-transform: capitalize;
  transition: opacity 120ms, color 120ms;
}
.nav-link:hover { opacity: 0.85; }
.nav-link-active {
  opacity: 1;
  color: var(--fg-pure);
  font-weight: 500;
}
/* Active section marked with the design's "// " prefix instead of an underline. */
.nav-link-active::before {
  content: "// ";
  color: var(--accent);
  white-space: pre;
}

.search {
  display: flex;
  gap: 0.4rem;
  flex: 1;
  margin: 0;
  justify-self: end;
}
.search input {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  color: var(--fg);
  /* The input has no width of its own — it would fall back to the intrinsic
     size=20 (~194px), leaving ~1px for the placeholder. Pin it wider. */
  min-width: 214px;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--accent); }
.search button {
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
  color: var(--muted);
}
.search button:hover { background: var(--accent-weak); border-color: var(--accent); color: var(--fg-pure); }
/* Hidden before the wider input + "search" button can overflow the header grid. */
@media (max-width: 768px) {
  .search { display: none; }
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
  display: grid;
  gap: 1.75rem;
}

.page-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0;
  padding-top: 0.5rem;
}
.page-head h1 {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--fg-pure);
}
.page-head .page-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.section-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
}
.section-card > h2:first-child { margin-top: 0; }

/* Vertical stack of cards inside a wrapper div that isn't a direct child of <main>. */
.stack { display: grid; gap: 1.75rem; }

.active-pill {
  font-size: 0.7rem;
  padding: 0.15rem 0.55rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

h2 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.5rem;
  font-weight: normal;
}
h2 .hint { font-size: 0.75rem; color: var(--muted); text-transform: none; letter-spacing: 0; margin-left: 0.5rem; }

.identity dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0;
}
.identity dt { color: var(--muted); }
.identity dd { margin: 0; color: var(--fg-pure); }
.identity code { word-break: break-all; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--card-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.1rem 1.25rem 0.6rem;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 0.35rem;
  position: relative;
  min-height: 128px;
  overflow: hidden;
}
.stat-card .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.stat-card .val {
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: var(--fg-pure);
}
.stat-card .delta {
  font-size: 0.75rem;
  color: var(--muted);
}
.stat-card .delta.delta-up   { color: var(--good); }
.stat-card .delta.delta-down { color: var(--bad); }
.stat-card .spark {
  align-self: end;
  height: 40px;
  margin: 0.25rem -1.25rem -0.6rem;
}
.stat-card .spark svg { display: block; width: 100%; height: 100%; }
a.stat-card { color: inherit; text-decoration: none; transition: border-color 120ms, background 120ms, transform 120ms; }
a.stat-card:hover { border-color: rgba(255, 115, 0, 0.55); background: #080808; transform: translateY(-1px); }
a.stat-card:hover .label { color: var(--accent); }

/* Legacy .card kept for /accounts/ identity etc. */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
}
.card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.card .val {
  font-size: 1.5rem;
  margin-top: 0.25rem;
  color: var(--fg-pure);
}

.chart {
  padding: 0.75rem 1.25rem 1rem;
}
.chart-body {
  height: 160px;
  display: flex;
  align-items: stretch;
}
.chart-body svg { width: 100%; height: 100%; }
.chart-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}
.chart-wrap > svg { display: block; width: 100%; height: 100%; }
.chart-axis {
  position: absolute;
  left: 0.5rem;
  font-size: 10px;
  color: var(--muted);
  font-family: inherit;
  pointer-events: none;
}
.chart-axis-top { top: 0.25rem; }
.chart-axis-bot { bottom: 0.25rem; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
/* Inside a section-card the card already provides bg + border; the table just
   sits inside it without doubling up. */
.section-card table {
  background: transparent;
  border: none;
  border-radius: 0;
  margin-top: 0.25rem;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
thead th {
  background: var(--bg-elev);
  font-weight: normal;
  color: var(--fg);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tbody td { color: var(--fg); }
tr:last-child td { border-bottom: none; }
td.muted { color: var(--muted); text-align: center; }
td code { font-size: 0.85em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.linkrow:hover { background: rgba(255, 255, 255, 0.03); }
/* tr.linkrow links inherit global <a> styling. */
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--fg-pure); }
thead th.sort-asc::after { content: ' ▲'; color: var(--accent); }
thead th.sort-desc::after { content: ' ▼'; color: var(--accent); }
.hint-link { font-size: 0.75rem; text-transform: none; letter-spacing: 0; margin-left: 0.5rem; font-weight: normal; }


.error {
  background: rgba(240, 86, 74, 0.12);
  border: 1px solid var(--bad);
  color: var(--bad);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
}

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem 1.25rem;
}
/* Inside a section-card, .kv inherits the card's bg/border. */
.section-card .kv,
.section-card > dl.kv {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; color: var(--fg-pure); }
.kv dd code { font-size: 0.95em; }
.kv pre.inline {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85em;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
}

.raw pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.8em;
  margin: 0;
  color: var(--fg);
}

.conflict-wrap + .conflict-wrap { margin-top: 1rem; }

.kv-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.kv-form input {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  color: var(--fg);
}
.kv-form button {
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
  color: var(--fg);
}
.kv-form button:hover { background: var(--accent-weak); border-color: var(--accent); }
.raw-pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-size: 0.8em;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--fg);
}

.info {
  background: rgba(70, 196, 106, 0.12);
  border: 1px solid var(--good);
  color: var(--good);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
}

.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin: 0.5rem 0;
  flex-wrap: wrap;
}

button {
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
}
button:hover { background: var(--accent-weak); border-color: var(--accent); }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
button.warn { border-color: var(--bad); color: var(--bad); }
button.warn:hover { background: rgba(240, 86, 74, 0.12); }

.send-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem 1.25rem;
}
.send-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.send-form input, .send-form select {
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
}
.send-form button {
  align-self: start;
  margin-top: 0.5rem;
}

#import-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
  max-width: 600px;
}
#import-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}
#import-form input {
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
}

details summary { cursor: pointer; color: var(--muted); }
details[open] summary { margin-bottom: 0.5rem; }

.activity {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: 320px;
  overflow-y: auto;
  font-size: 0.85rem;
}
.activity li {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.6rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--line);
}
.activity li:last-child { border-bottom: none; }
.activity li.muted { color: var(--muted); display: block; }
.activity-ts { color: var(--muted); font-size: 0.8em; }
.activity-msg { word-break: break-word; }
.activity-info .activity-msg { color: var(--fg); }
.activity-success .activity-msg { color: var(--good); }
.activity-error .activity-msg { color: var(--bad); }

.hint-btn {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  margin-left: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}
.hint-btn:hover { background: var(--accent-weak); border-color: var(--accent); color: var(--fg-pure); }
.hint-btn.warn { border-color: var(--bad); color: var(--bad); }
.hint-btn.warn:hover { background: rgba(240, 86, 74, 0.12); color: var(--bad); }

.passphrase-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  max-width: 600px;
  margin-top: 0.5rem;
}
.passphrase-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.passphrase-form input {
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
}
.passphrase-form button {
  align-self: start;
  margin-top: 0.5rem;
}
.passphrase-form.inline-form {
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
}
.passphrase-form.inline-form button { align-self: stretch; margin-top: 0; }

.seed-confirm {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: rgba(209, 160, 23, 0.10);
  border: 1px solid var(--warn);
  border-radius: 6px;
}
.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.checkbox-line input { margin: 0; }

.wallet-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.pills { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.pill {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
  color: var(--muted);
}
.pill:hover { background: var(--accent-weak); border-color: var(--accent); color: var(--fg-pure); }
.pill.pill-active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
/* A contact not resolved in the directory — advisory only (#746). */
.pill.pill-unregistered {
  border-color: var(--warn);
  border-style: dashed;
}

/* .reveal-section is now wrapped in .section-card; no extra styling needed. */

.op-row {
  display: grid;
  grid-template-columns: max-content 1fr 2fr max-content;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  align-items: center;
}

.util-table td:last-child { width: 30%; }
.util-bar {
  width: 100%;
  height: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.util-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 200ms linear, background 200ms linear;
}
.util-bar-fill.util-bar-hot { background: var(--bad); }

.messages {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem;
  height: 360px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}
.msg {
  max-width: 80%;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  word-break: break-word;
}
.msg-self {
  align-self: flex-end;
  background: var(--accent);
  color: var(--bg);
  flex-direction: row-reverse;
}
.msg-self .msg-ts { color: rgba(10, 10, 10, 0.65); }
.msg-other {
  align-self: flex-start;
  background: var(--bg-elev);
  color: var(--fg);
}
.msg-body { font-size: 0.9rem; }
.msg-ts { font-size: 0.75em; color: var(--muted); flex-shrink: 0; }

.pill-badge {
  margin-left: 0.4rem;
  background: var(--bad);
  color: #fff;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  font-size: 0.7rem;
}
.pill-active .pill-badge { background: var(--bg); color: var(--accent); }
.op-row select, .op-row input {
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  color: var(--fg);
}
.op-row input:disabled, .op-row select:disabled { opacity: 0.6; background: var(--bg); }
