/*
 * HarmonyStocks app.css (owner: app). The two working pages in the harmonic.fun look:
 *   /app     page head, then a graph-paper workspace: market bar, the desk window with tabs (Scan, Route, Run)
 *            and a side column of windows (Pools, Your cycles, Tape, Engine)
 *   /oracle  page head, a graph-paper workspace (stat strip, consensus table, heat table), then How to read it
 *            and the code window on paper
 * Paper ground, white windows with 1px rules, JetBrains Mono uppercase labels and column heads, tabular numbers,
 * blue for headings and primary actions, green for what pays and red for what reverts.
 * Loaded after css/base.css and uses its tokens and components (docs/SHELL.md). Breakpoints follow base.css:
 * 1199 (tablet), 1023 (one column, burger nav), 809 (phone). No inline styles anywhere (strict CSP): positions set
 * from JS go through el.style.
 */

.app-page {
  --app-gap: 16px;
  --app-pad: 16px;             /* inner padding of windows and panels */
  --row-hover: #f6f8fc;
  --row-sel: rgba(3, 67, 155, 0.06);
  --ask: #f6f8fc;              /* the quiet blue-grey inset (home's engine window uses it too) */
  --term-text: #e8eef8;
  --term-ok: #a9e07f;
  --term-err: #ffb4b4;
}

/* ============================================================== shared bits */

.t-num { font-family: var(--font-mono); font-weight: 400; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.up { color: var(--green-text); }
.down { color: var(--red-text); }

.live.is-loading { color: var(--muted); animation: app-pulse 1.4s ease-in-out infinite; }
@keyframes app-pulse { 50% { opacity: 0.45; } }

.app-logo {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  overflow: hidden;
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--blue);
  font: 500 12px/1 var(--font-mono);
}
.app-logo img { width: 100%; height: 100%; object-fit: cover; }
.app-logo--lg { width: 40px; height: 40px; font-size: 16px; }

/* tags: blue outline (in band), green (open), muted (one pool, thin), blue fill / outline (buy / sell) */
.chip {
  display: inline-block;
  padding: 2px 6px;
  color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
  font: 500 11px/14px var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip--open { color: var(--green-text); background: rgba(97, 162, 50, 0.1); box-shadow: inset 0 0 0 1px rgba(56, 112, 22, 0.6); }
.chip--thin { color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip--buy { background: var(--blue); color: var(--white); box-shadow: none; }
.chip--sell { color: var(--blue); }

/* small mono heads used inside panels */
.app-sub { font: 500 12px/16px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink); }
.app-sub--muted { font-weight: 400; font-size: 11px; color: var(--muted); }
.app-fine { margin-top: 12px; font: 400 13px/19px var(--font-sans); color: var(--muted); text-wrap: pretty; }
.app-fine--risk { margin-top: 16px; }
.app-empty { padding: 14px 0; font: 400 14px/20px var(--font-sans); color: var(--muted); }

/* ============================================================== page head */

.app-head { padding-bottom: 40px; }
.app-head__inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px 64px; align-items: end; }
.app-kicker {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--blue);
  font: 500 12px/16px var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.app-title { margin-top: 12px; max-width: 13em; font: 700 clamp(36px, calc(2.2vw + 22px), 60px)/1 var(--font-sans); letter-spacing: -0.03em; color: var(--blue); text-wrap: balance; }
.app-head__side { display: flex; flex-direction: column; gap: 18px; max-width: 34em; }
.app-lead { font: 400 18px/27px var(--font-sans); color: var(--ink); text-wrap: pretty; }
.app-head__links { display: flex; flex-wrap: wrap; gap: 8px 28px; }

/* ============================================================== the graph-paper workspace */

