/*
 * ArbiStocks app.css (owner: app). The two parestocks-shaped working pages in typesafe skin:
 *   /app     top bar + big tabbed card (Scan, Route, Run) + right column windows (Pools, Your Cycles, Tape, Engine)
 *   /oracle  consensus table, heat table of pools vs consensus, how to read it
 * Both sit on the pink field (body[data-ground="pink"]) inside a dotted OS field like typesafe's home OS section.
 * Loaded after css/base.css and uses its tokens, breakpoints (1439 / 1199 / 809) and components.
 * No inline styles anywhere (strict CSP): positions and widths set from JS go through el.style.
 */

:root {
  --up: #006633;             /* positive values on white / #dedede (7.3:1 / 5.2:1) */
  --up-dark: #7be3a8;        /* positive values on ink */
  --line: rgba(30, 30, 30, 0.16);
  --line-2: rgba(30, 30, 30, 0.32);
  --muted: rgba(30, 30, 30, 0.7);   /* 4.9:1 on #dedede, 7:1 on white */
  --app-gap: 20px;
}

/* ============================================================== page frame */

.app-page { padding-top: 20px; }
.app-shell { position: relative; }

.app-field {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 50px 30px 40px;
}
.app-field__label { position: absolute; left: 0; top: 0; z-index: 3; }
.app-field__art { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }  /* no z-index: the blobs must multiply onto the field, not onto a new stacking context */
.app-blob {
  position: absolute;
  width: 1700px;
  max-width: none;
  height: 1700px;
  mix-blend-mode: multiply;
  image-rendering: pixelated;
}
.app-blob--a { left: calc(46% - 850px); bottom: -1180px; }
.app-blob--b { left: calc(96% - 850px); top: -960px; }
.app-blob--c { left: calc(2% - 850px); top: 20%; }
.app-field > .os-window, .app-field > .app-grid { position: relative; z-index: 1; }

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: var(--app-gap);
  align-items: start;
  margin-top: var(--app-gap);
}
.app-col { display: flex; flex-direction: column; gap: var(--app-gap); min-width: 0; }

/* shared small type */
.app-sub { font: 500 18px/1 var(--font-pixel); letter-spacing: 0.01em; color: var(--ink); }
.app-sub--muted { font: 300 12px/1.2 var(--font-mono); letter-spacing: 0.03em; color: var(--muted); }
.app-fine { margin-top: 12px; font: 400 13px/1.35 var(--font-body); letter-spacing: 0.03em; color: var(--muted); text-wrap: pretty; }
.app-fine--risk { margin-top: 16px; }
.app-empty { font: 400 14px/1.35 var(--font-body); letter-spacing: 0.03em; color: var(--muted); padding: 4px 2px; }
.app-list--dark .app-empty { color: rgba(254, 254, 254, 0.78); font-family: var(--font-mono); font-size: 12px; }
.up { color: var(--up); }
.down { color: var(--muted); }
.t-num { font-family: var(--font-mono); font-weight: 400; font-variant-numeric: tabular-nums; letter-spacing: 0; }

.live.is-loading { color: color-mix(in srgb, currentColor 78%, transparent); animation: app-blink 1.2s steps(2, jump-none) infinite; } /* dimmed from the ground's own colour, so it holds on paper and on ink */
@keyframes app-blink { 50% { opacity: 0.45; } }

.app-logo {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border: 1px solid var(--ink);
  background: var(--paper);
  overflow: hidden;
  font: 500 14px/1 var(--font-pixel);
  color: var(--ink);
}
.app-logo img { width: 100%; height: 100%; object-fit: cover; }
.app-logo--lg { width: 34px; height: 34px; font-size: 20px; }

/* pixel chips */
.chip {
  display: inline-block;
  padding: 1px 4px 3px;
  font: 500 15px/1 var(--font-pixel);
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: var(--grey-2);
  color: var(--ink);
}
.chip--open { background: var(--ink); color: var(--pink); }
.chip--band { background: var(--grey-1); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.chip--thin { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-2); }
.chip--live { background: var(--ink); color: var(--up-dark); }

/* ============================================================== top bar */

