/* SabiMarkets — dark exchange theme with a Naija-green accent.
   Teal-green (yes) / rose (no). */

:root {
  --bg: #0d1117;
  --bg-soft: #141a23;
  --card: #1a2230;
  --card-hover: #202a3b;
  --border: #2a3547;
  --text: #e8edf5;
  --text-dim: #94a3b8;
  --accent: #22a06b;
  --yes: #2fbf8f;
  --yes-soft: rgba(47, 191, 143, 0.14);
  --no: #e05c6e;
  --no-soft: rgba(224, 92, 110, 0.14);
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }
a { color: inherit; text-decoration: none; }
main { flex: 1; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0.8rem 0;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 1.2rem; }
.brand-mark { color: var(--accent); font-size: 1.4rem; }
.brand-logo { display: block; border-radius: 6px; }
.brand-name { letter-spacing: -0.02em; }

.search-wrap { flex: 1; position: relative; max-width: 420px; }
.search-icon {
  position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); font-size: 1rem; pointer-events: none;
}
#search {
  width: 100%; padding: 0.55rem 0.9rem 0.55rem 2.1rem;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 0.9rem; outline: none;
}
#search:focus { border-color: var(--accent); }

.site-nav { display: flex; gap: 0.25rem; margin-left: auto; }
.nav-link {
  padding: 0.45rem 0.85rem; border-radius: 8px;
  color: var(--text-dim); font-size: 0.92rem; font-weight: 600;
  /* A wrapped nav label doubles the header height — never let it wrap. */
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--bg-soft); }
.nav-link.active { color: var(--text); background: var(--card); }

.brand-accent { color: var(--accent); }

.wallet-pill {
  background: linear-gradient(135deg, var(--accent), #1b7f55);
  color: #fff; font-weight: 700; font-size: 0.88rem;
  padding: 0.42rem 0.9rem; border-radius: 999px; white-space: nowrap;
}

.mb-switch { display: inline-flex; align-items: center; gap: 0.3rem; margin-left: 0.9rem; }
.mb-label { font-size: 0.76rem; opacity: 0.8; }
.mb-btn {
  font: inherit; font-size: 0.74rem; font-weight: 700; cursor: pointer;
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--border); color: inherit;
  padding: 0.2rem 0.6rem; border-radius: 999px;
}
.mb-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.mb-btn[data-unconfigured] { opacity: 0.65; }

/* ---------- Hero ---------- */
.hero {
  padding: 2.6rem 0 1.6rem;
  background:
    radial-gradient(700px 300px at 20% -10%, rgba(34, 160, 107, 0.18), transparent),
    radial-gradient(700px 300px at 85% -20%, rgba(47, 191, 143, 0.1), transparent);
}
.crypto-strip {
  display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: 1rem;
  font-size: 0.84rem; color: var(--text-dim);
}
.crypto-strip .coin {
  display: inline-flex; gap: 0.4rem; align-items: baseline;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.3rem 0.8rem;
}
.crypto-strip .coin b { color: var(--text); }
.coin-ngn { font-size: 0.74rem; opacity: 0.75; }

.hero-meta { display: flex; align-items: center; gap: 1rem; }
.feed-status {
  display: flex; align-items: center; gap: 0.3rem; white-space: nowrap;
  color: var(--text-dim); font-size: 0.78rem; margin-top: 1.1rem;
}
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim); vertical-align: middle; margin-right: 0.25rem;
}
.dot.on { background: var(--yes); box-shadow: 0 0 6px rgba(47, 191, 143, 0.8); }
.dot.off { background: var(--no); }

