:root {
  --bg: #0b0b0e; --card: #16161b; --card2: #1d1d24; --line: #26262f; --text: #f1f1f5; --muted: #8e8e9b; --dim: #62626e;
  --accent: #5b7dff; --accent-soft: rgba(91,125,255,.16); --pos: #34d17a; --pos-soft: rgba(52,209,122,.14); --warn: #f2b341; --warn-soft: rgba(242,179,65,.14); --neg: #ff6363; --neg-soft: rgba(255,99,99,.14);
  --r: 16px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#app { padding: calc(var(--safe-t) + 8px) 16px calc(84px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.boot { min-height: 70vh; display: grid; place-items: center; }
.spin { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } * { transition: none !important; } }

/* шапка */
.top { display: flex; align-items: center; gap: 10px; padding: 10px 0 12px; position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg) 78%, transparent); margin: 0 -16px; padding-left: 16px; padding-right: 16px; padding-top: calc(var(--safe-t) + 10px); margin-top: calc(-1 * var(--safe-t) - 8px); }
.top h1 { font-size: 28px; line-height: 1.1; margin: 0; font-weight: 750; letter-spacing: -.02em; flex: 1; min-width: 0; }
.top .sub { color: var(--muted); font-size: 13px; }
.back { display: flex; align-items: center; gap: 2px; background: none; border: 0; color: var(--accent); padding: 6px 6px 6px 0; font-size: 16px; }
.back svg { width: 24px; height: 24px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--card); display: grid; place-items: center; color: var(--text); }
.icon-btn.on { color: var(--warn); }
.icon-btn:active, .btn:active, .card:active, .seg button:active { transform: scale(.97); }

/* статус */
.status { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pos); flex: none; box-shadow: 0 0 0 4px var(--pos-soft); }
.dot.off { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); } .dot.err { background: var(--neg); box-shadow: 0 0 0 4px var(--neg-soft); }
.status b { display: block; font-size: 15px; } .status small { color: var(--muted); font-size: 12.5px; }
.status .grow { flex: 1; min-width: 0; }

