/* ==========================================================================
   confetti_  —  paper.css
   Design tokens and components only. No page content lives here.
   Source of truth: docs/DESIGN.md section 10.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600;700&family=Tinos:ital,wght@0,400;0,700;1,400&display=swap");

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* surfaces */
  --page: #f4ecd8;
  --panel: #f4ecd8;
  --raised: #faf6ed;
  --sunken: #e8dec8;

  /* ink */
  --ink: #2a2520;
  --ink-muted: #5f564b;
  --ink-faint: #7a7060;

  /* rules */
  --rule: #d4cbba;
  --rule-strong: #b8ad92;

  /* semantic */
  --pos: #2e7a4c;
  --neg: #b44855;
  --accent: #8b2020;

  /* tints derived from the above, used for soft fills */
  --pos-soft: rgba(46, 122, 76, 0.12);
  --neg-soft: rgba(180, 72, 85, 0.12);
  --accent-soft: rgba(139, 32, 32, 0.10);

  /* paper texture dot */
  --dot: rgba(42, 37, 32, 0.09);
  --dot-size: 14px;

  /* type */
  --font-display: "Tinos", "Times New Roman", Times, serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --text-xs: 11px;
  --text-sm: 12px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 28px;
  --text-3xl: 40px;

  /* controls */
  --slider-track: linear-gradient(90deg, var(--pos), var(--ink-muted), var(--neg));
  --focus: 0 0 0 2px var(--page), 0 0 0 4px var(--accent);

  /* layout */
  --gutter: 16px;
  --gap: 12px;
  --max-width: 1280px;
  --side-panel: 320px;
  --header-h: 52px;
  --radius: 0;

  color-scheme: light;
}

[data-theme="night"] {
  --page: #0d1229;
  --panel: #171d3d;
  --raised: #1e2548;
  --sunken: #10163a;

  --ink: #f4eaf2;
  --ink-muted: #b9b2c6;
  --ink-faint: #8a839c;

  --rule: #2a3261;
  --rule-strong: #3f4883;

  --pos: #91d8bd;
  --neg: #f0a0b2;
  --accent: #e86a6a;

  --pos-soft: rgba(145, 216, 189, 0.14);
  --neg-soft: rgba(240, 160, 178, 0.14);
  --accent-soft: rgba(232, 106, 106, 0.14);

  --dot: rgba(244, 234, 242, 0.07);

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--page);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-size: var(--dot-size) var(--dot-size);
  background-position: 0 0;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: 1.5;
  font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Reusable texture for panels that want their own dots on a different surface. */
.paper {
  background-color: var(--page);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-size: var(--dot-size) var(--dot-size);
}

.paper-raised {
  background-color: var(--raised);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-size: var(--dot-size) var(--dot-size);
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.4em;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
  margin: 0 0 1em;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: var(--ink);
}

hr,
.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--gap) 0;
}

.rule-strong {
  border-top-color: var(--rule-strong);
}

code,
kbd,
pre,
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

code,
kbd {
  font-size: 0.92em;
  background: var(--sunken);
  padding: 0 4px;
}

pre {
  background: var(--sunken);
  border: 1px solid var(--rule);
  padding: var(--gap);
  overflow-x: auto;
  font-size: var(--text-sm);
}