.app-field { padding: 24px; border: 1px solid var(--line-strong); }
.app-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; 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; }
/* when the bar is short, the meta gives way before the title */
.app-page .os-window__title { flex: 0 0 auto; max-width: 100%; }
.app-page .os-window__bar .os-window__meta { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.app-page .os-window--dark .os-window__meta { color: var(--cyan); }
.app-page .os-window__meta[data-user-address] { text-transform: none; letter-spacing: 0; }

/* ============================================================== market bar */

.app-top__body {
  display: grid;
  grid-template-columns: minmax(230px, auto) minmax(140px, auto) minmax(200px, 1fr) auto auto;
  grid-template-areas: 'pick mid strip engine block';
  gap: 1px;
  background: var(--line);
}
.app-top__body > * { min-width: 0; padding: 14px 18px; background: var(--white); }
.app-pick { grid-area: pick; }
.app-top__mid { grid-area: mid; }
.app-top__strip { grid-area: strip; }
.app-top__engine { grid-area: engine; }
.app-top__block { grid-area: block; }

.app-top__cell { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.app-top__label { display: block; font: 500 11px/16px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.app-top__value { font: 500 20px/1.1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; transition: color 0.3s var(--ease); }
.app-top__value--mid { font: 700 26px/1 var(--font-sans); letter-spacing: -0.02em; color: var(--blue); }
.app-top__value.is-tick { color: var(--blue); transition: none; }
.app-top__ago { min-height: 16px; font: 400 11px/16px var(--font-mono); color: var(--muted); white-space: nowrap; }

.app-pick { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; text-align: left; color: var(--ink); transition: background-color 0.15s; }
.app-pick:hover { background: var(--row-hover); }
.app-pick__logo { display: contents; }
.app-pick__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.app-pick__sym { font: 700 24px/1 var(--font-sans); letter-spacing: -0.02em; color: var(--blue); white-space: nowrap; }
.app-pick__sub { overflow: hidden; font: 500 11px/16px var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.app-pick__caret { flex: none; color: var(--blue); transition: transform 0.2s var(--ease); }
.app-pick[aria-expanded='true'] .app-pick__caret { transform: rotate(180deg); }

.app-top__strip-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.app-top__spread { font: 500 12px/16px var(--font-mono); color: var(--ink); white-space: nowrap; }
.strip { position: relative; height: 16px; margin-inline: 5px; }
.strip__line { position: absolute; left: -5px; right: -5px; top: 50%; height: 1px; background: rgba(23, 23, 23, 0.3); }
.strip__mark { position: absolute; top: 50%; width: 9px; height: 9px; background: var(--blue); box-shadow: 0 0 0 1.5px var(--white); transform: translate(-50%, -50%); }
.strip__mid { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); transform: translateX(-50%); }
.strip__ends { display: flex; justify-content: space-between; font: 400 11px/16px var(--font-mono); color: var(--muted); }

.engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font: 500 12px/16px var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.engine-pill__dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.engine-pill[data-mode='live'] .engine-pill__dot { background: var(--green); box-shadow: 0 0 0 3px rgba(97, 162, 50, 0.22); }
.engine-pill[data-mode='paused'] .engine-pill__dot { background: var(--red); box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.18); }

/* ============================================================== the desk window */

.app-card__body { display: flex; flex-direction: column; }
.app-tabs-row { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: space-between; gap: 0 16px; padding-right: var(--app-pad); border-bottom: 1px solid var(--line); }
.app-tabs { display: flex; }
.app-tab {
  margin-bottom: -1px;
  padding: 13px var(--app-pad) 11px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: 500 12px/16px var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.15s, border-color 0.15s;
}
.app-tab:hover { color: var(--ink); }
.app-tab[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--blue); }
.app-tabs-note { align-self: center; padding: 8px 0; font: 400 11px/16px var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.app-panel { padding: var(--app-pad); }
.app-panel[hidden] { display: none; }

/* ---------------------------------------------------------------- tables (scan, pools, oracle) */

.scan, .pools, .otable, .heat { width: 100%; border-collapse: collapse; }
.scan th, .pools th, .otable th {
  padding: 10px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--white);
  color: var(--muted);
  font: 500 11px/16px var(--font-mono);
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.scan th button, .otable th button { display: inline-flex; align-items: center; gap: 6px; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; }
.scan th button:hover, .otable th button:hover { color: var(--blue); }
.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;
  border-top: 5px solid currentColor;
  opacity: 0.3;
}
.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 th[aria-sort]:not([aria-sort='none']), .otable th[aria-sort]:not([aria-sort='none']) { color: var(--blue); }
.scan td, .pools td, .otable td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font: 400 13px/18px var(--font-mono);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
  white-space: nowrap;
}
.scan .n, .pools .n, .otable .n { text-align: right; }
.scan th:first-child, .scan td:first-child, .otable th:first-child, .otable td:first-child { padding-left: var(--app-pad); }
.scan th:last-child, .scan td:last-child, .otable th:last-child, .otable td:last-child { padding-right: var(--app-pad); }

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