.app-top__body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 26px;
  padding: 10px 12px 12px;
  font: 400 14px/1.2 var(--font-body);
}
.app-top__label { display: block; font: 300 11px/1.2 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.app-top__stat { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.app-top__value { font-size: 20px; line-height: 1; color: var(--ink); white-space: nowrap; }
.app-top__ago { font-size: 11px; color: var(--muted); min-height: 13px; }
.app-top__block .app-top__value { transition: color 0.3s var(--ease); }
.app-top__block .app-top__value.is-tick { color: var(--magenta); transition: none; }

.app-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 6px 12px 6px 6px;
  border: var(--border) solid var(--ink);
  background: var(--grey-1);
  box-shadow: inset -2px -2px 0 var(--grey-2), inset 2px 2px 0 var(--white);
  text-align: left;
  color: var(--ink);
}
.app-pick:hover { background: var(--ink); color: var(--paper); box-shadow: none; }
.app-pick:hover .app-pick__sub { color: rgba(254, 254, 254, 0.8); }
.app-pick__logo { display: contents; }
.app-pick__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.app-pick__sym { font: 500 26px/1 var(--font-pixel); letter-spacing: 0.01em; white-space: nowrap; }
.app-pick__sub { font: 300 11px/1.2 var(--font-mono); letter-spacing: 0.03em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.app-pick__caret { flex: none; }

.app-top__strip { flex: 1 1 200px; min-width: 160px; display: flex; flex-direction: column; gap: 4px; }
.app-top__strip-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.app-top__spread { font-size: 13px; color: var(--ink); }
.strip { position: relative; height: 18px; }
.strip__line { position: absolute; left: 0; right: 0; top: 50%; height: 1.2px; background: var(--ink); }
.strip__mark {
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  background: var(--ink);
  transform: translate(-50%, -50%);
}
.strip__mark--thin { background: var(--paper); box-shadow: inset 0 0 0 1.2px var(--ink); }
.strip__mid { position: absolute; top: 1px; bottom: 1px; width: 2px; background: var(--magenta); transform: translateX(-50%); }
.strip__ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

.engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 2px 6px 4px;
  background: var(--ink);
  color: var(--grey-1);
  font: 500 18px/1 var(--font-pixel);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.engine-pill__dot { width: 8px; height: 8px; background: var(--pink); flex: none; }
.engine-pill[data-mode='live'] .engine-pill__dot { background: var(--up-dark); }
.engine-pill[data-mode='paused'] .engine-pill__dot { background: var(--magenta); }

/* ============================================================== the big card */

.app-card__body { padding: 14px 16px 18px; font: 400 15px/1.3 var(--font-body); letter-spacing: 0.03em; }
.app-tabs-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.app-tabs { display: flex; gap: 5px; }
.app-tab, .guard__opt {
  position: relative;
  padding: 5px 14px 7px;
  border: var(--border) solid var(--ink);
  background: var(--grey-1);
  box-shadow: inset -2px -2px 0 var(--grey-2), inset 2px 2px 0 var(--white);
  color: var(--ink);
  font: 500 20px/1 var(--font-pixel);
  letter-spacing: 0.01em;
}
.app-tab:hover, .guard__opt:hover { background: var(--grey-2); }
.app-tab[aria-selected='true'], .guard__opt[aria-checked='true'] { background: var(--ink); color: var(--pink); box-shadow: none; }
.app-tabs-note { font: 300 12px/1.2 var(--font-mono); letter-spacing: 0.03em; color: var(--muted); }

.app-panel[hidden] { display: none; }

/* ---------------------------------------------------------------- scan */

.scan-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.scan-sum { font: 400 15px/1.2 var(--font-body); color: var(--ink-86); }
.scan-sum .t-num { color: var(--ink); font-size: 16px; }
.app-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font: 500 18px/1 var(--font-pixel); color: var(--ink); }
.app-check input { appearance: none; width: 16px; height: 16px; margin: 0; border: var(--border) solid var(--ink); background: var(--paper); display: grid; place-items: center; cursor: pointer; }
.app-check input:checked { background: var(--ink); box-shadow: inset 0 0 0 3px var(--paper); }

.scan-wrap { overflow: auto; max-height: 640px; border-top: var(--border) solid var(--ink); border-bottom: 1px solid var(--line-2); overscroll-behavior: contain; }
.scan thead th { position: sticky; top: 0; z-index: 1; background: var(--white); }
.scan, .pools, .otable, .heat { width: 100%; border-collapse: collapse; }
.scan th, .pools th, .otable th {
  padding: 8px 8px 7px;
  text-align: left;
  font: 300 11px/1.2 var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--line-2);
}
.scan th button, .otable th button { display: inline-flex; align-items: center; gap: 5px; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; }
.scan th button:hover, .otable th button:hover { color: var(--ink); }
.scan th[aria-sort] button::after, .otable th[aria-sort] button::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0.25;
  border-top: 5px solid currentColor;
}
.scan th[aria-sort='ascending'] button::after, .otable th[aria-sort='ascending'] button::after { border-top: 0; border-bottom: 5px solid currentColor; opacity: 1; }
.scan th[aria-sort='descending'] button::after, .otable th[aria-sort='descending'] button::after { opacity: 1; }
.scan td, .pools td, .otable td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; font: 400 13px/1.2 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.scan tbody tr { cursor: pointer; transition: background-color 0.15s var(--ease); }
.scan tbody tr:hover { background: var(--grey-1); }
.scan tbody tr.is-sel { background: var(--pink); }
.scan tbody tr.is-sel .stk__name { color: var(--ink-86); }
.scan__loading td { padding: 18px 8px; cursor: default; }
.scan .n, .pools .n, .otable .n { text-align: right; }
.scan th.c-edge, .scan th.c-pools, .scan th.c-spread { text-align: right; }
.scan td.c-edge, .scan td.c-pools, .scan td.c-spread { text-align: right; }
.scan th.c-edge button, .scan th.c-pools button, .scan th.c-spread button { flex-direction: row-reverse; }

