:root {
  color-scheme: dark;
  --bg: #020906;
  --panel: rgba(7, 23, 15, 0.92);
  --panel-strong: rgba(10, 31, 20, 0.98);
  --ink: #edf7f0;
  --muted: #849b8c;
  --line: #1b392b;
  --line-bright: #28523d;
  --green: #62d99f;
  --amber: #efc459;
  --red: #ef6666;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% -8%, rgba(38, 125, 76, 0.25), transparent 27rem),
    radial-gradient(circle at 96% 12%, rgba(60, 101, 78, 0.10), transparent 22rem),
    linear-gradient(180deg, #06120c, var(--bg) 68%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
summary {
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.35rem, 7vw, 2.15rem);
  letter-spacing: -0.045em;
}

h2 {
  font-size: 1rem;
}

noscript {
  display: block;
  padding: 20px;
  color: var(--amber);
  text-align: center;
}

.shell {
  width: min(1380px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.topbar,
.section-heading,
.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  align-items: flex-start;
  margin-bottom: 12px;
}

.brand-block,
.signal-copy-block,
.section-heading > div {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  line-height: 1.4;
}

.section-kicker {
  margin-bottom: 3px;
}

.connection-block {
  display: flex;
  align-items: flex-end;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 7px;
}

.health-badge {
  max-width: 48vw;
  overflow: hidden;
  border: 1px solid var(--amber);
  border-radius: 999px;
  padding: 7px 9px;
  color: var(--amber);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-badge.synced {
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 28px rgba(98, 217, 159, 0.12);
}

.health-badge.danger {
  border-color: var(--red);
  color: var(--red);
}

.ghost-button,
.icon-button,
.secondary-button,
.primary-button {
  min-height: 42px;
  border-radius: 10px;
  cursor: pointer;
}

.ghost-button {
  min-height: 28px;
  border: 0;
  padding: 2px 4px;
  color: var(--muted);
  background: transparent;
  font-size: 0.7rem;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.signal-card {
  display: flex;
  min-height: 174px;
  align-items: center;
  gap: 15px;
  padding: 17px;
  overflow: hidden;
}

.number-ball {
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid #718078;
  border-radius: 50%;
  background: #202925;
  font: 800 2.35rem/1 Georgia, serif;
  box-shadow: inset 0 0 24px rgba(255, 255, 255, 0.04), 0 12px 32px rgba(0, 0, 0, 0.22);
}

.number-ball.red,
.outcome.red {
  border-color: #cc5a62;
  background: #a8343d;
}

.number-ball.green,
.outcome.green {
  border-color: #4abb84;
  background: #147044;
}

.number-ball.black,
.outcome.black {
  border-color: #53615a;
  background: #202925;
}

.number-ball.neutral {
  color: var(--muted);
}

.signal-code {
  margin: 8px 0 5px;
  color: var(--amber);
  font: 800 clamp(3.35rem, 17vw, 6.2rem) / 0.82 Georgia, serif;
  letter-spacing: -0.055em;
}

.signal-code.go {
  color: var(--green);
  text-shadow: 0 0 36px rgba(98, 217, 159, 0.14);
}

.signal-code.stop {
  color: var(--red);
}

.signal-action {
  color: #f1dc96;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.07em;
}

.signal-copy {
  max-width: 720px;
  margin-top: 6px;
  color: #b9ccbf;
  font-size: 0.78rem;
  line-height: 1.45;
}

.snapshot-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.4;
}

.outcomes-panel,
.banks-panel,
.graph-panel {
  margin-top: 12px;
  padding: 15px;
}

.fresh-direction,
.readonly-mark,
.wallet-key {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.68rem;
}

.readonly-mark {
  border: 1px solid var(--line-bright);
  border-radius: 999px;
  padding: 5px 8px;
}

.outcome-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 55px;
  margin-right: -15px;
  padding: 12px 15px 2px 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scrollbar-color: var(--line-bright) transparent;
  scrollbar-width: thin;
}

.outcome {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #53615a;
  border-radius: 50%;
  background: #212a26;
  font-size: 0.86rem;
  font-weight: 850;
}

.outcome.latest {
  outline: 2px solid rgba(237, 247, 240, 0.72);
  outline-offset: 2px;
}

.empty-inline,
.graph-empty {
  color: var(--muted);
  font-size: 0.8rem;
}

.summary-grid,
.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

.metric-card {
  min-height: 150px;
  padding: 17px;
}

.large-value {
  margin: 9px 0 11px;
  color: var(--green);
  font: 800 3.25rem/1 Georgia, serif;
}

.negative {
  color: var(--red) !important;
}

.positive {
  color: var(--green) !important;
}

.neutral-value {
  color: var(--muted);
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-top: 1px solid rgba(40, 82, 61, 0.42);
  color: var(--muted);
  font-size: 0.74rem;
}

.metric-row strong {
  color: var(--ink);
  text-align: right;
  overflow-wrap: anywhere;
}

.episode-state {
  margin: 11px 0 14px;
  color: #dce9df;
  font: 750 1.2rem/1.15 Georgia, serif;
}

.bank-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 13px;
}

.bank {
  min-width: 0;
  border: 1px solid #1c3a2c;
  border-top: 2px solid var(--bank-color, #1c3a2c);
  border-radius: 11px;
  padding: 10px 9px;
  background: rgba(9, 30, 19, 0.72);
}

.bank p {
  min-height: 33px;
  color: #dce9df;
  font-size: 0.56rem;
  font-weight: 850;
  line-height: 1.25;
}

.bank strong {
  display: block;
  margin: 7px 0 6px;
  color: var(--muted);
  font: 800 1.28rem/1 Georgia, serif;
}

.bank small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.58rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  margin: 12px 0 4px;
  color: var(--muted);
  font-size: 0.58rem;
}

.legend span::before,
.wallet-key i {
  display: inline-block;
  width: 10px;
  height: 3px;
  margin-right: 5px;
  background: var(--series);
  content: "";
  vertical-align: middle;
}

.series-0 { --bank-color: #62d9a0; --series: #62d9a0; }
.series-1 { --bank-color: #f1c75b; --series: #f1c75b; }
.series-2 { --bank-color: #ae9bff; --series: #ae9bff; }
.series-3 { --bank-color: #59a987; --series: #59a987; }
.series-4 { --bank-color: #d5962f; --series: #d5962f; }
.series-5 { --bank-color: #8e73e8; --series: #8e73e8; }
.series-6 { --bank-color: #7bd5f0; --series: #7bd5f0; }
.series-7 { --bank-color: #ffe291; --series: #ffe291; }
.series-8 { --bank-color: #d4c5ff; --series: #d4c5ff; }

.wallet-key i {
  background: #f5fff8;
}

.graph-wrap {
  width: 100%;
  min-height: 215px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.graph-wrap svg {
  display: block;
  min-width: 680px;
  width: 100%;
  height: auto;
}

.grid-line {
  stroke: #173326;
  stroke-width: 1;
}

.zero-line {
  stroke: #315340;
  stroke-dasharray: 5 6;
  stroke-width: 1;
}

.graph-empty {
  display: grid;
  min-height: 215px;
  place-items: center;
  text-align: center;
}

.detail-panel {
  padding: 16px;
}

.detail-panel summary {
  min-height: 30px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 850;
}

.detail-panel dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  margin: 13px 0 0;
}

.detail-panel dt {
  color: var(--muted);
  font-size: 0.68rem;
}

.detail-panel dd {
  margin: 0 0 7px;
  overflow-wrap: anywhere;
  font-size: 0.77rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.hash {
  font-size: 0.64rem !important;
}

footer {
  padding: 20px 8px 4px;
  color: #6c8476;
  text-align: center;
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.5;
}

.endpoint-label {
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0;
}

.settings-dialog {
  width: min(520px, calc(100% - 20px));
  max-height: min(760px, calc(100vh - 20px));
  border: 1px solid var(--line-bright);
  border-radius: 18px;
  padding: 0;
  color: var(--ink);
  background: #081a11;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.65);
}

.settings-dialog::backdrop {
  background: rgba(0, 6, 3, 0.78);
  backdrop-filter: blur(5px);
}

.settings-form {
  padding: 18px;
}

.dialog-heading {
  align-items: flex-start;
  margin-bottom: 18px;
}

.icon-button {
  width: 42px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 1.55rem;
}

.settings-form label {
  display: block;
  margin: 15px 0 6px;
  color: #dce9df;
  font-size: 0.78rem;
  font-weight: 800;
}

.settings-form input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-bright);
  border-radius: 11px;
  padding: 10px 12px;
  outline: none;
  color: var(--ink);
  background: #041009;
}

.settings-form input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(98, 217, 159, 0.10);
}

.field-help {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.45;
}

.settings-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--red);
  font-size: 0.72rem;
}

.dialog-actions {
  align-items: stretch;
  margin-top: 7px;
}

.secondary-button,
.primary-button {
  flex: 1;
  border: 1px solid var(--line-bright);
  padding: 10px 13px;
  font-weight: 800;
}

.secondary-button {
  color: var(--muted);
  background: transparent;
}

.primary-button {
  border-color: var(--green);
  color: #03130a;
  background: var(--green);
}

button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

@media (min-width: 620px) {
  .shell {
    padding: 18px;
  }

  .signal-card {
    gap: 23px;
    padding: 22px;
  }

  .number-ball {
    width: 106px;
    height: 106px;
    font-size: 3.1rem;
  }

  .summary-grid,
  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }

  .bank-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .detail-panel dl {
    grid-template-columns: minmax(115px, 0.42fr) 1fr;
    gap: 8px 14px;
  }

  .detail-panel dd {
    margin-bottom: 0;
  }
}

@media (min-width: 980px) {
  .shell {
    padding: 22px;
  }

  .topbar {
    margin-bottom: 17px;
  }

  .signal-card {
    min-height: 202px;
    padding: 25px;
  }

  .number-ball {
    width: 118px;
    height: 118px;
    font-size: 3.45rem;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .bank-grid {
    grid-template-columns: repeat(9, minmax(105px, 1fr));
  }

  .bank {
    padding: 12px;
  }

  .bank p {
    font-size: 0.62rem;
  }

  .outcomes-panel,
  .banks-panel,
  .graph-panel {
    margin-top: 14px;
    padding: 19px;
  }

  .outcome-strip {
    margin-right: -19px;
    padding-right: 19px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
