:root {
  --bg: #06070b;
  --bg2: #0c0f17;
  --card: rgba(17, 21, 32, 0.88);
  --card2: rgba(255, 255, 255, 0.035);
  --border: rgba(120, 140, 200, 0.14);
  --text: #e8ebf3;
  --muted: #7a8399;
  --up: #22e0a1;
  --down: #ff4d6d;
  --hold: #38bdf8;
  --medium: #a78bfa;
  --high: #ff3ea5;
  --amber: #fbbf24;
  --steady: #2dd4bf;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --top-h: clamp(46px, 9vh, 58px);
  --gap: clamp(8px, 1.6vh, 12px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: radial-gradient(900px 520px at -5% -15%, rgba(167, 139, 250, 0.16), transparent 60%),
              radial-gradient(700px 420px at 105% 0%, rgba(255, 62, 165, 0.09), transparent 60%), var(--bg);
  color: var(--text);
  font: clamp(12px, 2.3vh, 16px)/1.35 Inter, system-ui, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.mono { font-family: var(--mono); }
.muted, .dim { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.hidden { display: none !important; }
.label { font-size: 0.68em; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; min-width: 0; min-height: 0; }

#app { display: grid; grid-template-rows: var(--top-h) 1fr; height: 100vh; height: 100dvh; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 10px; padding: 0 var(--gap); border-bottom: 1px solid var(--border); background: rgba(6, 7, 11, 0.8); }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--mono); letter-spacing: 1.5px; font-size: 0.88em; }
.logo { background: linear-gradient(135deg, var(--hold), var(--medium), var(--high)); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 1.3em; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--up); box-shadow: 0 0 8px var(--up); animation: pulse 2s infinite; }
.dot.err { background: var(--down); box-shadow: 0 0 8px var(--down); }
@keyframes pulse { 50% { opacity: 0.35; } }
.pill { font: 600 0.62em var(--mono); letter-spacing: 1px; padding: 3px 8px; border-radius: 999px; color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.4); }
.pill.paused { color: var(--down); border-color: rgba(255, 77, 109, 0.5); }
.back { height: calc(var(--top-h) - 12px); padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--card2); font-weight: 600; }
.page-title { font-weight: 700; font-size: 1.05em; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.clock { color: var(--muted); font-size: 0.9em; margin-right: 6px; }
.icon { width: calc(var(--top-h) - 10px); height: calc(var(--top-h) - 10px); border-radius: 12px; border: 1px solid var(--border); background: var(--card2); font-size: 1.15em; }
.icon:active, .back:active { background: rgba(255, 255, 255, 0.1); }

/* ---------- pages ---------- */
#pages { position: relative; overflow: hidden; }
.page { position: absolute; inset: 0; padding: var(--gap); display: none; flex-direction: column; gap: var(--gap); }
.page.active { display: flex; animation: enter 0.2s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateX(10px); } }
#p-home.active { animation-name: fade; }
@keyframes fade { from { opacity: 0; } }