.stk { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stk__btn { display: flex; align-items: center; gap: 8px; min-width: 0; text-align: left; }
.stk__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stk__sym { font: 500 18px/1 var(--font-pixel); letter-spacing: 0.01em; color: var(--ink); }
.stk__name { font: 400 12px/1.1 var(--font-body); letter-spacing: 0.02em; color: var(--muted); max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.c-route { font-family: var(--font-body) !important; font-size: 13px !important; letter-spacing: 0.02em; }
.c-route .rl { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

.mini { position: relative; display: block; width: 64px; height: 7px; margin: 4px 0 0 auto; }
.mini::before { content: ''; position: absolute; left: 0; right: 0; top: 3px; height: 1px; background: var(--ink); }
.mini__mark { position: absolute; top: 0; width: 7px; height: 7px; background: var(--ink); transform: translateX(-50%); }

/* ---------------------------------------------------------------- route */

.route-stock { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.route-stock__empty { font: 400 15px/1.3 var(--font-body); color: var(--muted); }
.route-stock__sym { font: 500 28px/1 var(--font-pixel); background: var(--ink); color: var(--paper); padding: 2px 4px 4px; letter-spacing: 0.01em; }
.route-stock__meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.route-stock__name { font: 500 20px/1.1 var(--font-display); color: var(--ink); letter-spacing: 0; }
.route-stock__sub { font: 300 12px/1.2 var(--font-mono); color: var(--muted); }

.route-block { margin-top: 18px; }
.route-block__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 8px; }

.routes { display: flex; flex-direction: column; border-top: 1px solid var(--line-2); }
.route {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  color: var(--ink);
  transition: background-color 0.15s var(--ease);
}
.route:hover { background: var(--grey-1); }
.route__radio { width: 12px; height: 12px; border: var(--border) solid var(--ink); background: var(--paper); }
.route[aria-checked='true'] { background: var(--ink); color: var(--paper); }
.route[aria-checked='true'] .route__radio { background: var(--pink); border-color: var(--paper); }
.route[aria-checked='true'] .route__sub { color: rgba(254, 254, 254, 0.78); }
.route[aria-checked='true'] .up { color: var(--up-dark); }
.route[aria-checked='true'] .down { color: rgba(254, 254, 254, 0.78); }
.route__main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.route__label { font: 400 15px/1.2 var(--font-body); letter-spacing: 0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route__sub { font: 300 11px/1.2 var(--font-mono); color: var(--muted); }
.route__edge { font: 400 14px/1 var(--font-mono); white-space: nowrap; text-align: right; }
.app-more { margin-top: 8px; font: 500 18px/1 var(--font-pixel); color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.app-more:hover { color: var(--magenta); }

.size-row { display: flex; gap: 8px; align-items: stretch; }
.size-field { display: flex; align-items: center; flex: 1 1 auto; min-width: 0; border: var(--border) solid var(--ink); background: var(--white); padding: 0 10px; }
.size-field:focus-within { outline: 2px solid var(--magenta); outline-offset: 2px; }
.size-field__cur { font: 500 26px/1 var(--font-pixel); color: var(--muted); }
.size-field__input { flex: 1 1 auto; min-width: 0; width: 100%; padding: 10px 6px; border: 0; background: transparent; font-size: 24px; color: var(--ink); outline: none; }
.size-row .os-button { padding-inline: 14px; }
.size-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.size-chip { padding: 2px 7px 4px; border: 1px solid var(--line-2); background: var(--paper); font: 400 12px/1.3 var(--font-mono); color: var(--ink); }
.size-chip:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.size-chip[aria-pressed='true'] { background: var(--ink); color: var(--pink); border-color: var(--ink); }

.quote {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-top: 18px;
  padding: 12px 14px 12px;
  border: var(--border) solid var(--ink);
  background: var(--grey-1);
}
.quote__cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.quote__label { font: 500 18px/1 var(--font-pixel); color: var(--ink); }
.quote__big { font-size: 30px; line-height: 1; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote__big.up { color: var(--up); }
.quote__sub { font-size: 12px; color: var(--muted); min-height: 14px; overflow-wrap: anywhere; }
.quote__note { grid-column: 1 / -1; font: 300 12px/1.35 var(--font-mono); letter-spacing: 0.02em; color: var(--ink-86); border-top: 1px dashed var(--line-2); padding-top: 8px; }
.quote__note b { font-weight: 400; color: var(--ink); }
.quote[data-state='loading'] .quote__big { color: var(--grey-3); }
.quote[data-kind='estimate'] .quote__big { font-style: italic; }

.app-chart { margin-top: 18px; }
.chart { position: relative; height: 230px; }
.chart svg { display: block; width: 100%; height: 100%; }
.chart__empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; font: 400 14px/1.3 var(--font-body); color: var(--muted); text-align: center; }
.chart text { font-family: var(--font-mono); font-size: 10px; fill: var(--ink); }
.chart .ax-label { fill: var(--muted); }

.bd { display: flex; flex-direction: column; border-top: 1px solid var(--line-2); }
.bd__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 2px; border-bottom: 1px dashed var(--line-2); }
.bd dt { font: 400 15px/1.2 var(--font-body); color: var(--ink-86); }
.bd dd { margin: 0; font: 400 14px/1.2 var(--font-mono); text-align: right; color: var(--ink); overflow-wrap: anywhere; }
.bd__row--total { border-bottom: var(--border) solid var(--ink); }
.bd__row--total dt { font: 500 18px/1 var(--font-pixel); color: var(--ink); }
.bd__row--total dd { font-size: 18px; }
.bd__row--muted dt, .bd__row--muted dd { color: var(--muted); font-size: 13px; }
.bd dd small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

.guard { display: flex; gap: 5px; }
.guard__opt { flex: 1 1 0; font-size: 18px; }

/* ---------------------------------------------------------------- run */

.run-sum { margin-bottom: 18px; }
.run-sum dd { font-family: var(--font-body); font-size: 15px; }
.run-sum dd.t-num { font-family: var(--font-mono); font-size: 14px; }
.run-log__body { min-height: 150px; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.run-line { font: 400 13px/1.45 var(--font-mono); color: var(--paper); overflow-wrap: anywhere; }
.run-line::before { content: '> '; color: var(--pink); }
.run-line--ok { color: var(--up-dark); }
.run-line--err { color: var(--pink); }
.run-line--muted { color: rgba(254, 254, 254, 0.78); }
.run-line a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.run-line a:hover { color: var(--magenta); }
.run-big { font: 500 28px/1.1 var(--font-pixel); color: var(--up-dark); }
.run-big::before { content: ''; }
.spin { display: inline-block; width: 10px; height: 10px; margin-right: 6px; background: currentColor; animation: app-spin 0.9s steps(4) infinite; vertical-align: -1px; }
@keyframes app-spin { to { transform: rotate(360deg); } }

.app-action { margin-top: 20px; padding-top: 16px; border-top: var(--border) solid var(--ink); }
.app-action[hidden] { display: none; }
.app-run { height: 58px; font-size: 24px; line-height: 24px; }
.app-action__note { margin-top: 8px; font: 300 12px/1.35 var(--font-mono); letter-spacing: 0.02em; color: var(--ink-86); text-align: center; text-wrap: pretty; }
.app-action__note:empty { display: none; }

/* ============================================================== right column */

.pools th { font-size: 10px; padding: 7px 8px 6px; }
.pools td { font-size: 12px; padding: 7px 8px; }
.pools td:first-child { font: 500 17px/1 var(--font-pixel); }
.pools .pool-name { white-space: nowrap; }
.pools th:first-child, .pools td:first-child { padding-left: 10px; }
.pools th:last-child, .pools td:last-child { padding-right: 10px; }
.pools tr.is-thin td { color: var(--muted); }
.pools .depth { display: block; font-size: 11px; line-height: 1.25; }
.pools .tag { margin-left: 5px; }
@media (max-width: 1199px) {
  .pools th, .pools td { padding-inline: 5px; }
  .pools td:first-child { white-space: normal; }
  .pools .tag { display: table; margin: 4px 0 0; }
}
.pools-note { padding: 8px 10px 10px; font: 300 11px/1.35 var(--font-mono); color: var(--muted); border-top: 1px solid var(--line); }

.app-list { display: flex; flex-direction: column; gap: 0; padding: 4px 10px 8px; max-height: 360px; overflow-y: auto; }
.app-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; padding: 8px 0; border-bottom: 1px dashed var(--line-2); }
.app-item:last-child { border-bottom: 0; }
.app-item__sym { font: 500 18px/1 var(--font-pixel); color: var(--ink); }
.app-item__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-item__amt { font: 400 13px/1.2 var(--font-mono); color: var(--ink); }
.app-item__sub { font: 300 11px/1.2 var(--font-mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-item__tx { font: 400 11px/1.2 var(--font-mono); color: var(--ink); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.app-item__tx:hover { color: var(--magenta); }
.app-item.is-new { animation: app-flash 1.6s var(--ease) 1; }
@keyframes app-flash { 0%, 30% { background: var(--pink); } 100% { background: transparent; } }
.app-list--dark .app-item { border-bottom-color: rgba(254, 254, 254, 0.2); }
.app-list--dark .app-item.is-new { animation-name: app-flash-dark; }
@keyframes app-flash-dark { 0%, 30% { background: #4a4a4a; } 100% { background: transparent; } }
.app-list--dark .app-item__sym { color: var(--pink); }
.app-list--dark .app-item__amt, .app-list--dark .app-item__tx { color: var(--paper); }
.app-list--dark .app-item__sub { color: rgba(254, 254, 254, 0.78); }
.app-list--dark .app-item__tx:hover { color: var(--pink); }

.kv-px { display: flex; flex-direction: column; gap: 7px; padding: 4px 2px 2px; }
.kv-px > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.kv-px dt { font: 500 18px/1 var(--font-pixel); color: var(--ink); white-space: nowrap; }
.kv-px dd { margin: 0; font: 500 18px/1 var(--font-pixel); color: var(--ink); text-align: right; }

/* ============================================================== bottom note */

.app-foot { margin-top: 50px; }
.app-foot__inner { padding: 30px 30px 34px; }
.app-foot__text { max-width: 900px; font: 400 22px/1.2 var(--font-body); letter-spacing: 0.05em; color: var(--ink-86); text-wrap: pretty; }
.app-foot + .ascii-sep { margin-top: 40px; }

/* ============================================================== popovers and the wallet modal */

.app-pop { position: absolute; z-index: 60; width: 380px; max-width: calc(100vw - 20px); }
.app-pop[hidden] { display: none; }
.app-pop--wallet { width: 320px; }
.app-x { flex: none; width: 18px; height: 16px; margin-top: 1px; display: grid; place-items: center; border: 1px solid var(--grey-1); color: var(--grey-1); font: 500 14px/1 var(--font-pixel); }
.app-x:hover { background: var(--magenta); border-color: var(--magenta); color: var(--white); }
.os-window__bar .app-x { pointer-events: auto; }

.pick { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.pick__search { width: 100%; padding: 8px 10px; border: var(--border) solid var(--ink); background: var(--paper); font: 400 14px/1.2 var(--font-mono); color: var(--ink); }
.pick__search::placeholder { color: var(--muted); }
.pick__list { max-height: min(420px, 55vh); overflow-y: auto; display: flex; flex-direction: column; }
.pick__item { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; color: var(--ink); }
.pick__item:hover, .pick__item:focus-visible { background: var(--grey-1); }
.pick__item[aria-selected='true'] { background: var(--ink); color: var(--paper); }
.pick__item[aria-selected='true'] .pick__name { color: rgba(254, 254, 254, 0.78); }
.pick__sym { font: 500 18px/1 var(--font-pixel); }
.pick__name { font: 400 12px/1.2 var(--font-body); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick__edge { font: 400 12px/1 var(--font-mono); }
.pick__none { padding: 12px 6px; font: 400 14px/1.3 var(--font-body); color: var(--muted); }

.app-modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; }
.app-modal[hidden] { display: none; }
.app-modal__back { position: absolute; inset: 0; background: rgba(30, 30, 30, 0.55); }
.app-modal__win { position: relative; width: min(420px, 100%); }
.wallets { display: flex; flex-direction: column; gap: 10px; padding: 10px; }
.wallets__list { display: flex; flex-direction: column; gap: 6px; }
.wallet-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; justify-content: flex-start; font-size: 20px; }
.wallet-opt img { width: 22px; height: 22px; flex: none; }
.wallet-opt__ph { width: 22px; height: 22px; flex: none; background: var(--ink); }
.wallets__msg { font: 400 14px/1.35 var(--font-body); color: var(--ink); }
.wallets__msg:empty { display: none; }
.wallets__msg.is-err { color: var(--ink); padding: 6px 8px; background: var(--pink); }
.wallets__fine { font: 300 11px/1.4 var(--font-mono); color: var(--muted); }

.wallet-menu { display: flex; flex-direction: column; gap: 10px; padding: 10px; }
.wallet-menu__addr { font-size: 13px; line-height: 1.35; color: var(--ink); overflow-wrap: anywhere; }
.wallet-menu__meta { font: 400 13px/1.3 var(--font-body); color: var(--ink-86); }

/* ============================================================== /oracle */

.or-head { max-width: var(--container); margin: 40px auto 0; padding: 26px 30px 34px; }
.or-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; font: 300 12px/1.2 var(--font-mono); letter-spacing: 0.05em; color: var(--ink); }
.or-title { margin-top: 26px; font: 500 var(--fs-h2)/0.9 var(--font-display); color: var(--ink); text-transform: capitalize; text-wrap: balance; max-width: 980px; }
.or-lead { margin-top: 24px; max-width: 860px; font: 400 22px/1.2 var(--font-body); letter-spacing: 0.05em; color: var(--ink-86); text-wrap: pretty; }

.or-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.or-stat .os-window__body { display: flex; flex-direction: column; gap: 6px; padding: 8px 8px 10px; }
.or-stat__v { font: 400 22px/1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.or-stat__s { font: 300 11px/1.25 var(--font-mono); color: var(--muted); }

.or-sec { margin-top: 44px; }
.or-sec__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 12px; }
.or-h2 { display: flex; align-items: baseline; gap: 12px; padding: 2px 6px 4px 0; background: var(--pink); font: 500 30px/1 var(--font-display); color: var(--ink); letter-spacing: 0.01em; }
.or-h2 .or-num { font: 400 13px/1 var(--font-mono); color: var(--ink); }
.or-asof { padding: 2px 4px; background: var(--pink); font: 300 12px/1.2 var(--font-mono); color: var(--ink); }
.or-note { width: fit-content; max-width: 1000px; margin-top: 10px; padding: 6px 8px; background: var(--pink); font: 400 14px/1.4 var(--font-body); letter-spacing: 0.03em; color: var(--ink); text-wrap: pretty; }

.otable-wrap { overflow-x: auto; }
.th-sm { display: none; }
.otable td .sub { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.otable tbody tr:hover { background: var(--grey-1); }
.otable td.c-stock { font-family: var(--font-body); }
.otable .c-tag { text-align: right; }

.heat-wrap { overflow-x: auto; }
.heat { table-layout: fixed; min-width: 520px; }
.heat th { padding: 6px 4px; font: 500 14px/1 var(--font-pixel); color: var(--ink); text-align: center; border-bottom: var(--border) solid var(--ink); white-space: nowrap; }
.heat th small { display: block; margin-top: 3px; font: 300 10px/1 var(--font-mono); color: var(--muted); }
.heat th:first-child { text-align: left; width: 78px; }
.heat td { height: 26px; padding: 0 3px; border: 1px solid var(--paper); text-align: center; font: 400 11px/1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.heat td:first-child { text-align: left; font: 500 16px/1 var(--font-pixel); padding-left: 6px; background: transparent; }
.heat td.h-none { background: transparent; color: transparent; }
.heat td.h-thin { background: var(--paper); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.heat td.h-0 { background: #ececec; }
.heat td.h-p1 { background: #f6c9d6; }
.heat td.h-p2 { background: #ee9fbd; }
.heat td.h-p3 { background: #e27ab9; }
.heat td.h-p4 { background: var(--magenta); } /* ink, like the lighter buckets: white on this magenta is 3.5:1 */
.heat td.h-n1 { background: #cfe3e1; }
.heat td.h-n2 { background: #9fcdc8; }
.heat td.h-n3 { background: #5fb3ab; }
.heat td.h-n4 { background: #0b7f76; color: var(--white); }
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; width: fit-content; max-width: 100%; margin-top: 10px; padding: 6px 8px; background: var(--pink); font: 300 11px/1.2 var(--font-mono); color: var(--ink); }
.heat-legend span { display: inline-flex; align-items: center; gap: 5px; }
.heat-legend i { display: inline-block; width: 14px; height: 10px; }
.heat-legend .l-n4 { background: #0b7f76; } .heat-legend .l-n2 { background: #9fcdc8; } .heat-legend .l-0 { background: #ececec; }
.heat-legend .l-p2 { background: #ee9fbd; } .heat-legend .l-p4 { background: var(--magenta); } .heat-legend .l-thin { background: var(--paper); box-shadow: inset 0 0 0 1px var(--line-2); }

.or-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.or-card .os-window__body { padding: 10px 12px 14px; font: 400 15px/1.35 var(--font-body); letter-spacing: 0.03em; color: var(--ink); }
.or-card h3 { font: 500 20px/1 var(--font-pixel); margin-bottom: 10px; }
.or-card p + p { margin-top: 8px; }
.or-code pre { margin: 0; padding: 12px 14px; overflow-x: auto; font: 400 13px/1.55 var(--font-mono); color: var(--paper); }
.or-code .k { color: var(--pink); }
.or-code .c { color: rgba(254, 254, 254, 0.72); }

/* ============================================================== breakpoints */

@media (max-width: 1439px) {
  .app-grid { grid-template-columns: minmax(0, 1fr) 370px; }
}

@media (max-width: 1199px) {
  .app-field { padding: 46px 20px 30px; }
  .app-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .scan .c-route { display: none; }
  .app-top__body { gap: 12px 20px; }
  .or-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .or-cards { grid-template-columns: 1fr; }
  .or-head { padding: 22px 20px 30px; }
}

@media (max-width: 1023px) {
  .app-grid { grid-template-columns: minmax(0, 1fr) 290px; }
  .app-pick { min-width: 0; }
}

@media (max-width: 899px) {
  .app-grid { grid-template-columns: 1fr; }
  .app-col--side { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
}

@media (max-width: 809px) {
  :root { --app-gap: 14px; }
  .app-page { padding-top: 12px; }
  .app-field { padding: 34px 8px 16px; }
  .app-col--side { display: flex; align-items: stretch; }
  .app-top__body { gap: 12px 16px; padding: 8px; }
  .app-pick { flex: 1 1 100%; }
  .app-pick__sub { max-width: none; }
  .app-top__strip { flex: 1 1 100%; order: 5; }
  .app-card__body { padding: 10px 8px 14px; }
  .app-tab { padding: 5px 12px 7px; }
  .quote { grid-template-columns: 1fr; padding: 10px; }
  .quote__big { font-size: 26px; }
  .chart { height: 190px; }
  .app-foot { margin-top: 30px; }
  .app-foot__inner { padding: 22px 12px 24px; }
  .app-foot__text { font-size: 18px; }
  .app-blob { width: 1100px; height: 1100px; }
  .app-blob--a { left: calc(50% - 550px); bottom: -760px; }
  .app-blob--b, .app-blob--c { display: none; }
  .or-head { margin-top: 20px; padding: 18px 10px 22px; }
  .or-lead { font-size: 18px; }
  .or-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .or-h2 { font-size: 24px; }
  .otable .c-twapdev, .otable .c-depth { display: none; }
}

@media (max-width: 559px) {
  .scan .c-pools { display: none; }
  .scan td, .scan th { padding-inline: 5px; }
  .stk__name { max-width: 96px; }
  .mini { width: 48px; }
  .size-row { flex-wrap: wrap; }
  .route__label { white-space: normal; }
  .size-row .os-button { flex: 1 1 100%; }
  .app-run { font-size: 20px; }
  .otable .c-pools, .otable .c-twap { display: none; }
}

@media (max-width: 559px) {
  .heat { min-width: 0; }
  .heat thead th:first-child { width: 46px; }
  .heat th { padding: 4px 1px; font-size: 11px; }
  .heat th small { font-size: 8.5px; letter-spacing: -0.02em; }
  .heat td { padding: 0 1px; font-size: 9.5px; letter-spacing: -0.02em; }
  .heat tbody th { padding: 0 3px; font-size: 13px; }
}

@media (max-width: 419px) {
  .otable .c-tag { display: none; }
  .or-stat__v { font-size: 17px; }
  .otable td, .otable th { padding-inline: 5px; }
  .otable .stk__name { max-width: 80px; }
  .th-lg { display: none; }
  .th-sm { display: inline; }
}

@media (max-width: 379px) {
  .scan .c-spread { display: none; }
  .scan td, .scan th { padding-inline: 4px; }
  .scan td { font-size: 12px; }
  .stk__btn, .stk { gap: 6px; }
  .stk__name { max-width: 78px; }
  .chip { font-size: 14px; }
  .app-tabs-note { display: none; }
  .route__label { white-space: normal; }
  .app-pick__sym { font-size: 22px; }
  .otable td, .otable th { padding-inline: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  .live.is-loading, .spin { animation: none; }
}

/* ============================================================== profit curve marks (svg classes, no inline styles) */

.chart .c-grid { stroke: var(--line); stroke-width: 1; }
.chart .c-zero { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .c-axis, .chart .c-tick { stroke: var(--ink); stroke-width: 1.2; }
.chart .c-line { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.chart .c-line--est { stroke-dasharray: 5 4; }
.chart .c-pt { fill: var(--ink); }
.chart .c-pt--neg { fill: var(--white); stroke: var(--ink); stroke-width: 1.2; }
.chart .c-best { fill: var(--magenta); stroke: var(--ink); stroke-width: 1; }
.chart .c-best-t { fill: var(--ink); font-size: 10px; }
.chart .c-cur { fill: none; stroke: var(--magenta); stroke-width: 2; }
.chart .c-bad { stroke: var(--grey-3); stroke-width: 1.4; fill: none; }

/* oracle extras */
.or-field { margin-top: 0; }
.heat tbody th { padding: 0 6px; text-align: left; font: 500 16px/1 var(--font-pixel); color: var(--ink); background: var(--white); border: 1px solid var(--paper); border-bottom-color: var(--line); white-space: nowrap; }
.or-stat__s--dark { color: rgba(254, 254, 254, 0.78); }
.os-window--dark .or-stat__v { color: var(--paper); }
.or-stat .os-window__body { min-height: 64px; }
.os-window--pink .or-stat__s { color: var(--ink); }
