:root {
  --bg: #e8edf2;
  --bg-wash: #d4e8ef;
  --ink: #0b1220;
  --muted: #4a5a6a;
  --line: #c5d0db;
  --surface: #f7fafc;
  --surface-2: #ffffff;
  --accent: #ff4d2e;
  --accent-ink: #fff8f6;
  --pos: #0f8a6b;
  --neg: #e23d28;
  --warn: #e8940a;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "DM Sans", system-ui, sans-serif;
  --display: "Syne", "DM Sans", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  background:
    radial-gradient(ellipse 90% 60% at 12% -10%, var(--bg-wash) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(255, 77, 46, 0.08) 0%, transparent 45%),
    var(--bg);
}

[hidden] { display: none !important; }

/* Session shell: hide sign-in before modules load when boot.js saw a token */
html.is-authed #login,
html.is-authed #connect,
html.is-authed #agent-landing,
html.is-authed #site-footer {
  display: none !important;
}
html.is-authed #app {
  display: block !important;
}
html.is-authed #session {
  display: flex !important;
}

html.is-authed .nav-login {
  display: none !important;
}

/* Public read-only watch URI: /{walletAddress} — no sign-in, no trading */
html.is-view-only #connect,
html.is-view-only #agent-landing,
html.is-view-only .nav-login {
  display: none !important;
}
html.is-view-only #app {
  display: block !important;
}
html.is-view-only #session {
  display: flex !important;
}
html.is-view-only .tabs button[data-tab="trade"],
html.is-view-only .tabs button[data-tab="settings"],
html.is-view-only #tab-settings,
html.is-view-only #tab-trade > .trade-layout,
html.is-view-only .trade-ticket-col,
html.is-view-only #trade-form,
html.is-view-only #trade-empty,
html.is-view-only .nav-extra,
html.is-view-only #logout {
  display: none !important;
}
html.is-view-only .trade-layout {
  grid-template-columns: 1fr;
}
html.is-view-only .tabs {
  margin-top: 2px;
}
html.is-view-only #holdings th.pos-actions,
html.is-view-only #holdings td.pos-actions,
html.is-view-only #lev-table th.pos-actions,
html.is-view-only #lev-table td.pos-actions {
  display: none;
}
.view-only-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 5px 10px;
  border-radius: 999px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 250, 252, 0.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
  display: flex;
  gap: 10px;
  align-items: center;
}

.logo,
img.logo {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: contain;
  /* Avoid percentage width/height on img.logo — those resolve against
     the header flex parent and blow the mark up to full row height. */
}

.brandlink {
  color: var(--ink);
  display: flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
}

.toplinks {
  display: flex;
  gap: 20px;
  margin-left: auto;
}
.toplinks a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}
.toplinks a:hover { color: var(--ink); }

.nav-extra { display: contents; }

.session {
  display: flex;
  gap: 12px;
  align-items: center;
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

/* —— Signed-out hero —— */
.hero {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  max-width: 440px;
  margin: 0 auto;
  padding: 56px 0 40px;
}

@media (min-width: 721px) {
  .hero {
    min-height: calc(100vh - 160px);
    justify-content: center;
    padding: 40px 0 48px;
  }
}

.hero-brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3.25rem, 10vw, 4.75rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
  margin: 0 0 16px;
  color: var(--ink);
}

.hero-brand span {
  color: var(--accent);
}

.hero-line {
  margin: 0 0 36px;
  font-size: 1.125rem;
  color: var(--muted);
  max-width: 22em;
}

.hero-form h1 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-form .lede {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.95rem;
}

.otp-step.is-entering {
  animation: fade-swap 0.28s ease-out both;
}

.phone-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.phone-row label { margin: 0; flex: 1 1 160px; }
.phone-row .country-label { flex: 0 1 200px; max-width: 240px; }
.phone-row select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  font-family: var(--sans);
}
.phone-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* —— Connect disclosure —— */
.connect-wrap {
  max-width: 640px;
  margin: 0 auto 48px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.connect-wrap details {
  padding: 8px 0;
}

.connect-wrap summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  padding: 12px 0;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}
.connect-wrap summary::-webkit-details-marker { display: none; }
.connect-wrap summary::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.connect-wrap details[open] summary::before {
  transform: rotate(45deg);
}

.connect-body {
  padding: 4px 0 20px;
}

.connect-body .hint {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 0.95rem;
}

.ref-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.ref-links a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.ref-links a:hover { color: var(--accent); }

