/* ---------- base / WebView hygiene ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
html, body { margin: 0; padding: 0; overscroll-behavior: none; }
body {
  min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font-family: var(--font); font-weight: 500;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.is-light { background: var(--surface); }
a { color: inherit; text-decoration: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; text-align: inherit; }
.tap, button, a, [role="button"], .stock-row, .seg, .toggle {
  cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
img { -webkit-user-drag: none; user-select: none; -webkit-user-select: none; }
.tnum { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.scroll-x { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none; -ms-overflow-style: none; }
.scroll-x::-webkit-scrollbar { display: none; }

.app { position: relative; max-width: var(--max-w); margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  padding: calc(var(--top-pad) + 8px) 0 calc(var(--nav-h) + 16px); }
.app--discover { padding-top: calc(var(--top-pad) + 10px); }
.app--detail { padding-top: calc(var(--top-pad) + 6px); padding-bottom: calc(var(--nav-h) + 84px); }
.pad { padding: 0 var(--gutter); }

/* ---------- headings ---------- */
.screen-head { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--gutter); margin-bottom: 18px; }
.screen-head--watch { margin-bottom: 20px; }
.screen-title { font: 800 30px/1.25 var(--font); color: var(--ink); letter-spacing: -.03em; margin: 0; }
.section-title { font: 800 20px/1.25 var(--font); color: var(--ink); letter-spacing: -.02em; margin: 0; padding: 24px var(--gutter) 12px; }
.section-title--flush { padding: 0; margin-bottom: 12px; }
.section-title--spaced { padding-top: 26px; }

.status-pill { display: flex; align-items: center; gap: 6px; font: 600 13px var(--font); color: var(--text-2);
  background: var(--surface); padding: 7px 12px; border-radius: var(--r-pill); }
.status-pill .ph-fill { font-size: 8px; color: var(--primary); }
.status-pill.is-closed .ph-fill { color: var(--text-4); }

/* ---------- index cards + sparklines ---------- */
.rail { display: flex; gap: 12px; padding: 0 var(--gutter) 6px; }
.rail--tight { padding-bottom: 4px; }
.rail--trend { gap: 13px; }
.index-card { flex: 0 0 auto; width: 152px; border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px; background: var(--surface); }
.index-card__name { font: 600 13px var(--font); color: var(--text-2); margin-bottom: 3px; }
.index-card__val { font: 700 18px var(--font); color: var(--ink); letter-spacing: -.01em; }
.index-card__pct { font: 700 13px var(--font); margin-bottom: 9px; }
.index-card--lg { width: 170px; padding: 15px; }
.index-card--lg .index-card__name { margin-bottom: 0; }
.index-card--lg .index-card__pct { font-size: 22px; margin: 3px 0 9px; }
.sparkline { display: block; }
.is-up { color: var(--up); }
.is-down { color: var(--down); }

/* ---------- segmented pills ---------- */
.seg-group { display: flex; gap: 8px; padding: 0 var(--gutter) 14px; }
.seg { font: 700 13px var(--font); color: var(--text-2); background: var(--surface); padding: 8px 15px; border-radius: var(--r-pill); white-space: nowrap; }
.seg.is-active { background: var(--ink); color: var(--bg); }
.seg-group--tabs { gap: 10px; padding: 0; margin-bottom: 22px; }
.seg-group--tabs .seg { font-size: 14px; padding: 9px 16px; }
.seg-group--movers { gap: 6px; padding: 0; }
.seg-group--movers .seg { padding: 7px 13px; }

/* ---------- stock table ---------- */
.table-head { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 0 var(--gutter) 6px; font: 600 12px var(--font); color: var(--text-3); }
.table-head > :nth-child(2) { text-align: right; }
.table-head > :nth-child(3) { text-align: right; min-width: 62px; }
.table-head--watch { padding-top: 8px; }
.table-head--watch > :nth-child(3) { min-width: 72px; }

