/* Polybot — instrument panel.
   Direction: a rack of gauges, read in the dark, one warm accent reserved
   entirely for the control that stops things. The signature element is the
   probability track: on a prediction market, price IS probability, so every
   position renders as a 0→1 rail with entry and mark placed on it. */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --ground:  #131A22;
  --panel:   #1B242E;
  --panel-2: #212C38;
  --rule:    #2C3844;
  --bone:    #E4E7E1;
  --muted:   #77879A;
  --dim:     #4E5E6E;
  --gain:    #6FD6B3;
  --loss:    #E9736A;
  --brass:   #C79A4E;

  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;

  --gap: 14px;
  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ground);
  color: var(--bone);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body {
  padding:
    env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

main { padding: 0 var(--gap) 96px; }

/* --- Token gate ---------------------------------------------------- */

.gate {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: var(--gap);
  background: var(--ground);
  z-index: 50;
}
.gate-inner { width: 100%; max-width: 340px; }
.gate-title {
  font-family: var(--mono);
  font-size: 15px; font-weight: 600;
  letter-spacing: 0.24em; text-transform: uppercase;
  margin: 0 0 8px;
}
.gate-note { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 20px; }
.gate-note code { font-family: var(--mono); color: var(--bone); }
.gate-error { color: var(--loss); font-size: 13px; margin: 12px 0 0; }

.field {
  width: 100%; padding: 12px 13px;
  background: var(--panel); color: var(--bone);
  border: 1px solid var(--rule); border-radius: var(--radius);
  font-family: var(--mono); font-size: 15px;
  margin-bottom: 10px;
}
.field:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }

/* --- Masthead ------------------------------------------------------ */

.masthead {
  position: sticky; top: 0; z-index: 20;
  padding: 14px var(--gap) 11px;
  background: color-mix(in srgb, var(--ground) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
}
.masthead-row { display: flex; align-items: center; gap: 9px; }

.wordmark {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase;
}

.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--dim); flex: none;
  transition: background 240ms ease;
}
.pulse.is-live   { background: var(--gain); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gain) 18%, transparent); }
.pulse.is-stale  { background: var(--brass); }
.pulse.is-halted { background: var(--loss); }
@media (prefers-reduced-motion: no-preference) {
  .pulse.is-live { animation: breathe 2.6s ease-in-out infinite; }
}
@keyframes breathe { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--gain) 6%, transparent); } }

.chip {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 3px 7px; border: 1px solid var(--rule);
  border-radius: var(--radius); color: var(--muted);
}
.chip.is-live { color: var(--brass); border-color: color-mix(in srgb, var(--brass) 45%, transparent); }

.icon-btn {
  margin-left: auto;
  background: none; border: none; color: var(--muted);
  font-size: 17px; cursor: pointer; padding: 4px 6px;
  font-family: var(--mono);
}
.icon-btn:active { color: var(--bone); }

.health-line {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  margin: 7px 0 0; letter-spacing: 0.02em;
}

/* --- Tabs ---------------------------------------------------------- */

.tabs {
  display: flex; gap: 2px;
  padding: 10px var(--gap) 0;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  background: none; border: none; border-bottom: 1px solid transparent;
  color: var(--muted); cursor: pointer;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase;
  padding: 9px 11px;
}
.tab.is-active { color: var(--bone); border-bottom-color: var(--bone); }
.tab:focus-visible { outline: 2px solid var(--brass); outline-offset: -2px; }

/* --- Readouts ------------------------------------------------------ */

.readout-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--rule); border: 1px solid var(--rule);
  border-radius: var(--radius); overflow: hidden;
  margin-top: var(--gap);
}
.readout {
  background: var(--panel);
  padding: 13px 13px 14px;
  display: flex; flex-direction: column; gap: 3px;
}
.readout-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--muted);
}
.readout-value {
  font-family: var(--mono); font-size: 23px; font-weight: 500;
  line-height: 1.15; font-variant-numeric: tabular-nums;
}
.readout-value.is-gain { color: var(--gain); }
.readout-value.is-loss { color: var(--loss); }
.readout-sub { font-family: var(--mono); font-size: 10px; color: var(--dim); }

.meter { height: 2px; background: var(--rule); margin: 6px 0 2px; }
.meter-fill { height: 100%; width: 0; background: var(--muted); transition: width 400ms ease, background 400ms ease; }
.meter-fill.is-warn { background: var(--brass); }
.meter-fill.is-over { background: var(--loss); }

/* --- Sections ------------------------------------------------------ */

.section-head {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted);
  margin: 26px 0 9px;
}

