/* Layout: a phone-width trading app, centered on larger screens, fixed tab bar. Single dark look by choice. */
:root {
  --bg: #050706;
  --surface: #0e1210;
  --surface-2: #151a17;
  --line: #1f2622;
  --fg: #f2f5f3;
  --muted: #7d8a83;
  --green: #2fe27a;
  --green-dim: #13391f;
  --red: #ff4d5e;
  --red-dim: #3a1418;
  --amber: #ffb547;
  --amber-dim: #3a2a10;
  --f-ui: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-num: "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --f-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--fg); }
body { margin: 0; font-family: var(--f-ui); font-size: 15px; -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 8px; }
input, select { font: inherit; color: var(--fg); }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); }
.muted { color: var(--muted); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.warn { color: var(--amber); }
h1, h2 { margin: 0; text-wrap: balance; }

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; }
#views { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 8px calc(96px + env(safe-area-inset-bottom, 0px)); }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding-block: 10px 4px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: radial-gradient(circle at 50% 50%, var(--bg) 0 3px, transparent 3.5px), conic-gradient(var(--green) 0 25%, transparent 0 50%, var(--green) 0 75%, transparent 0); border: 1.5px solid var(--green); }
.mode-pill { font-size: 10.5px; letter-spacing: .08em; font-weight: 700; padding: 3px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.mode-pill.paper { color: var(--amber); border-color: var(--amber-dim); }
.mode-pill.live { color: var(--bg); background: var(--green); border-color: var(--green); }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; border: 1px solid var(--line); }
.icon-btn svg { width: 16px; height: 16px; fill: var(--fg); }

/* equity */
.equity { padding-block: 6px 0; }
.equity-value { font-size: clamp(44px, 13vw, 58px); font-weight: 700; letter-spacing: -0.035em; line-height: 1.05; }
.equity-value.down { color: var(--red); }
.equity-sub { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 14px; font-weight: 500; }
.mult { background: var(--green); color: var(--bg); font-weight: 700; font-size: 13px; padding: 2px 7px; border-radius: 6px; }
.mult.down { background: var(--red); color: var(--fg); }

.chart-wrap { height: 210px; margin: 6px -16px 0; position: relative; }
#chart { width: 100%; height: 100%; display: block; }
.ranges { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.range { font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 10px; border-radius: 999px; letter-spacing: .04em; display: inline-flex; align-items: center; gap: 5px; }
.range.on { color: var(--fg); background: var(--surface-2); }
.range.live.on { background: var(--green); color: var(--bg); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }
.range.live.on .dot, .pill-live .dot { animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }

.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 26px; margin-bottom: 10px; }
.section-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.section-head .muted { font-size: 13px; }
.link { color: var(--green); font-size: 13px; font-weight: 500; }

/* desk */
.desk { display: grid; grid-auto-flow: column; grid-auto-columns: 46%; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin-inline: -16px; padding-inline: 16px; scrollbar-width: none; }
.desk::-webkit-scrollbar { display: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; scroll-snap-align: start; min-height: 150px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card.hot { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset, 0 0 24px -8px var(--green); }
.card.alarm { border-color: var(--red); }
.card-h { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; }
.card-h .ic { width: 20px; height: 20px; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; font-size: 11px; }
.card-sub { font-size: 11.5px; color: var(--muted); margin-top: -6px; }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 5px; font-size: 12px; min-width: 0; }
.mini-row { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; min-width: 0; }
.mini-row > :first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot { font-size: 11.5px; font-weight: 600; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); text-align: center; color: var(--muted); }
.card-foot.ok { background: var(--green-dim); color: var(--green); }
.card-foot.bad { background: var(--red-dim); color: var(--red); }
.card-foot.busy { background: var(--green-dim); color: var(--green); position: relative; overflow: hidden; }
.card-foot.busy::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--green) 25%, transparent), transparent); animation: sweep 1.1s infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.ring-row { display: flex; align-items: center; gap: 10px; }
.ring { width: 48px; height: 48px; flex: none; }
.ring-txt { font-size: 12px; min-width: 0; }
.ring-txt b { display: block; font-size: 13px; }
.dots { display: flex; justify-content: center; gap: 5px; margin-top: 10px; }
.dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--fg); width: 14px; border-radius: 3px; }

