:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #15171c;
  --muted: #5d6470;
  --line: #e3e6eb;
  --accent: #2f6fde;
  --up: #11804a;
  --down: #c62f2f;
  --flat: #5d6470;
  --shadow: 0 1px 2px rgba(15, 20, 30, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --card: #1a1d23;
    --text: #e9ebef;
    --muted: #9aa1ad;
    --line: #2a2e36;
    --accent: #6c9cf0;
    --up: #3fbf7f;
    --down: #f06a6a;
    --flat: #9aa1ad;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317;
  --card: #1a1d23;
  --text: #e9ebef;
  --muted: #9aa1ad;
  --line: #2a2e36;
  --accent: #6c9cf0;
  --up: #3fbf7f;
  --down: #f06a6a;
  --flat: #9aa1ad;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main, .top, .foot { max-width: 1100px; margin: 0 auto; }

/* Thin moving strip of the day's biggest moves; still and scrollable for reduced motion. */
.movers {
  max-width: 1100px; margin: 0 auto 12px; display: flex; align-items: center; gap: 8px;
  height: 30px; padding-left: 10px; font-size: 0.8rem; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.movers[hidden] { display: none; }
.movers-label { flex: none; color: var(--muted); font-weight: 600; }
.movers-view {
  flex: 1; min-width: 0; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
}
.movers-track { display: flex; width: max-content; animation: movers-scroll var(--dur, 40s) linear infinite; }
.movers-view:hover .movers-track, .movers-view:active .movers-track { animation-play-state: paused; }
.movers-copy { display: flex; }
.mover { padding-right: 16px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mover b { font-weight: 650; margin-right: 5px; }
.mover .px { color: var(--muted); margin-right: 5px; }
@keyframes movers-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .movers-track { animation: none; }
  .movers-view { overflow-x: auto; -webkit-mask-image: none; mask-image: none; }
  .movers-copy + .movers-copy { display: none; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 28px; height: 28px; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -0.02em; }
.status { margin: 0 0 0 auto; color: var(--muted); font-size: 0.875rem; }
.jump { font-size: 0.875rem; font-weight: 600; color: var(--accent); text-decoration: none; }
.jump:hover { text-decoration: underline; }

.add { display: flex; gap: 8px; }
.add .pick { flex: 1; min-width: 0; }
.add input, .wi-form input {
  width: 100%; box-sizing: border-box;
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.add input:focus, .wi-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.add button, .wi-go {
  font: inherit; font-weight: 600; color: #fff; background: var(--accent);
  border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
}
/* Suggestions as you type, under the add box and the What if stock box */
.pick { position: relative; display: block; }
.suggest {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px 0; max-height: 320px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
.suggest[hidden] { display: none; }
.suggest li { display: flex; align-items: baseline; gap: 8px; padding: 9px 12px; cursor: pointer; }
.suggest li b { flex: none; min-width: 3.5em; font-weight: 650; font-variant-numeric: tabular-nums; }
.suggest li span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest li small { flex: none; color: var(--muted); font-size: 0.75rem; }
.suggest li.on, .suggest li:hover { background: var(--line); }
.suggest li.wait { color: var(--muted); cursor: default; font-size: 0.875rem; }
.add-msg { min-height: 1.3em; margin: 6px 2px 10px; font-size: 0.875rem; color: var(--muted); }

.list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 14px 10px; box-shadow: var(--shadow); min-width: 0;
}
.card.stale .price { opacity: 0.7; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.name { font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sym { color: var(--muted); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.03em; }
.remove {
  font-size: 1.25rem; line-height: 1; color: var(--muted); background: none; border: 0;
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; flex: none;
}
.remove:hover { background: var(--line); color: var(--text); }

.money { justify-content: flex-start; align-items: baseline; gap: 10px; margin-top: 4px; }
.price { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.move { font-weight: 600; font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }

.chart { position: relative; margin: 10px 0 2px; touch-action: pan-y; -webkit-user-select: none; user-select: none; cursor: crosshair; border-radius: 6px; }
.chart:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.chart.dim .spark { opacity: 0.35; }
.spark { display: block; width: 100%; height: 110px; overflow: visible; }
.cursor { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--muted); pointer-events: none; }
.dot {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--text); pointer-events: none;
}
.card.scrubbing .move, .card.scrubbing .price { transition: none; }
.ranges { display: flex; gap: 2px; margin: 4px 0 2px; }
.ranges button {
  flex: 1; min-width: 0; font: 600 0.75rem/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--muted); background: none; border: 0; border-radius: 7px; padding: 8px 0; cursor: pointer;
}
.ranges button:hover { color: var(--text); }
.ranges button.on { background: var(--line); color: var(--text); }
.spark path.line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark path.area { stroke: none; opacity: 0.12; }
.spark.up path { stroke: var(--up); fill: var(--up); }
.spark.down path { stroke: var(--down); fill: var(--down); }
.spark.flat path { stroke: var(--flat); fill: var(--flat); }
.spark path.line { fill: none; }
.spark path.base { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; opacity: 0.6; }
.meta, .note { margin: 2px 0 6px; color: var(--muted); font-size: 0.8rem; }

.more summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; padding: 4px 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 4px 0 8px; font-size: 0.875rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }

.news { list-style: none; margin: 6px 0 0; padding: 0; border-top: 1px solid var(--line); }
.news li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.news li:last-child { border-bottom: 0; }
.news li.extra { display: none; }
.news.open li.extra { display: block; }
.news a { color: var(--text); text-decoration: none; font-size: 0.925rem; display: block; }
.news a:hover { text-decoration: underline; }
.news small { display: block; color: var(--muted); font-size: 0.75rem; margin-top: 2px; }
.news .toggle { border-bottom: 0; padding-bottom: 2px; }
.linklike { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.empty { color: var(--muted); font-size: 0.875rem; }

.foot { margin-top: 28px; color: var(--muted); font-size: 0.8rem; }
.foot p { margin: 6px 0; }

/* What if */
.whatif { margin-top: 16px; }
.whatif .name { white-space: normal; }
.wi-form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; margin-top: 8px; }
.wi-field { display: grid; gap: 4px; font-size: 0.8rem; color: var(--muted); }
.wi-field > span:first-child { font-weight: 600; }
.wi-amount { position: relative; display: block; }
.wi-amount > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.wi-amount input { padding-left: 24px; font-variant-numeric: tabular-nums; }
.wi-form input[type="date"] { min-height: 44px; -webkit-appearance: none; appearance: none; }
.wi-quick { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 1 / -1; }
.wi-quick button {
  font: inherit; font-size: 0.8rem; color: var(--muted); background: none;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; cursor: pointer;
}
.wi-quick button:hover { color: var(--text); }
.wi-go { grid-column: 1 / -1; }
.wi-out[hidden] { display: none; }
.wi-line { margin: 4px 0 0; font-size: 0.925rem; }
.fine { margin: 8px 0 0; color: var(--muted); font-size: 0.75rem; }

/* My holdings: per card and the total at the top. Kept in this browser only. */
.holdings { margin-bottom: 12px; }
.holdings[hidden] { display: none; }
.mine { margin: 4px 0 0; font-size: 0.85rem; }
.mine-line { margin: 0; font-variant-numeric: tabular-nums; }
.mine-line .linklike { margin-left: 6px; font-size: 0.8rem; }
.mine-open { font-size: 0.8rem; color: var(--muted); }
.mine-form { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; margin: 6px 0 2px; align-items: end; }
.mine-form[hidden] { display: none; }
.mine-form label { display: grid; gap: 2px; font-size: 0.75rem; color: var(--muted); }
.mine-form input {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 0.9rem; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-variant-numeric: tabular-nums;
}
.mine-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.mine-save { font: inherit; font-weight: 600; color: #fff; background: var(--accent); border: 0; border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.mine-del { justify-self: start; align-self: center; }