/* сегменты */
.seg { display: flex; gap: 4px; background: var(--card); border-radius: 12px; padding: 3px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; border: 0; background: none; color: var(--muted); padding: 8px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.seg button.on { background: var(--card2); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.seg button i { font-style: normal; color: var(--dim); font-weight: 500; margin-left: 4px; }

.search { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px; padding: 0 12px; margin-bottom: 12px; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 11px 0; font-size: 16px; color: var(--text); }
.search svg { width: 18px; height: 18px; }

/* карточки объявлений */
.list { display: flex; flex-direction: column; gap: 10px; }
.card { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; background: var(--card); border-radius: var(--r); padding: 10px; border: 0; text-align: left; width: 100%; transition: transform .12s; }
.card .ph { width: 84px; height: 84px; border-radius: 12px; background: var(--card2) center/cover no-repeat; position: relative; }
.card .ph .new { position: absolute; top: 6px; left: 6px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.card .t { font-weight: 600; font-size: 14.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .row { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.price { font-weight: 750; font-size: 17px; font-variant-numeric: tabular-nums; }
.gain { font-weight: 700; font-size: 13px; color: var(--pos); font-variant-numeric: tabular-nums; }
.gain.neg { color: var(--neg); }
.meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 7px; background: var(--card2); color: var(--muted); }
.chip.pos { background: var(--pos-soft); color: var(--pos); } .chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.neg { background: var(--neg-soft); color: var(--neg); } .chip.acc { background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty svg { width: 34px; height: 34px; color: var(--dim); margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* панели */
.panel { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.panel h2 svg { width: 16px; height: 16px; }
.kv { display: flex; flex-direction: column; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.kv > div:first-child { border-top: 0; padding-top: 0; }
.kv span:first-child { color: var(--muted); } .kv span:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tile { background: var(--card); border-radius: var(--r); padding: 12px 14px; }
.tile small { color: var(--muted); font-size: 12.5px; display: block; }
.tile b { font-size: 21px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile b.pos { color: var(--pos); }

/* детально */
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: 0 0 86%; height: 300px; object-fit: cover; border-radius: var(--r); scroll-snap-align: center; background: var(--card); }
.gallery img:only-child { flex-basis: 100%; }
.d-title { font-size: 19px; font-weight: 700; line-height: 1.3; margin: 0 0 6px; }
.d-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.d-price .price { font-size: 26px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 14px; border-radius: 13px; border: 0; background: var(--card2); color: var(--text); font-weight: 650; font-size: 15px; text-decoration: none; transition: transform .12s; }
.btn svg { width: 19px; height: 19px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.wide { grid-column: 1 / -1; width: 100%; }
.btn.ghost { background: none; color: var(--accent); min-height: 36px; padding: 6px 0; justify-content: flex-start; }
.btn.danger { color: var(--neg); }
.btn[disabled] { opacity: .45; }
.offer { border-radius: var(--r); padding: 14px; margin-bottom: 12px; background: var(--accent-soft); }
.offer.take { background: var(--pos-soft); } .offer.skip { background: var(--neg-soft); }
.offer b.big { font-size: 22px; display: block; margin: 2px 0; font-variant-numeric: tabular-nums; }
.offer .msg { background: rgba(0,0,0,.28); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-top: 10px; user-select: text; -webkit-user-select: text; }
.offer .row { display: flex; gap: 8px; margin-top: 8px; }
.offer .row .btn { flex: 1; min-height: 40px; font-size: 14px; }
.alert { border-radius: var(--r); padding: 12px 14px; margin-bottom: 12px; background: var(--neg-soft); color: var(--text); font-size: 14px; }
.alert b { color: var(--neg); display: block; margin-bottom: 2px; }
.alert.warn { background: var(--warn-soft); } .alert.warn b { color: var(--warn); }
.rows { display: flex; flex-direction: column; gap: 8px; }
.r { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
.r::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); margin-top: 6px; flex: none; }
.r.pos::before { background: var(--pos); } .r.warn::before { background: var(--warn); } .r.neg::before { background: var(--neg); }
.r.neg { color: #ffb4b4; }
.r small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.r .grow { flex: 1; min-width: 0; }
.r .ph-link { color: var(--accent); font-size: 12.5px; background: none; border: 0; padding: 0; white-space: nowrap; }
.desc { white-space: pre-wrap; font-size: 14.5px; color: #d6d6de; user-select: text; -webkit-user-select: text; max-height: 9.5em; overflow: hidden; position: relative; }
.desc.open { max-height: none; }
.ask { color: var(--muted); font-size: 13.5px; margin-top: 10px; }
.ask ul { margin: 4px 0 0; padding-left: 18px; color: var(--text); }
.bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; width: 40%; background: var(--accent); animation: ld 1.2s ease-in-out infinite; }
@keyframes ld { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* формы */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input, .textarea, .select { width: 100%; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 16px; outline: none; color: var(--text); }
.input:focus, .textarea:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 92px; }
.inline { display: flex; gap: 8px; } .inline .input { flex: 1; min-width: 0; } .inline .btn { flex: none; }
.picker { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 1.5px dashed var(--line); border-radius: var(--r); padding: 22px 12px; color: var(--muted); background: none; width: 100%; text-align: center; }
.picker b { color: var(--text); }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; background: var(--card2) center/cover; }
.thumb button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: #000; color: #fff; display: grid; place-items: center; }
.thumb button svg { width: 14px; height: 14px; }
.verdict { border-radius: var(--r); padding: 12px 14px; margin-bottom: 12px; background: var(--card2); }
.verdict.pos { background: var(--pos-soft); } .verdict.warn { background: var(--warn-soft); } .verdict.neg { background: var(--neg-soft); }
.verdict b { display: block; font-size: 16px; }
.sub-h { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 0 8px; font-weight: 650; }

/* чат */
.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 18px; font-size: 15px; line-height: 1.45; user-select: text; -webkit-user-select: text; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.msg.ai { align-self: flex-start; background: var(--card); border-bottom-left-radius: 6px; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin: 0; }
.msg .copy { display: block; margin-top: 6px; color: var(--accent); background: none; border: 0; padding: 0; font-size: 13px; }
.prompts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.prompts button { text-align: left; background: var(--card); border: 0; border-radius: 14px; padding: 12px 14px; font-size: 14.5px; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(64px + var(--safe-b)); padding: 8px 12px; background: rgba(11,11,14,.92); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); z-index: 9; }
.composer .textarea { min-height: 42px; max-height: 120px; border-radius: 21px; padding: 10px 14px; resize: none; }
.composer .send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.composer .send[disabled] { opacity: .4; }
.ctx-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 600; margin-bottom: 12px; border: 0; max-width: 100%; }
.ctx-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-chip svg { width: 14px; height: 14px; }
.chat-pad { height: 70px; }

/* сделки */
.item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; padding-top: 2px; }
.item .grow { flex: 1; min-width: 0; }
.item b { display: block; font-weight: 600; font-size: 15px; }
.item small { color: var(--muted); font-size: 12.5px; }
.item .num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.item .num small { display: block; font-weight: 500; }
.ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--card2); flex: none; }
.ico svg { width: 19px; height: 19px; }
.ico.pos { background: var(--pos-soft); color: var(--pos); } .ico.warn { background: var(--warn-soft); color: var(--warn); } .ico.neg { background: var(--neg-soft); color: var(--neg); } .ico.acc { background: var(--accent-soft); color: var(--accent); }
.x-btn { border: 0; background: none; color: var(--dim); padding: 6px; }
.x-btn svg { width: 18px; height: 18px; }

/* таббар */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: rgba(14,14,18,.92); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); z-index: 10; }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; color: var(--dim); font-size: 10.5px; font-weight: 600; padding: 4px 0; }
.tabs button.on { color: var(--accent); }
.tabs svg { width: 25px; height: 25px; }
.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: #2a2a33; color: var(--text); padding: 10px 16px; border-radius: 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.pair { text-align: center; padding: 60px 8px 20px; }
.pair img { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 14px; }
.pair h1 { font-size: 24px; margin: 0 0 8px; }
.pair p { color: var(--muted); margin: 0 0 18px; }
.steps { text-align: left; background: var(--card); border-radius: var(--r); padding: 14px 14px 14px 34px; margin: 0 0 16px; color: #d6d6de; font-size: 14.5px; }
.steps li { margin: 4px 0; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.mt { margin-top: 10px; }
.tabs[hidden] { display: none; }