.scan-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.scan-sum { font: 400 14px/20px var(--font-sans); color: var(--muted); }
.scan-sum .t-num { font-weight: 500; color: var(--ink); }
.app-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink); font: 500 12px/16px var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.app-check input { appearance: none; width: 14px; height: 14px; margin: 0; border: 1px solid rgba(23, 23, 23, 0.4); background: var(--white); cursor: pointer; transition: background-color 0.15s, border-color 0.15s; }
.app-check input:checked { border-color: var(--blue); background: var(--blue); box-shadow: inset 0 0 0 2.5px var(--white); }
.app-check:hover input { border-color: var(--blue); }

.scan-wrap { margin-inline: calc(var(--app-pad) * -1); max-height: 640px; overflow: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overscroll-behavior: contain; }
.scan thead th { position: sticky; top: 0; z-index: 1; }
.scan th.c-edge, .scan th.c-pools, .scan th.c-spread, .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; }
.scan th.c-status, .scan td.c-status { text-align: right; }
.scan th.c-status button { flex-direction: row-reverse; }
.scan td.c-edge { font-weight: 500; }
.scan tbody tr { cursor: pointer; transition: background-color 0.15s; }
.scan tbody tr:hover { background: var(--row-hover); }
.scan tbody tr.is-sel { background: var(--row-sel); }
.scan tbody tr.is-sel td:first-child { box-shadow: inset 2px 0 0 var(--blue); }
.scan__loading td { padding: 20px var(--app-pad); cursor: default; color: var(--muted); font-family: var(--font-sans); white-space: normal; }
.scan tbody tr.scan__loading { cursor: default; }
.scan tbody tr.scan__loading:hover { background: transparent; }
.scan td.c-route { font-size: 12px; color: var(--ink); }
.c-route .rl { display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }

.stk, .stk__btn { display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left; }
.stk__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stk__sym { font: 500 13px/18px var(--font-mono); color: var(--ink); }
.stk__name { max-width: 150px; overflow: hidden; font: 400 12px/16px var(--font-sans); color: var(--muted); text-overflow: ellipsis; }
.stk__btn:hover .stk__sym { color: var(--blue); }

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

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