/* avatars */
.av { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: hsl(var(--h) 80% 12%); background: radial-gradient(circle at 35% 30%, hsl(var(--h) 90% 78%), hsl(var(--h) 75% 52%)); position: relative; }
.av.sm { width: 22px; height: 22px; font-size: 10px; }
.av .badge { position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--bg); }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li { display: flex; align-items: center; gap: 12px; padding-block: 9px; border-bottom: 1px solid var(--line); min-width: 0; }
.feed li:last-child { border-bottom: 0; }
.feed .txt { flex: 1; min-width: 0; }
.feed .t1 { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed .t2 { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.feed .amt { text-align: right; flex: none; }
.feed .a1 { font-weight: 600; font-size: 15px; }
.feed .a2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.feed .empty { color: var(--muted); font-size: 13px; justify-content: center; padding: 22px 0; border: 0; }
.feed li.new { animation: slidein .45s ease-out; }
@keyframes slidein { from { background: color-mix(in srgb, var(--green) 12%, transparent); } to { background: transparent; } }

/* positions */
.pos-list { display: flex; flex-direction: column; gap: 8px; }
.pos-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; }
.pos-card .txt { flex: 1; min-width: 0; }
.pos-card .t1 { font-weight: 600; }
.pos-card .t2 { font-size: 12px; color: var(--muted); }
.btn { border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 9px; }
.btn.primary { background: var(--green); color: var(--bg); border-color: var(--green); }
.btn.danger { color: var(--red); border-color: var(--red-dim); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.block { width: 100%; }

/* pages */
.page-head { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; }
.page-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { margin: 4px 0 14px; font-size: 13.5px; line-height: 1.45; max-width: 60ch; }
.pill-live { font-size: 12px; font-weight: 600; color: var(--green); background: var(--green-dim); padding: 4px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin-inline: -16px; padding: 0 16px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px 4px 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11.5px; font-weight: 600; white-space: nowrap; flex: none; }
.filter .chip { padding: 6px 12px; font-size: 13px; }
.chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.wallet-list { list-style: none; margin: 0; padding: 0; }
.wrow { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 8px 6px; border-radius: 10px; }
.wrow.flash { background: color-mix(in srgb, var(--green) 10%, transparent); }
.wtag { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: hsl(var(--h) 70% 12%); background: hsl(var(--h) 70% 62%); }
.waddr { font-family: var(--f-mono); font-size: 13px; }
.wbar { display: flex; gap: 1.5px; margin-top: 4px; align-items: center; }
.wbar i { width: 3px; height: 9px; border-radius: 1px; background: var(--line); }
.wbar i.w { background: var(--green); }
.wbar i.l { background: var(--red); }
.wbar span { font-size: 10px; color: var(--muted); margin-left: 6px; }
.wlast { font-size: 11.5px; color: var(--muted); text-align: right; }
.wlast.buy { color: var(--green); }
.wdetail { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--muted); padding: 4px 0 6px 40px; align-items: center; }
.wdetail b { color: var(--fg); font-weight: 600; }

.match { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-top: 14px; }
.match.hot { border-color: var(--green); background: color-mix(in srgb, var(--green) 7%, var(--surface)); }
.match.bad { border-color: var(--red-dim); }
.match-h { display: flex; align-items: center; gap: 10px; }
.match-h b { font-size: 16px; }
.match-h .muted { font-size: 12px; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 10px; }
.slot { background: var(--surface-2); border-radius: 10px; padding: 8px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; }
.slot small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 500; }
.slot .chk { width: 18px; height: 18px; border-radius: 50%; background: var(--green); color: var(--bg); display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.slot.empty .chk { background: var(--line); color: var(--muted); }

.add-form { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.add-form input { flex: 1 1 180px; min-width: 0; }
input[type=text], input[type=url], input[type=number], select { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; }
.scan-form { display: flex; gap: 8px; }
.scan-form input { flex: 1; min-width: 0; font-family: var(--f-mono); font-size: 13px; }

/* scan report */
.report { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.rep-top { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.rep-top .txt { flex: 1; min-width: 0; }
.rep-top b { font-size: 18px; }
.gauge { width: 76px; height: 76px; flex: none; }
.verdict { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .08em; padding: 3px 8px; border-radius: 6px; margin-top: 6px; }
.verdict.clear { background: var(--green-dim); color: var(--green); }
.verdict.caution { background: var(--amber-dim); color: var(--amber); }
.verdict.block { background: var(--red-dim); color: var(--red); }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.metrics div { background: var(--surface); padding: 10px 12px; }
.metrics small { display: block; font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.metrics span { font-weight: 600; font-size: 15px; }
.flags { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.flag { display: grid; grid-template-columns: 4px 1fr auto; gap: 10px; background: var(--surface); border-radius: 12px; padding: 10px 12px 10px 0; overflow: hidden; }
.flag::before { content: ""; border-radius: 0 3px 3px 0; background: var(--muted); }
.flag.hard::before { background: var(--red); }
.flag.high::before { background: var(--amber); }
.flag.med::before { background: #c9b458; }
.flag.good::before { background: var(--green); }
.flag b { font-size: 14px; font-weight: 600; }
.flag p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.flag .pts { font-size: 12px; font-weight: 700; color: var(--muted); align-self: start; }
.flag.hard .pts { color: var(--red); }
.rep-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.recent { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.playbook { margin-top: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.playbook summary { font-weight: 600; cursor: pointer; }
.playbook ul { padding: 0; margin: 12px 0 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.playbook li { font-size: 13px; line-height: 1.45; color: var(--muted); }
.playbook li b { color: var(--fg); display: block; font-size: 13.5px; }
.sev { font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 1px 5px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; }
.sev.hard { background: var(--red-dim); color: var(--red); }
.sev.high { background: var(--amber-dim); color: var(--amber); }
.sev.med, .sev.low { background: var(--surface-2); color: var(--muted); }

.summary-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stat small { display: block; font-size: 11px; color: var(--muted); }
.stat span { font-weight: 700; font-size: 17px; }

/* account */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.panel h3 { margin: 0; font-size: 16px; }
.panel p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { padding: 8px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--fg); color: var(--bg); }
.wallet-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wbtn { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; }
.wbtn .logo { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.wbtn .logo.ph { background: #ab9ff2; color: #1c1640; }
.wbtn .logo.tw { background: #3375bb; color: #fff; }
.field { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.field label { font-size: 14px; font-weight: 500; }
.field .val { font-family: var(--f-num); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.field small { grid-column: 1 / -1; font-size: 12px; color: var(--muted); line-height: 1.4; }
.field input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--green); }
.field.full { grid-template-columns: 1fr; }
.toggle { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; }
.toggle::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--fg); transition: transform .2s; }
.toggle:checked { background: var(--green); }
.toggle:checked::after { transform: translateX(18px); }
.notice { font-size: 12.5px; line-height: 1.45; padding: 10px 12px; border-radius: 10px; background: var(--amber-dim); color: var(--amber); }
.notice.red { background: var(--red-dim); color: var(--red); }
.notice.green { background: var(--green-dim); color: var(--green); }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.learn-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.learn-list li { display: flex; justify-content: space-between; gap: 10px; }
.confirm-row { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.4; }
.confirm-row input { margin-top: 2px; accent-color: var(--green); }

/* tab bar */
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px max(8px, env(safe-area-inset-left, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-right, 0px)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); z-index: 20; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: var(--muted); padding: 4px 0; }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.tab.on { color: var(--fg); }
.tab.on svg { stroke-width: 2.1; }

/* toasts */
#toasts { position: fixed; top: calc(8px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); width: calc(100% - 20px); max-width: 460px; z-index: 30; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 18px; background: color-mix(in srgb, #2a302d 82%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: 0 10px 30px -10px #000; animation: drop .35s cubic-bezier(.2,.9,.3,1.2); pointer-events: auto; }
.toast.out { animation: lift .3s ease-in forwards; }
.toast .ti { width: 30px; height: 30px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; flex: none; }
.toast .ti .brand-mark { width: 18px; height: 18px; }
.toast .tt { flex: 1; min-width: 0; }
.toast .tt b { font-size: 13.5px; display: block; }
.toast .tt span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.toast .tn { font-size: 11px; color: var(--muted); align-self: flex-start; }
@keyframes drop { from { transform: translateY(-120%); opacity: 0; } }
@keyframes lift { to { transform: translateY(-120%); opacity: 0; } }

@media (min-width: 700px) {
  #app { border-inline: 1px solid var(--line); }
  .desk { grid-auto-columns: 40%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
