/* PT/USD: Lighter's own look. Near-black with a violet cast, Geist Mono everywhere,
   hairline frames with corner brackets, dot-matrix charts. */
:root {
  --bg: #09090d;
  --frame: #050507;
  --panel: #0e0e14;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .15);
  --ink: rgba(255, 255, 255, .93);
  --ink-2: rgba(255, 255, 255, .64);
  --muted: rgba(255, 255, 255, .42);
  --dim: rgba(255, 255, 255, .22);
  --up: #3ddc97;
  --down: #f2626e;
  --warn: #f5b942;
  --rh: #c6f35e;                         /* the Robinhood badge */
  --mono: "Geist Mono", "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 400 13px/1.5 var(--mono);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(ellipse 70% 45% at 50% -8%, #1a1924 0%, rgba(26, 25, 36, 0) 70%),
    var(--bg);
}

.shell { max-width: 1120px; margin: 0 auto; padding: 16px 16px 48px; position: relative; z-index: 1; }

/* ASCII side rails, like lighter.xyz */
.rail {
  position: fixed; top: 0; bottom: 0; width: 132px; margin: 0; overflow: hidden;
  font: 400 9px/9px var(--mono); color: rgba(255, 255, 255, .075);
  pointer-events: none; user-select: none; z-index: 0;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
          mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
}
.rail.l { left: 0; }
.rail.r { right: 0; text-align: right; }
@media (max-width: 1420px) { .rail { display: none; } }

/* ---- top bar ---------------------------------------------------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 2px 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 500; letter-spacing: .1em; }
.brand svg { width: 12px; height: 22px; display: block; }

/* the RH badge: Robinhood green, pinned to the Lighter mark's top-right */
.rh {
  position: absolute; font-style: normal; font-family: var(--mono); font-weight: 600; line-height: 1;
  letter-spacing: .02em; color: #0b1205; background: var(--rh); border-radius: 4px; user-select: none;
}
.logo-tile { position: relative; display: inline-flex; margin-right: 14px; }
.logo-tile .rh { top: -8px; left: 8px; font-size: 8.5px; padding: 2px 3.5px 1.5px; border-radius: 3px; }
.brand small { color: var(--muted); font-weight: 400; letter-spacing: .08em; text-transform: uppercase; font-size: 10.5px; }
.nav { display: flex; gap: 8px; align-items: center; }
.btn {
  font: inherit; font-size: 12px; letter-spacing: .03em; color: var(--ink-2); text-decoration: none;
  border: 1px solid var(--line-2); background: transparent; padding: 7px 12px; border-radius: 6px; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { color: var(--ink); border-color: rgba(255, 255, 255, .32); }
.btn-primary { background: #fff; color: #08080b; border-color: #fff; font-weight: 500; }
.btn-primary:hover { background: rgba(255, 255, 255, .86); color: #08080b; border-color: transparent; }

/* ---- corner brackets ---------------------------------------------------- */
.br::before {
  content: ""; position: absolute; inset: 5px; pointer-events: none;
  --c: rgba(255, 255, 255, .28); --s: 7px;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--s) 1px,
    linear-gradient(var(--c), var(--c)) top left / 1px var(--s),
    linear-gradient(var(--c), var(--c)) top right / var(--s) 1px,
    linear-gradient(var(--c), var(--c)) top right / 1px var(--s),
    linear-gradient(var(--c), var(--c)) bottom left / var(--s) 1px,
    linear-gradient(var(--c), var(--c)) bottom left / 1px var(--s),
    linear-gradient(var(--c), var(--c)) bottom right / var(--s) 1px,
    linear-gradient(var(--c), var(--c)) bottom right / 1px var(--s);
  background-repeat: no-repeat;
}

/* ---- the terminal frame ------------------------------------------------ */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  min-height: clamp(540px, 56vw, 640px);
  border: 1px solid var(--line-2); border-radius: 14px;
  background: radial-gradient(ellipse 60% 70% at 50% 45%, #0b0b10 0%, var(--frame) 70%);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .025), 0 30px 80px -30px rgba(0, 0, 0, .9);
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 6;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .02) 0 1px, transparent 1px 3px);
}
.curve { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }

.blink { animation: blink 1.05s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.status {
  position: absolute; top: 18px; right: 20px; z-index: 3;
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  font-size: 10.5px; letter-spacing: .07em; color: var(--ink-2); text-transform: uppercase;
}
.feed { display: inline-flex; align-items: center; gap: 8px; }
.feed .dot { width: 6px; height: 6px; display: inline-block; background: var(--down); box-shadow: 0 0 8px var(--down); }
.feed.ok .dot { background: var(--up); box-shadow: 0 0 8px var(--up); animation: pulse 2.2s ease-in-out infinite; }
.feed.stale .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.status .age { color: var(--muted); }
@keyframes pulse { 50% { opacity: .35; } }

.center {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); z-index: 2;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 20px 40px; width: max-content; max-width: 100%;
}
.center::before {
  content: ""; position: absolute; inset: -30px -70px; z-index: -1;
  background: radial-gradient(closest-side, rgba(5, 5, 7, .9) 25%, rgba(5, 5, 7, .55) 65%, rgba(5, 5, 7, 0));
}

.mark {
  position: relative; margin: 0; overflow: hidden;
  font: 400 9px/9px var(--mono); letter-spacing: 0; color: rgba(255, 255, 255, .88);
  user-select: none;
}
.mark::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 30%;
  background: linear-gradient(to bottom, rgba(5, 5, 7, 0), rgba(5, 5, 7, .55), rgba(5, 5, 7, 0));
  animation: scan 3.6s linear infinite;
}
@keyframes scan { from { transform: translateY(-100%); } to { transform: translateY(340%); } }

.wordmark {
  margin-top: 14px; font-size: 19px; font-weight: 400;
  letter-spacing: .42em; padding-left: .42em; color: rgba(255, 255, 255, .74);
}
.price-label {
  margin-top: 26px; font-size: 10.5px; letter-spacing: .26em; padding-left: .26em;
  color: var(--muted); text-transform: uppercase;
}
.price {
  margin: 8px 0 0; color: #fff;
  font: 300 clamp(58px, 9.6vw, 112px)/1 var(--mono); letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
  transition: color .9s ease, text-shadow .9s ease, opacity .45s ease;
}
.price .tail { color: rgba(255, 255, 255, .3); }
.price.flash-up { color: var(--up); text-shadow: 0 0 28px rgba(61, 220, 151, .35); transition: none; }
.price.flash-down { color: var(--down); text-shadow: 0 0 28px rgba(242, 98, 110, .35); transition: none; }
.price-sub { margin-top: 14px; font-size: 12px; color: var(--ink-2); letter-spacing: .03em; }
.price-sub b { color: var(--ink); font-weight: 500; }
.price-sub .sep { color: var(--dim); margin: 0 6px; }

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

.live-chip {
  position: absolute; left: 20px; bottom: 16px; z-index: 3;
  display: flex; gap: 8px; align-items: center;
  font-size: 11px; font-weight: 600; letter-spacing: .1em; color: #fff;
}
.live-chip span { font-size: 9px; }
.tagline {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3;
  font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
  border-bottom: 1px dashed rgba(255, 255, 255, .28); padding: 0 4px 3px;
}
.tagline .blink { color: var(--ink); margin-left: 1px; }

/* today's tag on the supply curve, above the centre's backdrop */
.now-tag {
  position: absolute; z-index: 3; white-space: nowrap; pointer-events: none;
  font-size: 11px; font-weight: 500; line-height: 16px; letter-spacing: .07em; color: #fff;
}
.now-tag .w { color: var(--muted); font-weight: 400; margin-right: 10px; }
.now-tag::after { content: ""; position: absolute; border: 0 dashed rgba(255, 255, 255, .5); }
/* leader left: the text ends a dashed run short of today's bar */
.now-tag.left { transform: translate(-100%, -50%); padding-right: 48px; }
.now-tag.left::after { right: 6px; top: 50%; width: 34px; border-top-width: 1px; }
/* leader up: the text sits above the bar, flush with it */
.now-tag.up { transform: translate(-100%, -100%); padding: 0 0 30px; margin-left: 1px; }
.now-tag.up::after { right: 0; bottom: 0; height: 24px; border-right-width: 1px; }
.now-tag.low { transform: translateX(-100%); background: rgba(5, 5, 7, .88); padding: 2px 6px; }
.now-tag.low::after { display: none; }