/* Lifecycle: settled and closed markets read differently from live ones. */
.badge-row { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.status-badge {
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.05em;
  border-radius: 6px; padding: 0.14rem 0.5rem; white-space: nowrap; border: 1px solid;
}
.status-badge.settled { color: var(--yes); background: var(--yes-soft); border-color: rgba(47,191,143,0.4); }
.status-badge.closed { color: #e5b567; background: rgba(229,181,103,0.13); border-color: rgba(229,181,103,0.38); }
/* A finished market shouldn't compete with live ones for attention. */
.market-card.is-settled, .market-card.is-closed { opacity: 0.72; }
.market-card.is-settled:hover, .market-card.is-closed:hover { opacity: 1; }

.settled-result {
  display: flex; align-items: baseline; gap: 0.5rem;
  background: var(--yes-soft); border: 1px solid rgba(47,191,143,0.35);
  border-radius: 10px; padding: 0.7rem 0.9rem; margin-bottom: 0.7rem;
}
.settled-result b { font-size: 1.4rem; color: var(--yes); letter-spacing: -0.02em; }
.settled-label { color: var(--text-dim); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.section-note { font-weight: 400; font-size: 0.85rem; color: var(--text-dim); text-transform: none; letter-spacing: 0; }

.src-badge {
  align-self: flex-start;
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em;
  border-radius: 6px; padding: 0.12rem 0.45rem; border: 1px solid;
  white-space: nowrap;
}
.src-badge.sabi { color: var(--yes); background: var(--yes-soft); border-color: rgba(47, 191, 143, 0.35); }
.src-badge.pm { color: #b39ddb; background: rgba(124, 108, 245, 0.14); border-color: rgba(124, 108, 245, 0.4); }
.src-badge.ks { color: #7fb8f0; background: rgba(90, 141, 245, 0.14); border-color: rgba(90, 141, 245, 0.4); }
.source-line { color: var(--text-dim); font-size: 0.8rem; margin: 0.4rem 0 0.8rem; max-width: 62ch; }

.source-legend {
  display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.55rem 0.9rem; margin-top: 1rem;
  color: var(--text-dim); font-size: 0.8rem;
}
.legend-title { font-weight: 700; color: var(--text); }
.legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.stale-tag { color: var(--no); font-size: 0.78rem; }
.hero h1 { font-size: clamp(1.6rem, 3.5vw, 2.5rem); letter-spacing: -0.03em; }
.accent { color: var(--accent); }
.hero-tagline {
  color: var(--text); font-weight: 700; font-size: 1.05rem;
  margin-top: 0.5rem; letter-spacing: -0.01em;
}
.hero-sub { color: var(--text-dim); margin-top: 0.25rem; max-width: 46rem; }

.ticker {
  margin-top: 1.1rem; overflow: hidden; white-space: nowrap;
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
  font-size: 0.85rem; color: var(--text-dim);
}
.tick { margin-right: 0.4rem; }
.tick-title { opacity: 0.85; }
.tick-sep { margin-right: 0.4rem; color: var(--border); }

/* ---------- Filters ---------- */
.filter-row {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 0 1.2rem; flex-wrap: wrap;
}
.chips { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--bg-soft); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.42rem 0.85rem; font-size: 0.86rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.sort-select {
  margin-left: auto; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0.45rem 0.7rem; font-size: 0.86rem; cursor: pointer;
}

/* ---------- Market grid ---------- */
.market-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem; padding-bottom: 2.5rem;
}
.market-card {
  display: flex; flex-direction: column; gap: 0.8rem; cursor: pointer;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.market-card:hover {
  transform: translateY(-2px); border-color: var(--accent); background: var(--card-hover);
}
.card-top { display: flex; gap: 0.7rem; align-items: flex-start; }
.card-icon {
  font-size: 1.5rem; line-height: 1;
  background: var(--bg-soft); border-radius: 10px; padding: 0.45rem;
}
.card-title { font-size: 0.98rem; font-weight: 700; letter-spacing: -0.01em; }

.price-row { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; }
.chance { display: flex; flex-direction: column; }
.chance-num { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; }
.chance-label { color: var(--text-dim); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
canvas.spark { width: 130px; height: 44px; }

.yn-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.btn-yes, .btn-no {
  text-align: center; font-weight: 700; font-size: 0.9rem;
  border-radius: 10px; padding: 0.55rem 0; transition: filter 0.15s;
}
.btn-yes { background: var(--yes-soft); color: var(--yes); }
.btn-no { background: var(--no-soft); color: var(--no); }
.btn-yes:hover { filter: brightness(1.25); }
.btn-no:hover { filter: brightness(1.25); }

.outcomes { display: flex; flex-direction: column; gap: 0.45rem; }
.outcome-row {
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto;
  gap: 0.15rem 0.6rem; font-size: 0.88rem;
}
.outcome-name { font-weight: 600; }
.outcome-price { font-weight: 800; color: var(--accent); }
.outcome-bar {
  grid-column: 1 / -1; height: 5px; border-radius: 4px;
  background: var(--bg-soft); overflow: hidden;
}
.outcome-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.more-outcomes { color: var(--text-dim); font-size: 0.8rem; }

.card-meta {
  margin-top: auto; display: flex; justify-content: space-between; gap: 0.6rem;
  color: var(--text-dim); font-size: 0.8rem; border-top: 1px solid var(--border);
  padding-top: 0.7rem;
}
.up { color: var(--yes); }
.down { color: var(--no); }
.flat { color: var(--text-dim); }

.empty-state { color: var(--text-dim); padding: 3rem 0; text-align: center; }
.account-page .empty-state,
.portfolio-page .empty-state { padding: 0.9rem 0 1.4rem; text-align: left; }
.empty-state a { color: var(--accent); font-weight: 600; }

.intl-link {
  display: block; text-align: center; margin: 0 0 2.5rem;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.9rem 1rem; color: var(--text-dim); font-weight: 700; font-size: 0.95rem;
  transition: border-color 0.15s, color 0.15s;
}
.intl-link:hover { border-color: var(--accent); color: var(--text); }

/* ---------- Market detail ---------- */
.market-page { padding: 1.6rem 0 3rem; }
.back-link { color: var(--text-dim); font-size: 0.88rem; font-weight: 600; }
.back-link:hover { color: var(--text); }

.market-layout {
  display: grid; grid-template-columns: 1fr 330px; gap: 1.4rem; margin-top: 1rem;
  align-items: start;
}
.market-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.2rem; }
.market-icon { font-size: 2.2rem; background: var(--card); border-radius: 14px; padding: 0.6rem; }
.market-head h1 { font-size: clamp(1.25rem, 2.4vw, 1.7rem); letter-spacing: -0.02em; }
.market-stats { display: flex; gap: 1rem; color: var(--text-dim); font-size: 0.86rem; margin-top: 0.3rem; flex-wrap: wrap; }

.big-chance { display: flex; align-items: baseline; gap: 0.6rem; margin-bottom: 1rem; }
.big-num { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.04em; }
.big-label { color: var(--text-dim); text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.08em; }

.outcomes-table { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.2rem; }
.outcome-line {
  display: grid; grid-template-columns: 140px 1fr auto; gap: 0.8rem; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.65rem 0.9rem; cursor: pointer; color: var(--text);
  font: inherit; text-align: left; transition: border-color 0.15s;
}
.outcome-line:hover { border-color: var(--accent); }
.outcome-line.selected { border-color: var(--accent); background: var(--card-hover); }
.outcome-line .outcome-price { font-size: 1rem; }

.chart-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1.2rem;
}
.chart-title { color: var(--text-dim); font-size: 0.82rem; margin-bottom: 0.6rem; }
#price-chart { width: 100%; height: 220px; display: block; }

.tabs { display: flex; gap: 0.4rem; border-bottom: 1px solid var(--border); margin-bottom: 0.9rem; }
.tab {
  background: none; border: none; color: var(--text-dim); font: inherit; font-weight: 700;
  font-size: 0.9rem; padding: 0.5rem 0.8rem; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { color: var(--text-dim); font-size: 0.94rem; max-width: 60ch; }

/* ---------- Order panel ---------- */
.order-panel {
  position: sticky; top: 84px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow);
}
.panel-title { font-size: 1rem; margin-bottom: 0.8rem; }
.side-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.9rem; }
.side-btn {
  font: inherit; font-weight: 800; font-size: 0.92rem; padding: 0.6rem 0;
  border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--bg-soft); color: var(--text-dim); cursor: pointer;
}
.side-btn.yes.active { background: var(--yes-soft); color: var(--yes); border-color: var(--yes); }
.side-btn.no.active { background: var(--no-soft); color: var(--no); border-color: var(--no); }

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.8rem; }
.field span { color: var(--text-dim); font-size: 0.8rem; font-weight: 600; }
.field input {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 1rem; padding: 0.55rem 0.7rem; outline: none;
}
.field input:focus { border-color: var(--accent); }

.order-math { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; font-size: 0.88rem; }
.order-math div { display: flex; justify-content: space-between; }
.order-math span { color: var(--text-dim); }
.order-math .profit b { color: var(--yes); }

.submit-btn {
  width: 100%; font: inherit; font-weight: 800; font-size: 0.95rem;
  border: none; border-radius: 10px; padding: 0.7rem 0; cursor: pointer;
  color: #06251a; background: var(--yes); transition: filter 0.15s;
}
.submit-btn.no { background: var(--no); color: #2b0a10; }
.submit-btn:hover { filter: brightness(1.1); }

/* The trade CTA carries more weight than a generic button — bigger, brighter,
   with a colour-matched glow so Buy reads as the primary action. YES stays
   green, NO stays red (semantic), but both get presence. */
.order-panel .submit-btn {
  font-size: 1.08rem; padding: 0.95rem 0; letter-spacing: 0.01em;
  border-radius: 12px; box-shadow: 0 6px 20px rgba(47, 191, 143, 0.32);
}
.order-panel .submit-btn.no { box-shadow: 0 6px 20px rgba(224, 92, 110, 0.34); }
.order-panel .submit-btn:active { transform: translateY(1px); }
/* Give the Yes/No selector the same brightness bump so the whole panel reads
   as one bold control, not a faint one above a loud one. */
.side-btn.yes.active { box-shadow: inset 0 0 0 1px var(--yes), 0 2px 10px rgba(47, 191, 143, 0.18); }
.side-btn.no.active { box-shadow: inset 0 0 0 1px var(--no), 0 2px 10px rgba(224, 92, 110, 0.18); }

.panel-note { color: var(--text-dim); font-size: 0.78rem; margin-top: 0.7rem; }
.side-hint { color: var(--text-dim); font-size: 0.76rem; margin: -0.3rem 0 0.7rem; }
.side-hint b { color: var(--text); }
.signin-cta { display: block; text-align: center; background: var(--accent); color: #fff; margin-top: 0.4rem; }
.order-panel span.side-btn { cursor: default; text-align: center; }
.order-msg { margin-top: 0.6rem; font-size: 0.85rem; font-weight: 600; }
.order-msg.success { color: var(--yes); }
.order-msg.error { color: var(--no); }

/* ---------- Portfolio ---------- */
.portfolio-page { padding: 1.8rem 0 3rem; }
.portfolio-page h1 { letter-spacing: -0.02em; }
.portfolio-page h2 { font-size: 1.05rem; margin: 1.6rem 0 0.8rem; color: var(--text-dim); }

.summary-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.9rem; margin-top: 1.1rem;
}
.summary-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.2rem;
}
.summary-label { color: var(--text-dim); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; }
.summary-value { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.summary-sub { color: var(--text-dim); font-size: 0.72rem; line-height: 1.3; }
.reconcile { color: var(--text-dim); font-size: 0.88rem; margin: 0.8rem 0 0.2rem; }
.reconcile b { color: var(--text); }

.positions { display: flex; flex-direction: column; gap: 0.8rem; }
.position-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; display: flex; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; align-items: center;
}
.pos-head { display: flex; gap: 0.8rem; align-items: center; }
.pos-title { font-weight: 700; }
.pos-title:hover { color: var(--accent); }
.pos-sub { color: var(--text-dim); font-size: 0.84rem; margin-top: 0.15rem; }
.side-tag {
  font-size: 0.72rem; font-weight: 800; padding: 0.1rem 0.4rem; border-radius: 6px;
}
.side-tag.yes { background: var(--yes-soft); color: var(--yes); }
.side-tag.no { background: var(--no-soft); color: var(--no); }

.pos-numbers { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.pos-numbers > div { display: flex; flex-direction: column; font-size: 0.92rem; }
.pos-numbers span { color: var(--text-dim); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; }

.sell-btn {
  font: inherit; font-weight: 700; font-size: 0.84rem; cursor: pointer;
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.5rem 0.9rem; transition: border-color 0.15s;
}
.sell-btn:hover { border-color: var(--accent); }

.reset-btn {
  margin-top: 2rem; font: inherit; font-size: 0.85rem; font-weight: 600;
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 10px; padding: 0.55rem 1rem; cursor: pointer;
}
.reset-btn:hover { border-color: var(--no); color: var(--no); }

/* ---------- Docs ---------- */
.docs-page { padding: 1.8rem 0 3rem; max-width: 760px; }
.docs-page h1 { letter-spacing: -0.02em; margin-bottom: 1.2rem; }
.doc-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.3rem; margin-bottom: 0.9rem;
}
.doc-card h2 { font-size: 1rem; margin-bottom: 0.4rem; }
.doc-card p { color: var(--text-dim); font-size: 0.94rem; }
.doc-card.warn { border-color: rgba(224, 92, 110, 0.5); }

/* ---------- Account & auth ---------- */
.account-chip {
  color: var(--text-dim); font-size: 0.86rem; font-weight: 700; white-space: nowrap;
  border: 1px solid var(--border); border-radius: 999px; padding: 0.38rem 0.85rem;
  transition: border-color 0.15s, color 0.15s;
}
.account-chip:hover { border-color: var(--accent); color: var(--text); }
.account-chip.signed-in { color: var(--accent); border-color: var(--accent); }

.account-page, .leaderboard-page, .intl-page { padding: 1.8rem 0 3rem; }
.intl-page h1 { letter-spacing: -0.02em; margin-top: 0.6rem; }
.account-page h1, .leaderboard-page h1 { letter-spacing: -0.02em; margin-bottom: 0.4rem; }
.section-title { font-size: 1.05rem; margin: 1.8rem 0 0.8rem; color: var(--text-dim); }

.auth-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem; margin-top: 1.2rem; max-width: 720px;
}
.auth-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem;
}
.auth-card h2 { font-size: 1rem; margin-bottom: 0.5rem; }
/* The signed-out account view is a single card — centre it rather than leaving
   it stranded against the left margin. */