::selection {
  background: var(--ink);
  color: var(--page);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* Text utilities */
.display   { font-family: var(--font-display); }
.ui        { font-family: var(--font-ui); }
.muted     { color: var(--ink-muted); }
.faint     { color: var(--ink-faint); }
.pos       { color: var(--pos); }
.neg       { color: var(--neg); }
.accent    { color: var(--accent); }
.xs        { font-size: var(--text-xs); }
.sm        { font-size: var(--text-sm); }
.lg        { font-size: var(--text-lg); }
.caps      { text-transform: uppercase; letter-spacing: 0.08em; }
.num       { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.right     { text-align: right; }
.center    { text-align: center; }
.nowrap    { white-space: nowrap; }
.truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Section label: small caps rule-aligned heading used above panels and stats. */
.label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* --------------------------------------------------------------------------
   3. Wordmark and cursor
   -------------------------------------------------------------------------- */

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  line-height: 1;
}

.wordmark-hero {
  font-size: clamp(48px, 10vw, 112px);
}

/* The red cursor block that follows the wordmark: confetti_ */
.cursor {
  display: inline-block;
  width: 0.5em;
  height: 0.12em;
  margin-left: 0.06em;
  background: var(--accent);
  vertical-align: baseline;
  transform: translateY(0.02em);
  animation: cursor-blink 1.1s steps(1, end) infinite;
}

.cursor-block {
  height: 0.85em;
  width: 0.5em;
  transform: translateY(0.1em);
}

@keyframes cursor-blink {
  0%, 55%   { opacity: 1; }
  56%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
}

/* --------------------------------------------------------------------------
   4. Buttons  —  bracketed text, 1px ink border, no radius
   -------------------------------------------------------------------------- */

.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.btn::before { content: "[ "; }
.btn::after  { content: " ]"; }
.btn::before,
.btn::after {
  color: var(--ink-faint);
  white-space: pre;
  transition: color 120ms ease;
}

.btn:hover {
  background: var(--ink);
  color: var(--page);
}

.btn:hover::before,
.btn:hover::after {
  color: var(--page);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover,
.btn[aria-disabled="true"]:hover {
  background: transparent;
  color: var(--ink);
}

/* Filled primary */
.btn-primary {
  background: var(--ink);
  color: var(--page);
  border-color: var(--ink);
}
.btn-primary::before,
.btn-primary::after { color: var(--page); }
.btn-primary:hover {
  background: transparent;
  color: var(--ink);
}
.btn-primary:hover::before,
.btn-primary:hover::after { color: var(--ink); }

/* Long / short action buttons */
.btn-long {
  border-color: var(--pos);
  color: var(--pos);
}
.btn-long::before,
.btn-long::after { color: var(--pos); }
.btn-long:hover {
  background: var(--pos);
  color: var(--page);
}
.btn-long:hover::before,
.btn-long:hover::after { color: var(--page); }

.btn-short {
  border-color: var(--neg);
  color: var(--neg);
}
.btn-short::before,
.btn-short::after { color: var(--neg); }
.btn-short:hover {
  background: var(--neg);
  color: var(--page);
}
.btn-short:hover::before,
.btn-short:hover::after { color: var(--page); }

/* Accent (auth / connect) */
.btn-accent {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-accent::before,
.btn-accent::after { color: var(--accent); }
.btn-accent:hover {
  background: var(--accent);
  color: var(--page);
}
.btn-accent:hover::before,
.btn-accent:hover::after { color: var(--page); }

/* Borderless text button, keeps the brackets */
.btn-ghost {
  border-color: transparent;
}
.btn-ghost:hover {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}
.btn-ghost:hover::before,
.btn-ghost:hover::after { color: var(--ink); }

/* Sizes */
.btn-sm {
  min-height: 28px;
  padding: 0 10px;
  font-size: var(--text-xs);
}

.btn-lg {
  min-height: 44px;
  padding: 0 20px;
  font-size: var(--text-md);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* No brackets variant for icon-ish buttons */
.btn-plain::before,
.btn-plain::after { content: none; }

/* --------------------------------------------------------------------------
   5. Panels
   -------------------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  min-width: 0;
}

.panel-raised {
  background: var(--raised);
  border-color: var(--rule-strong);
}

.panel-sunken {
  background: var(--sunken);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  line-height: 1.2;
}

.panel-head .label {
  font-family: var(--font-ui);
}

.panel-body {
  padding: 12px;
}

.panel-body-tight {
  padding: 8px;
}

.panel-foot {
  padding: 8px 12px;
  border-top: 1px solid var(--rule);
}

/* Key/value rows inside panels (Account Equity, Order Value, Bust Price ...) */
.kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
  padding: 6px 0;
  border-bottom: 1px dotted var(--rule);
}

.kv:last-child {
  border-bottom: 0;
}

.kv-key {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.kv-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  color: var(--ink);
  text-align: right;
}

/* --------------------------------------------------------------------------
   6. Chips, badges, status
   -------------------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sunken);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1;
  white-space: nowrap;
  color: var(--ink);
}

.chip-label {
  color: var(--ink-faint);
  font-family: var(--font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chip-value {
  color: var(--ink);
}

.chip-pos .chip-value { color: var(--pos); }
.chip-neg .chip-value { color: var(--neg); }

/* Live dot */
.chip-live {
  border-color: var(--pos);
  color: var(--pos);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.dot-pulse {
  animation: dot-pulse 1.6s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
  .dot-pulse { animation: none; }
}

/* Tier badges: A 1000x, B 250x, C 50x */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
  background: transparent;
}

.badge-a { border-color: var(--neg); color: var(--neg); background: var(--neg-soft); }
.badge-b { border-color: var(--ink-muted); color: var(--ink-muted); }
.badge-c { border-color: var(--pos); color: var(--pos); background: var(--pos-soft); }

/* Current price pill on the chart */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: var(--ink);
  color: var(--page);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.4;
}

.pill-pos { background: var(--pos); }
.pill-neg { background: var(--neg); }

/* --------------------------------------------------------------------------
   7. Inputs, segmented toggle, slider
   -------------------------------------------------------------------------- */

.input,
.select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--sunken);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.input::placeholder {
  color: var(--ink-faint);
}

.input:focus,
.select:focus {
  border-color: var(--ink);
  outline: none;
  box-shadow: none;
}

.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Input with trailing unit or quick buttons */
.input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--rule-strong);
  background: var(--sunken);
}