.stock-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 13px var(--gutter); border-top: 1px solid var(--surface); }
.stock-row--watch { padding: 14px var(--gutter); }
.stock-row--discover { padding: 12px var(--gutter); }
.stock-row:active { background: rgba(10, 10, 20, .03); }
.stock-row__main { min-width: 0; }
.stock-row__sym { font: 700 16px var(--font); color: var(--ink); }
.stock-row__name { font: 500 13px var(--font); color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-row__price { font: 700 15px var(--font); color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }

.pill { justify-self: end; min-width: 62px; text-align: center; font: 700 13px var(--font); padding: 6px 8px; border-radius: var(--r-chip); font-variant-numeric: tabular-nums; }
.pill.is-up { background: var(--primary-a16); color: var(--up); }
.pill.is-down { background: var(--down-a16); color: var(--down); }
.pill--solid { min-width: 72px; font-size: 13.5px; padding: 8px 10px; border-radius: var(--r-mono); color: #fff !important; }
.pill--solid.is-up { background: var(--up); }
.pill--solid.is-down { background: var(--down); }

.empty { padding: 28px var(--gutter); text-align: center; font: 500 14px var(--font); color: var(--text-3); }

/* ---------- watchlist ---------- */
.link-action { display: flex; align-items: center; gap: 5px; font: 700 14px var(--font); color: var(--ink); }
.link-action .ph-bold { font-size: 14px; }
.watch-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.watch-meta__count { font: 700 14px var(--font); color: var(--ink); }
.watch-meta .ph-bold { color: var(--text-3); font-size: 18px; padding: 4px 0 4px 8px; }
.outline-btn { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--border); border-radius: var(--r-pill); padding: 13px 24px; font: 700 15px var(--font); color: var(--ink); }
.outline-btn .ph-bold { font-size: 15px; }
.center-row { display: flex; justify-content: center; margin-top: 26px; }

/* ---------- discover ---------- */
.search-field { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-search); padding: 13px 16px; margin-bottom: 22px; width: 100%; }
.search-field .ph { color: var(--text-3); font-size: 19px; }
.search-field span, .search-field input { font: 500 16px var(--font); color: var(--text-3); }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); padding: 0; -webkit-appearance: none; appearance: none; }
.search-field input::placeholder { color: var(--text-3); }
.trend-card { flex: 0 0 auto; width: 128px; border: 1px solid var(--border); border-radius: var(--r-trend); padding: 16px; background: var(--surface); display: block; }
.trend-card__tile { width: 48px; height: 48px; border-radius: var(--r-tile); display: flex; align-items: center; justify-content: center; font: 800 22px var(--font); margin-bottom: 14px; }
.trend-card__sym { font: 700 15px var(--font); color: var(--ink); }
.trend-card__name { font: 500 12px var(--font); color: var(--text-3); margin: 1px 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trend-card__pct { font: 700 14px var(--font); }
.movers-head { display: flex; align-items: center; gap: 14px; padding: 26px var(--gutter) 14px; }
.movers-head .section-title { padding: 0; }

/* ---------- settings ---------- */
.settings-title { padding: 0 var(--gutter) 8px; }
.group-title { font: 700 12px var(--font); color: var(--text-4); text-transform: uppercase; letter-spacing: .1em; margin: 0 var(--gutter) 9px; }
.group { margin: 0 var(--gutter) 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-group); overflow: hidden; }
.set-row { display: flex; align-items: center; gap: 13px; padding: 14px 16px; width: 100%; }
.set-row + .set-row { border-top: 1px solid var(--divider); }
.set-row__icon { width: 34px; height: 34px; border-radius: var(--r-icon); background: var(--divider); color: var(--text-2); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.set-row__icon .ph { font-size: 18px; }
.set-row__label { flex: 1; font: 600 15.5px var(--font); color: var(--ink); }
.set-row__value { font: 600 14px var(--font); color: var(--text-3); }
.set-row .ph-caret-right { font-size: 15px; color: var(--text-4); }
.toggle { width: 46px; height: 28px; border-radius: var(--r-pill); background: var(--border); display: flex; align-items: center; padding: 3px; justify-content: flex-start; transition: background .15s; flex: 0 0 auto; }
.toggle::after { content: ""; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-knob); }
.toggle.is-on { background: var(--primary); justify-content: flex-end; }
.app-foot { text-align: center; margin-top: 16px; font: 500 12px var(--font); color: var(--text-4); }