.auth-single { max-width: 420px; margin: 1.2rem auto 0; }
.auth-single form { display: flex; flex-direction: column; gap: 0.4rem; }
#auth-forms .hero-sub { text-align: center; max-width: 46ch; margin: 0 auto; }
/* When signed out, the heading centres over the card too; signed in, the
   page-head keeps its heading-left / log-out-right layout. */
.account-page:has(#auth-forms:not([hidden])) .page-head { justify-content: center; }
/* display:flex above would defeat the hidden attribute — restore it explicitly
   so only the active tab's form is ever visible */
.auth-single form[hidden] { display: none; }
.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem;
  background: var(--bg-soft); border-radius: 10px; padding: 0.3rem; margin-bottom: 0.9rem;
}
.auth-tab {
  font: inherit; font-weight: 700; font-size: 0.88rem; cursor: pointer;
  background: none; border: none; color: var(--text-dim);
  border-radius: 8px; padding: 0.5rem 0;
}
.auth-tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.field-hint { color: var(--text-dim); font-size: 0.74rem; font-weight: 400; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.logout-top { margin-top: 0; }

.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 2.6rem; }
.pw-eye {
  position: absolute; right: 0.4rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 1rem; cursor: pointer;
  padding: 0.2rem; line-height: 1; opacity: 0.7;
}
.pw-eye:hover { opacity: 1; }