.input-group .input {
  border: 0;
  background: transparent;
  flex: 1 1 auto;
  min-width: 0;
}

.input-group .unit {
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  border-left: 1px solid var(--rule);
}

/* Quick-size row: ½x 2x Max */
.quick {
  display: flex;
  gap: 6px;
}

.quick .btn {
  flex: 1 1 0;
  min-height: 26px;
  padding: 0 6px;
  font-size: var(--text-xs);
}

/* Segmented control (Long / Short, tabs in header) */
.seg {
  display: inline-flex;
  width: 100%;
  border: 1px solid var(--ink);
  background: transparent;
}

.seg-item {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 0;
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.seg-item + .seg-item {
  border-left: 1px solid var(--ink);
}

.seg-item[aria-pressed="true"],
.seg-item.is-active {
  background: var(--ink);
  color: var(--page);
}

.seg-long[aria-pressed="true"],
.seg-long.is-active { background: var(--pos); }

.seg-short[aria-pressed="true"],
.seg-short.is-active { background: var(--neg); }

/* Leverage slider: green-to-red track, square ink thumb */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.slider:focus {
  outline: none;
}

.slider::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--slider-track);
  border: 1px solid var(--rule-strong);
}

.slider::-moz-range-track {
  height: 6px;
  background: var(--slider-track);
  border: 1px solid var(--rule-strong);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 18px;
  margin-top: -7px;
  background: var(--ink);
  border: 1px solid var(--page);
  border-radius: 0;
  box-shadow: 0 0 0 1px var(--ink);
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 18px;
  background: var(--ink);
  border: 1px solid var(--page);
  border-radius: 0;
  box-shadow: 0 0 0 1px var(--ink);
}

.slider:focus-visible::-webkit-slider-thumb {
  box-shadow: var(--focus);
}

.slider:focus-visible::-moz-range-thumb {
  box-shadow: var(--focus);
}

/* x1 Safe ...... Wild x1000 */
.slider-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-faint);
}

.slider-scale .safe { color: var(--pos); }
.slider-scale .wild { color: var(--neg); }