/* ---------- home ---------- */
.home { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--gap); }
.hero { display: flex; flex-direction: column; padding: clamp(10px, 2.2vh, 16px) clamp(12px, 2vw, 18px); overflow: hidden; }
.hero-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.big-total { font-size: clamp(30px, 9vh, 56px); font-weight: 700; letter-spacing: -1px; line-height: 1.05; margin-top: 2px; }
.big-total small, .amb-total small { font-size: 0.32em; color: var(--muted); margin-left: 6px; letter-spacing: 0; font-weight: 600; }
.usd { font-size: 0.85em; color: #aab3c9; margin-top: 2px; }
.usd .muted { font-size: 0.9em; }
.changes { display: flex; flex-direction: column; gap: 6px; text-align: right; }
.chg { display: flex; flex-direction: column; }
.chg b { font-size: 0.95em; }
.hero-chart { flex: 1; min-height: 0; margin-top: 6px; display: flex; flex-direction: column; }
.chart { position: relative; flex: 1; min-height: 0; }
.ranges { display: flex; gap: 4px; align-self: flex-end; margin-bottom: 2px; }
.ranges button { min-width: 44px; height: 32px; border-radius: 9px; border: 1px solid transparent; background: rgba(6, 7, 11, 0.6); color: var(--muted); font: 600 0.72em var(--mono); }
.ranges button.active { color: var(--text); border-color: var(--border); background: rgba(167, 139, 250, 0.16); }

.side { display: grid; grid-auto-rows: minmax(0, 1fr); gap: var(--gap); min-height: 0; }
.acct, .aicard {
  position: relative; overflow: hidden; text-align: left; border: 1px solid var(--border); border-radius: 14px; background: var(--card);
  padding: 0 14px 0 18px; display: flex; align-items: center; gap: 10px; min-height: 0; transition: transform 0.08s;
  --c: var(--medium);
}
.acct:active, .aicard:active, .ticker:active, .pos:active { transform: scale(0.98); }
.acct::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); box-shadow: 0 0 14px var(--c); }
.acct.hold, .acct.vault { --c: var(--hold); }
.acct.steady { --c: var(--steady); }
.acct.momentum { --c: var(--high); }
.acct.ai_trader { --c: var(--amber); }
.acct-main { flex: 1; min-width: 0; }
.acct-name { font-weight: 600; font-size: 0.86em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-sub { font-size: 0.72em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.acct-val { text-align: right; }
.acct-val b { display: block; font: 700 1.05em var(--mono); }
.acct-val span { font: 600 0.78em var(--mono); }
.chev { color: var(--muted); font-size: 1.4em; margin-left: 2px; }
.aicard { border-color: rgba(167, 139, 250, 0.3); }
.aicard .emoji { font-size: 1.7em; }
.mood-word { font: 700 0.95em var(--mono); text-transform: uppercase; letter-spacing: 1px; }
.mood-word.bullish { color: var(--up); }
.mood-word.bearish { color: var(--down); }
.mood-word.neutral { color: var(--amber); }
.ticker {
  flex-shrink: 0; height: clamp(38px, 7.5vh, 46px); display: flex; align-items: center; gap: 10px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); text-align: left; font: 0.78em var(--mono); color: #b3bbd0;
}
.ticker span:first-child { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- account page ---------- */
.two-col { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.5fr); gap: var(--gap); }
.acct-summary { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; --c: var(--medium); border-top: 3px solid var(--c); }
.acct-summary.hold, .acct-summary.vault { --c: var(--hold); }
.acct-summary.steady { --c: var(--steady); }
.acct-summary.momentum { --c: var(--high); }
.acct-summary.ai_trader { --c: var(--amber); }
.acct-summary .big-total { font-size: clamp(26px, 7vh, 42px); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 0.85em; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv span:nth-child(even) { font-family: var(--mono); text-align: right; }
.strategy-note { font-size: 0.78em; color: #aab3c9; line-height: 1.4; }
.acct-btns { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.acct-right { min-height: 0; display: flex; flex-direction: column; }
.positions { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--gap); scrollbar-width: none; }
.positions::-webkit-scrollbar { display: none; }
.pos { border: 1px solid var(--border); border-radius: 14px; background: var(--card); padding: 10px 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.pos-sym { font: 700 1.05em var(--mono); }
.pos-pnl { font: 700 1.05em var(--mono); text-align: right; }
.pos-line { font-size: 0.75em; color: var(--muted); }
.pos-line .down, .pos-line .up { font-family: var(--mono); }
.pos .btn { min-height: 44px; padding: 0 18px; }
.ai-note { color: #c4b5fd; }
.empty { color: var(--muted); padding: 20px; text-align: center; border: 1px dashed var(--border); border-radius: 14px; }

/* ---------- market ---------- */
.market { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); }
.coins { display: flex; gap: 8px; overflow-x: auto; flex-shrink: 0; scrollbar-width: none; }
.coins::-webkit-scrollbar { display: none; }
.coin { flex-shrink: 0; min-width: 66px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); font: 600 0.85em var(--mono); color: var(--muted); }
.coin.active { color: var(--text); border-color: var(--medium); box-shadow: 0 0 12px rgba(167, 139, 250, 0.35); }
.chart-card { flex: 1; min-height: 0; position: relative; padding: 8px; display: flex; flex-direction: column; }
.coin-info { display: flex; gap: 14px; align-items: baseline; padding: 2px 6px 6px; font-family: var(--mono); }
.coin-info b { font-size: 1.2em; }


/* ---------- AI + activity ---------- */
.ai-page { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); }
.ai-bar { display: flex; gap: var(--gap); align-items: stretch; flex-shrink: 0; }
.seg { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 3px; margin-right: auto; }
.seg button { min-width: 84px; height: 40px; border: none; border-radius: 9px; background: none; color: var(--muted); font-weight: 600; font-size: 0.85em; }
.seg button.active { background: rgba(167, 139, 250, 0.18); color: var(--text); }
.ai-body { flex: 1; min-height: 0; padding: 12px 14px; overflow: hidden; position: relative; }
.seg-pane { display: none; height: 100%; overflow-y: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.seg-pane::-webkit-scrollbar { display: none; }
.seg-pane.active { display: block; }
.mood { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.mood .emoji { font-size: 2.2em; }
.mood .mood-word { font-size: 1.4em; }
.ai-text { font-size: 0.92em; margin: 0 0 10px; }
.events { margin: 0; padding-left: 0; list-style: none; font-size: 0.84em; color: #c3c9d8; }
.events li { margin-bottom: 5px; }
.picks-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pick { display: flex; gap: 8px; align-items: baseline; margin-bottom: 8px; font-size: 0.82em; }
.chip { flex-shrink: 0; font: 600 0.78em var(--mono); padding: 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); }
.chip.good { color: var(--up); border-color: rgba(34, 224, 161, 0.35); }
.chip.bad { color: var(--down); border-color: rgba(255, 77, 109, 0.35); }
.lessons { margin: 0; padding-left: 22px; font-size: 0.86em; }
.lessons li { margin-bottom: 8px; }
.trade { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 2px; border-bottom: 1px solid var(--border); align-items: baseline; font-size: 0.84em; }
.trade .why { grid-column: 1 / -1; color: var(--muted); font-size: 0.85em; }
/* Public view-only page: no controls */
body.view-only :is(#pauseAll, #bucketCtrls, #aiCtlBtn, #askBtn, #labBtn, #planBtn, #fullLink, #dSave, #xGo,
  [data-go="transfer"], [data-pause], [data-sellall], [data-sell], [data-stacking], [data-go-drip],
  [data-ocancel], [data-xcancel], .acct-btns) { display: none !important; }
.side-buy { color: var(--up); font-weight: 700; }
.side-sell { color: var(--down); font-weight: 700; }
.logs { font-size: 0.75em; line-height: 1.6; color: #aab3c9; white-space: pre-wrap; }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card2); font-weight: 600; font-size: 0.88em; transition: transform 0.08s, background 0.15s;
}
.btn:active { transform: scale(0.97); background: rgba(255, 255, 255, 0.1); }
.btn:disabled { opacity: 0.45; }
.btn.big { min-height: clamp(52px, 11vh, 66px); font-size: 1em; }
.btn.red { border-color: rgba(255, 77, 109, 0.55); background: rgba(255, 77, 109, 0.12); color: #ffc2cd; }
.btn.green { border-color: rgba(34, 224, 161, 0.55); background: rgba(34, 224, 161, 0.12); color: #b4f5dc; }
.btn.violet { border-color: rgba(167, 139, 250, 0.55); background: rgba(167, 139, 250, 0.12); }
.btn.cyan { border-color: rgba(56, 189, 248, 0.5); background: rgba(56, 189, 248, 0.1); }
.thinking { animation: pulse 1.2s infinite; color: var(--medium); }

/* ---------- controls ---------- */
.controls { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); }
.bucket-ctrls { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: var(--gap); }
a.btn { color: inherit; text-decoration: none; }
.bucket-ctrl { border: 1px solid var(--border); border-radius: 14px; background: var(--card); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.bucket-ctrl b { font-size: 0.86em; }
.ctrl-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.status { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); margin-top: auto; }
.status div { border: 1px solid var(--border); border-radius: 12px; background: var(--card); padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.status b { font-size: 0.85em; }
.status span { font-size: 0.7em; color: var(--muted); }

/* ---------- overlays ---------- */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.65); display: flex; align-items: center; justify-content: center; }
.modal-panel { width: min(92vw, 460px); background: var(--bg2); border: 1px solid var(--border); border-radius: 18px; padding: 20px; }
.modal-text { font-size: 1.1em; margin-bottom: 16px; text-align: center; }
.modal-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-btns .btn { min-height: 56px; }
.ambient { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.4vh; text-align: center; }
.amb-clock { font-size: 7vh; color: var(--muted); }
.amb-total { font-size: 15vh; font-weight: 700; line-height: 1; letter-spacing: -2px; }
.amb-total span { background: linear-gradient(135deg, var(--hold), var(--medium), var(--high)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.amb-pnl { font-size: 4.2vh; }
.amb-buckets { display: flex; gap: 5vw; margin-top: 2vh; font: 600 3vh var(--mono); }
.amb-buckets small { display: block; font: 500 1.8vh Inter, sans-serif; color: var(--muted); }
.amb-last { max-width: 90vw; color: #8f98ad; font: 2.1vh var(--mono); margin-top: 2vh; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dimmer { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.88); z-index: 40; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 18px; z-index: 50; font-weight: 600; }

/* ---------- small screens ---------- */
@media (max-height: 500px) {
  .acct-sub { display: none; }
  .changes .chg:last-child { display: none; }
  .status { display: none; }
}
@media (max-aspect-ratio: 1/1) {
  .home, .two-col { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1.2fr) minmax(0, 1fr); }
  .bucket-ctrls, .ctrl-row, .picks-cols { grid-template-columns: minmax(0, 1fr); grid-auto-flow: row; }
  .drip { grid-template-columns: minmax(0, 1fr); }
  .status { grid-template-columns: 1fr 1fr; }
}

/* ---------- transfer ---------- */
.xfer { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--gap); }
.xfer-form { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.pickrow { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 6px; }
.pick { min-height: 46px; border-radius: 11px; border: 1px solid var(--border); background: var(--card2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; --c: var(--medium); padding: 2px 4px; }
.pick b { font-size: 0.72em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pick span { font-size: 0.72em; color: var(--muted); }
.pick.hold, .pick.vault { --c: var(--hold); }
.pick.steady { --c: var(--steady); }
.pick.momentum { --c: var(--high); }
.pick.ai_trader { --c: var(--amber); }
.pick.active { border-color: var(--c); box-shadow: 0 0 12px var(--c) inset; }
.pick:disabled { opacity: 0.3; }
.amount-row { display: grid; grid-template-columns: 64px 64px minmax(0, 1fr) 64px 64px; gap: 6px; align-items: center; }
.amount-row .btn.step { min-height: 46px; font-size: 0.9em; }
.amount { display: flex; flex-direction: column; align-items: center; }
.amount b { font-size: 1.35em; }
.amount span { font-size: 0.72em; }
.quick { display: flex; gap: 6px; }
.quick button { flex: 1; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--card2); color: var(--muted); font: 600 0.78em var(--mono); }
.seg.wide { margin-right: 0; }
.seg.wide button { flex: 1; min-width: 0; height: 36px; }
.xplan { font-size: 0.78em; color: #b8c0d4; line-height: 1.4; min-height: 2.8em; }
.xfer-form .btn.big { min-height: 50px; margin-top: auto; }
.xfer-list { padding: 10px 12px; overflow-y: auto; scrollbar-width: none; }
.xitem { border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.xitem .btn { min-height: 40px; }
.xhead { font-size: 0.82em; }
.xstatus { float: right; font: 600 0.75em var(--mono); text-transform: uppercase; color: var(--muted); }
.xitem.active .xstatus { color: var(--amber); }
.xitem.done .xstatus { color: var(--up); }
.xbar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.xbar div { height: 100%; background: linear-gradient(90deg, var(--hold), var(--medium)); }
@media (max-aspect-ratio: 1/1) { .ctrl-row { grid-template-columns: 1fr 1fr; } .xfer { grid-template-columns: minmax(0, 1fr); } .pickrow { grid-template-columns: 1fr 1fr; grid-auto-flow: row; } }

/* ---------- AI usage + headline ---------- */
.usage { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.usage-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.usage-body { display: flex; gap: 16px; align-items: stretch; }
.usage-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1; }
.usage-nums div { display: flex; flex-direction: column; gap: 1px; }
.usage-nums b { font-size: 1.05em; }
.usage-bars { display: flex; gap: 6px; align-items: flex-end; height: 54px; }
.ub { width: 18px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.ub div { width: 100%; min-height: 2px; border-radius: 4px; background: linear-gradient(180deg, var(--medium), var(--hold)); }
.ub span { font-size: 0.62em; color: var(--muted); }
.ai-headline { font-size: 1.08em; font-weight: 600; margin: 0 0 8px; color: var(--text); }
.aicard .acct-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- personal ---------- */
.personal-link { margin-top: 6px; background: none; border: 1px dashed var(--border); border-radius: 10px; padding: 5px 10px;
  color: #aab3c9; font: 0.8em var(--mono); text-align: left; }
.personal-link:active { background: rgba(255, 255, 255, 0.06); }
.pick.personal, .acct-summary.personal { --c: var(--amber); }

/* ---------- profit drip ---------- */
.drip-row { display: flex; align-items: center; gap: 8px; font-size: 0.8em; color: #aab3c9; }
.drip-row b { color: #7dd3fc; }
.drip { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--gap); }
.drip-form { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.drip-form .btn.big { min-height: 50px; margin-top: auto; }
.drip-example { font-size: 0.85em; color: #b8c0d4; line-height: 1.45; }
.drip-example b { color: var(--text); }

/* ---------- vault stacking ---------- */
.stack-card { border: 1px solid rgba(56, 189, 248, 0.35); border-radius: 14px; background: var(--card); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.stack-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.stack-big { font: 700 1.25em var(--mono); }
.stack-round { font-size: 0.78em; color: #b8c0d4; border-top: 1px solid var(--border); padding-top: 6px; }
.stack-round .mono { font-family: var(--mono); }

/* ---------- liquidity reserve (top bar) ---------- */
.reserve-pill { height: 40px; padding: 0 12px; border-radius: 12px; border: 1px solid rgba(52, 211, 153, 0.45); background: rgba(52, 211, 153, 0.08);
  font: 600 0.8em var(--mono); color: #a7f3d0; white-space: nowrap; }
.reserve-pill .live { color: var(--amber); }
.acct-summary.reserve { --c: #34d399; }

/* ---------- trade history pages ---------- */
.pager { display: flex; align-items: center; gap: 8px; }
.pager .btn { min-height: 40px; padding: 0 14px; font-size: 0.85em; }
.pager span { font-size: 0.8em; min-width: 52px; text-align: center; }
.tfilter { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.tfilter::-webkit-scrollbar { display: none; }
.tfilter button { flex-shrink: 0; height: 34px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--card2); color: var(--muted); font: 600 0.75em Inter, sans-serif; }
.tfilter button.active { color: var(--text); border-color: rgba(167, 139, 250, 0.6); background: rgba(167, 139, 250, 0.15); }

.pill.live { color: #fecaca; border-color: rgba(255, 77, 109, 0.7); background: rgba(255, 77, 109, 0.15); }

/* ---------- PIN pad ---------- */
.pin-panel { width: min(92vw, 340px); display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; }
.pin-title { font-weight: 600; }
.pin-dots { display: flex; gap: 14px; height: 18px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots span.on { background: var(--medium); border-color: var(--medium); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.pin-pad button { height: clamp(44px, 9vh, 58px); border-radius: 12px; border: 1px solid var(--border); background: var(--card2); font: 700 1.2em var(--mono); }
.pin-pad button:active { background: rgba(167, 139, 250, 0.25); }
.pin-pad .pin-cancel { font: 600 0.8em Inter, sans-serif; color: var(--muted); }
.shake { animation: shake 0.35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- phones (narrow portrait): compact top bar, one column, pages scroll ---------- */
@media (max-width: 600px) {
  body { font-size: 15px; }
  #app { grid-template-columns: minmax(0, 1fr); }
  .top { gap: 6px; padding: 0 8px; min-width: 0; }
  .brand b, .clock { display: none; }
  .top-right { gap: 4px; min-width: 0; }
  .icon { width: 38px; height: 38px; font-size: 1em; border-radius: 10px; }
  .reserve-pill { height: 34px; padding: 0 8px; }
  .back { flex-shrink: 0; height: 38px; padding: 0 10px; white-space: nowrap; }
  .icon { flex-shrink: 0; }
  .top-right { flex-shrink: 0; }
  .page-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.95em; }
  .top:has(#backBtn:not(.hidden)) :is(#mode, #reserveBtn) { display: none; }  /* sub-pages: room for the buttons */
  .pos-pnl .muted { display: block; font-size: 0.7em; }
  .page { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 28px; }
  .home, .two-col { flex: none; display: flex; flex-direction: column; }
  .hero { flex: none; height: 400px; }
  .hero-head { flex-wrap: wrap; }
  .big-total { font-size: 42px; }
  .side { grid-auto-rows: 62px; }
  .ticker { height: auto; min-height: 44px; padding: 8px 12px; }
  .acct-summary { overflow: visible; }
  .acct-right, .positions { flex: none; overflow: visible; }
  .market { flex: none; }
  .chart-card { flex: none; height: 62vh; }
  .ai-page, .controls, .drip, .xfer { flex: none; }
  .ai-bar { flex-wrap: wrap; }
  .seg { margin-right: 0; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; }
  .seg button { min-width: 0; flex: 1 0 auto; padding: 0 10px; }
  .ai-body { flex: none; overflow: visible; min-height: 50vh; }
  .seg-pane { height: auto; overflow: visible; }
  .pager { width: 100%; justify-content: space-between; }
  .trade { grid-template-columns: auto auto minmax(0, 1fr); }
  .trade > :nth-child(4) { grid-column: 1 / -1; }
  .status { grid-template-columns: 1fr 1fr; margin-top: 0; }
  .usage-body { flex-direction: column; }
  .amount-row { grid-template-columns: 48px 48px minmax(0, 1fr) 48px 48px; }
  .amb-total { font-size: 15vw; }
  .amb-buckets { flex-wrap: wrap; justify-content: center; font-size: 2.4vh; }
}
