/* Одна колонка шириной с телефон: шапка, прокручиваемый экран, нижние вкладки.
   Углы квадратные, цвет приходит только от редкости скина и шкалы износа.
   Палитра и фирменный стиль временные — заменим, когда они будут выбраны. */
:root {
  color-scheme: dark;
  --bg: #0e1117; --surface: #161a23; --surface2: #1e2330; --line: #2a3040;
  --fg: #eef0f5; --muted: #8d95a8; --ink: #10131a;
  --up: #4fd08a; --down: #ff6b6b; --warn: #f2b63c;
  --r-mil: #4b69ff; --r-res: #8847ff; --r-cla: #d32ce6; --r-cov: #eb4b4b; --r-gold: #e4ae39;
  --w-fn: #4fd08a; --w-mw: #a5d64a; --w-ft: #f0c33c; --w-ww: #f08a3c; --w-bs: #e2504c;
  --display: "Geologica", "Golos Text", system-ui, sans-serif;
  --body: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --px: polygon(0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px));
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; line-height: 1.45; display: flex; justify-content: center; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.app { width: 100%; max-width: 430px; height: 100%; display: flex; flex-direction: column; background: var(--bg); padding-top: env(safe-area-inset-top, 0px); }
@media (min-width: 520px) { .app { border-inline: 1px solid var(--line); } }

.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.logo { display: grid; grid-template-columns: repeat(3, 6px); grid-auto-rows: 6px; gap: 1px; flex: none; }
.logo i { display: block; }
.brand { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .04em; text-transform: uppercase; line-height: 1.1; min-width: 0; }
.brand small { display: block; font-family: var(--body); font-weight: 500; font-size: 10px; letter-spacing: .08em; color: var(--muted); }
.seg { margin-left: auto; display: flex; border: 1px solid var(--line); flex: none; }
.seg button { padding: 5px 9px; font-size: 13px; font-weight: 600; color: var(--muted); min-width: 32px; text-align: center; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--ink); }

.view { flex: 1; overflow-y: auto; padding: 18px 16px 28px; display: flex; flex-direction: column; gap: 18px; min-height: 0; }
.view > * { flex-shrink: 0; } /* иначе блоки с прокруткой внутри (фильтры) сжимаются до нуля */
.tabs { display: flex; border-top: 1px solid var(--line); background: var(--surface); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabs button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 2px 10px; font-size: 10px; font-weight: 600; color: var(--muted); }
.tabs button[aria-current="page"] { color: var(--fg); }
.tabs svg { width: 20px; height: 20px; fill: currentColor; }

h1 { font-family: var(--display); font-weight: 700; font-size: 28px; line-height: 1.1; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
h2 { font-family: var(--display); font-weight: 600; font-size: 18px; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }

.btn { display: block; width: 100%; padding: 14px 16px; text-align: center; text-decoration: none; font-weight: 700; font-size: 15px; background: var(--fg); color: var(--ink); clip-path: var(--px); }
.btn.ghost { background: var(--surface2); color: var(--fg); }
.btn:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--r-mil); }
.btn:active { transform: translateY(1px); }
.field { width: 100%; padding: 13px 12px; font: inherit; font-size: 15px; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 0; }
.field::placeholder { color: var(--muted); }
.err { color: var(--down); font-size: 13px; }
details { border: 1px solid var(--line); padding: 10px 12px; font-size: 13px; }
summary { cursor: pointer; font-weight: 600; }
details ol { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }

/* Картинка скина на подложке цвета его редкости */
.art { position: relative; clip-path: var(--px); background: radial-gradient(ellipse at 50% 60%, color-mix(in srgb, var(--rar, var(--muted)) 26%, var(--surface)), var(--surface) 72%); }
.art img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; padding: 6%; }
.art.hero img { aspect-ratio: 16 / 9; padding: 3%; }
.art .rar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--rar, var(--muted)); }
.art .badge { position: absolute; top: 6px; padding: 2px 6px; font-size: 11px; font-weight: 700; line-height: 1.3; background: rgba(14, 17, 23, .78); color: var(--fg); }
.art .badge.wear { left: 6px; }
.art .badge.float { right: 6px; font-weight: 500; }
.tag { display: inline-block; padding: 3px 7px; font-size: 11px; font-weight: 700; letter-spacing: .04em; background: var(--surface2); white-space: nowrap; }
.tag.st { color: #ff9a4a; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
.chips button { flex: none; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); }
.chips button[aria-pressed="true"] { background: var(--fg); color: var(--ink); border-color: var(--fg); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cell { display: flex; flex-direction: column; gap: 6px; background: var(--surface); padding: 6px 6px 10px; min-width: 0; }
.cell .n { padding-inline: 4px; min-width: 0; }
.cell .w { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .s { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .p { font-family: var(--display); font-weight: 600; font-size: 16px; padding-inline: 4px; }
.cell .p.none { font-family: var(--body); font-weight: 500; font-size: 13px; color: var(--muted); }

.profile { display: flex; align-items: center; gap: 12px; }
.profile .avatar { width: 52px; height: 52px; flex: none; object-fit: cover; background: var(--surface2); clip-path: var(--px); }
.profile .who { min-width: 0; flex: 1; }
.profile h2 { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile .level { flex: none; display: flex; flex-direction: column; align-items: center; padding: 5px 10px; border: 1px solid var(--line); line-height: 1.15; }
.profile .level span { font-size: 17px; font-weight: 500; }
.profile .level small { font-size: 9px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.back { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: var(--muted); padding: 4px 0; align-self: flex-start; }
.panel { background: var(--surface); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.price { font-family: var(--display); font-weight: 700; font-size: clamp(24px, 7.4vw, 32px); line-height: 1.08; font-variant-numeric: tabular-nums; }
.conf { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.conf i { flex: none; width: 8px; height: 8px; margin-top: 6px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 7px 0; border-top: 1px solid var(--line); }
.kv span:first-child { color: var(--muted); flex: none; }
.kv span:last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.kv.sub { font-size: 13px; padding: 6px 0; }
.note { border-left: 3px solid var(--warn); background: var(--surface2); padding: 10px 12px; font-size: 13px; }

.fbar { position: relative; height: 14px; margin-top: 14px; }
.fbar .segm { position: absolute; top: 0; bottom: 0; }
.fbar .dim { position: absolute; top: 0; bottom: 0; background: rgba(14, 17, 23, .82); }
.fbar .mark { position: absolute; top: -9px; bottom: -4px; width: 3px; margin-left: -1.5px; background: var(--fg); box-shadow: 0 0 0 2px var(--bg); }
.fbar .mark::before { content: ""; position: absolute; top: 0; left: -3px; width: 9px; height: 4px; background: var(--fg); }
.flab { position: relative; height: 14px; margin-top: 6px; font-size: 10px; font-weight: 700; color: var(--muted); }
.flab span { position: absolute; transform: translateX(-50%); }
.zoom { position: relative; height: 8px; background: var(--surface2); margin-top: 10px; }
.zoom .mark { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; background: var(--fg); }
.chart { display: block; width: 100%; height: 96px; }

.cardpreview { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; background: var(--surface); }
.hist { display: flex; gap: 12px; align-items: center; background: var(--surface); padding: 8px; width: 100%; }
.hist .art { width: 84px; flex: none; }
.hist .t { min-width: 0; flex: 1; }
.addcell { align-items: center; justify-content: center; gap: 8px; min-height: 170px; background: none; border: 2px dashed var(--line); color: var(--muted); font-weight: 600; font-size: 13px; }
.addcell .plus { font-family: var(--display); font-size: 34px; line-height: 1; color: var(--fg); }
.out.win { background: color-mix(in srgb, var(--up) 16%, var(--surface)); }
.out.lose { background: color-mix(in srgb, var(--down) 14%, var(--surface)); }
.out .delta { padding-inline: 4px; font-size: 13px; font-weight: 500; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 4px; background: var(--surface); padding: 12px; min-width: 0; }
.stat .mono { font-size: 17px; font-weight: 500; overflow-wrap: anywhere; }
.formrow { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field:disabled { opacity: .55; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; padding: 10px 0; flex: none; }
.check input { width: 18px; height: 18px; accent-color: var(--fg); }
.link { font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
div.hist { cursor: default; }
.cell.out { width: 100%; }
.site { display: flex; align-items: center; gap: 12px; background: var(--surface); padding: 14px; text-decoration: none; }
.site .t { min-width: 0; flex: 1; }
.site .go { flex: none; font-size: 18px; color: var(--muted); }
.load { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; padding-top: 40px; }
.bar { width: 100%; height: 10px; background: var(--surface2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 40%; background: var(--fg); animation: run 1s steps(8) infinite; }
@keyframes run { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { .bar i { animation: none; width: 100%; } }
.foot { font-size: 11px; color: var(--muted); text-align: center; }

/* Выгодные крафты: строка найденного контракта */
.deal { display: flex; flex-direction: column; gap: 8px; width: 100%; background: var(--surface); padding: 10px 12px 10px 10px; border-left: 3px solid var(--line); text-align: left; }
.deal .dhead { display: flex; align-items: center; gap: 10px; min-width: 0; }
.deal .pic { position: relative; flex: none; width: 60px; height: 45px; }
.deal .pic img { width: 100%; height: 100%; object-fit: contain; }
.deal .pic .x { position: absolute; right: -4px; bottom: -4px; padding: 1px 4px; font-size: 11px; font-weight: 700; background: var(--surface2); }
.deal .t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.deal .t .s { font-weight: 600; font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.deal .w { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal .roi { flex: none; font-family: var(--display); font-size: 20px; font-weight: 600; }
.deal .dfoot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.deal .warn { color: var(--warn); }