/* --------------------------------------------------------------------------
   8. Tabs, tables, ticker
   -------------------------------------------------------------------------- */

.tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  -webkit-appearance: none;
  appearance: none;
  padding: 8px 12px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected="true"],
.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.table th {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.table td {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.table .right {
  text-align: right;
}

.table tbody tr:hover {
  background: var(--raised);
}

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

/* Ticker tape across the top of the landing page */
.ticker {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--rule);
  background: var(--sunken);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 28px;
  height: 28px;
  white-space: nowrap;
}

.ticker-track {
  display: inline-flex;
  gap: 32px;
  padding-left: 100%;
  animation: ticker-scroll 60s linear infinite;
  will-change: transform;
}

.ticker:hover .ticker-track {
  animation-play-state: paused;
}

.ticker-item {
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
}

.ticker-item .sym {
  color: var(--ink-muted);
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track {
    animation: none;
    padding-left: 0;
  }
}

/* --------------------------------------------------------------------------
   9. Layout  —  16px gutters, single column on phones
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.container-fluid {
  width: 100%;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap);
}

.row-between {
  justify-content: space-between;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.grid {
  display: grid;
  gap: var(--gap);
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Site header */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--gap);
  border-bottom: 1px solid var(--rule);
  background: var(--page);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-size: var(--dot-size) var(--dot-size);
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a {
  padding: 6px 10px;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--ink);
}

.nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-color: var(--accent);
}

/* Trade page: chart + side panel on top, positions table below */
.trade-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-panel);
  grid-template-areas:
    "chart   side"
    "bottom  side";
  gap: var(--gap);
  align-items: start;
}

.trade-chart  { grid-area: chart; min-width: 0; }
.trade-side   { grid-area: side; position: sticky; top: calc(var(--header-h) + var(--gap)); }
.trade-bottom { grid-area: bottom; min-width: 0; }

.chart-box {
  position: relative;
  width: 100%;
  height: clamp(280px, 50vh, 520px);
  background: var(--raised);
  border: 1px solid var(--rule);
}

.chart-box .pill {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* Landing hero */
.hero {
  padding: clamp(40px, 10vh, 120px) 0 clamp(32px, 6vh, 72px);
}

.hero-lines {
  margin: 20px 0 28px;
  font-family: var(--font-display);
  font-size: clamp(18px, 2.4vw, 24px);
  line-height: 1.5;
  color: var(--ink-muted);
}

.hero-lines > * {
  margin: 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}

/* Screenshot-style preview card */
.preview {
  margin-top: 40px;
  border: 1px solid var(--rule-strong);
  background: var(--raised);
  box-shadow: 8px 8px 0 var(--sunken);
  overflow: hidden;
}

/* Spacing helpers */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.p-0  { padding: 0; }
.p-2  { padding: 8px; }
.p-3  { padding: 12px; }
.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   10. Breakpoints
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  :root {
    --side-panel: 288px;
  }
}

@media (max-width: 900px) {
  .trade-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "chart"
      "side"
      "bottom";
  }

  .trade-side {
    position: static;
  }

  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  :root {
    --text-3xl: 32px;
    --text-2xl: 24px;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }

  .header {
    height: auto;
    min-height: var(--header-h);
    flex-wrap: wrap;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .hero-actions .btn {
    flex: 1 1 auto;
  }

  .chart-box {
    height: clamp(220px, 40vh, 360px);
  }
}

/* --------------------------------------------------------------------------
   11. Print
   -------------------------------------------------------------------------- */