.route-stock { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.route-stock__empty { font: 400 15px/22px var(--font-sans); color: var(--muted); }
.route-stock__sym { font: 700 32px/1 var(--font-sans); letter-spacing: -0.02em; color: var(--blue); }
.route-stock__meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.route-stock__name { font: 500 17px/1.2 var(--font-sans); color: var(--ink); }
.route-stock__sub { font: 400 11px/16px var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

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

.routes { display: flex; flex-direction: column; border-top: 1px solid var(--line-strong); }
.route {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  transition: background-color 0.15s;
}
.route:hover { background: var(--row-hover); }
.route__radio { width: 12px; height: 12px; border: 1px solid rgba(23, 23, 23, 0.4); border-radius: 50%; background: var(--white); }
.route[aria-checked='true'] { background: var(--row-sel); box-shadow: inset 2px 0 0 var(--blue); }
.route[aria-checked='true'] .route__radio { border-color: var(--blue); background: var(--blue); box-shadow: inset 0 0 0 2.5px var(--white); }
.route__main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.route__label { overflow: hidden; font: 500 13px/18px var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.route__sub { font: 400 12px/16px var(--font-sans); color: var(--muted); }
.route__edge { font: 500 13px/18px var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.app-more { margin-top: 10px; color: var(--blue); font: 500 12px/16px var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; text-decoration: underline 1px; text-underline-offset: 4px; }
.app-more:hover { color: var(--blue-hover); }

.size-row { display: flex; align-items: stretch; gap: 8px; }
.size-field { display: flex; flex: 1 1 auto; align-items: center; min-width: 0; min-height: 48px; padding: 0 14px; border: 1px solid var(--line-strong); background: var(--white); transition: border-color 0.15s, box-shadow 0.15s; }
.size-field:hover { border-color: rgba(23, 23, 23, 0.32); }
.size-field:focus-within { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.size-field__cur { font: 500 18px/1 var(--font-mono); color: var(--muted); }
.size-field__input { flex: 1 1 auto; width: 100%; min-width: 0; padding: 10px 6px; border: 0; background: transparent; color: var(--ink); font: 500 20px/1 var(--font-mono); font-variant-numeric: tabular-nums; outline: none; }
.size-row .os-button { min-height: 48px; padding-inline: 18px; }
.size-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.size-chip { min-height: 28px; padding: 4px 10px; border: 1px solid var(--line-strong); background: var(--white); color: var(--ink); font: 500 12px/18px var(--font-mono); font-variant-numeric: tabular-nums; transition: color 0.15s, border-color 0.15s, background-color 0.15s; }
.size-chip:hover { border-color: var(--blue); color: var(--blue); }
.size-chip[aria-pressed='true'] { border-color: var(--blue); background: var(--blue); color: var(--white); }

.quote { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 24px; border: 1px solid var(--line); background: var(--ask); }
.quote__cell { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 16px 18px; }
.quote__cell + .quote__cell { border-left: 1px solid var(--line); }
.quote__label { font: 500 11px/16px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.quote__big { overflow: hidden; color: var(--blue); font: 700 34px/1 var(--font-sans); font-variant-numeric: tabular-nums; letter-spacing: -0.025em; text-overflow: ellipsis; white-space: nowrap; }
.quote__big.up { color: var(--green-text); }
.quote__big.down { color: var(--red-text); }
.quote__sub { min-height: 16px; font: 400 12px/16px var(--font-mono); color: var(--muted); overflow-wrap: anywhere; }
.quote__note { grid-column: 1 / -1; padding: 12px 18px 14px; border-top: 1px solid var(--line); font: 400 13px/19px var(--font-sans); color: var(--ink); text-wrap: pretty; }
.quote__note b { font-weight: 500; color: var(--blue); }
.quote[data-state='loading'] .quote__big { color: var(--muted); }

.app-chart { margin-top: 16px; box-shadow: none; }
.chart { position: relative; height: 240px; }
.chart svg { display: block; width: 100%; height: 100%; }
.chart__empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; color: var(--muted); font: 400 14px/20px var(--font-sans); text-align: center; }
.chart text { font-family: var(--font-mono); font-size: 10px; fill: var(--ink); }
.chart .ax-label { fill: var(--muted); }
.chart .c-grid { stroke: rgba(3, 67, 155, 0.1); stroke-width: 1; }
.chart .c-zero { stroke: rgba(23, 23, 23, 0.5); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .c-axis, .chart .c-tick { stroke: rgba(23, 23, 23, 0.35); stroke-width: 1; }
.chart .c-line { fill: none; stroke: var(--blue); stroke-width: 1.75; stroke-linejoin: round; }
.chart .c-line--est { stroke-dasharray: 5 4; }
.chart .c-pt { fill: var(--blue); }
.chart .c-pt--neg { fill: var(--white); stroke: var(--red); stroke-width: 1.2; }
.chart .c-best { fill: var(--green); stroke: var(--white); stroke-width: 1; }
.chart .c-best-t { fill: var(--green-text); font-size: 10px; font-weight: 500; text-transform: uppercase; }
.chart .c-cur { fill: none; stroke: var(--blue); stroke-width: 1.5; }
.chart .c-bad { fill: none; stroke: var(--red); stroke-width: 1.4; }

.bd { display: flex; flex-direction: column; border-top: 1px solid var(--line-strong); }
.bd__row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bd dt { font: 400 15px/20px var(--font-sans); color: var(--ink); }
.bd dd { margin: 0; color: var(--ink); font: 400 14px/20px var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.bd dd small { display: block; margin-top: 2px; font: 400 11px/16px var(--font-mono); color: var(--muted); }
.bd__row--total { border-bottom-color: var(--line-strong); }
.bd__row--total dt { font-weight: 500; font-size: 16px; }
.bd__row--total dd { font-size: 18px; font-weight: 500; color: var(--blue); }
.bd__row--muted dt, .bd__row--muted dd { font-size: 13px; color: var(--muted); }

.guard { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line-strong); background: var(--white); }
.guard__opt { min-height: 40px; padding: 8px; color: var(--ink); font: 500 13px/20px var(--font-mono); font-variant-numeric: tabular-nums; transition: color 0.15s, background-color 0.15s; }
.guard__opt + .guard__opt { border-left: 1px solid var(--line-strong); }
.guard__opt:hover { background: var(--row-hover); color: var(--blue); }
.guard__opt[aria-checked='true'] { background: var(--blue); color: var(--white); }

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

.run-sum { margin-bottom: 20px; }
.run-sum dd { font: 400 15px/20px var(--font-sans); }
.run-sum dd.t-num { font: 400 14px/20px var(--font-mono); }
.run-log__body { display: flex; flex-direction: column; gap: 6px; min-height: 168px; padding: 14px var(--app-pad) 16px; }
.run-line { color: var(--term-text); font: 400 13px/1.55 var(--font-mono); overflow-wrap: anywhere; }
.run-line::before { content: '> '; color: var(--cyan); }
.run-line--ok { color: var(--term-ok); }
.run-line--err { color: var(--term-err); }
.run-line--muted { color: rgba(232, 238, 248, 0.72); }
.run-line a { color: inherit; text-decoration: underline 1px; text-underline-offset: 3px; }
.run-line a:hover { color: var(--cyan); }
.run-big { margin: 4px 0; color: var(--term-ok); font: 700 32px/1.1 var(--font-sans); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.spin { display: inline-block; flex: none; width: 12px; height: 12px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: app-spin 0.8s linear infinite; }
@keyframes app-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- the action bar */

.app-action { padding: var(--app-pad); border-top: 1px solid var(--line); background: #fbfbfb; }
.app-action[hidden] { display: none; }
.app-run { min-height: 52px; font-size: 14px; letter-spacing: 0.04em; }
.btn.app-run:disabled { background: #ececec; color: #555555; box-shadow: inset 0 0 0 1px var(--line); }
.app-action__note { margin-top: 10px; font: 400 13px/19px var(--font-sans); color: var(--muted); text-align: center; text-wrap: pretty; }
.app-action__note:empty { display: none; }

/* ============================================================== side column */

.app-pools__body { overflow-x: auto; }
.pools th { padding: 9px 8px; font-size: 10px; }
.pools td { padding: 9px 8px; font-size: 12px; }
.pools th:first-child, .pools td:first-child { padding-left: 14px; }
.pools th:last-child, .pools td:last-child { padding-right: 14px; }
.pools td:first-child { white-space: normal; }
.pools .pool-name { font-weight: 500; white-space: nowrap; }
.pools tr.is-thin td { color: var(--muted); }
.pools .depth { display: block; font-size: 11px; line-height: 15px; }
.pools .depth + .depth { color: var(--muted); }
.pools .tag { margin-left: 6px; padding: 1px 5px; font-size: 10px; }
.pools-note { padding: 10px 14px 12px; border-top: 1px solid var(--line); font: 400 12px/17px var(--font-sans); color: var(--muted); }

.app-list { display: flex; flex-direction: column; max-height: 360px; padding: 0 14px; overflow-y: auto; }
.app-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.app-item:last-child { border-bottom: 0; }
.app-item__sym { min-width: 3.4em; font: 500 13px/18px var(--font-mono); color: var(--blue); }
.app-item__main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.app-item__amt { font: 500 13px/18px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--green-text); }
.app-item__sub { overflow: hidden; font: 400 11px/16px var(--font-mono); color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.app-item__tx { color: var(--blue); font: 400 11px/16px var(--font-mono); text-decoration: underline 1px; text-underline-offset: 3px; white-space: nowrap; }
.app-item__tx:hover { color: var(--blue-hover); }
.app-item.is-new { animation: app-flash 1.8s var(--ease) 1; }
@keyframes app-flash { 0%, 30% { background: color-mix(in srgb, var(--cyan) 45%, transparent); } 100% { background: transparent; } }

.app-engine__body { padding: 4px 14px 6px; }
.kv { display: flex; flex-direction: column; }
.kv > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid rgba(3, 67, 155, 0.12); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: #4f5b6b; font: 500 11px/16px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.kv dd { margin: 0; color: var(--ink); font: 500 13px/16px var(--font-mono); text-align: right; }

/* ============================================================== closing note */

.app-foot { padding-block: 48px 24px; }
.app-foot__inner { display: grid; grid-template-columns: minmax(160px, 0.4fr) minmax(0, 1.6fr) auto; gap: 16px 40px; align-items: center; padding: 26px 30px; border: 1px solid var(--line-strong); background: var(--white); }
.app-foot__label { color: var(--blue); font: 500 12px/16px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; }
.app-foot__text { max-width: 46em; font: 400 17px/26px var(--font-sans); color: var(--ink); text-wrap: pretty; }

/* ============================================================== 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 { display: grid; place-items: center; flex: none; width: 22px; height: 22px; margin: -3px -6px -3px auto; border: 1px solid var(--line-strong); background: var(--white); color: var(--muted); transition: color 0.15s, border-color 0.15s; }
.app-x:hover { border-color: var(--blue); color: var(--blue); }

.pick { display: flex; flex-direction: column; }
.pick__search { margin: 12px; padding: 9px 12px; border: 1px solid var(--line-strong); background: var(--white); color: var(--ink); font: 400 14px/20px var(--font-mono); outline: none; }
.pick__search:focus { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.pick__search::placeholder { color: var(--muted); }
.pick__list { display: flex; flex-direction: column; max-height: min(420px, 55vh); overflow-y: auto; border-top: 1px solid var(--line); }
.pick__item { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--ink); text-align: left; }
.pick__item:hover, .pick__item:focus-visible { background: var(--row-hover); }
.pick__item[aria-selected='true'] { background: var(--row-sel); box-shadow: inset 2px 0 0 var(--blue); }
.pick__sym { font: 500 13px/18px var(--font-mono); }
.pick__name { overflow: hidden; font: 400 13px/18px var(--font-sans); color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.pick__edge { font: 500 12px/16px var(--font-mono); font-variant-numeric: tabular-nums; }
.pick__none { padding: 14px 12px; font: 400 14px/20px var(--font-sans); 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(2, 31, 74, 0.45); }
.app-modal__win { position: relative; width: min(420px, 100%); }
.wallets { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
.wallets__list { display: flex; flex-direction: column; gap: 6px; }
.wallet-opt { justify-content: flex-start; gap: 12px; width: 100%; min-height: 46px; padding: 8px 12px; font-size: 13px; }
.wallet-opt img { flex: none; width: 24px; height: 24px; }
.wallet-opt__ph { flex: none; width: 24px; height: 24px; background: var(--blue-14); }
.wallets__msg { font: 400 14px/20px var(--font-sans); color: var(--ink); }
.wallets__msg:empty { display: none; }
.wallets__msg.is-err { padding: 8px 10px; border-left: 2px solid var(--red); background: rgba(198, 40, 40, 0.06); color: var(--red-text); }
.wallets__fine { font: 400 12px/18px var(--font-sans); color: var(--muted); }

.wallet-menu { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.wallet-menu__addr { color: var(--ink); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.wallet-menu__meta { font: 400 13px/19px var(--font-sans); color: var(--muted); }

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

.or-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--line-strong); background: var(--line); box-shadow: 0 1px 0 rgba(23, 23, 23, 0.04), 0 18px 40px -28px rgba(3, 67, 155, 0.35); }
.or-stat { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 16px 18px 18px; background: var(--white); }
.or-stat__k { font: 500 11px/16px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.or-stat__v { overflow: hidden; color: var(--blue); font: 700 28px/1.1 var(--font-sans); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; text-overflow: ellipsis; white-space: nowrap; }
.or-stat__s { font: 400 12px/17px var(--font-sans); color: var(--muted); }

.or-sec { margin-top: 40px; }
.or-sec__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 14px; }
.or-h2 { display: flex; align-items: baseline; gap: 12px; color: var(--blue); font: 700 clamp(24px, calc(0.8vw + 18px), 34px)/1.1 var(--font-sans); letter-spacing: -0.02em; }
.or-num { font: 500 12px/16px var(--font-mono); letter-spacing: 0.04em; color: var(--muted); }
.or-asof { font: 400 11px/16px var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.or-note { max-width: 62em; margin-top: 12px; font: 400 14px/21px var(--font-sans); color: #3a3a3a; text-wrap: pretty; }
.or-note b { font-weight: 500; color: var(--ink); }

.otable-wrap { overflow-x: auto; }
.th-sm { display: none; }
.otable td .sub { display: block; margin-top: 2px; font-size: 11px; line-height: 15px; color: var(--muted); }
.otable tbody tr { transition: background-color 0.15s; }
.otable tbody tr:hover { background: var(--row-hover); }
.otable .c-tag { text-align: right; }
.otable th.c-tag button { flex-direction: row-reverse; }
.otable th.n button { flex-direction: row-reverse; }

.heat-wrap { overflow-x: auto; }
.heat { min-width: 560px; table-layout: fixed; }
.heat th { padding: 9px 4px 8px; border-bottom: 1px solid var(--line-strong); color: var(--ink); font: 500 11px/14px var(--font-mono); letter-spacing: 0.04em; text-align: center; text-transform: uppercase; white-space: nowrap; }
.heat th small { display: block; margin-top: 2px; font: 400 10px/12px var(--font-mono); letter-spacing: 0; color: var(--muted); }
.heat thead th:first-child { width: 84px; padding-left: var(--app-pad); text-align: left; }
.heat tbody th { padding: 0 6px 0 var(--app-pad); border-bottom: 1px solid var(--line); background: var(--white); color: var(--ink); font: 500 12px/1 var(--font-mono); text-align: left; text-transform: none; }
.heat td { height: 28px; padding: 0 3px; border: 1px solid var(--white); color: var(--ink); font: 400 11px/1 var(--font-mono); font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap; }
.heat td.h-none { background: transparent; color: transparent; }
.heat td.h-thin { background: var(--white); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); }
.heat td.h-0 { background: #eeeeee; }
/* above the consensus: blue; below it: cyan to teal (diverging, brand colours only) */
.heat td.h-p1 { background: #e4ecf7; }
.heat td.h-p2 { background: #bccfea; }
.heat td.h-p3 { background: #84a3d4; }
.heat td.h-p4 { background: var(--blue); color: var(--white); }
.heat td.h-n1 { background: #e3fdfd; }
.heat td.h-n2 { background: #b0f7f7; }
.heat td.h-n3 { background: #6be3e3; }
.heat td.h-n4 { background: #23aaaa; }
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 12px; color: var(--muted); font: 400 11px/16px var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.heat-legend span { display: inline-flex; align-items: center; gap: 6px; }
.heat-legend i { display: inline-block; width: 14px; height: 10px; }
.heat-legend .l-n4 { background: #23aaaa; }
.heat-legend .l-n2 { background: #b0f7f7; }
.heat-legend .l-0 { background: #eeeeee; box-shadow: inset 0 0 0 1px var(--line); }
.heat-legend .l-p2 { background: #bccfea; }
.heat-legend .l-p4 { background: var(--blue); }
.heat-legend .l-thin { background: var(--white); box-shadow: inset 0 0 0 1px var(--line-strong); }

.or-read { padding-top: 72px; }
.or-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line-strong); background: var(--white); }
.or-card { display: flex; flex-direction: column; padding: 28px 28px 32px; }
.or-card + .or-card { border-left: 1px solid var(--line-strong); }
.or-card__k { font: 500 11px/16px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.or-card h3 { margin-top: 20px; color: var(--blue); font: 500 var(--fs-h4)/1.15 var(--font-sans); letter-spacing: -0.01em; }
.or-card p { margin-top: 12px; font: 400 16px/24px var(--font-sans); color: var(--ink); text-wrap: pretty; }
.or-sec--code { margin-top: 64px; }
.or-code pre { margin: 0; padding: 16px 18px; overflow-x: auto; color: var(--term-text); font: 400 13px/1.6 var(--font-mono); }
.or-code .k { color: var(--cyan); }
.or-code .c { color: rgba(232, 238, 248, 0.64); }

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

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

@media (max-width: 1199px) {
  .app-field { padding: 20px; }
  .app-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .app-top__body {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto;
    grid-template-areas: 'pick mid engine block' 'strip strip strip strip';
  }
  .pools th, .pools td { padding-inline: 6px; }
  .pools .tag { display: table; margin: 4px 0 0; }
  .or-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* the Best route column only where the desk is wide enough */
@media (min-width: 1024px) and (max-width: 1199px), (max-width: 899px) {
  .scan .c-route { display: none; }
}

@media (max-width: 1023px) {
  .app-head__inner { grid-template-columns: minmax(0, 1fr); }
  .app-grid { grid-template-columns: minmax(0, 1fr); }
  .app-col--side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .pools .tag { display: inline-block; margin: 0 0 0 6px; }
  .or-cards { grid-template-columns: minmax(0, 1fr); }
  .or-card + .or-card { border-left: 0; border-top: 1px solid var(--line-strong); }
  .app-foot__inner { grid-template-columns: minmax(0, 1fr) auto; }
  .app-foot__label { grid-column: 1 / -1; }
}

@media (max-width: 809px) {
  .app-page { --app-gap: 12px; --app-pad: 14px; }
  .app-head { padding-bottom: 28px; }
  .app-title { font-size: min(40px, 10.4vw); }
  .app-lead { font-size: 17px; line-height: 25px; }
  .app-field { padding: 8px; }
  .app-col--side { display: flex; align-items: stretch; }
  .app-top__body > * { padding: 12px 14px; }
  .app-top__value { font-size: 17px; }
  .app-top__value--mid { font-size: 22px; }
  .quote { grid-template-columns: minmax(0, 1fr); }
  .quote__cell { gap: 6px; padding: 12px 14px; }
  .quote__cell + .quote__cell { border-left: 0; border-top: 1px solid var(--line); }
  .quote__big { font-size: 28px; }
  .quote__sub:empty { display: none; }
  .quote__note { padding: 10px 14px 12px; }
  .chart { height: 200px; }
  .app-foot { padding-top: 32px; }
  .app-foot__inner { grid-template-columns: minmax(0, 1fr); padding: 22px 18px; }
  .or-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .or-stat { padding: 14px; }
  .or-stat__v { font-size: 22px; }
  .or-sec { margin-top: 32px; }
  .or-read { padding-top: 56px; }
  .or-card { padding: 22px 18px 24px; }
  .or-card h3 { margin-top: 12px; }
  .otable .c-twapdev, .otable .c-depth { display: none; }
}

@media (max-width: 639px) {
  .app-top__body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: 'pick pick' 'mid block' 'strip strip' 'engine engine'; }
  .app-top__engine { flex-direction: row; align-items: center; justify-content: space-between; }
}

@media (max-width: 559px) {
  .scan .c-pools, .scan .c-status { display: none; }
  .otable .c-tag { display: none; }
  .pools .tag { display: table; margin: 4px 0 0; }
  .app-tabs-note { display: none; }
  .scan td, .scan th { padding-inline: 6px; }
  .stk__name { max-width: 96px; }
  .mini { width: 44px; }
  .size-row { flex-wrap: wrap; }
  .size-row .os-button { flex: 1 1 100%; }
  .route__label { white-space: normal; }
  .otable .c-pools, .otable .c-twap { display: none; }
  .heat { min-width: 0; }
  .heat thead th:first-child { width: 50px; padding-left: 8px; }
  .heat th { padding: 6px 1px; font-size: 10px; letter-spacing: 0; }
  .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 0 8px; font-size: 11px; }
}

@media (max-width: 419px) {
  .app-top__value:not(.app-top__value--mid) { font-size: 15px; }
  .app-pick__sym { font-size: 22px; }
  .otable td, .otable th { padding-inline: 6px; }
  .otable .stk__name { max-width: 84px; }
  .or-stat { padding: 12px 10px; }
  .or-stat__v { font-size: 19px; }
  .th-lg { display: none; }
  .th-sm { display: inline; }
}

@media (max-width: 379px) {
  .app-page { --app-pad: 12px; }
  .scan .c-spread { display: none; }
  .scan td, .scan th { padding-inline: 5px; }
  .stk, .stk__btn { gap: 8px; }
  .stk__name { max-width: 80px; }
  .otable td, .otable th { padding-inline: 4px; }
  .otable td:first-child, .otable th:first-child { padding-left: 10px; }
  .otable td:last-child, .otable th:last-child { padding-right: 10px; }
  .otable .stk__name { max-width: 72px; }
  .pools th, .pools td { padding-inline: 4px; }
  .pools th:first-child, .pools td:first-child { padding-left: 10px; }
  .pools th:last-child, .pools td:last-child { padding-right: 10px; }
  .or-stat__v { font-size: 17px; }
  .app-tab { padding-inline: 12px; }
  .app-head__links { gap: 8px 20px; }
}

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