/* ---------- stock detail ---------- */
.detail-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px var(--gutter) 14px; }
.detail-bar .ph-bold, .detail-bar .ph, .detail-bar .ph-fill { font-size: 23px; color: var(--ink); }
.detail-bar .is-on .ph-fill { color: var(--primary); }
.alert-banner { margin: 0 var(--gutter) 14px; display: flex; align-items: center; gap: 9px; background: var(--primary-a12); border: 1px solid var(--primary-a30); border-radius: var(--r-banner); padding: 11px 14px; }
.alert-banner .ph-fill { font-size: 17px; color: var(--primary); }
.alert-banner span { font: 600 13.5px var(--font); color: var(--primary); }
.mono { width: 38px; height: 38px; border-radius: var(--r-mono); display: flex; align-items: center; justify-content: center; font: 800 17px var(--font); flex: 0 0 auto; }
.detail-id { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.detail-id__name { font: 600 15px var(--font); color: var(--text-2); }
.detail-price { font: 800 40px/1.2 var(--font); color: var(--ink); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.detail-chg { display: flex; align-items: center; gap: 6px; margin: 6px 0 3px; }
.detail-chg .ph-bold { font-size: 16px; }
.detail-chg span { font: 700 16px var(--font); }
.detail-updated { font: 500 13px var(--font); color: var(--text-3); margin-bottom: 18px; }
.detail-tabs { display: flex; gap: 26px; padding: 0 var(--gutter); border-bottom: 1px solid var(--divider); margin-bottom: 18px; }
.detail-tab { font: 700 15px var(--font); color: var(--text-3); padding-bottom: 11px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.detail-tab.is-active { color: var(--ink); border-bottom-color: var(--ink); }
.chart-wrap { padding: 0 16px; }
.chart { position: relative; height: 232px; }
.chart svg { display: block; width: 100%; height: 232px; }
.chart.is-loading { opacity: .5; transition: opacity .15s; }
.timeframes { display: flex; justify-content: space-between; align-items: center; padding: 18px 18px 4px; }
.tf { font: 700 13px var(--font); color: var(--text-3); padding: 6px 11px; border-radius: var(--r-chip); }
.tf.is-active { background: var(--primary); color: #fff; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--divider); border-top: 1px solid var(--divider); border-bottom: 1px solid var(--divider); }
.stat { background: var(--bg); padding: 15px var(--gutter); }
.stat__k { font: 500 12.5px var(--font); color: var(--text-3); margin-bottom: 3px; }
.stat__v { font: 700 15px var(--font); color: var(--ink); font-variant-numeric: tabular-nums; }
.news-item { padding: 15px var(--gutter); border-top: 1px solid var(--surface); display: flex; gap: 14px; align-items: center; }
.news-item__body { flex: 1; min-width: 0; }
.news-item__title { font: 700 15px/1.3 var(--font); color: var(--ink); margin-bottom: 5px; }
.news-item__meta { font: 500 12.5px var(--font); color: var(--text-3); }
.news-item__thumb { width: 56px; height: 56px; border-radius: var(--r-banner); flex: 0 0 auto; background: var(--stripes-thumb) center/cover no-repeat; }
.detail-footer { position: fixed; left: 0; right: 0; bottom: var(--nav-h); max-width: var(--max-w); margin: 0 auto; background: var(--footer-bg);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--divider); padding: 12px var(--gutter) 14px; z-index: 50; }
.cta-watch { display: flex; width: 100%; align-items: center; justify-content: center; gap: 9px; background: var(--primary); color: #fff; border-radius: var(--r-group); padding: 17px; font: 700 17px var(--font); }
.cta-watch .ph-bold { font-size: 19px; }
.cta-watch.is-watched { background: var(--primary-a16); color: var(--primary); }

/* ---------- bottom nav ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; max-width: var(--max-w); margin: 0 auto; background: var(--nav-bg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--divider);
  display: flex; padding: 11px 14px var(--nav-pad-bottom); z-index: 55; }
.nav__tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-4); }
.nav__tab i { font-size: 24px; }
.nav__tab span { font: 600 10.5px var(--font); }
.nav__tab.is-active { color: var(--ink); }

/* ---------- onboarding (web only; native in the iOS app) ---------- */
.ob { position: relative; max-width: var(--max-w); margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--surface); overflow: hidden; }
.ob-launch { display: flex; align-items: center; justify-content: center; }
.ob-launch img { width: 110px; height: 110px; object-fit: contain; display: block; }
.ob-col { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
  padding: calc(var(--top-pad) + 28px) var(--gutter-ob) calc(48px + var(--sab)); }
.ob-col--preview { padding-top: calc(var(--top-pad) + 20px); }
.ob-logo { width: 38px; height: 38px; object-fit: contain; display: block; }
.ob-center { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.ob-center--stack { gap: 12px; }
.ob-eyebrow { font: 700 15px var(--font); color: var(--primary-a80); margin-bottom: 14px; }
.ob-h1 { font: 800 54px/.98 var(--font); color: var(--primary); letter-spacing: -.045em; margin: 0 0 18px; }
.ob-h2 { font: 800 41px/1.02 var(--font); color: var(--primary); letter-spacing: -.035em; margin: 0 0 13px; }
.ob-h2--sm { font-size: 38px; line-height: 1.04; }
.ob-lead { font: 500 17px/1.45 var(--font); color: var(--primary-a85); max-width: 290px; margin: 0; }
.ob-desc { font: 500 16px/1.45 var(--font); color: var(--primary-a80); margin: 0 0 26px; max-width: 298px; }
.ob-btn { display: block; width: 100%; background: var(--primary); border-radius: var(--r-card); padding: 18px; text-align: center; font: 700 17px var(--font); color: #fff; }
.ob-btn--welcome { margin-bottom: 8px; }
.ob-skip { display: block; text-align: center; padding: 12px; font: 700 15px var(--font); color: var(--primary-a85); }
.ob-skip-top { display: flex; justify-content: flex-end; }
.ob-skip-top a { font: 700 15px var(--font); color: var(--primary-a85); padding: 6px 0; }
.dots { display: flex; gap: 7px; margin-bottom: 26px; }
.dots i { width: 5px; height: 5px; border-radius: 3px; background: var(--primary-a35); }
.dots i.is-active { width: 22px; background: var(--primary); }
.ob-hero__bg { position: absolute; inset: 0; background: var(--stripes-hero); }
.ob-hero__fade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,.5) 0%, rgba(255,255,255,0) 28%, rgba(255,255,255,.15) 52%, #FFFFFF 90%); }
.ob-hero__logo { position: absolute; top: calc(var(--top-pad) + 20px); left: var(--gutter-ob); }
.ob-hero__bottom { position: absolute; left: var(--gutter-ob); right: var(--gutter-ob); bottom: calc(48px + var(--sab)); }
.preview-row { display: flex; align-items: center; gap: 12px; background: var(--primary-a07); border-radius: var(--r-group); padding: 14px 16px; }
.preview-row__mono { width: 38px; height: 38px; border-radius: var(--r-mono); background: var(--primary); display: flex; align-items: center; justify-content: center; font: 800 15px var(--font); color: #fff; }
.preview-row__main { flex: 1; min-width: 0; }
.preview-row__sym { font: 700 15px var(--font); color: var(--primary); }
.preview-row__name { font: 500 12.5px var(--font); color: var(--primary-a75); }
.preview-row__pct { font: 700 14px var(--font); color: var(--primary); }
.ob .alert-banner { margin: 0; }

/* ---------- sheet + toast ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 10, 20, .32); z-index: 90; opacity: 0; transition: opacity .2s; }
.sheet-backdrop.is-open { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: var(--max-w); margin: 0 auto; z-index: 91; background: var(--bg);
  border-radius: 22px 22px 0 0; padding: 10px var(--gutter) calc(18px + var(--sab)); transform: translateY(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  max-height: calc(100dvh - var(--top-pad) - 24px); display: flex; flex-direction: column; }
.sheet.is-open { transform: none; }
.sheet__grip { width: 38px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 14px; }
.sheet__title { font: 800 20px var(--font); letter-spacing: -.02em; margin: 0 0 14px; }
.sheet__body { overflow-y: auto; overscroll-behavior: contain; margin: 0 calc(-1 * var(--gutter)); }
.sheet .search-field { margin-bottom: 10px; }
.sheet-input { width: 100%; font: 600 16px var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-search); padding: 14px 16px; outline: 0; margin-bottom: 14px; -webkit-appearance: none; }
.sheet-input:focus { border-color: var(--primary); }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.sheet-btn { display: block; width: 100%; text-align: center; padding: 16px; border-radius: var(--r-group); font: 700 16px var(--font); background: var(--surface); border: 1px solid var(--border); color: var(--ink); }
.sheet-btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.sheet-btn--danger { background: var(--down-a06); border-color: var(--down-border); color: var(--down); }
.search-result { display: flex; align-items: center; gap: 12px; padding: 12px var(--gutter); border-top: 1px solid var(--surface); width: 100%; }
.search-result__main { flex: 1; min-width: 0; }
.search-result .ph-bold { font-size: 18px; color: var(--primary); }
.search-result.is-added .ph-bold { color: var(--text-4); }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 96px); transform: translate(-50%, 12px); background: var(--ink); color: var(--bg);
  font: 600 14px var(--font); padding: 11px 16px; border-radius: 12px; z-index: 100; opacity: 0; transition: opacity .2s, transform .2s; max-width: calc(100% - 44px); text-align: center; pointer-events: none; }
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ---------- native app (UA "AlphaApp/1.0"): elements the app handles itself ---------- */
.is-native-app .web-only { display: none !important; }

/* ---------- watchlist sort ---------- */
.watch-meta__actions { display: flex; align-items: center; gap: 2px; }
.sort-btn { display: flex; align-items: center; gap: 5px; font: 700 13px var(--font); color: var(--text-3); padding: 6px 10px; border-radius: var(--r-pill); }
.watch-meta .sort-btn .ph-bold { font-size: 14px; padding: 0; color: inherit; }
.sort-btn.is-active { background: var(--primary-a07); color: var(--primary); }
.sheet-btn.is-selected { border-color: var(--primary); color: var(--primary); }

/* ---------- recently viewed ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 var(--gutter); }
.section-head .section-title { margin-bottom: 12px; }
.link-action--muted { color: var(--text-3); font-size: 13px; }
.rail--recent { padding-bottom: 22px; }

/* ---------- live prices ---------- */
@keyframes flash-up { from { background: var(--primary-a16); } to { background: transparent; } }
@keyframes flash-down { from { background: var(--down-a16); } to { background: transparent; } }
.flash-up, .flash-down { border-radius: 6px; }
.flash-up { animation: flash-up 1.2s ease-out; }
.flash-down { animation: flash-down 1.2s ease-out; }
.live-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); margin-right: 6px; vertical-align: middle; animation: live-pulse 2s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: .3; } }