.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--panel);
  margin-bottom: 6px;
  font-family: var(--mono); font-size: 12px;
}
.feed-name { color: var(--bone); }
.feed-state { margin-left: auto; color: var(--muted); font-size: 11px; }
.feed-state.is-ok   { color: var(--gain); }
.feed-state.is-bad  { color: var(--loss); }

/* --- Cards --------------------------------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 13px; margin: 8px 0;
}
.card-question {
  font-size: 14px; line-height: 1.4; font-weight: 500;
  margin: 0 0 3px;
}
.card-context {
  font-family: var(--mono); font-size: 10px; color: var(--dim);
  letter-spacing: 0.06em; margin: 0 0 11px;
}
.card-figures {
  display: flex; gap: 18px; margin-top: 11px;
  font-family: var(--mono); font-size: 11px;
}
.figure { display: flex; flex-direction: column; gap: 2px; }
.figure-label { color: var(--dim); font-size: 9px; letter-spacing: 0.13em; text-transform: uppercase; }
.figure-value { font-size: 13px; font-variant-numeric: tabular-nums; }
.figure-value.is-gain { color: var(--gain); }
.figure-value.is-loss { color: var(--loss); }

/* --- Signature: the probability track ------------------------------ */
/* A 0→1 rail. Entry price is a hairline tick, current mark is a filled
   dot, and the span between them is the position's fortune, drawn to
   scale. Reading the rack tells you where the book sits on every
   question without reading a single number. */

.track {
  position: relative; height: 26px; margin-top: 4px;
  border-top: 1px solid var(--rule);
}
.track-rail {
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: var(--rule);
}
.track-span {
  position: absolute; top: 0; height: 3px;
  background: var(--muted);
}
.track-span.is-gain { background: var(--gain); }
.track-span.is-loss { background: var(--loss); }
.track-entry {
  position: absolute; top: -3px; width: 1px; height: 9px;
  background: var(--bone);
}
.track-mark {
  position: absolute; top: -2.5px;
  width: 7px; height: 7px; margin-left: -3.5px;
  border-radius: 50%; background: var(--bone);
}
.track-mark.is-gain { background: var(--gain); }
.track-mark.is-loss { background: var(--loss); }
.track-mark.is-stale { background: var(--dim); }
.track-scale {
  position: absolute; top: 12px; left: 0; right: 0;
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 9px; color: var(--dim);
}
.track-caption {
  position: absolute; top: 11px;
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  transform: translateX(-50%); white-space: nowrap;
}

/* --- Rows (activity) ----------------------------------------------- */

.row {
  display: flex; gap: 10px; align-items: baseline;
  padding: 9px 11px; margin-bottom: 4px;
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-family: var(--mono); font-size: 11px;
}
.row-time { color: var(--dim); flex: none; }
.row-body { flex: 1; color: var(--muted); line-height: 1.45; word-break: break-word; }
.row-verdict { flex: none; font-size: 10px; letter-spacing: 0.1em; }
.row-verdict.is-ok  { color: var(--gain); }
.row-verdict.is-no  { color: var(--dim); }

/* --- Danger zone --------------------------------------------------- */
/* The only warm element on the page. If something is glowing, it stops things. */

.danger {
  display: flex; align-items: center; gap: 14px;
  margin: 30px 0 10px; padding: 14px;
  border: 1px solid color-mix(in srgb, var(--brass) 40%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--brass) 5%, var(--panel));
}
.danger-copy { display: flex; flex-direction: column; gap: 3px; }
.danger-title {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--brass);
}
.danger-note { font-size: 12px; color: var(--muted); line-height: 1.4; }

/* --- Buttons ------------------------------------------------------- */

.btn {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 11px 16px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
}
.btn:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.btn-primary { width: 100%; background: var(--bone); color: var(--ground); }
.btn-danger {
  margin-left: auto; flex: none;
  background: var(--brass); color: #17120A;
}
.btn-resume { background: none; border-color: var(--rule); color: var(--bone); }

.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--dim); font-family: var(--mono); font-size: 11px;
  text-decoration: underline; text-underline-offset: 3px;
}

/* --- Empty & footer ------------------------------------------------ */

.empty {
  padding: 34px 14px; text-align: center;
  color: var(--muted); font-size: 13px; line-height: 1.55;
}
.empty strong { display: block; color: var(--bone); font-weight: 500; margin-bottom: 5px; }

.footer { padding: 0 var(--gap) 34px; text-align: center; }

@media (min-width: 640px) {
  main, .masthead, .tabs, .footer { max-width: 720px; margin-inline: auto; }
  .readout-grid { grid-template-columns: repeat(4, 1fr); }
}

.gate[hidden] { display: none; }

.gate[hidden] { display: none; }