@media print {
  body {
    background-image: none;
  }

  .ticker,
  .header,
  .btn {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   12. Landing page  (appended for index.html; nothing above this line changed)
   -------------------------------------------------------------------------- */

/* Page scaffold: content sits above the confetti layer; the tilted preview is
   clipped horizontally so a phone never gets a sideways scroll. */
.landing-main {
  position: relative;
  z-index: 1;
  overflow-x: clip;
}

@supports not (overflow-x: clip) {
  .landing-main { overflow-x: hidden; }
}

.landing .ticker {
  z-index: 2;
}

/* Seamless tape: the content is rendered twice and the track slides by half
   its own width, so the loop point is invisible. */
.ticker-track.is-loop {
  gap: 0;
  padding-left: 0;
  animation-name: ticker-loop;
  animation-duration: var(--ticker-duration, 48s);
}

.ticker-track.is-static {
  padding-left: 0;
  animation: none;
}

.ticker-half {
  display: inline-flex;
  gap: 32px;
  padding-right: 32px;
}

@keyframes ticker-loop {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.ticker-item .px {
  color: var(--ink);
  transition: color 600ms ease;
}

.ticker-item.is-up .px   { color: var(--pos); }
.ticker-item.is-down .px { color: var(--neg); }

.ticker-dot {
  color: var(--ink-faint);
}

.ticker-status {
  position: absolute;
  top: 0;
  right: 0;
  height: 28px;
  padding: 0 12px;
  background: var(--sunken);
  border-left: 1px solid var(--rule);
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.ticker-status[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track.is-loop { animation: none; }
  .ticker-item .px { transition: none; }
}

/* Hero: copy on the left, tilted preview on the right */
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 10fr) minmax(0, 11fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
}

.hero-copy {
  min-width: 0;
}

.hero-wordmark {
  margin: 0;
  line-height: 0.95;
}

.hero-lines-ui {
  list-style: none;
  margin: 24px 0 30px;
  padding: 0;
  font-family: var(--font-ui);
  font-size: clamp(16px, 1.7vw, 20px);
  line-height: 1.55;
  color: var(--ink-muted);
}

.hero-lines-ui li {
  margin: 0;
}

.hero-lines-ui b {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink);
}

.hero-preview {
  min-width: 0;
  padding: 28px 0 28px 6px;
}

.preview-tilt {
  transform: perspective(1600px) rotateY(-9deg) rotateX(2deg) rotate(-1.5deg);
  transform-origin: 50% 50%;
  transition: transform 600ms ease;
}

@media (hover: hover) {
  .preview-tilt:hover {
    transform: perspective(1600px) rotateY(-4deg) rotateX(1deg) rotate(-0.6deg);
  }
}

.hero-preview .preview {
  margin-top: 0;
}

/* Preview card internals: a miniature of the trade page, drawn with the
   same components at a smaller scale. Prefix: .pv */
.pv {
  font-size: 10px;
  line-height: 1.3;
  color: var(--ink);
  user-select: none;
}

.pv-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

.pv-head .wordmark {
  font-size: 15px;
}

.pv-nav {
  display: flex;
  gap: 2px;
  margin-left: 4px;
  min-width: 0;
  overflow: hidden;
}

.pv-nav span {
  padding: 2px 5px;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.pv-nav span.is-current {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--accent);
}

.pv-auth {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.pv .btn {
  min-height: 18px;
  padding: 0 6px;
  font-size: 8px;
}

.pv-market {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--rule);
}

.pv-sym {
  font-family: var(--font-display);
  font-size: 14px;
  margin-right: 2px;
}

.pv .chip {
  min-height: 18px;
  padding: 0 5px;
  gap: 4px;
  font-size: 8px;
}

.pv .badge {
  height: 15px;
  min-width: 15px;
  font-size: 8px;
}

.pv-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
}

.pv-chart {
  position: relative;
  height: 200px;
  border-right: 1px solid var(--rule);
  background: var(--raised);
}

.pv-chart canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pv-chart .pill {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 1px 6px;
  font-size: 9px;
}

.pv-interval {
  position: absolute;
  top: 7px;
  left: 8px;
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--ink-faint);
}

.pv-side {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
}

.pv .label {
  font-size: 8px;
}

.pv .kv {
  padding: 2px 0;
  gap: 6px;
}