/* ---- panels ------------------------------------------------------------ */
.box {
  position: relative; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px;
}
/* headings keep the label look */
h1, h2 { margin: 0; font-weight: inherit; }
.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;
}
.noscript { margin: 14px 0 0; font-size: 12px; color: var(--ink-2); }
.k { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.k .hint { letter-spacing: .04em; text-transform: none; color: var(--dim); }
.x { font-size: 11px; color: var(--muted); }

.stats { margin-top: 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat .v { margin-top: 8px; font-size: 26px; font-weight: 400; letter-spacing: -.02em; color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .s { margin-top: 2px; font-size: 12px; color: var(--ink-2); }
.stat .x { margin-top: 8px; }
.bag input {
  display: block; width: 100%; margin-top: 8px; font: inherit; font-size: 20px; color: #fff;
  background: rgba(255, 255, 255, .03); border: 1px solid var(--line-2); border-radius: 6px; padding: 4px 10px;
  font-variant-numeric: tabular-nums;
}
.bag input::placeholder { color: var(--dim); font-size: 13px; }
.bag input:focus { outline: none; border-color: rgba(255, 255, 255, .45); }
.bag .s { margin-top: 8px; }
.bag .s b { font-size: 16px; font-weight: 500; color: #fff; }
.card-btn { margin-top: 12px; width: 100%; }
.card-btn:disabled { opacity: .35; cursor: not-allowed; }
.card-btn:not(:disabled) { color: #fff; border-color: rgba(255, 255, 255, .32); background: rgba(255, 255, 255, .04); }
.card-btn:not(:disabled):hover { background: #fff; color: #08080b; }

/* ---- history chart ----------------------------------------------------- */
.chart-panel { margin-top: 14px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.chart-sum { margin-top: 4px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart-sum b { color: var(--ink); font-weight: 500; }
.seg { display: flex; gap: 4px; }
.seg button {
  font: inherit; font-size: 11px; color: var(--ink-2); background: transparent;
  border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 10px; cursor: pointer;
}
.seg button:hover { color: var(--ink); border-color: rgba(255, 255, 255, .32); }
.seg button[aria-pressed="true"] { background: #fff; color: #08080b; border-color: #fff; }
.chart-box { position: relative; height: 260px; margin-top: 12px; }
.chart-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: pan-y; }
.tip {
  position: absolute; top: 0; z-index: 2; pointer-events: none;
  background: rgba(8, 8, 11, .94); border: 1px solid var(--line-2); border-radius: 6px;
  padding: 7px 10px; font-size: 11px; line-height: 1.5; white-space: nowrap; color: var(--ink-2);
}
.tip b { color: #fff; font-weight: 500; }

/* ---- scenarios --------------------------------------------------------- */
.scen { margin-top: 14px; }
.scen-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.srow {
  display: grid; grid-template-columns: 1.25fr 1fr 1fr .8fr .85fr 1.7fr; gap: 10px; align-items: center;
  width: 100%; padding: 8px 10px; border: 0; border-top: 1px solid var(--line); background: transparent;
  font-size: 12.5px; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.srow.gap { border-top: 1px dashed var(--line-2); }
.srow.sel { background: rgba(255, 255, 255, .055); color: #fff; }
.srow.sel .c-w::before { content: "▸ "; }
.srow .c-usd { color: var(--ink); font-weight: 500; }
.srow.sel .c-usd { color: #fff; }
.srow .c-bar { letter-spacing: -.02em; overflow: hidden; white-space: nowrap; }
.srow .c-bar .on { color: rgba(255, 255, 255, .7); }
.srow .c-bar .off { color: rgba(255, 255, 255, .1); }
.srow .tag { font-size: 10px; letter-spacing: .1em; color: var(--up); margin-left: 8px; }
.shead { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); border-top: 0; padding-top: 0; }

/* ---- rules ----------------------------------------------------------- */
.rules { margin-top: 14px; }
.rules-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.rule-eq {
  margin: 14px 0 6px; padding: 14px 16px; border: 1px solid var(--line-2); border-radius: 8px;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .015) 0 1px, transparent 1px 3px), #08080c;
  display: flex; flex-direction: column; gap: 10px;
  font-size: 13px; letter-spacing: .1em; color: #fff;
}
.eq-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.eq-line.now { color: var(--ink-2); letter-spacing: .04em; }
.eq-line.now b { color: #fff; font-weight: 500; }
.eq-line.now em { font-style: normal; font-size: 11px; color: var(--dim); letter-spacing: .06em; }
.rule-eq i { font-style: normal; color: var(--muted); }
.rule-eq .prompt { color: var(--up); }
.rule-list {
  list-style: none; margin: 0; padding: 0; counter-reset: rule;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px;
}
.rule-list li {
  counter-increment: rule; display: grid; grid-template-columns: 34px minmax(0, 1fr); row-gap: 2px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.rule-list li::before {
  content: counter(rule, decimal-leading-zero); grid-row: span 2;
  font-size: 11px; color: var(--dim); letter-spacing: .06em; padding-top: 1px;
}
.rule-list b { font-size: 10.5px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--ink); }
.rule-list span { font-size: 12px; line-height: 1.55; color: var(--ink-2); }

.foot {
  margin-top: 18px; padding: 14px 4px 0; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; justify-content: center; text-align: center;
  gap: 6px 10px; font-size: 11px; color: var(--muted); letter-spacing: .03em;
}
.foot-sep { color: var(--dim); }

/* ---- PnL card sheet ----------------------------------------------------- */
body.locked { overflow: hidden; }
.sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.sheet[hidden] { display: none; }
.sheet-back { position: absolute; inset: 0; background: rgba(3, 3, 5, .82); backdrop-filter: blur(6px); }
.sheet-body {
  position: relative; width: min(940px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: #0b0b10; border-color: var(--line-2); box-shadow: 0 40px 120px -20px rgba(0, 0, 0, .9);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.btn-ghost { border-color: transparent; padding: 4px 8px; }
.card-canvas { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 675; border-radius: 10px; background: #050507; }
.sheet-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.name-field { display: flex; flex-direction: column; gap: 6px; }
.name-field input {
  width: 220px; font: inherit; font-size: 14px; color: #fff;
  background: rgba(255, 255, 255, .03); border: 1px solid var(--line-2); border-radius: 6px; padding: 7px 10px;
}
.name-field input:focus { outline: none; border-color: rgba(255, 255, 255, .45); }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- small screens ----------------------------------------------------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .rule-list { grid-template-columns: minmax(0, 1fr); }
  .sheet-actions { width: 100%; }
  .sheet-actions .btn { flex: 1; }
  .name-field, .name-field input { width: 100%; }
  .hero { min-height: 600px; }
  .status { font-size: 9.5px; right: 16px; top: 14px; }
  .center { top: 47%; padding: 16px 8px; }
  .mark { font-size: 7px; line-height: 7px; }
  .wordmark { font-size: 15px; }
  .live-chip { display: none; }
  .tagline { font-size: 11px; }
  .srow { grid-template-columns: 1.2fr 1fr .8fr .9fr; }
  .srow .c-pts, .srow .c-bar { display: none; }
  .brand small { display: none; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .nav .btn:not(.btn-primary) { display: none; }
  .chart-box { height: 220px; }
}

/* ---- arrival -------------------------------------------------------------
   On load everything settles in once: a short fade and a 6px rise, staggered top to
   bottom. The head script holds the page until Geist Mono is in (600ms at most), so the
   swap from the fallback font never shows. Fill mode is "backwards" so that nothing is
   left pinned after the animation, and nothing that redraws on every quote animates. */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }

.js:not(.ready) .shell > *, .js:not(.ready) .rail { opacity: 0; }
.ready .rail { animation: fade 1.2s ease backwards; }
.ready .topbar, .ready .hero, .ready .stats, .ready .chart-panel, .ready .scen, .ready .rules, .ready .foot {
  animation: rise .5s cubic-bezier(.2, .7, .2, 1) backwards;
}
.ready .hero { animation-delay: .04s; }
.ready .stats { animation-delay: .12s; }
.ready .chart-panel { animation-delay: .18s; }
.ready .scen { animation-delay: .24s; }
.ready .rules { animation-delay: .3s; }
.ready .foot { animation-delay: .34s; }

/* inside the frame: the curve fades up, then the mark, the name, the label, the price */
.ready .hero .curve { animation: fade .9s ease .1s backwards; }
.ready .hero .center > * { animation: rise .55s cubic-bezier(.2, .7, .2, 1) backwards; }
.ready .hero .center > :nth-child(1) { animation-delay: .1s; }
.ready .hero .center > :nth-child(2) { animation-delay: .16s; }
.ready .hero .center > :nth-child(3) { animation-delay: .22s; }
.ready .hero .center > :nth-child(4) { animation-delay: .26s; }
.ready .hero .center > :nth-child(5) { animation-delay: .32s; }
.ready .hero .status, .ready .hero .live-chip, .ready .hero .tagline, .ready .now-tag {
  animation: fade .6s ease .35s backwards;
}

/* values that need a quote start dim and brighten when the first one lands */
#pt-chg, #s-lit, #s-chg, #s-range { transition: opacity .45s ease; }
.js:not(.has-data) :is(#pt-price, #pt-chg, #s-lit, #s-chg, #s-range) { opacity: .3; }

/* the history chart fades in when its data first shows, and on a range switch */
.chart-box canvas.enter { animation: fade .35s ease backwards; }

/* the PnL card sheet */
.sheet:not([hidden]) .sheet-back { animation: fade .2s ease backwards; }
.sheet:not([hidden]) .sheet-body { animation: pop .24s cubic-bezier(.2, .7, .2, 1) backwards; }

@media (prefers-reduced-motion: reduce) {
  .blink, .feed.ok .dot, .mark::after { animation: none; }
  .rail, .shell > *, .hero .curve, .hero .center > *, .hero .status, .hero .live-chip, .hero .tagline,
  .now-tag, .chart-box canvas, .sheet-back, .sheet-body { animation: none !important; }
  .price { transition: none; }
}
