/* Paper Trader. Every value here comes from DESIGN.md. */

:root {
  --bg: #0B0F0D;
  --surface: #121816;
  --well: rgba(255, 255, 255, 0.06);
  --edge: rgba(255, 255, 255, 0.16);
  --hairline: rgba(255, 255, 255, 0.08);
  --text: #E8EDEA;
  --text-muted: #93A39B;
  --up: #3DF28A;
  --down: #FF4B3E;
  --warn: #FFB01F;
  --on-up: #07110B;

  --font-body: "Helvetica Neue", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-figures: "DIN Alternate", Bahnschrift, system-ui, sans-serif;
  --font-heading: "DIN Condensed", "Bahnschrift Condensed", Bahnschrift, "Arial Narrow", sans-serif;

  --small: 14px;
  --body: 16px;
  --large: 20px;
  --total: 24px;
  --mood: 40px;
  --price: clamp(34px, 5vw, 44px);

  --unit: 8px;
  --gutter: 20px;
  --section: 24px;
  --column: 1200px;
  --radius: 6px;
  --control: 48px;
}

/* Light: the same page in daylight. Picked by the header button or the
   system setting; saved on its own key. */
:root[data-theme="light"] {
  --bg: #F5F7F6;
  --surface: #FFFFFF;
  --well: rgba(0, 0, 0, 0.04);
  --edge: rgba(0, 0, 0, 0.18);
  --hairline: rgba(0, 0, 0, 0.08);
  --text: #121816;
  --text-muted: #5E6B66;
  --up: #0F9F5A;
  --down: #D93B2F;
  --warn: #B9770E;
  --on-up: #FFFFFF;
}

/* Native controls and scrollbars follow the theme. */
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; scrollbar-color: var(--edge) transparent; }

html { background: var(--bg); }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--body);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  transition: background 200ms, color 200ms;
}

.fig {
  font-family: var(--font-figures);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

/* Header */

.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px var(--gutter);
  max-width: var(--column);
  margin: 0 auto;
  padding: 16px var(--gutter);
  border-bottom: 1px solid var(--edge);
}

.brand {
  font-family: var(--font-heading);
  font-size: var(--large);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--small);
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.nav a:hover { color: var(--text); border-color: var(--edge); }
.nav a[aria-current="page"] { color: var(--up); border-color: var(--up); }

.top-right { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.theme-btn { height: 32px; padding: 0 10px; font-size: var(--small); }

.totals {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
  align-items: baseline;
}

.total { font-size: var(--total); }
.pnl { font-size: var(--body); }

.up { color: var(--up); }
.down { color: var(--down); }

/* Tape: the top coins, one strip, scrolls sideways on a phone */

.tape-wrap {
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--hairline);
}

/* The carousel: two identical lists side by side, both sliding left by
   their own width, so when the first leaves the second is exactly where it
   was. Pauses under the pointer. Off for reduced motion, where it scrolls
   by hand instead. */
.marquee {
  flex: 1;
  min-width: 0;
  display: flex;
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}

.marquee:hover .tape, .marquee:focus-within .tape { animation-play-state: paused; }

.tape {
  list-style: none;
  margin: 0;
  padding: 10px 6px 10px 0;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  min-width: max-content;
  animation: tape var(--tape-duration, 60s) linear infinite;
}

.marquee.static .tape { animation: none; }
.marquee.static .tape-clone { display: none; }
.marquee.static { overflow-x: auto; mask-image: none; }

@keyframes tape {
  to { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
  .marquee .tape { animation: none; }
  .marquee .tape-clone { display: none; }
  .marquee { overflow-x: auto; mask-image: none; }
}

.tape-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  font-size: var(--small);
  background: transparent;
  border: 1px solid transparent;
}

.tape-item:hover, .tape-item:focus-visible { border-color: var(--edge); }
.tape-item.active { border-color: var(--up); }
.tape-item .sym { font-weight: 700; }
.tape-item svg { display: block; }
.spark { fill: none; stroke-width: 1.5; }

