@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url(/static/fonts/ibm-plex-sans-cyrillic-400.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url(/static/fonts/ibm-plex-sans-cyrillic-500.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url(/static/fonts/ibm-plex-sans-cyrillic-600.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url(/static/fonts/ibm-plex-sans-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url(/static/fonts/ibm-plex-sans-latin-500.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url(/static/fonts/ibm-plex-sans-latin-600.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: dark;
  --bg: #0b0e11;
  --panel: #14181d;
  --panel-2: #1c2128;
  --panel-3: #262d36;
  --border: #232a33;
  --text: #eaecef;
  --text-2: #b7bdc6;
  --muted: #7d8794;
  --up: #0ecb81;
  --down: #f6465d;
  --up-bg: rgba(14, 203, 129, 0.14);
  --down-bg: rgba(246, 70, 93, 0.14);
  --accent: #fcd535;
  --accent-bg: rgba(252, 213, 53, 0.16);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef0f3;
  --panel: #ffffff;
  --panel-2: #f3f4f6;
  --panel-3: #e6e9ed;
  --border: #e3e6ea;
  --text: #1e2329;
  --text-2: #474d57;
  --muted: #7a828e;
  --up: #0a9f6a;
  --down: #e03a50;
  --up-bg: rgba(14, 203, 129, 0.16);
  --down-bg: rgba(246, 70, 93, 0.13);
  --accent: #f0b90b;
  --accent-bg: rgba(240, 185, 11, 0.2);
  --shadow: 0 12px 32px rgba(30, 35, 41, 0.16);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { overflow-x: hidden; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.up { color: var(--up); }
.down { color: var(--down); }
.grow { flex: 1; min-width: 0; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 60px;
  padding: 0 16px;
  flex: none;
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.brand svg { width: 30px; height: 30px; }
.wordmark { font-size: 19px; font-weight: 400; color: var(--text-2); letter-spacing: -0.03em; }
.wordmark b { font-weight: 600; color: var(--text); }

.token-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px 0 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.token-btn:hover { border-color: var(--panel-3); background: var(--panel-2); }
#market-logo { display: inline-flex; }
.caret { width: 12px; height: 12px; color: var(--muted); flex: none; }

.ticker { display: flex; gap: 32px; }
.ticker div { display: flex; flex-direction: column; line-height: 1.25; }
.ticker span { color: var(--muted); font-size: 12px; }
.ticker b { font-size: 14px; font-weight: 500; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

.select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 8px 0 12px;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 500;
  transition: border-color 0.15s;
}
.select:hover { border-color: var(--panel-3); }

/* ---------- token icon ---------- */

.tok {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--s, 24px);
  height: var(--s, 24px);
  border-radius: 50%;
  overflow: hidden;
  background: hsl(var(--h, 40) 28% 30%);
  color: #fff;
  font-size: calc(var(--s, 24px) * 0.45);
  font-weight: 600;
}
.tok img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
.tok.ok b { display: none; }

/* ---------- layout ---------- */

main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px 0px;
  gap: 8px;
  padding: 0 8px 8px;
  overflow: hidden;
  transition: grid-template-columns 0.26s var(--ease);
}
main.with-level { grid-template-columns: minmax(0, 1fr) 380px 440px; }

.panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 48px;
  padding: 0 12px 0 16px;
  flex: none;
}
.chart-panel .panel-head { padding-left: 12px; }
.panel-title { font-size: 15px; font-weight: 600; }

.panel-sub { display: flex; align-items: center; padding: 0 12px 8px 16px; flex: none; }

/* segmented control */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--panel-2);
  border-radius: 8px;
}
.seg button {
  height: 28px;
  padding: 0 12px;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel-3); color: var(--text); }
.seg.small button { height: 24px; padding: 0 10px; font-size: 12px; }

.pill-btn {
  height: 28px;
  padding: 0 12px;
  background: var(--accent-bg);
  border: 0;
  border-radius: 8px;
  color: var(--accent);
  font-weight: 500;
}
.pill-btn[hidden] { display: none; }

.chart-legend { position: absolute; z-index: 2; left: 14px; top: 6px; pointer-events: none; }
.legend { display: flex; align-items: center; gap: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; font-size: 12px; }
.legend b { margin-left: 4px; color: var(--text); font-weight: 500; }
.lg-time { color: var(--text-2); }
.key { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; }
.key.up { background: var(--up); }
.key.down { background: var(--down); }
.legend b.up { color: var(--up); }
.legend b.down { color: var(--down); }

/* ---------- chart ---------- */

.chart-wrap { position: relative; flex: 1; min-height: 0; }
#chart { position: absolute; inset: 0; }

.price-tag {
  position: absolute;
  right: 0;
  width: 70px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 4px 0 0 4px;
  background: var(--up);
  color: #0b0e11;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
}
.price-tag.down { background: var(--down); color: #fff; }
.price-tag[hidden] { display: none; }

.msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 85%, transparent);
}
.msg[hidden] { display: none; }

/* ---------- order book ---------- */

.cols {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr 0.85fr;
  gap: 4px;
  padding: 0 16px;
}
.cols > span:not(:first-child) { text-align: right; }
.head { height: 26px; align-items: center; color: var(--muted); font-size: 12px; flex: none; }

.rows { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; font-variant-numeric: tabular-nums; }
.rows.asks { justify-content: flex-end; }

.row { position: relative; flex: none; height: 21px; line-height: 21px; cursor: pointer; user-select: none; }
.row::before {
  content: "";
  position: absolute;
  top: 1px;
  right: 0;
  bottom: 1px;
  width: var(--w, 0%);
  pointer-events: none;
}
.row.ask::before { background: var(--down-bg); }
.row.bid::before { background: var(--up-bg); }
.row:hover { background: var(--panel-2); }
.row.sel { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
.row > span { position: relative; }
.row.ask .price { color: var(--down); }
.row.bid .price { color: var(--up); }

.prem { z-index: 0; color: var(--accent); }
.prem::before {
  content: "";
  position: absolute;
  top: 4px;
  right: -4px;
  bottom: 4px;
  width: var(--p, 0%);
  background: var(--accent-bg);
  border-radius: 2px 0 0 2px;
  z-index: -1;
}
.prem.none { color: var(--muted); }
.prem.none::before { display: none; }

.mid {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex: none;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.mid b { font-size: 18px; font-weight: 600; }
.mid span { color: var(--muted); font-size: 12px; }
.mid.up b { color: var(--up); }
.mid.down b { color: var(--down); }

.book-foot {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: none;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
.book-foot b { margin-left: 6px; color: var(--accent); font-weight: 500; }
.book-foot .age { margin-left: auto; }
.book-foot .age.stale { color: var(--down); }

/* ---------- level panel ---------- */

.level-panel {
  margin-left: -8px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(16px);
  transition: margin 0.26s var(--ease), opacity 0.18s ease, transform 0.26s var(--ease), visibility 0s linear 0.26s;
}
.with-level .level-panel {
  margin-left: 0;
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: margin 0.26s var(--ease), opacity 0.22s ease, transform 0.26s var(--ease), visibility 0s;
}

.level-inner { display: flex; flex-direction: column; width: 438px; height: 100%; }
.level-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 16px 16px; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.card { padding: 10px 12px; background: var(--panel-2); border-radius: 10px; }
.card span { display: block; color: var(--muted); font-size: 12px; }
.card b { display: block; margin-top: 2px; font-size: 15px; font-weight: 600; }
.card small { color: var(--muted); font-size: 12px; }
.card.premium b { color: var(--accent); }

.share { display: flex; height: 4px; margin-bottom: 8px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.share i { display: block; background: var(--accent); }

.note { padding: 8px 12px; margin-bottom: 10px; color: var(--muted); background: var(--panel-2); border-radius: 10px; }

.order { padding: 12px 0; border-top: 1px solid var(--border); }
.order .top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.order a { color: var(--text); text-decoration: none; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; word-break: break-all; }
.order a:hover { color: var(--accent); text-decoration: underline; }
.order .meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 4px; color: var(--muted); font-size: 12px; }
.order .meta b { color: var(--text); font-weight: 500; }
.order .meta i { font-style: normal; margin-left: 8px; }

.badge { flex: none; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; }
.badge.premium { color: var(--accent); background: var(--accent-bg); }
.badge.standard { color: var(--muted); background: var(--panel-2); }
.loading { color: var(--muted); }

/* ---------- popup ---------- */

.popup {
  position: fixed;
  z-index: 20;
  display: flex;
  flex-direction: column;
  max-height: 440px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: pop 0.14s var(--ease);
}
.popup[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }

.search { position: relative; margin: 12px 12px 8px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); }

.popup .seg { margin: 0 12px 8px; align-self: flex-start; }

.list {
  position: relative;
  overflow: auto;
  padding: 8px 6px;
  /* items fade out at the edges instead of being cut off against the header */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
}
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 10px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 500;
}
.item:hover, .item.hl { background: var(--panel-2); }
.item.on { color: var(--accent); }
.empty { padding: 16px; color: var(--muted); text-align: center; }

.step-list .item { height: 34px; }

/* ---------- scrollbars ---------- */

* { scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }

/* ---------- narrow screens ---------- */

@media (max-width: 1280px) {
  main, main.with-level { grid-template-columns: minmax(0, 1fr) 380px; }
  .level-panel {
    position: fixed;
    z-index: 10;
    top: 68px;
    right: 8px;
    bottom: 8px;
    width: min(440px, calc(100vw - 16px));
    margin: 0;
    transform: translateX(calc(100% + 16px));
    box-shadow: var(--shadow);
  }
  .with-level .level-panel { transform: none; }
  .level-inner { width: 100%; }
}

@media (max-width: 900px) {
  body { height: auto; }
  main, main.with-level { grid-template-columns: 1fr; }
  .chart-wrap { height: 420px; flex: none; }
  .ticker { display: none; }
}


/* ---------- calculator ---------- */

.icon-btn.active { background: var(--accent-bg); color: var(--accent); }

.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; height: 34px; }
.seg button.buy.on { background: var(--up-bg); color: var(--up); }
.seg button.sell.on { background: var(--down-bg); color: var(--down); }

.field { margin-top: 16px; }
.field .label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--muted); }

