/* Pulsia: dark, mobile first (approved mockup 2026-12-04). Classes only: the CSP forbids inline styles. */
@font-face { font-family: Manrope; font-weight: 400; font-display: swap; src: url(/static/fonts/manrope-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: Manrope; font-weight: 600 700; font-display: swap; src: url(/static/fonts/manrope-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: Manrope; font-weight: 800; font-display: swap; src: url(/static/fonts/manrope-latin-800-normal.woff2) format("woff2"); }

:root {
  color-scheme: dark;
  --bg: #10151f; --surface: #182030; --line: #263046; --line-2: #34405a; --bar: #0b0f17;
  --ink: #eef1f6; --soft: #c9d3e6; --muted: #a3adc2;
  --up: #3fd69b; --down: #ff7a85; --accent: #7cc4ff; --level: #f4c86a;
  --radius: 18px;
}
* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Manrope, system-ui, sans-serif; font-variant-numeric: tabular-nums; overflow-x: clip; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #b3dcff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1 { margin: 0 0 4px; font-size: clamp(28px, 6vw, 36px); line-height: 1.08; letter-spacing: -0.02em; font-weight: 800; }
h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.up { color: var(--up); }
.down { color: var(--down); }
.nowrap { white-space: nowrap; }

/* Shell: bottom tab bar on phones, side menu from 900 px */
.shell { min-height: 100vh; }
.main { padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.nav { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; background: var(--bar); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.nav ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.nav ul a { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px; justify-content: center; font-size: 12px; color: var(--muted); }
.nav ul a[aria-current="page"] { color: var(--accent); }
.nav svg path { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav .brand { display: none; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.brand svg path { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pill { font-size: 12px; font-weight: 700; color: var(--bg); background: var(--soft); border-radius: 999px; padding: 2px 9px; letter-spacing: 0; }
.pill.ai { background: var(--accent); }
.pill.tpl { background: var(--level); }
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); }
  .nav { position: sticky; top: 0; height: 100vh; border-top: 0; border-right: 1px solid var(--line); padding: 26px 14px; }
  .nav .brand { display: flex; padding: 0 10px 22px; }
  .nav .brand .pill { margin-left: auto; }
  .nav ul { display: flex; flex-direction: column; gap: 2px; }
  .nav ul a { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 15px; color: var(--soft); }
  .nav ul a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 700; }
  .main { padding: 28px clamp(16px, 3vw, 40px) 32px; }
}

/* Building blocks */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; }
.card.outline { background: none; border: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.disclaimer { font-size: 13px; color: var(--muted); padding: 8px 4px; }
.error { color: var(--down); font-weight: 600; }
.notice { color: var(--level); font-weight: 600; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--accent); color: var(--bg); font: 700 15px Manrope, system-ui, sans-serif; cursor: pointer; }
.btn:hover { background: #a5d6ff; color: var(--bg); }
.btn.ghost { background: none; color: var(--accent); border: 1px solid var(--line-2); }
.btn.danger { background: var(--down); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; min-height: 44px; color: var(--accent); font: 600 14px Manrope, system-ui, sans-serif; cursor: pointer; }
label { font-weight: 600; }
input[type="text"], input[type="password"] { width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink); font: 16px Manrope, system-ui, sans-serif; }
.htmx-request .busy-hide { display: none; }
.busy { display: none; }
.htmx-request .busy { display: inline; }

/* Login */
.login { max-width: 380px; margin: 0 auto; padding: 18vh 16px 32px; display: flex; flex-direction: column; gap: 22px; }
.brand-lg { font-size: 30px; justify-content: center; }

/* Market state */
.market { display: flex; align-items: center; gap: 14px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.open { background: var(--up); box-shadow: 0 0 0 5px rgba(63, 214, 155, 0.18); }

/* Alert cards */
.alert { display: flex; gap: 14px; color: var(--ink); }
.alert:hover { color: var(--ink); background: #1d2739; }
.alert .icon { flex: none; width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: #263a5a; }
.alert .icon.down { background: #4a2630; }
.alert .icon.up { background: #1f4236; }
.alert .icon path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.alert .icon { color: var(--accent); }
.alert .icon.down { color: var(--down); }
.alert .icon.up { color: var(--up); }
.alert .body { display: flex; flex-direction: column; gap: 4px; }
.alert .line { font-size: 14px; color: var(--soft); }

/* Watchlist rows */
.wl { background: var(--surface); border-radius: var(--radius); }
.wl-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px 92px; align-items: center; gap: 10px; padding: 14px 16px; color: var(--ink); border-top: 1px solid var(--line); }
.wl-row:first-child { border-top: 0; }
a.wl-row:hover { color: var(--ink); background: #1d2739; border-radius: var(--radius); }
.wl-row .sym { display: flex; flex-direction: column; }
.wl-row .name { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-row .tag { font-size: 13px; color: var(--muted); }
.wl-row .tag:empty { display: none; }
.wl-row .px { display: flex; flex-direction: column; align-items: flex-end; }
.wl-row .px span { font-size: 13px; font-weight: 700; white-space: nowrap; }
.wl-row .px span.when { font-weight: 400; font-size: 12px; }
.spark path { fill: none; stroke-width: 1.8; stroke-linejoin: round; }
.spark.up path { stroke: var(--up); }
.spark.down path { stroke: var(--down); }
.wl-edit { grid-template-columns: 64px minmax(0, 1fr) auto; }

/* Ticker */
.quote { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.quote .price { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.quote .chg { font-weight: 700; }
.ticker-grid { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.ticker-grid > .left { flex: 3 1 520px; display: flex; flex-direction: column; gap: 14px; }
.ticker-grid > .right { flex: 2 1 340px; display: flex; flex-direction: column; gap: 14px; }
.chart-box { margin: 0; background: var(--surface); border-radius: var(--radius); padding: 12px 8px 8px; }
.chart { height: 300px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 6px 8px 0; font-size: 13px; color: var(--soft); }
.legend .sw { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--accent); margin-right: 6px; vertical-align: middle; }
.legend .sw.level { border-top: 2px dashed var(--level); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.tile { background: var(--surface); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; color: var(--ink); }
a.tile:hover { color: var(--ink); background: #1d2739; }
.tile b { font-size: 19px; }
.tile .lbl { font-size: 13px; color: var(--muted); }
.tile .sub { font-size: 13px; color: var(--soft); }

/* Explanation */
.expl { display: flex; flex-direction: column; gap: 14px; scroll-margin-top: 16px; }
.expl .lead { font-size: 16px; font-weight: 600; }
.expl h3 { margin: 0; font-size: 14px; color: var(--muted); }
.expl ul { margin: 4px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 14px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--soft); }
.chip:hover { color: var(--ink); border-color: var(--accent); }

/* Feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.feed .when { font-size: 13px; color: var(--muted); line-height: 1.35; }
.feed .what { display: flex; flex-direction: column; gap: 4px; }
.feed .line { font-size: 14px; color: var(--soft); overflow-wrap: anywhere; }

/* Glossary */
.terms { display: flex; flex-direction: column; gap: 10px; }
.term { scroll-margin-top: 16px; }
.term:target { outline: 2px solid var(--accent); }
.term h2 { font-size: 18px; }
.toc { display: flex; flex-wrap: wrap; gap: 8px; }

/* Settings */
.devices { list-style: none; margin: 0; padding: 0; }
.devices li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Watchlist editing */
.wl-edit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-top: 1px solid var(--line); }
.wl-edit-row:first-child { border-top: 0; }
.wl-edit-row .wl-row { border-top: 0; }
.remove { padding: 0 16px; }
.grow { flex: 1 1 200px; }
code { font-size: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; overflow-wrap: anywhere; }
