/* Шрифти лежать поруч зі сторінкою, щоб платформа не залежала від сторонніх сервісів. */
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 200 900; font-display: swap; src: url("../fonts/unbounded-cyrillic-wght-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 200 900; font-display: swap; src: url("../fonts/unbounded-latin-wght-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("../fonts/manrope-cyrillic-wght-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("../fonts/manrope-latin-wght-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap; src: url("../fonts/jetbrains-mono-cyrillic-wght-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap; src: url("../fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Ті самі кольори й шрифти, що на Prime і сторінці статистики. */
:root {
  color-scheme: dark;
  --bg: #131722;
  --panel: #1a1f2d;
  --line: #2a3042;
  --ink: #eceef4;
  --muted: #8a91a6;
  --gold: #ffcc00;
  --gain: #35d688;
  --loss: #f0604d;
  --display: "Unbounded", "Manrope", system-ui, sans-serif;
  --body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { background: var(--bg); }
body { margin: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden;
  background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 14px; line-height: 1.4; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Шапка */
.bar { position: relative; z-index: 5; display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 10px 18px;
  padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { flex: none; margin-right: 6px; font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: -.005em; color: var(--gold); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--ink); }

.pill { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--ink); font-weight: 600; font-size: 13px; white-space: nowrap; transition: border-color .15s, color .15s; }
.pill:hover, .pill[aria-expanded="true"] { border-color: var(--gold); }
.pill svg { width: 12px; height: 12px; color: var(--muted); transition: transform .15s; }
.pill[aria-expanded="true"] svg { color: var(--gold); }
.pair-btn b { font-family: var(--display); font-weight: 700; font-size: 13px; }
.pair-btn span { color: var(--muted); font-weight: 600; }
.pair-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.ind-btn { margin-left: auto; }
.ind-btn svg { width: 15px; height: 15px; color: var(--gold); }

.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .03); }
.seg button { border: 0; border-radius: 999px; min-height: 28px; padding: 0 12px; background: transparent; color: var(--muted); font: 700 12px var(--body); white-space: nowrap; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--gold); color: #131722; }

/* Бічна панель розділів */
.shell { display: grid; grid-template-columns: 212px minmax(0, 1fr); min-height: 0; }
.side { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 14px 12px; border-right: 1px solid var(--line); background: var(--bg); overflow-y: auto; }
.side-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 14px; border-radius: 12px; color: var(--muted); font-weight: 600; font-size: 14.5px; text-decoration: none; white-space: nowrap; transition: background .15s, color .15s; }
.side-item svg { flex: none; width: 20px; height: 20px; }
.side-item:hover { background: rgba(255, 255, 255, .035); color: var(--ink); }
.side-item[aria-current="page"] { background: #1e2536; color: var(--ink); font-weight: 700; }
.side-item[aria-current="page"] svg { color: var(--gold); }
@media (min-width: 761px) and (max-width: 1023px) {
  .shell { grid-template-columns: 64px minmax(0, 1fr); }
  .side { padding: 12px 8px; }
  .side-item { justify-content: center; padding: 0; }
  .side-item span { display: none; }
}

/* Поле графіка */
.stage { position: relative; min-height: 0; overflow: hidden;
  background: radial-gradient(ellipse 52% 46% at 16% 0%, rgba(255, 204, 0, .07), transparent 70%), var(--bg); }
.chart { position: absolute; inset: 0; }

.legend { position: absolute; z-index: 3; top: 14px; left: 18px; right: 84px; pointer-events: none; }
.lg-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.lg-price { font-family: var(--mono); font-weight: 700; font-size: clamp(22px, 2.4vw, 30px); line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.lg-day { font-family: var(--mono); font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lg-day small { margin-left: 6px; font-family: var(--body); font-weight: 600; font-size: 12px; color: var(--muted); }
.up { color: var(--gain); }
.down { color: var(--loss); }

/* Завантаження й помилки */
.state { position: absolute; inset: 0; z-index: 4; display: grid; align-content: center; justify-items: center; gap: 16px; padding: 24px; text-align: center; background: rgba(19, 23, 34, .72); }
.state p { margin: 0; font-family: var(--display); font-weight: 700; font-size: 16px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-gold { height: 44px; padding: 0 24px; border: 0; border-radius: 999px; background: var(--gold); color: #131722; font-weight: 700; font-size: 14px; transition: transform .15s, box-shadow .15s; }
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 10px 34px rgba(255, 204, 0, .22); }

/* Випадні вікна: вибір пари й індикатори */
.backdrop { position: fixed; inset: 0; z-index: 20; }
.pop { position: fixed; z-index: 21; width: 380px; max-width: calc(100vw - 24px); max-height: min(580px, calc(100dvh - 84px)); display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: 0 24px 70px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 204, 0, .04); }
.pop-head { flex: none; padding: 12px 12px 8px; }
.search { width: 100%; height: 42px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font-weight: 600; font-size: 14px; outline: 0; -webkit-appearance: none; appearance: none; }
.search::placeholder { color: var(--muted); font-weight: 500; }
.search:focus { border-color: var(--gold); }
.search::-webkit-search-cancel-button { -webkit-appearance: none; }
.pairs, .inds { flex: 1 1 auto; min-height: 0; margin: 0; padding: 0 6px 8px; list-style: none; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.pairs button { display: grid; grid-template-columns: minmax(0, 1fr) auto 76px; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; text-align: left; }
.pairs button:hover, .pairs button.is-first { background: rgba(255, 255, 255, .045); }
.pairs button[aria-current="true"] { background: rgba(255, 204, 0, .09); }
.pairs .p-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 14px; }
.pairs .p-name small { margin-left: 5px; font-weight: 600; font-size: 12px; color: var(--muted); }
.pairs .p-price, .pairs .p-chg { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pairs .p-price { font-weight: 500; }
.pairs .p-chg { font-weight: 600; }
.pop-note { margin: 0; padding: 22px 16px 26px; text-align: center; color: var(--muted); font-size: 13px; }
.pop-note .spinner { margin: 0 auto; }

.pop-ind { width: 320px; }
.inds { padding-top: 8px; }
.inds:empty { display: none; }
.inds button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 46px; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; font-weight: 700; font-size: 14px; text-align: left; }
.inds button:hover { background: rgba(255, 255, 255, .045); }
.inds i { flex: none; position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--line); transition: background .15s; }
.inds i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.inds button[aria-pressed="true"] i { background: var(--gold); }
.inds button[aria-pressed="true"] i::after { transform: translateX(16px); background: #131722; }
.pop-empty { margin: 0; padding: 26px 20px; text-align: center; color: var(--muted); font-size: 13.5px; font-weight: 600; }

/* Вузькі екрани: шапка у два ряди, вікна виїжджають знизу */
@media (max-width: 760px) {
  .bar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 8px; padding: 9px 12px 8px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .brand { margin-right: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  .ind-btn { order: 3; margin-left: 0; padding: 0 11px; }
  .ind-btn span { display: none; }
  .pair-btn { order: 2; padding: 0 12px; }
  .seg { order: 5; grid-column: 1 / -1; display: flex; }
  .seg button { flex: 1 1 0; min-height: 32px; padding: 0 2px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .side { order: 2; flex-direction: row; gap: 6px; padding: 6px 12px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); overflow: visible; }
  .side-item { flex: 1 1 0; justify-content: center; gap: 8px; min-height: 40px; padding: 0 8px; font-size: 13px; }
  .legend { top: 10px; left: 12px; right: 84px; }
  .lg-day { font-size: 12px; }
  .backdrop { background: rgba(8, 10, 16, .6); }
  .pop, .pop-ind { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0; width: auto; max-width: none; max-height: 82dvh; border-radius: 22px 22px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
  .pop-head { padding: 14px 12px 8px; }
  .search { height: 46px; font-size: 16px; }
  .pairs button { min-height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