.input-row { display: flex; align-items: center; gap: 8px; padding: 0 6px 0 14px; background: var(--panel-2); border: 1px solid transparent; border-radius: 10px; transition: border-color 0.15s; }
.input-row:focus-within { border-color: var(--accent); }
.input-row input { flex: 1; min-width: 0; height: 44px; background: none; border: 0; outline: none; font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
.input-row input::placeholder { color: var(--muted); }

.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick button { height: 26px; padding: 0 10px; background: var(--panel-2); border: 0; border-radius: 8px; color: var(--text-2); font-size: 12px; transition: background 0.15s; }
.quick button:hover { background: var(--panel-3); }

.lev-value { display: inline-flex; align-items: center; gap: 2px; padding: 0 10px; height: 28px; background: var(--panel-2); border-radius: 8px; color: var(--text); }
.lev-value input { width: 36px; background: none; border: 0; outline: none; text-align: right; font-weight: 500; }
.lev-value b { font-weight: 500; color: var(--muted); }

input[type="range"] { width: 100%; height: 20px; margin: 0; background: none; -webkit-appearance: none; appearance: none; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--panel-3); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; background: var(--accent); border: 3px solid var(--panel); border-radius: 50%; box-shadow: 0 0 0 1px var(--accent); }
input[type="range"]::-moz-range-track { height: 4px; background: var(--panel-3); border-radius: 2px; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; background: var(--accent); border: 3px solid var(--panel); border-radius: 50%; }