/* Chart */

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.ranges { display: flex; gap: 4px; }
.range.active { border-color: var(--up); color: var(--up); }

.chart {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 6px;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.chart.dragging { cursor: grabbing; }
.chart-hint { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; margin-top: 4px; min-height: 26px; }

.chart .grid { stroke: var(--hairline); stroke-width: 1; }
.chart .axis { fill: var(--text-muted); font-size: 11px; font-family: var(--font-figures); font-weight: 700; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .baseline { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.7; }
.chart .last-line { stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.6; }
.chart .tag { fill: var(--bg); font-size: 11px; font-family: var(--font-figures); font-weight: 700; }
.chart .mark { stroke: var(--bg); stroke-width: 2; }
.chart .mark.buy { fill: var(--up); }
.chart .mark.sell { fill: var(--down); }
.chart .cross { stroke: var(--edge); stroke-width: 1; }
.chart .cross-dot { stroke: var(--bg); stroke-width: 2; }
.chart .readout-box { fill: var(--surface); stroke: var(--edge); stroke-width: 1; }
.chart .readout { fill: var(--text); font-size: 12px; font-family: var(--font-figures); font-weight: 700; }

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--up);
  margin-right: 6px;
  vertical-align: middle;
}

/* Layout */

.layout {
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.block {
  padding: var(--section) 0;
  border-bottom: 1px solid var(--hairline);
}

h2 {
  margin: 0 0  12px;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

p { margin: 0; }

.muted { color: var(--text-muted); font-size: var(--small); }
.error { color: var(--down); font-size: var(--small); }
.note { font-size: var(--small); min-height: 1.5em; margin-top: 8px; }
.note.warn { color: var(--warn); }
.note.block { color: var(--down); }

/* Controls */

.row {
  display: flex;
  gap: var(--unit);
  align-items: stretch;
}

input {
  flex: 1;
  min-width: 0;
  height: var(--control);
  padding: 0 12px;
  font: inherit;
  font-size: var(--body);
  color: var(--text);
  background: var(--well);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
}

input.fig { font-family: var(--font-figures); font-weight: 700; }

input::placeholder { color: var(--text-muted); font-weight: 400; }

input:focus {
  border-color: var(--up);
  outline: 2px solid var(--up);
  outline-offset: 0;
}

input.invalid { border-color: var(--down); }

input:disabled { opacity: 0.4; }

button {
  height: var(--control);
  padding: 0 18px;
  font: inherit;
  font-size: var(--body);
  color: var(--text);
  background: transparent;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

button.small { height: 32px; padding: 0 10px; font-size: var(--small); }

button.buy {
  background: var(--up);
  border-color: var(--up);
  color: var(--on-up);
  font-weight: 700;
}

button.buy:hover { filter: brightness(1.1); }

button.sell {
  border-color: var(--down);
  color: var(--down);
  font-weight: 700;
}

button.danger { color: var(--down); border-color: var(--down); }

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
}

button:focus-visible { outline: 2px solid var(--up); outline-offset: 2px; }

label {
  display: block;
  font-size: var(--small);
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field-msg {
  color: var(--down);
  font-size: var(--small);
  min-height: 1.5em;
  margin-top: 6px;
}

/* Market toggle */

.market { display: flex; gap: 4px; }
.market-btn.active { border-color: var(--up); color: var(--up); }

/* Search results */

.search-block form { position: relative; }

.results {
  list-style: none;
  margin: 0;
  padding: 6px;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--control) + 6px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.results:empty { display: none; }

.result {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  text-align: left;
  background: var(--well);
}

.result:hover, .result:focus-visible { border-color: var(--up); }

.result .meta { color: var(--text-muted); font-size: var(--small); }

/* Coin */

.coin-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.coin-name { font-size: var(--large); }
.coin-price-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.coin-price-row .price { margin: 0; }
.range-change { font-size: var(--small); margin-left: 6px; align-self: center; }

.alert-form { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.alert-form label { margin: 0; }
.alert-form input { flex: 0 1 140px; height: 36px; }
.alert-form .field-msg.inline { min-height: 0; margin: 0; }
.alerts { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.alerts li { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border: 1px solid var(--edge); border-radius: 999px; font-size: 13px; }
.alerts .cancel { height: auto; padding: 0; border: 0; color: var(--text-muted); font-size: 13px; }
.mood-line { font-size: var(--small); display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; margin-bottom: 12px; }
.mood-line .fig { font-size: var(--body); }
.link { color: var(--text-muted); text-decoration: underline; font-size: var(--small); }
.link:hover { color: var(--text); }

.price {
  font-size: var(--price);
  line-height: 1;
  margin: 6px 0 8px;
  letter-spacing: -0.01em;
  transition: color 300ms;
}

.price.flash-up { color: var(--up); }
.price.flash-down { color: var(--down); }

/* Trade */

.forms {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Order ticket */

.seg { display: inline-flex; border: 1px solid var(--edge); border-radius: var(--radius); overflow: hidden; }
.seg-btn { height: 40px; padding: 0 16px; border: 0; border-radius: 0; background: transparent; color: var(--text-muted); font-size: var(--small); }
.seg-btn + .seg-btn { border-left: 1px solid var(--edge); }
.seg-btn.active { background: var(--well); color: var(--text); font-weight: 700; }
#side-buy.active { color: var(--up); }
#side-sell.active { color: var(--down); }
.seg.small .seg-btn { height: 26px; padding: 0 10px; font-size: 13px; }
label .seg { margin-left: 8px; vertical-align: middle; }

.ticket-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.ticket-grid .field.wide { grid-column: 1 / -1; }
.ticket-grid select, .ticket-grid input { width: 100%; }
.presets { display: flex; gap: 4px; margin-top: 6px; }
.presets button { flex: 1; height: 36px; padding: 0; }

.estimate {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  margin: 14px 0 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.estimate div { display: flex; flex-direction: column; gap: 2px; font-size: var(--small); }
.estimate dt { color: var(--text-muted); white-space: nowrap; }
.estimate dd { margin: 0; font-size: var(--body); }

.ticket-btn { width: 100%; margin-top: 8px; }
.ticket-btn.sell-side { background: var(--down); border-color: var(--down); color: #FFFFFF; }

.review {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--up);
  border-radius: var(--radius);
  background: var(--surface);
}

.review.sell-side { border-color: var(--down); }
.review-title { font-family: var(--font-heading); text-transform: uppercase; letter-spacing: 0.1em; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.review .row { margin-top: 12px; }
.review .row button { flex: 1; }

.steps { margin: 8px 0 0; padding-left: 20px; font-size: var(--small); color: var(--text-muted); }
.steps li { margin-bottom: 4px; }

.star { height: 32px; padding: 0 10px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.star-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.star[aria-pressed="true"] { border-color: var(--warn); color: var(--warn); }
.star[aria-pressed="true"] .star-icon { fill: currentColor; }

.tape-row { display: flex; align-items: center; gap: 12px; }
.tape-tabs { flex-shrink: 0; }

.history { margin-top: 12px; }
.history #history-more { margin-top: 8px; }
h2 .count { margin-left: 6px; font-size: 13px; letter-spacing: 0; text-transform: none; }
.history summary { cursor: pointer; font-size: var(--small); color: var(--text-muted); list-style: none; display: flex; gap: 8px; }
.history summary::-webkit-details-marker { display: none; }
.history summary::before { content: "▸"; }
.history[open] summary::before { content: "▾"; }
.history .table-wrap, .history p { margin-top: 8px; }

.close-btn { height: 26px; padding: 0 8px; font-size: 13px; }
.close-btn + .close-btn { margin-left: 4px; }
.grid td .close-btn { white-space: nowrap; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.toast { padding: 10px 14px; background: var(--surface); border: 1px solid var(--edge); border-left: 3px solid var(--up); border-radius: var(--radius); font-size: var(--small); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); }
.toast.down { border-left-color: var(--down); }
.toast.warn { border-left-color: var(--warn); }

/* Sizer, orders */

label[for="buy-amount"] { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 8px; }
.sizer { color: var(--text-muted); white-space: nowrap; }
.sizer button { height: 24px; padding: 0 8px; font-size: 13px; margin-left: 6px; vertical-align: middle; }

select {
  flex: 1;
  min-width: 0;
  height: var(--control);
  padding: 0 10px;
  font: inherit;
  font-size: var(--small);
  color: var(--text);
  background: var(--well);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
}

select:focus { border-color: var(--up); outline: 2px solid var(--up); outline-offset: 0; }
select:disabled { opacity: 0.4; }

.order { margin-top: 16px; }
.order .row { flex-wrap: wrap; }
.order select { flex: 1 1 100%; }
.order #order-price, .order #order-dollars { flex: 1 1 100px; }

.orders {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.orders li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: var(--small);
}

.orders .cancel {
  height: auto;
  padding: 0;
  border: 0;
  color: var(--text-muted);
  text-decoration: underline;
  font-size: var(--small);
}

.orders .cancel:hover { color: var(--down); }

/* Performance */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 20px;
  margin: 14px 0 0;
}

.stats div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--hairline); padding-bottom: 6px; }
.stats dt { color: var(--text-muted); font-size: var(--small); }
.stats dd { margin: 0; font-size: var(--small); }

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-head h2 { margin-bottom: 12px; }

/* Mood */

.mood { display: flex; flex-wrap: wrap; gap: 6px 24px; align-items: baseline; }
.mood-number { font-size: var(--mood); line-height: 1; }
.mood-fng, .mood-news { display: flex; gap: 8px; align-items: baseline; }

/* News */

.news {
  list-style: none;
  margin: 0;
  padding: 0;
}

.news li {
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.news-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.news-img {
  width: 88px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--well);
  flex-shrink: 0;
}

.news li:last-child { border-bottom: 0; }

.news a { color: var(--text); text-decoration: underline; }
.news a:hover { color: var(--up); }

/* AI read of the headlines */

.brief {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: var(--small);
}

.brief-head { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }

/* Tables */

.cash { font-size: var(--large); margin-bottom: 10px; }
.cash .fig { margin-left: 6px; }

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--small);
}

.grid th, .grid td {
  padding: 8px 6px;
  text-align: right;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

.grid th:first-child, .grid td:first-child,
.grid th:nth-child(2), .grid td:nth-child(2) { text-align: left; }

.grid th { color: var(--text-muted); font-weight: 400; }

.grid td { font-family: var(--font-figures); font-variant-numeric: tabular-nums; font-weight: 700; }
.grid td:first-child, .grid td:nth-child(2) { font-family: var(--font-body); font-weight: 400; }
.grid td:nth-child(2) { font-family: var(--font-body); }

.grid tfoot td { border-bottom: 0; border-top: 1px solid var(--edge); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Pages: portfolio, trades, markets */

.page {
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 var(--gutter) 48px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: var(--section) 0 8px;
}

.page-head h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 12px 0 0;
}

.card {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.card dt { color: var(--text-muted); font-size: var(--small); }
.card dd { margin: 2px 0 0; font-size: var(--total); }
.card dd.small { font-size: 13px; margin-top: 2px; }
.order-right { display: flex; gap: 12px; align-items: center; }

.alloc { display: flex; flex-direction: column; gap: 14px; }
.alloc-bar { display: flex; height: 22px; border-radius: var(--radius); overflow: hidden; background: var(--well); }
.alloc-bar span { display: block; height: 100%; min-width: 2px; }
.alloc-bar span + span { border-left: 2px solid var(--bg); }
.alloc-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 20px; font-size: var(--small); }
.alloc-legend li { display: flex; align-items: center; gap: 8px; }
.alloc-legend .fig { margin-left: auto; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex-shrink: 0; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters select, .filters input { flex: 0 1 200px; height: 40px; }

.day-head td { color: var(--text-muted); font-weight: 400; padding-top: 16px; font-family: var(--font-body); }
.note-input { height: 32px; width: 180px; font-size: 13px; font-family: var(--font-body); font-weight: 400; }
.grid td:last-child .note-input { text-align: left; }
.day-head td:first-child { text-align: left; }

.markets .grid td:nth-child(3), .markets .grid th:nth-child(3) { text-align: left; }
.markets .grid td:nth-child(3) { font-family: var(--font-body); font-weight: 400; }
.markets .grid td:nth-child(2) { font-family: var(--font-figures); font-weight: 700; }
.markets tr.pick { cursor: pointer; }
.markets .grid td:last-child { text-align: right; }
.filters.compact { margin: 0; }
.filters.compact input { height: 36px; width: 220px; flex: none; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--text); }
.sortable.sorted { color: var(--text); }
.sortable.sorted[aria-sort="descending"]::after { content: " ▾"; }
.sortable.sorted[aria-sort="ascending"]::after { content: " ▴"; }
.row-star { height: 26px; width: 26px; padding: 0; justify-content: center; border-color: transparent; color: var(--text-muted); }
.row-star:hover { border-color: var(--edge); }
.row-star.on { color: var(--warn); }
.row-star.on .star-icon { fill: currentColor; }
.markets tr.pick:hover td { background: var(--well); }

/* Footer: rules and start over */

.foot {
  max-width: var(--column);
  margin: 0 auto;
  padding: var(--section) var(--gutter) 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rules-box summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--small);
  color: var(--text-muted);
}

.rules-box summary::-webkit-details-marker { display: none; }

.summary-action { color: var(--text); text-decoration: underline; }

.rules {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
}

.rule input { width: 100%; }
.rule-actions { display: flex; gap: 8px; align-items: flex-end; }
.rule-actions button { flex: 1; }

/* Phone: a fixed Buy / Sell bar that jumps to the ticket */
.mobile-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 10px var(--gutter);
  background: var(--bg);
  border-top: 1px solid var(--edge);
  z-index: 8;
}

.mobile-bar button { flex: 1; font-weight: 700; }
.mobile-bar .sell { background: var(--down); color: #FFFFFF; }

@media (max-width: 959px) {
  body { padding-bottom: 72px; }
  .toasts { bottom: 76px; }

  /* One column, in the order a phone needs: search, asset, ticket, orders,
     positions, trades, then the news. The two columns dissolve. */
  .layout { display: flex; flex-direction: column; }
  .col { display: contents; }
  .search-block { order: 1; }
  .coin { order: 2; }
  .ticket-block { order: 3; }
  .orders-block { order: 4; }
  .positions-block { order: 5; }
  .trades-block { order: 6; }
  .news-block { order: 7; }

  .tape-tabs .seg-btn { padding: 0 8px; font-size: 12px; height: 32px; }
}

/* Laptop */

@media (min-width: 960px) {
  .layout {
    display: grid;
    grid-template-columns: 3fr 2fr;
    column-gap: 40px;
    align-items: start;
  }

  .col.right {
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-gutter: stable;
  }

  .mobile-bar { display: none; }

  .forms { flex-direction: row; }
  .forms form { flex: 1; }

  .order .row { flex-wrap: nowrap; }
  .order select { flex: 1 1 auto; }
  .order #order-price, .order #order-dollars { flex: 0 1 120px; }

  .cards { grid-template-columns: repeat(4, 1fr); }
  .foot { flex-direction: row; justify-content: space-between; align-items: flex-start; }
  .rules-box { flex: 1; }
  .rules { grid-template-columns: repeat(4, 1fr); align-items: end; }
  .estimate { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .price { transition: none; }
}