.linklike {
  background: none; border: none; color: var(--accent); font: inherit;
  font-size: 0.82rem; font-weight: 600; cursor: pointer; padding: 0;
  text-align: left; margin-top: 0.4rem;
}
.linklike:hover { text-decoration: underline; }
#forgot-panel { border-top: 1px solid var(--border); margin-top: 0.8rem; padding-top: 0.8rem;
  display: flex; flex-direction: column; gap: 0.5rem; }
/* `display` on the panel itself would otherwise beat the hidden attribute,
   leaving the reset form open before anyone clicks "Forgot password?". */
#forgot-panel[hidden] { display: none; }
#forgot-panel form { display: flex; flex-direction: column; gap: 0.4rem; }
#forgot-panel form[hidden] { display: none; }
.summary-email { font-size: 0.95rem; word-break: break-all; }
.auth-card .submit-btn { background: var(--accent); color: #fff; margin-top: 0.3rem; }
.auth-card .submit-btn.yes { background: var(--yes); color: #06251a; }

.topup-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.topup-btn {
  font: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer;
  background: var(--yes-soft); color: var(--yes);
  border: 1px solid rgba(47, 191, 143, 0.35); border-radius: 10px;
  padding: 0.55rem 1rem; transition: filter 0.15s;
}
.topup-btn:hover { filter: brightness(1.25); }
.topup-btn:disabled { opacity: 0.5; cursor: wait; }

.trade-list { display: flex; flex-direction: column; gap: 0.55rem; max-width: 820px; }
.trade-row {
  display: flex; align-items: center; gap: 0.8rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.65rem 0.9rem;
}
.trade-main { flex: 1; min-width: 0; }
.trade-time { color: var(--text-dim); font-size: 0.78rem; white-space: nowrap; }

/* ---------- Leaderboard ---------- */
.board { display: flex; flex-direction: column; gap: 0.5rem; max-width: 720px; margin-top: 1.2rem; }
.board-row {
  display: grid; grid-template-columns: 3rem 1fr auto auto; gap: 1rem; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.7rem 1rem;
}
.board-row.top { border-color: rgba(34, 160, 107, 0.45); }
.board-rank { font-size: 1.05rem; font-weight: 800; color: var(--text-dim); }
.board-name { font-weight: 700; }
.board-worth { font-weight: 800; }
.board-pnl { font-size: 0.88rem; font-weight: 700; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); padding: 1.4rem 0; margin-top: auto;
  color: var(--text-dim); font-size: 0.82rem;
}

/* ---------- Responsive ----------
   Phones and tablets, iOS and Android. Two things drive this section:

   1. Nothing may scroll sideways. The page is a column; anything wider than
      the screen (tables, chart rows, ticker) scrolls inside its own box.
   2. The header must stay one tidy line. On a 360px phone the four nav links
      alone are ~536px, so below 720px the nav leaves the header entirely and
      becomes a bottom tab bar — the pattern both platforms already use.
*/

/* Backstop against sideways scroll. `clip`, not `hidden`: overflow-x: hidden
   turns the element into a scroll container, which kills the sticky header.
   Browsers without `clip` simply ignore it — the real overflow sources are
   fixed below, so there is nothing for it to catch. */
body { max-width: 100%; overflow-x: clip; }
img, svg, canvas, video { max-width: 100%; height: auto; }

@media (max-width: 1024px) {
  .market-layout { grid-template-columns: 1fr; }
  .order-panel { position: static; }
}

/* Below this the brand, nav, account chip and balance already fill the bar;
   the search box would be squeezed to a useless sliver (50px at 1024px) and
   push the nav labels into wrapping. Search returns on the markets page as a
   full-width row under 720px. */
@media (max-width: 1150px) {
  .search-wrap { display: none; }
}

/* ---- Tablets ----
   Wide enough to keep the nav in the header, not wide enough for the search
   box as well. Everything tightens so the header stays a single row: at 768px
   the untightened header wraps onto two. */
@media (min-width: 721px) and (max-width: 900px) {
  .header-inner { gap: 0.7rem; flex-wrap: nowrap; }
  .search-wrap { display: none; }
  .brand { font-size: 1.05rem; min-width: 0; flex: 0 1 auto; overflow: hidden; }
  .brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Everything to the right holds its size; the brand is what gives way, so a
     tight header truncates rather than letting the nav overlap the wordmark. */
  .brand-logo, .site-nav, .account-chip, .wallet-pill { flex: none; }
  .site-nav { gap: 0.1rem; }
  .nav-link { padding: 0.4rem 0.55rem; font-size: 0.83rem; white-space: nowrap; }
  .account-chip {
    font-size: 0.83rem; padding: 0.36rem 0.7rem;
    max-width: 22vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .wallet-pill { font-size: 0.82rem; padding: 0.36rem 0.75rem; }
  .pill-label { display: none; }
  .summary-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Below ~800px the nav, chip and balance leave too little for the wordmark and
   it would truncate to "SabiMark…". The logo carries it instead. */
@media (min-width: 721px) and (max-width: 800px) {
  .brand-name { display: none; }
}

/* ---- Phones and small tablets ---- */
@media (max-width: 720px) {
  .container { width: min(1180px, 100% - 1.6rem); }

  /* backdrop-filter establishes a containing block for fixed-position
     descendants, which would pin the bottom nav to the bottom of the *header*
     instead of the viewport. Solid background on mobile, no filter. */
  .site-header { backdrop-filter: none; background: var(--bg); }

  /* Header: brand on the left, identity and balance on the right. One line. */
  .header-inner {
    flex-wrap: wrap;
    gap: 0.5rem 0.6rem;
    padding: 0.55rem 0;
  }
  .brand { font-size: 1.02rem; gap: 0.4rem; }
  .brand-logo { width: 22px; height: 22px; }
  .account-chip {
    margin-left: auto;
    font-size: 0.8rem;
    padding: 0.34rem 0.7rem;
    max-width: 42vw;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .wallet-pill { font-size: 0.78rem; padding: 0.34rem 0.7rem; }

  /* Search drops to its own full-width row rather than being hidden — on a
     phone it is the fastest way to reach a market. Pages that carry the div
     only as a desktop spacer leave it empty, so those collapse instead. */
  .search-wrap { display: block; order: 10; flex: 1 0 100%; max-width: none; }
  .search-wrap:empty { display: none; }
  #search { font-size: 16px; }  /* 16px stops iOS zooming the page on focus */

  /* Nav becomes a fixed bottom bar. Same markup, moved by CSS. */
  .site-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 60;
    margin-left: 0;
    gap: 0;
    background: rgba(13, 17, 23, 0.97);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .nav-link {
    flex: 1 1 0;
    display: flex; align-items: center; justify-content: center;
    text-align: center;
    min-height: 46px;
    padding: 0.5rem 0.2rem;
    border-radius: 0;
    font-size: 0.74rem;
    line-height: 1.15;
  }
  /* `display: flex` above would otherwise beat the hidden attribute, which is
     what gates the Portfolio link when signed out. */
  .nav-link[hidden] { display: none; }
  .nav-link.active {
    background: transparent;
    color: var(--accent);
    box-shadow: inset 0 2px 0 var(--accent);
  }
  /* Clear the bar so the footer and last card are never trapped under it. */
  body { padding-bottom: calc(46px + env(safe-area-inset-bottom, 0px)); }

  /* Funding banner: the mode always shows, the explanation steps aside. */
  .money-banner { font-size: 0.74rem; padding: 0.4rem 0.7rem; line-height: 1.35; }
  .mb-detail { display: none; }
  .mb-switch { margin-left: 0.5rem; gap: 0.25rem; }
  .mb-btn { font-size: 0.68rem; padding: 0.18rem 0.5rem; }

  /* Hero */
  .hero { padding: 1.6rem 0 1.1rem; }
  .hero h1 { font-size: clamp(1.75rem, 8.5vw, 2.4rem); line-height: 1.12; }
  .hero-sub, .hero-tagline { font-size: 0.92rem; }
  .ticker { font-size: 0.78rem; }

  /* Cards and rows */
  .market-grid { grid-template-columns: 1fr; gap: 0.8rem; }
  .summary-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .filters { gap: 0.4rem; }
  .outcome-line { grid-template-columns: 1fr auto; }
  .outcome-line .outcome-bar { display: none; }

  /* Position and trade rows stack instead of squeezing. */
  .position, .trade-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .pos-numbers { width: 100%; justify-content: space-between; }

  /* Comfortable tap targets — 44px is the floor on both platforms. */
  .submit-btn, .topup-btn, .reset-btn, .auth-tab, .side-btn, .sell-btn {
    min-height: 44px;
  }
  input, select, textarea { font-size: 16px; }
}

/* ---- Narrow phones ----
   Below 480px the brand wordmark, the account chip and the balance cannot all
   fit on one line. The logo alone carries the brand — the standard phone
   pattern — which keeps identity and balance together on that line. */
@media (max-width: 480px) {
  .brand-name { display: none; }
  .pill-label { display: none; }
}

@media (max-width: 400px) {
  .container { width: min(1180px, 100% - 1.2rem); }
  .account-chip { max-width: 46vw; }
  .summary-cards { grid-template-columns: 1fr; }
  .nav-link { font-size: 0.68rem; padding: 0.5rem 0.1rem; }
}

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .ticker { animation: none !important; }
}

/* Funding mode: never leave anyone guessing whether money is real. */
.money-banner {
  padding: 0.45rem 1rem; text-align: center; font-size: 0.82rem;
  border-bottom: 1px solid var(--border); position: relative; z-index: 60;
}
.money-banner.demo { background: rgba(124, 108, 245, 0.16); color: #cfc6ff; }
.money-banner.test { background: rgba(229, 181, 103, 0.16); color: #f0d9a8; }
.money-banner.live { background: rgba(224, 92, 110, 0.18); color: #ffc9d0; }
.money-banner.unknown { background: rgba(224, 92, 110, 0.22); color: #ffd2d8; font-weight: 600; }
/* Mode unverified: don't offer funding controls. */
:root[data-funding-mode="unknown"] .topup-btn { pointer-events: none; opacity: 0.45; }

/* ---------- Share button ---------- */
.share-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--bg-soft); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0.4rem 0.8rem; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; margin-bottom: 1rem; transition: color 0.15s, border-color 0.15s;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.share-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Comments ---------- */
.comments { margin-top: 2rem; border-top: 1px solid var(--border); padding-top: 1.4rem; }
.comments-title { font-size: 1.1rem; margin-bottom: 1rem; }
.comments-count { color: var(--text-dim); font-weight: 500; font-size: 0.9rem; }

.comment-form textarea {
  width: 100%; resize: vertical; min-height: 2.6rem;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0.6rem 0.8rem; font: inherit; font-size: 0.9rem;
}
.comment-form textarea:focus { outline: none; border-color: var(--accent); }
.comment-form-row { display: flex; align-items: center; justify-content: space-between; margin-top: 0.5rem; gap: 0.75rem; }
.comment-count-hint { color: var(--text-dim); font-size: 0.75rem; }
.comment-submit { background: var(--accent); color: #fff; padding: 0.45rem 1.2rem; width: auto; }
.comment-signin { color: var(--text-dim); font-size: 0.9rem; }
.comment-signin a { color: var(--yes); font-weight: 600; }

.comment-list { margin-top: 1.2rem; display: flex; flex-direction: column; gap: 0.9rem; }
.comment-empty { color: var(--text-dim); font-size: 0.9rem; }
.comment-row { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0.7rem 0.9rem; }
.comment-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.3rem; }
.comment-user { font-weight: 700; font-size: 0.86rem; color: var(--yes); }
.comment-time { color: var(--text-dim); font-size: 0.72rem; }
.comment-del {
  margin-left: auto; background: none; border: none; color: var(--text-dim);
  font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 0.2rem;
}
.comment-del:hover { color: var(--no); }
.comment-body { font-size: 0.92rem; word-break: break-word; white-space: pre-wrap; }

/* ---------- Live activity feed ---------- */
.activity { margin: 2.5rem 0 1rem; }
.activity-title { font-size: 1.05rem; margin-bottom: 0.9rem; }
.activity-list { display: flex; flex-direction: column; gap: 0.5rem; }
.activity-row {
  display: flex; align-items: baseline; gap: 0.7rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.55rem 0.85rem; font-size: 0.88rem;
}
.activity-icon { font-size: 1rem; flex-shrink: 0; }
.activity-text { flex: 1; color: var(--text-dim); min-width: 0; }
.activity-text b { color: var(--text); font-weight: 700; }
.activity-text a { color: var(--text); border-bottom: 1px solid var(--border); }
.activity-text a:hover { border-color: var(--accent); }
.activity-quote { font-style: italic; }
.activity-time { color: var(--text-dim); font-size: 0.72rem; flex-shrink: 0; white-space: nowrap; }

@media (max-width: 560px) {
  .activity-row { flex-wrap: wrap; }
  .activity-time { width: 100%; margin-left: 1.7rem; }
}
