:root {
  color-scheme: dark;
  --bg: #0c0a07;
  --panel: rgba(255, 176, 64, 0.025);
  --line: #3b2e17;
  --fg: #ffb547;
  --hot: #ffe4b0;
  --dim: #a8762f;
  --faint: #4d3a1b;
  --cyan: #6fd6e8;
  --err: #ff6f5e;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--mono); }
body { text-shadow: 0 0 5px rgba(255, 181, 71, 0.18); }
::selection { background: var(--fg); color: var(--bg); text-shadow: none; }
a { color: var(--hot); }

/* faint scanlines and vignette: CRT feel without the theatrics */
.crt { position: fixed; inset: 0; z-index: 10; pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.45) 100%),
    repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.13) 2px 3px); }

.shell { height: 100%; max-width: 1240px; margin: 0 auto; padding: 14px 18px 0;
  display: grid; grid-template-rows: auto 1fr auto; gap: 14px; }

.top { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.logo { margin: 0; font-size: 17px; font-weight: 600; color: var(--hot); letter-spacing: 0.5px; }
.logo .mark { color: var(--fg); }
.logo .ver, .tag { color: var(--dim); font-size: 12px; font-weight: 400; margin: 0; }
.links { margin-left: auto; display: flex; gap: 4px 14px; flex-wrap: wrap; font-size: 12px; }
.links a { color: var(--fg); text-decoration: none; }
.links a::before { content: "["; color: var(--faint); }
.links a::after { content: "]"; color: var(--faint); }
.links a:hover, .links a:focus-visible { color: var(--hot); outline: none; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; min-height: 0; }
.side { display: flex; flex-direction: column; gap: 18px; min-height: 0; }

/* panes: a box with its title set into the top border */
.pane { position: relative; border: 1px solid var(--line); background: var(--panel); padding: 16px 14px 12px; min-height: 0; }
.pane > h2 { position: absolute; top: -0.75em; left: 10px; margin: 0; padding: 0 6px; background: var(--bg);
  font-size: 12px; font-weight: 400; color: var(--dim); }
.pane > h2::before { content: "┤ "; color: var(--faint); }
.pane > h2::after { content: " ├"; color: var(--faint); }

/* chat */
.chat { display: flex; flex-direction: column; padding-bottom: 0; }
.model { position: absolute; top: -0.8em; right: 10px; padding: 0 6px; background: var(--bg); font-size: 12px; color: var(--dim); }
select { background: var(--bg); color: var(--fg); border: 1px solid var(--line); font: 12px var(--mono); }
#log { flex: 1; overflow-y: auto; padding: 2px 2px 10px; scrollbar-color: var(--faint) transparent; }
.line { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 10px; }
.ps { color: var(--dim); }
.you { color: var(--hot); }
.sys { color: var(--dim); }
.sys b { color: var(--fg); font-weight: 400; }
.ok { color: var(--cyan); }
.err { color: var(--err); }
.out { color: var(--fg); }
.out.community { border-left: 2px solid var(--err); padding-left: 10px; }
.out pre { border-left: 2px solid var(--faint); margin: 6px 0; padding: 4px 12px; background: rgba(255, 181, 71, 0.04); overflow-x: auto; white-space: pre; }
.meta { color: var(--dim); font-size: 12px; margin-top: -6px; }
.meta .ok { color: var(--cyan); }
.cur { display: inline-block; width: 0.6em; height: 1.05em; background: var(--fg); vertical-align: text-bottom; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

form.prompt { display: flex; align-items: flex-start; gap: 8px; border-top: 1px solid var(--line); margin: 0 -14px; padding: 10px 14px; }
form.prompt label { color: var(--dim); white-space: nowrap; }
textarea { flex: 1; resize: none; background: transparent; border: 0; color: var(--hot); font: inherit; caret-color: var(--fg);
  outline: none; min-height: 1.5em; max-height: 9em; padding: 0; text-shadow: inherit; }
textarea::placeholder { color: var(--faint); }
button { font: 13px var(--mono); background: transparent; color: var(--fg); border: 1px solid var(--dim); padding: 1px 10px; cursor: pointer; }
button:hover, button:focus-visible { background: var(--fg); color: var(--bg); outline: none; text-shadow: none; }
button:disabled { opacity: 0.4; cursor: wait; }

/* contract address */
.ca { margin-left: auto; font-size: 12px; padding: 1px 10px; border-color: var(--fg); color: var(--hot); }
.ca:not([hidden]) ~ .links { margin-left: 14px; }

/* wallet */
.wallet-btn { font-size: 12px; padding: 1px 10px; }
.links + .wallet-btn, .tag + .wallet-btn { margin-left: 14px; }
.top:not(:has(.links a)) .wallet-btn { margin-left: auto; }
.wallet-btn.on { border-color: var(--cyan); color: var(--cyan); }
.wallet-btn.on:hover { background: var(--cyan); color: var(--bg); }
.wallet-dlg { position: fixed; inset: 0; margin: auto; width: min(360px, 92vw); height: fit-content; max-height: 80vh;
  background: var(--bg); color: var(--fg); border: 1px solid var(--dim); overflow: visible; }
.wallet-dlg::backdrop { background: rgba(0, 0, 0, 0.7); }
.wallet-dlg .x { position: absolute; top: 6px; right: 8px; border: 0; font-size: 18px; line-height: 1; padding: 2px 6px; }
#wallet-list { display: grid; gap: 8px; margin-top: 4px; }
#wallet-list p { margin: 0; }
#wallet-list code { color: var(--hot); word-break: break-all; }
.pick { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; font-size: 14px;
  border: 1px solid var(--line); color: var(--fg); text-decoration: none; background: transparent; }
.pick:hover, .pick:focus-visible { border-color: var(--fg); background: rgba(255, 181, 71, 0.06); color: var(--hot); outline: none; }
.pick img { width: 22px; height: 22px; }
.wallet-dlg .hint { margin: 10px 0 0; }

/* globe */
.map canvas { display: block; width: 100%; aspect-ratio: 1; }
.legend { margin: 6px 0 0; font-size: 11px; color: var(--dim); display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 6px; height: 6px; margin-right: -6px; }
.k-node { background: var(--cyan); } .k-busy { background: var(--fg); } .k-you { background: var(--hot); }
#g-note { margin-left: auto; }

/* telemetry */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; margin: 0 0 12px; }
.stats div { min-width: 0; }
.stats dt { font-size: 11px; color: var(--dim); }
.stats dd { margin: 0; font-size: 16px; color: var(--hot); font-variant-numeric: tabular-nums; }
.spark-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); }
#t-tps { color: var(--cyan); }
#spark { display: block; width: 100%; height: 44px; margin-top: 4px; }

