:root {
  --bg: #fcf8f4; --card: #f8f3ec; --line: #efe1d2; --line2: #f3ede7; --white: #fff; --ink: #2c180b; --mute: #5c4c3f; --soft: #8a7a6c;
  --accent: #ff6c02; --accent-soft: #fff1e6; --dark: #120a04; --green: #1f8a4c; --red: #c4361b;
  --mono: 'Geist Mono', ui-monospace, monospace; --sans: 'Geist', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .92em; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 20; background: rgba(252, 248, 244, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line2); }
.bar .in { max-width: 1240px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 28px; }
.logo { display: flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 600; font-size: 19px; letter-spacing: -.02em; }
.logo img { height: 22px; display: block; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { text-decoration: none; color: var(--mute); padding: 7px 12px; border-radius: 8px; font-size: 14.5px; }
.nav a:hover { color: var(--ink); background: var(--card); }
.nav a.on { color: var(--ink); background: var(--white); box-shadow: 0 0 0 1px var(--line); }
.btn { border: 0; background: var(--dark); color: #fff; padding: 10px 16px; border-radius: 9px; font-weight: 500; font-size: 14.5px; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: #2c180b; }
.btn.ghost { background: var(--white); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { background: var(--card); }
.btn.orange { background: var(--accent); }
.btn.orange:hover { background: #e96000; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.wide { width: 100%; justify-content: center; padding: 14px; font-size: 15.5px; }
.ca { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--mute); background: var(--white); box-shadow: inset 0 0 0 1px var(--line); padding: 8px 10px; border-radius: 8px; cursor: pointer; display: none; }
.ca.on { display: inline-block; }

main { max-width: 1240px; margin: 0 auto; padding: 32px 24px 80px; }
.head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 4px 0 22px; flex-wrap: wrap; }
.head h1 { font-size: 34px; line-height: 1.1; letter-spacing: -.03em; font-weight: 500; margin: 0; }
.head p { margin: 8px 0 0; color: var(--mute); max-width: 640px; }
.tag { display: none; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--soft); font-variant-numeric: tabular-nums; }
.live i { display: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 108, 2, .45); } 70% { box-shadow: 0 0 0 7px rgba(255, 108, 2, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 108, 2, 0); } }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.gs { grid-template-columns: 420px 1fr; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; min-width: 0; }
.card.white { background: var(--white); }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card h3 small { font-weight: 400; color: var(--soft); font-size: 13px; }
.inner { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.stat .k { font-size: 13px; color: var(--soft); }
.stat .v { font-size: 30px; font-weight: 500; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--mute); font-size: 13px; margin-top: 2px; }
.stat .v.orange { color: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 500; color: var(--soft); font-size: 12.5px; padding: 0 10px 8px; white-space: nowrap; }
td { padding: 9px 10px; border-top: 1px solid var(--line2); white-space: nowrap; font-variant-numeric: tabular-nums; }
td.r, th.r { text-align: right; }
tr.flash td { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.up { color: var(--green); } .down { color: var(--red); } .dim { color: var(--soft); }
.pill { font-size: 13px; }
.pill.buy { color: var(--green); } .pill.sell { color: var(--red); }
.scroll { overflow-x: auto; }

/* ticket */
.ticket .side { display: grid; grid-template-columns: 1fr 1fr; background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 12px; }
.ticket .side button { border: 0; background: none; padding: 9px; border-radius: 7px; color: var(--mute); font-weight: 500; }
.ticket .side button.on { background: var(--dark); color: #fff; }
.field { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.field label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--soft); }
.field .row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.field input { border: 0; outline: 0; background: none; font: 500 26px var(--sans); letter-spacing: -.02em; width: 100%; color: var(--ink); min-width: 0; }
.field .tok { font-weight: 600; padding: 6px 10px; border-radius: 8px; background: var(--card); white-space: nowrap; }
.quick { display: flex; gap: 6px; margin: 0 0 12px; }
.quick button { flex: 1; border: 1px solid var(--line); background: var(--white); border-radius: 8px; padding: 6px; font-size: 12.5px; color: var(--mute); }
.quick button:hover { color: var(--ink); }
.lines { font-size: 13.5px; margin: 12px 0; }
.lines div { display: flex; justify-content: space-between; padding: 5px 0; color: var(--mute); }
.lines b { color: var(--ink); font-weight: 500; }
.note { font-size: 12.5px; color: var(--soft); margin-top: 10px; }
.msg { font-size: 13px; margin-top: 10px; padding: 10px 12px; border-radius: 9px; background: var(--white); border: 1px solid var(--line); display: none; }
.msg.on { display: block; }
.msg.err { border-color: #f1c6bb; color: var(--red); }
.msg.ok { border-color: #bfe0cb; color: var(--green); }

/* book ladder */
.ladder { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ladder .lvl { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 8px; background: var(--white); border: 1px solid var(--line); margin-bottom: 6px; font-size: 14px; font-variant-numeric: tabular-nums; position: relative; overflow: hidden; }
.ladder .lvl .bar2 { position: absolute; inset: 0 auto 0 0; opacity: .12; }
.ladder .bid .bar2 { background: var(--green); } .ladder .ask .bar2 { background: var(--red); }
.spreadline { text-align: center; font-size: 13px; color: var(--mute); margin: 8px 0; }
.ageblk { display: inline-flex; gap: 2px; vertical-align: middle; }
.ageblk i { width: 5px; height: 12px; border-radius: 2px; background: var(--line); }
.ageblk i.f { background: var(--accent); }

/* charts */
canvas.chart { width: 100%; height: 260px; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--mute); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

/* forms */
.form { display: grid; gap: 10px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form label { font-size: 12.5px; color: var(--soft); display: grid; gap: 5px; }
.form input, .form select { border: 1px solid var(--line); background: var(--white); border-radius: 8px; padding: 9px 10px; font: 14px var(--sans); color: var(--ink); outline: 0; }
.form input:focus { border-color: var(--accent); }
pre.code { background: var(--dark); color: #f6e9dc; border-radius: 10px; padding: 14px 16px; font: 12.5px/1.6 var(--mono); overflow-x: auto; margin: 0; }
pre.code .c { color: #a38f7d; } pre.code .s { color: #ffb37a; } pre.code .k { color: #ff8a3d; }

.view { display: none; }
.view.on { display: block; }
.foot { border-top: 1px solid var(--line2); margin-top: 60px; }
.foot .in { max-width: 1240px; margin: 0 auto; padding: 22px 24px; display: flex; justify-content: space-between; gap: 16px; color: var(--soft); font-size: 13px; flex-wrap: wrap; }
.foot a { color: var(--mute); text-decoration: none; margin-left: 16px; }

@media (max-width: 980px) {
  .g4 { grid-template-columns: 1fr 1fr; } .g3, .g2, .gs { grid-template-columns: 1fr; }
  .nav { display: none; } .bar .in { gap: 12px; justify-content: space-between; }
  .mnav { display: flex !important; }
}
.mnav { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--white); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
.mnav a { text-decoration: none; font-size: 12.5px; color: var(--mute); padding: 8px 10px; border-radius: 8px; }
.mnav a.on { color: var(--ink); background: var(--card); }
@media (max-width: 600px) { main { padding: 22px 16px 90px; } .head h1 { font-size: 27px; } .g4 { grid-template-columns: 1fr 1fr; } .stat .v { font-size: 24px; } .bar .in { padding: 12px 16px; } }

/* embed mode (the landing's hero shows the live app in a frame) */
body.embed .bar, body.embed .foot, body.embed .mnav, body.embed .head p { display: none !important; }
body.embed main { padding: 22px 26px 0; max-width: none; }
body.embed .head { margin: 0 0 16px; }
body.embed .head h1 { font-size: 26px; }
body.embed { overflow: hidden; }

/* in the landing frame the live block label would sit under the floating card */
body.embed .head .live { display: none !important; }