.pv .kv-key,
.pv .kv-val {
  font-size: 9px;
}

.pv .seg-item {
  min-height: 20px;
  font-size: 8px;
}

.pv .input {
  min-height: 22px;
  padding: 0 6px;
  font-size: 10px;
}

.pv .input-group .unit {
  padding: 0 6px;
  font-size: 8px;
}

.pv .quick .btn {
  min-height: 18px;
  padding: 0 4px;
  font-size: 8px;
}

.pv-lev {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 2px;
}

.pv-lev .num {
  font-size: 9px;
}

.pv .slider {
  height: 16px;
}

.pv .slider::-webkit-slider-thumb {
  width: 10px;
  height: 14px;
  margin-top: -5px;
}

.pv .slider::-moz-range-thumb {
  width: 10px;
  height: 14px;
}

.pv .slider-scale {
  font-size: 8px;
}

.pv-bottom {
  border-top: 1px solid var(--rule);
}

.pv .tabs {
  align-items: center;
  padding-right: 6px;
}

.pv .tab {
  padding: 4px 8px;
  font-size: 8px;
}

.pv .table th,
.pv .table td {
  padding: 3px 8px;
  font-size: 8px;
}

.pv .table th {
  font-size: 7px;
}

/* Confetti scatter: a few dozen paper-coloured rectangles drifting down
   behind the content. Pieces are positioned by custom properties set from JS. */
.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -24px;
  left: var(--x, 50%);
  width: var(--w, 7px);
  height: var(--h, 12px);
  background: var(--c, var(--neg));
  opacity: 0.8;
  transform: translate3d(0, -10vh, 0) rotate(var(--r0, 0deg));
  animation: confetti-fall var(--dur, 20s) linear var(--delay, 0s) infinite;
  will-change: transform;
}

@keyframes confetti-fall {
  from { transform: translate3d(0, -10vh, 0) rotate(var(--r0, 0deg)); }
  to   { transform: translate3d(var(--drift, 0px), 110vh, 0) rotate(var(--r1, 540deg)); }
}

.confetti-layer.is-paused .confetti-piece {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .confetti-piece {
    top: var(--ty, 50%);
    transform: rotate(var(--r0, 0deg));
    animation: none;
  }
  .preview-tilt {
    transition: none;
  }
}

/* Footer */
.landing-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin-top: clamp(24px, 6vh, 64px);
  padding-top: 20px;
  padding-bottom: 40px;
  border-top: 1px solid var(--rule);
  font-size: var(--text-xs);
  color: var(--ink-faint);
}

.landing-foot .wordmark {
  font-size: var(--text-lg);
}

.landing-foot a {
  color: var(--ink-muted);
}

.landing-foot .spacer {
  flex: 1 1 auto;
}

/* Landing breakpoints */
@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-preview {
    padding: 12px 0 8px;
  }

  .preview-tilt {
    transform: perspective(1600px) rotateY(-4deg) rotate(-1deg);
  }
}

@media (max-width: 480px) {
  .pv-body {
    grid-template-columns: minmax(0, 1fr) 118px;
  }

  .pv-chart {
    height: 160px;
  }

  .pv-nav span:nth-child(n+4),
  .pv-auth .btn:not(.btn-accent),
  .pv .quick .btn:nth-child(3),
  .pv-bottom {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Position lines: one row per position, no table
   -------------------------------------------------------------------------- */
.pos-line {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow-x: auto;
}
.pos-line .sym { font-weight: 600; color: var(--ink); }
.pos-line .grow { flex: 1 1 auto; }
.pos-line .btn { flex: 0 0 auto; }
/* A list of lines scrolls as one unit; the page never widens. */
.pos-lines { min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pos-lines .pos-line { overflow: visible; min-width: max-content; }
.pos-lines .empty { padding: 12px 0; color: var(--ink-faint); font-size: var(--text-sm); }
@media (max-width: 480px) { .pos-line { gap: 10px; font-size: var(--text-xs); } }