/* activity feed */
.feed { flex: 1; display: flex; flex-direction: column; min-height: 120px; }
#feed { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; font-size: 11.5px; line-height: 1.45; scrollbar-color: var(--faint) transparent; }
#feed li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--dim); }
#feed li.new { animation: flash 1.2s ease-out; }
#feed time { color: var(--faint); margin-right: 6px; }
#feed .tag { display: inline-block; width: 5ch; color: var(--fg); }
#feed .tag.up, #feed .tag.ok { color: var(--cyan); }
#feed .tag.bad { color: var(--err); }
#feed b { color: var(--hot); font-weight: 400; }
#feed .empty { color: var(--faint); }
@keyframes flash { from { background: rgba(255, 181, 71, 0.16); } to { background: transparent; } }

/* tmux-style status line */
.statusline { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 -18px; padding: 3px 18px;
  background: #1c1509; border-top: 1px solid var(--line); font-size: 12px; color: var(--dim); }
.statusline b { color: var(--fg); font-weight: 400; }
.statusline a { color: var(--dim); text-decoration: none; margin-left: 6px; }
.statusline a[aria-current], .statusline a:hover { color: var(--hot); }
.dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.dot.off { background: var(--err); box-shadow: 0 0 6px var(--err); }
.dot.busy { background: var(--fg); box-shadow: 0 0 6px var(--fg); }

/* docs page */
.docs .grid { max-width: 820px; gap: 22px; }
.docs .pane ul, .docs .pane ol { margin: 0 0 10px; padding-left: 22px; }
.docs .pane li { margin-bottom: 4px; }
.docs .pane b { color: var(--hot); font-weight: 400; }
.docs .note { color: var(--dim); font-size: 12px; border-left: 2px solid var(--faint); padding-left: 10px; }
.docs .toc ol { columns: 2; column-gap: 24px; font-size: 13px; }
.docs .toc a { color: var(--fg); text-decoration: none; }
.docs .toc a:hover { color: var(--hot); }
.faq dt { color: var(--hot); margin-top: 8px; }
.faq dd { margin: 2px 0 0; }
.docs section { scroll-margin-top: 16px; }

/* leaderboard */
.lb { list-style: none; margin: 0; padding: 0; }
.lb li { padding: 4px 0; border-bottom: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.lb .rk { color: var(--dim); width: 3ch; }
.lb .pts { color: var(--cyan); margin-left: auto; }
.lb .hint { width: 100%; padding-left: calc(3ch + 10px); }
#mine .stats { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 600px) { #mine .stats { grid-template-columns: repeat(2, 1fr); } }

/* join page */
.page .grid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; max-width: 760px; align-content: start; overflow-y: auto; padding-top: 10px; }
.page .pane p, .page .pane ol { margin: 0 0 10px; }
.page .pane ol { padding-left: 22px; }
.page code { color: var(--hot); }
.page input { background: transparent; border: 0; border-bottom: 1px solid var(--dim); color: var(--hot); font: inherit; outline: none; width: 16em; }
.page input:focus { border-color: var(--fg); }
.page form { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.hint { color: var(--dim); font-size: 12px; }
.cmd { display: block; white-space: pre-wrap; word-break: break-all; border: 1px dashed var(--dim); padding: 10px; margin: 8px 0; color: var(--hot); }

@media (max-width: 900px) {
  html, body { height: auto; }
  .shell { height: auto; min-height: 100vh; min-height: 100dvh; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .chat { height: 72vh; height: 72dvh; } /* dvh tracks the phone's address bar */
  .map canvas { max-width: 320px; margin: 0 auto; }
  .feed { max-height: 260px; }
}
@media (max-width: 600px) {
  .shell { padding: 10px 12px 0; gap: 12px; }
  .grid { gap: 16px; }
  .statusline { margin: 0 -12px; padding: 4px 12px calc(4px + env(safe-area-inset-bottom)); }
  .statusline .r { font-size: 11px; }
  .pane { padding: 14px 10px 10px; }
  form.prompt { margin: 0 -10px; padding: 8px 10px; align-items: center; }
  /* iOS zooms into any field under 16px when tapped */
  textarea, select, .page input { font-size: 16px; }
  .prompt .long { display: none; }
  button { min-height: 36px; padding: 4px 12px; }
  .model { right: 6px; }
  .tag { width: 100%; }
  .docs .toc ol { columns: 1; }
  .links { margin-left: 0; font-size: 13px; }
  .links a { padding: 4px 0; }
  .top .wallet-btn { margin-left: 0 !important; }
  .top .ca { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .cur, #feed li.new { animation: none; }
}