/* —— Surfaces (interaction containers only) —— */
.card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}

.panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}

h1 { margin: 0 0 8px; font-size: 22px; font-family: var(--display); }
h2 { font-size: 15px; margin: 24px 0 8px; font-family: var(--display); font-weight: 700; }

label {
  display: block;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  font-family: var(--sans);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 77, 46, 0.15);
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 14px;
  font-family: var(--sans);
  transition: transform 0.15s ease, filter 0.15s ease;
}
button:hover { filter: brightness(1.05); }
button:active { transform: translateY(1px); }
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
  transform: none;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 7px 12px;
  font-weight: 500;
}
button.ghost:hover { border-color: var(--ink); filter: none; }
button.ghost.active {
  border-color: var(--accent);
  color: var(--accent);
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.msg { min-height: 20px; color: var(--warn); font-size: 14px; margin-top: 10px; }
.msg.ok { color: var(--pos); }

select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-family: var(--sans);
}
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 77, 46, 0.15);
}

.trade-layout {
  display: grid;
  gap: 20px;
  min-width: 0;
}
.trade-browse,
.trade-ticket-col,
.market-board {
  min-width: 0;
  max-width: 100%;
}
@media (max-width: 959px) {
  /* Focus mode: browse OR ticket, not both stacked */
  .trade-layout.is-browsing .trade-ticket-col {
    display: none;
  }
  .trade-layout.is-browsing.has-success .trade-ticket-col {
    display: block;
  }
  .trade-layout.is-browsing.has-success .trade-browse {
    display: none;
  }
  .trade-layout:not(.is-browsing) .trade-browse {
    display: none;
  }
}
@media (min-width: 960px) {
  .trade-layout {
    grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.7fr);
    align-items: start;
  }
  .trade-layout.is-browsing {
    grid-template-columns: 1fr;
  }
  .trade-layout.is-browsing .trade-ticket-col {
    display: none;
  }
  .trade-ticket-col {
    position: sticky;
    top: 88px;
  }
}

.browse-head {
  margin: 0 0 14px;
}
.browse-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.5rem, 2.4vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.browse-sub {
  margin: 6px 0 0;
  font-size: 13.5px;
  max-width: 42ch;
}

.class-chips,
.discover-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.chip, .starter, .lev-pill {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  font-size: 13px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.chip:hover, .starter:hover, .lev-pill:hover { filter: none; border-color: var(--ink); }
.chip.active, .lev-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 77, 46, 0.06);
}
.chip.chip-desk {
  border-color: rgba(11, 18, 32, 0.28);
}
.chip.chip-desk.active {
  border-color: var(--ink);
  color: var(--ink);
  background: rgba(11, 18, 32, 0.05);
}
.chip:disabled, .lev-pill:disabled { opacity: 0.4; cursor: not-allowed; }