.result { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.hint { color: var(--muted); }
.res-main span, .res-grid span, .prem-head span { display: block; color: var(--muted); font-size: 12px; }
.res-main b { display: block; margin-top: 2px; font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.res-main small { color: var(--muted); font-size: 12px; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; margin-top: 16px; }
.res-grid b { display: block; margin-top: 1px; font-size: 14px; font-weight: 500; }
.res-grid small { color: var(--muted); font-size: 12px; }
.prem-box { margin-top: 18px; padding: 14px; background: var(--panel-2); border-radius: 12px; }
.prem-head { display: flex; align-items: baseline; justify-content: space-between; }
.prem-head b { font-size: 22px; font-weight: 600; color: var(--accent); }
.prem-box .share { margin: 10px 0; background: var(--panel-3); }
.prem-split { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.prem-split b { margin-left: 6px; color: var(--text); font-weight: 500; }
.warn { margin-top: 12px; padding: 8px 12px; color: var(--down); background: var(--down-bg); border-radius: 10px; font-size: 12px; }
.warn.soft { color: var(--muted); background: var(--panel-2); }

/* ---------- notice ---------- */

.toast {
  position: fixed;
  z-index: 30;
  left: 16px;
  bottom: 16px;
  max-width: 420px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--down);
  border-radius: 10px;
  box-shadow: var(--shadow);
  animation: pop 0.2s var(--ease);
}