.trade-search {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 10px;
}
.trade-search label { margin: 0; flex: 1 1 220px; }
.search-field {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.search-field input {
  flex: 1;
  margin-top: 0;
}
.search-clear {
  flex: 0 0 auto;
  padding: 10px 12px;
}
.market-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tag-pill {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  border: 1px solid rgba(255, 77, 46, 0.35);
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.3;
}
.tag-pill.bias-long {
  color: var(--pos);
  border-color: rgba(15, 138, 107, 0.4);
}
.tag-pill.bias-short {
  color: var(--neg);
  border-color: rgba(226, 61, 40, 0.4);
}
.tag-pill.bias-watch {
  color: var(--muted);
  border-color: var(--line);
}
.tag-pill.tag-desk.pick-long {
  color: var(--pos);
  border-color: rgba(15, 138, 107, 0.4);
}
.tag-pill.tag-thin {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--accent);
}
.tag-pill.tag-desk.pick-short {
  color: var(--neg);
  border-color: rgba(226, 61, 40, 0.4);
}
.opportunity-desk {
  margin: 0 0 12px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 77, 46, 0.06), transparent 42%),
    var(--surface-2);
}
.opp-desk-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.opp-desk-kicker {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.opp-desk-model {
  font-size: 11px;
  color: var(--muted);
}
.opp-desk-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 720px) {
  .opp-desk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .opportunity-desk { padding: 12px; }
  .opp-desk-pick { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
}
.opp-desk-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.opp-desk-value { font-size: 15px; }
.opp-desk-pick {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 700;
  font-family: var(--mono);
  font-size: 13px;
}
.opp-desk-pick.pick-long { color: var(--pos); border-color: rgba(15, 138, 107, 0.35); }
.opp-desk-pick.pick-short { color: var(--neg); border-color: rgba(226, 61, 40, 0.35); }
.opp-desk-pick:disabled { opacity: 0.45; }
.market-row-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.market-board.is-opportunities .market-board-head,
.market-board.is-opportunities .market-row {
  grid-template-columns: minmax(160px, 2fr) minmax(56px, 0.65fr) minmax(52px, 0.55fr) minmax(64px, 0.7fr);
}
.package-legs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 14px;
}
.package-leg {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 2px 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.package-leg-kind {
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.package-leg-name {
  font-size: 14px;
  line-height: 1.25;
}
.package-leg-meta {
  grid-column: 2;
}
.market-board.is-predictions .market-board-head,
.market-board.is-predictions .market-row {
  grid-template-columns: minmax(160px, 2.4fr) minmax(72px, 0.7fr) minmax(56px, 0.55fr);
}
.lean-cell {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lean-cell.bias-long { color: var(--pos); }
.lean-cell.bias-short { color: var(--neg); }
.lean-cell.bias-watch { color: var(--muted); }
.opp-score-cell {
  font-weight: 700;
  font-size: 14px;
}
.market-row.is-desk-pick {
  background: rgba(255, 77, 46, 0.04);
}

.market-board {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.market-board-head,
.market-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.6fr) repeat(5, minmax(64px, 0.85fr));
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
}
.market-board-head {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface);
}
.market-results {
  min-height: 420px;
  max-height: min(70vh, 720px);
  overflow-y: auto;
  overflow-x: hidden;
}
@media (max-width: 959px) {
  .market-results {
    min-height: 240px;
    max-height: min(62vh, 640px);
  }
  /* Markets: Market · Mark · 24h · Lev — drop Funding + OI */
  .market-board:not(.is-opportunities):not(.is-predictions) .market-board-head span:nth-child(4),
  .market-board:not(.is-opportunities):not(.is-predictions) .market-board-head span:nth-child(5),
  .market-board:not(.is-opportunities):not(.is-predictions) .market-row > :nth-child(4),
  .market-board:not(.is-opportunities):not(.is-predictions) .market-row > :nth-child(5) { display: none; }
  .market-board:not(.is-opportunities):not(.is-predictions) .market-board-head,
  .market-board:not(.is-opportunities):not(.is-predictions) .market-row {
    grid-template-columns: minmax(0, 1.6fr) minmax(64px, 0.85fr) minmax(56px, 0.7fr) minmax(40px, 0.45fr);
  }
  .market-board.is-predictions .market-board-head,
  .market-board.is-predictions .market-row {
    grid-template-columns: minmax(0, 2fr) minmax(64px, 0.7fr) minmax(48px, 0.5fr);
  }
  /* Opportunities packages: Package · Lean · Score · Split */
  .market-board.is-opportunities .market-board-head,
  .market-board.is-opportunities .market-row {
    grid-template-columns: minmax(0, 1.5fr) minmax(48px, 0.55fr) minmax(44px, 0.5fr) minmax(64px, 0.8fr);
  }
}
.market-row {
  width: 100%;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 500;
  padding-top: 7px;
  padding-bottom: 7px;
  transition: background 0.12s ease;
}
.market-row:last-child { border-bottom: 0; }
.market-row:hover { background: rgba(11, 18, 32, 0.03); filter: none; transform: none; }
.market-row.selected {
  background: rgba(255, 77, 46, 0.07);
  box-shadow: inset 3px 0 0 var(--accent);
}
.market-row-market {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.market-row-market strong {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Outcome questions are sentences — sans reads better than mono tickers. */
.market-board.is-predictions .market-row-market strong {
  font-family: var(--sans);
  font-size: 13.5px;
  letter-spacing: -0.01em;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.market-row .num { font-size: 12.5px; }
.market-empty { padding: 20px 12px; margin: 0; }
.market-status { margin-top: 8px; min-height: 18px; font-size: 12px; color: var(--muted); }

.trade-empty {
  padding: 36px 18px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  text-align: left;
  background:
    radial-gradient(ellipse 80% 70% at 0% 0%, rgba(255, 77, 46, 0.07), transparent 55%),
    var(--surface-2);
}
.trade-empty.is-success {
  border-style: solid;
  border-color: rgba(15, 138, 107, 0.35);
  background:
    radial-gradient(ellipse 80% 70% at 0% 0%, rgba(15, 138, 107, 0.1), transparent 55%),
    var(--surface-2);
  animation: fade-swap 0.35s ease-out both;
}
.trade-empty-title {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.trade-empty .muted { margin: 0; max-width: 28ch; line-height: 1.45; }
.trade-success {
  margin: 14px 0 0;
  font-weight: 650;
  font-size: 14px;
}
.trade-success-done {
  margin-top: 16px;
  width: 100%;
}

.trade-form {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(11, 18, 32, 0.05);
}
.trade-form.ticket-enter {
  animation: fade-swap 0.28s ease-out both;
}
.ticket-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.ticket-hero-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}
.ticket-price {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.ticket-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.trade-asset-name {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.45rem, 2.5vw, 1.75rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.ticket-meta {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.35;
  max-width: 28ch;
}
.ticket-clear { flex: 0 0 auto; }
.ticket-block { margin-bottom: 16px; }
.ticket-block-label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ticket-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ticket-pill {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 650;
  font-size: 14px;
  min-width: 72px;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.ticket-pill:hover { border-color: var(--ink); }
.ticket-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 77, 46, 0.07);
}
.ticket-pill.side-buy.active,
.ticket-pill.side-long.active {
  border-color: var(--pos);
  color: var(--pos);
  background: rgba(15, 138, 107, 0.08);
}
.ticket-pill.side-short.active {
  border-color: var(--neg);
  color: var(--neg);
  background: rgba(226, 61, 40, 0.08);
}
.ticket-pill.side-sell.active,
.ticket-pill.side-close.active {
  border-color: var(--ink);
  color: var(--ink);
  background: rgba(11, 18, 32, 0.06);
}
.ticket-size-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ticket-size-head .ticket-block-label { margin-bottom: 0; }
.ticket-suggest {
  padding: 6px 10px;
  font-size: 12px;
}
.ticket-size-field {
  position: relative;
  margin-top: 8px;
}
.ticket-size-field input[type="text"] {
  width: 100%;
  margin-top: 0;
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 600;
  padding: 14px 72px 14px 14px;
  border-radius: 12px;
}
.ticket-size-unit {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}
.sell-all-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  margin-top: 10px;
  font-weight: 500;
}
.sell-all-label[hidden] { display: none !important; }
.sell-all-label input { width: auto; margin: 0; }

.ticket-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 14px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.ticket-summary.summary-flash {
  animation: summary-flash 0.45s ease-out;
}
@keyframes summary-flash {
  from { border-color: rgba(255, 77, 46, 0.45); background: rgba(255, 77, 46, 0.06); }
  to { border-color: var(--line); background: var(--surface); }
}
.ticket-stat-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.ticket-stat strong {
  font-size: 14px;
  font-weight: 700;
}
.ticket-stat-wide {
  grid-column: 1 / -1;
}
.ticket-hint {
  margin: 0 0 10px;
  font-size: 12.5px;
  line-height: 1.4;
}
.ticket-hint.warn { color: var(--accent); }

.trade-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.ticket-submit {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
}
.ticket-submit.is-long {
  background: var(--pos);
  border-color: var(--pos);
}
.ticket-submit.is-short {
  background: var(--neg);
  border-color: var(--neg);
}
.ticket-submit.is-close {
  background: var(--ink);
  border-color: var(--ink);
}
.ticket-msg { margin: 0; min-height: 1.2em; font-size: 13px; }

.settings-form {
  max-width: 420px;
  margin-top: 8px;
}
.settings-form label {
  margin-bottom: 4px;
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
#settings-usage {
  margin: 4px 0 12px;
}
.trade-row-btn { padding: 4px 10px; font-size: 12px; }
.success-pulse { animation: fade-swap 0.35s ease-out both; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(11, 18, 32, 0.45);
}
.modal[hidden] { display: none !important; }
.modal-card {
  width: min(420px, 100%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  animation: fade-swap 0.22s ease-out both;
}
.modal-card h2 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 1.25rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* —— Signed-in portfolio —— */
#app.is-ready .kpi {
  animation: rise-in 0.45s ease-out both;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 28px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.up-next {
  margin: 0 0 24px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
}
.up-next .label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 6px;
}
.up-next-summary {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.4;
}
.up-next-steps {
  margin: 0;
  padding-left: 1.2em;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.up-next-steps li + li { margin-top: 4px; }

.kpi {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}
#app.is-ready .kpi:nth-child(2) { animation-delay: 0.06s; }
#app.is-ready .kpi:nth-child(3) { animation-delay: 0.12s; }

.kpi .label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.kpi .value {
  font-family: var(--mono);
  font-size: clamp(1.5rem, 3vw, 1.85rem);
  font-weight: 600;
  margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.sub {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}
.pos { color: var(--pos); }
.neg { color: var(--neg); }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
}
.tabs button {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 14px;
  margin-bottom: -1px;
  font-weight: 600;
}
.tabs button:hover { filter: none; color: var(--ink); }
.tabs button[aria-selected="true"] {
  background: transparent;
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.range {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.chart {
  height: 240px;
  margin: 0 -4px 8px;
  background:
    linear-gradient(180deg, rgba(15, 138, 107, 0.06) 0%, transparent 70%);
  border-radius: 12px;
}
.chart svg { width: 100%; height: 100%; }

.nav-gains {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 20px;
  margin: 4px 0 22px;
  padding: 14px 0 16px;
  border-bottom: 1px solid var(--line);
}
.nav-gain .label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 4px;
}
.nav-gain strong {
  font-family: var(--mono);
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--sans);
}
.num { text-align: right; }

#tab-nav, #tab-pnl, #tab-history { overflow-x: auto; }
#holdings {
  min-width: 860px;
}
.pos-actions {
  text-align: right;
  white-space: nowrap;
}
.pos-action-row {
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
}
button.pos-action {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface, #fff);
  color: var(--ink);
  cursor: pointer;
  line-height: 1.2;
}
button.pos-action:hover {
  border-color: var(--ink);
}
button.pos-action.is-close {
  border-color: color-mix(in srgb, var(--neg) 35%, var(--line));
  color: var(--neg);
}
button.pos-action.is-close:hover {
  border-color: var(--neg);
}
button.pos-action:disabled {
  opacity: 0.5;
  cursor: wait;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.tag {
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-family: var(--sans);
  font-weight: 600;
}
.tag.confirmed { color: var(--pos); border-color: rgba(15, 138, 107, 0.35); }
.tag.failed { color: var(--neg); border-color: rgba(226, 61, 40, 0.35); }
.tag.pending { color: var(--warn); border-color: rgba(232, 148, 10, 0.4); }

.copyrow {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}
code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 13px;
}
.copyrow code {
  flex: 1;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: nowrap;
}

.field .label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.quick-add { margin-top: 16px; }
.qa-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.qa-btn {
  display: inline-block;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.qa-btn:hover,
.qa-btn[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.qa-panel {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.qa-panel ol { margin: 6px 0 4px; padding-left: 20px; }
.qa-panel .copyrow { margin: 6px 0 12px; }

/* Docs */
.doc { max-width: 860px; }
.doc h1 { margin-top: 0; }
.doc h2 { margin-top: 0; }
.doc .card {
  background: var(--surface-2);
}
pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  overflow-x: auto;
  margin: 8px 0 16px;
  font-family: var(--mono);
  font-size: 13px;
}
pre code { border: 0; padding: 0; background: none; }
.doc li { margin: 6px 0; }
.doc td, .doc th { white-space: normal; vertical-align: top; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-swap {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.lev-positions {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line, rgba(0, 0, 0, 0.08));
}
.lev-positions h2 {
  font-family: var(--display, inherit);
  font-size: 1.1rem;
  margin: 0 0 12px;
  font-weight: 700;
}
.pred-positions {
  margin-top: 20px;
}
.pred-positions h3 {
  font-family: var(--display, inherit);
  font-size: 0.98rem;
  margin: 0 0 10px;
  font-weight: 700;
}
#pred-table td:first-child {
  font-family: var(--sans);
  max-width: 280px;
}
#trade-leverage-hint { margin: 0; }
#trade-leverage-foot { margin: 0 0 4px; }

@media (max-width: 720px) {
  .top {
    padding: 10px 14px;
    flex-wrap: nowrap;
    gap: 10px;
  }
  .toplinks { display: none; }
  .session { margin-left: auto; }
  .nav-extra { display: none; }
  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
  }
  .kpi .label { font-size: 10px; letter-spacing: 0.04em; }
  .kpi .value {
    font-size: 1.05rem;
    margin: 4px 0 0;
  }
  .kpi .sub { display: none; }
  .nav-gains {
    gap: 8px 10px;
    margin-bottom: 16px;
    padding: 10px 0 12px;
  }
  .nav-gain .label { font-size: 10px; letter-spacing: 0.04em; }
  .nav-gain strong { font-size: 1rem; }
  .tabs button { padding: 10px 12px; font-size: 13px; }
  .browse-title { font-size: 1.35rem; }
  .browse-sub { font-size: 12.5px; }
  .discover-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -14px 12px;
    padding: 0 14px 4px;
    gap: 8px;
  }
  .discover-chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
  .trade-search { margin-bottom: 8px; }
  .search-field { min-width: 0; }
  .search-field input { min-width: 0; width: 100%; }
  .market-board-head,
  .market-row {
    padding-left: 8px;
    padding-right: 8px;
    gap: 4px;
  }
  .market-row-market strong { font-size: 12.5px; }
  .tag-pill { display: none; }
  .ticket-hero {
    flex-wrap: wrap;
    gap: 10px;
  }
  .ticket-hero-aside {
    flex-direction: row;
    align-items: center;
    width: 100%;
    justify-content: space-between;
  }
  .ticket-meta { max-width: none; }
  .ticket-pill {
    min-width: calc(25% - 6px);
    flex: 1 1 calc(25% - 6px);
    padding: 11px 6px;
    text-align: center;
    font-size: 13px;
  }
  #trade-side-pills .ticket-pill {
    min-width: 0;
    flex: 1 1 0;
  }
  .ticket-pills { gap: 6px; }
  .ticket-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
  }
  .trade-form {
    padding: 14px;
    border-radius: 14px;
  }
  .ticket-submit {
    position: sticky;
    bottom: 10px;
    z-index: 5;
    box-shadow: 0 8px 24px rgba(11, 18, 32, 0.18);
  }
  .hero { padding: 28px 0 20px; }
  .hero-brand { font-size: 2.75rem; }
  .hero-line { margin-bottom: 28px; }
  main {
    padding: 14px 14px 40px;
    overflow-x: clip;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Agent-first landing */
.agent-landing {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 0 28px;
  animation: agent-in 0.55s ease-out both;
}
@keyframes agent-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.agent-h1 {
  font-family: var(--display);
  font-size: clamp(1.85rem, 4.5vw, 2.6rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 8px 0 12px;
}
.agent-sub {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 40rem;
  margin: 0 0 28px;
}
.install-tabs {
  margin: 0 0 28px;
  animation: agent-in 0.6s ease-out 0.08s both;
}
.install-tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.install-tab {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
}
.install-tab[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent-ink);
  color: var(--ink);
}
.install-panel pre {
  margin: 12px 0 0;
  overflow-x: auto;
}
.install-panel pre code {
  display: block;
  white-space: pre;
}
.agent-prompt-box {
  margin: 0 0 28px;
  animation: agent-in 0.65s ease-out 0.14s both;
}
.agent-prompt-box pre {
  max-height: 220px;
  overflow: auto;
  margin: 8px 0 12px;
}
.value-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 0 0 16px;
}
.value-strip div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.value-strip strong {
  font-family: var(--display);
  font-size: 1rem;
}
.value-strip span {
  color: var(--muted);
  font-size: 0.9rem;
}
.live-strip {
  font-size: 0.9rem;
  margin: 0 0 8px;
}
.nav-login {
  font-weight: 600;
  color: var(--ink);
}
a.nav-login {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-decoration: none;
}
a.nav-login:hover {
  border-color: var(--ink);
}
.login-page .login-main {
  max-width: 440px;
  margin: 0 auto;
  padding: 48px 20px 24px;
}
.login-panel .env-badge {
  display: inline-block;
  margin: 0 0 12px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
}
.login-panel .env-badge[data-env='sandbox'] {
  border-color: color-mix(in srgb, var(--accent, #e85d04) 35%, var(--line));
  color: var(--ink);
}
.login-panel .env-badge[data-env='mainnet'] {
  border-color: color-mix(in srgb, #b42318 30%, var(--line));
}
.login-panel .hero-brand {
  font-size: clamp(2rem, 6vw, 2.75rem);
  margin-bottom: 8px;
}
.login-panel h1 {
  font-family: var(--display);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  letter-spacing: -0.03em;
  margin: 0 0 10px;
}
.login-panel .lede {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}
.login-agent-hint {
  margin-top: 28px;
}
.site-footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.8;
}
.site-footer a { color: var(--muted); }
.doc-md-actions {
  margin: 0 0 12px;
  font-size: 0.9rem;
}
@media (max-width: 640px) {
  .value-strip { grid-template-columns: 1fr; }
  .agent-landing { padding-top: 20px; }
}
