/* Цвета — токены. Статусы (good/warn/bad) только для вердикта, не для украшения. */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --ink: #101318; --ink-2: #3d4452; --muted: #6b7280;
  --line: #e4e7ec; --accent: #2457d6; --accent-soft: #eaf0fd; --accent-ink: #ffffff;
  --good: #11804a; --good-soft: #e5f4ec; --warn: #a15c00; --warn-soft: #fff3e0; --bad: #c62d23; --bad-soft: #fdecea;
  --neutral-soft: #eef0f3; --bar: #2457d6; --bar-soft: #c9d7f7;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
  --head: 60px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f13; --surface: #15181e; --surface-2: #1c2028; --ink: #eef1f5; --ink-2: #c4cad4; --muted: #8e96a3;
    --line: #272c35; --accent: #6f9bff; --accent-soft: #1a2540; --accent-ink: #0d0f13;
    --good: #4cc38a; --good-soft: #10291d; --warn: #f0a648; --warn-soft: #2d2110; --bad: #ff7a6e; --bad-soft: #301614;
    --neutral-soft: #20242c; --bar: #6f9bff; --bar-soft: #2a3a63; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3, h4 { letter-spacing: -.3px; margin: 0; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* шапка */
header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.hbar { display: flex; align-items: center; gap: 16px; height: var(--head); }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; color: var(--ink); min-width: 0; }
.logo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.logo:hover { text-decoration: none; }
.logo i { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-style: normal; font-size: 14px; }
nav.main { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
nav.main a { color: var(--ink-2); padding: 7px 12px; border-radius: 9px; font-weight: 500; white-space: nowrap; }
nav.main a:hover { background: var(--surface-2); text-decoration: none; }
nav.main a.on { background: var(--accent-soft); color: var(--accent); }
.langs { margin-left: auto; flex: none; display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 9px; }
.langs button { border: 0; background: none; color: var(--muted); font: 600 12px Inter, sans-serif; padding: 5px 8px; border-radius: 7px; cursor: pointer; }
.langs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
#trial { color: var(--muted); font-size: 13px; white-space: nowrap; }
.tabs { display: none; }
@media (max-width: 720px) {
  :root { --head: 52px; }
  /* вырез и системные панели: шапка и нижние вкладки не уходят под них */
  header { padding-top: env(safe-area-inset-top); }
  .hbar { flex-wrap: nowrap; height: var(--head); gap: 8px; padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  nav.main, #trial { display: none; }
  .tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 4px max(4px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left)); }
  .tabs a { flex: 1; min-width: 0; text-align: center; color: var(--muted); font-size: 11.5px; font-weight: 600; line-height: 1.2; padding: 8px 1px; border-radius: 10px; white-space: nowrap; }
  .tabs a:hover { text-decoration: none; }
  .tabs a.on { background: var(--accent-soft); color: var(--accent); }
  main.wrap { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .vhead { flex-direction: column; align-items: stretch; }
  .filters, .filters.tight { grid-template-columns: 1fr 1fr; }
  .fbtns { grid-column: 1 / -1; }
  .hero h1 { font-size: 26px; }
}

/* общие элементы */
.btn { border: 0; cursor: pointer; font: 600 14px Inter, sans-serif; border-radius: 10px; padding: 10px 16px; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.p { background: var(--accent); color: var(--accent-ink); } .btn.p:hover { filter: brightness(1.08); text-decoration: none; }
.btn.s { background: var(--surface-2); color: var(--ink); }
.btn:disabled { opacity: .55; cursor: wait; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
select, input.f { font: 14px Inter, sans-serif; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; width: 100%; min-width: 0; }
label.fl { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; min-width: 0; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.pill { display: inline-flex; align-items: center; gap: 5px; font: 600 12px Inter, sans-serif; padding: 4px 9px; border-radius: 99px; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.neutral { background: var(--neutral-soft); color: var(--ink-2); }
section.view { display: none; padding: 20px 0 64px; } section.view.on { display: block; }
.vhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.vhead h2 { font-size: 24px; } .vhead p { margin: 4px 0 0; color: var(--muted); max-width: 720px; }

/* поиск */
.hero { padding: 26px 0 6px; }
.hero h1 { font-size: clamp(24px, 4vw, 36px); line-height: 1.15; letter-spacing: -.8px; max-width: 760px; }
.hero p { color: var(--ink-2); margin: 8px 0 16px; max-width: 680px; }
.ask { display: flex; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); max-width: 760px; }
.ask input { flex: 1; border: 0; outline: 0; background: none; font: 15px Inter, sans-serif; color: var(--ink); padding: 8px 10px; min-width: 0; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.examples button { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 99px; padding: 5px 11px; font: 13px Inter, sans-serif; cursor: pointer; }
.examples button:hover { border-color: var(--accent); color: var(--accent); }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-items: end; margin-top: 18px; }
.filters.tight { margin: 0; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.filters.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 18px; }
.filters.bar .fl { flex: 1 1 180px; max-width: 240px; }
.filters.bar .btn { width: auto; }
.budget-filters { margin: 0 0 12px; grid-template-columns: repeat(4, minmax(130px, 1fr)); }
@media (max-width: 720px) {
  .filters.bar .fl { flex: 1 1 calc(50% - 10px); max-width: none; }
  .filters.bar .btn { flex: 1 1 100%; width: 100%; }
  .budget-filters { grid-template-columns: 1fr 1fr; }
  .budget-filters .btn { grid-column: 1 / -1; }
}
.filters .more { display: contents; }
.filters .more.closed > * { display: none; }
.fbtns { display: flex; gap: 8px; }
.resbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 18px 0 12px; flex-wrap: wrap; }
.resbar .count { color: var(--muted); }
.resbar select { width: auto; }
.pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin-top: 18px; }
.pager:empty { display: none; }
.pager button { min-width: 40px; padding: 8px 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; font: 600 14px Inter, sans-serif; cursor: pointer; }
.pager button:hover { border-color: var(--accent); color: var(--accent); }
.pager button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pager button:disabled { opacity: .4; cursor: default; border-color: var(--line); color: var(--muted); }
.pager .dots { color: var(--muted); padding: 0 2px; }
.coverage { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; margin-top: 12px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform .12s, box-shadow .12s; display: flex; flex-direction: column; color: inherit; }
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(16,24,40,.12); text-decoration: none; }
.card .img { aspect-ratio: 4/3; background: var(--surface-2) center/cover no-repeat; position: relative; }
.card .img .pill { position: absolute; left: 10px; top: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .t { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { color: var(--muted); font-size: 13px; }
.card .ai { font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .ai::before { content: "✦ "; color: var(--accent); }
.card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: auto; padding-top: 4px; }
.price { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.mkt { font-size: 12px; color: var(--muted); text-align: right; }

/* страница машины */
.back { position: sticky; top: calc(var(--head) + 8px); z-index: 6; display: inline-flex; align-items: center; gap: 6px; margin: 0 0 12px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-weight: 600; color: var(--ink); box-shadow: var(--shadow); }
.back:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.car-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: 20px; align-items: start; }
.car-top > * { min-width: 0; }
@media (max-width: 900px) { .car-top { grid-template-columns: minmax(0, 1fr); } }
.gal .main { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius); background: var(--surface-2); display: block; cursor: zoom-in; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; padding-bottom: 4px; }
.thumbs img { width: 76px; height: 57px; object-fit: cover; border-radius: 8px; cursor: pointer; opacity: .75; flex: none; }
.thumbs img:hover, .thumbs img.on { opacity: 1; outline: 2px solid var(--accent); outline-offset: -2px; }
.buy { position: sticky; top: calc(var(--head) + 12px); display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 720px) {
  .buy { position: static; }
  /* на телефоне кнопка «← К поиску» стоит в потоке под шапкой и не перекрывает её и текст */
  .back { position: static; margin: 4px 0 12px; align-self: flex-start; }
}
.buy h1 { font-size: 22px; line-height: 1.25; overflow-wrap: anywhere; }
.buy .sub { color: var(--muted); font-size: 14px; }
.bigprice { font-size: 32px; font-weight: 800; letter-spacing: -.8px; line-height: 1.1; }
.keyline { display: flex; flex-wrap: wrap; gap: 6px; }
.keyline span { background: var(--surface-2); border-radius: 8px; padding: 4px 9px; font-size: 13px; font-weight: 500; }
.verdict { border-radius: 12px; padding: 14px; }
.verdict.good { background: var(--good-soft); } .verdict.warn { background: var(--warn-soft); } .verdict.bad { background: var(--bad-soft); } .verdict.neutral { background: var(--neutral-soft); }
.verdict .vt { font-weight: 700; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.verdict.good .vt { color: var(--good); } .verdict.warn .vt { color: var(--warn); } .verdict.bad .vt { color: var(--bad); }
.verdict .vh { margin-top: 6px; color: var(--ink); }
.scale { margin-top: 14px; }
.scale .track { position: relative; height: 10px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 8%, transparent); }
.scale .band { position: absolute; top: 0; bottom: 0; border-radius: 99px; background: color-mix(in srgb, var(--ink) 18%, transparent); }
.scale .med { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--ink-2); }
.scale .me { position: absolute; top: -5px; width: 20px; height: 20px; margin-left: -10px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface); }
.scale .lbls { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; gap: 8px; }
.loc { font-size: 14px; color: var(--ink-2); }

.blocks { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 24px; }
.blk { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.blk > h3 { font-size: 17px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.blk > h3 .pill { margin-left: auto; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 760px) { .two { grid-template-columns: minmax(0, 1fr); } }
.lst { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.lst li { display: flex; gap: 10px; align-items: flex-start; overflow-wrap: anywhere; }
.lst li::before { flex: none; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.lst.plus li::before { content: "+"; background: var(--good-soft); color: var(--good); }
.lst.minus li::before { content: "−"; background: var(--bad-soft); color: var(--bad); }
.lst.why li::before { content: "?"; background: var(--neutral-soft); color: var(--ink-2); }
.lst.check li::before { content: "✓"; background: var(--accent-soft); color: var(--accent); }
.lst.dot li::before { content: "•"; color: var(--muted); }
.subh { font-size: 14px; font-weight: 600; margin: 0 0 10px; color: var(--ink-2); }
.summary { font-size: 15px; line-height: 1.6; margin: 0; }
.says { margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid var(--line); color: var(--ink-2); font-size: 14px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.facts .pill { white-space: normal; }
.score { display: flex; align-items: baseline; gap: 4px; font-weight: 800; font-size: 28px; }
.score small { font-size: 14px; color: var(--muted); font-weight: 600; }
.dmg { display: grid; gap: 8px; }
.dmg .d { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 8px 10px; background: var(--surface-2); border-radius: 10px; }
.dmg .d b { font-weight: 600; }
.dmg .d .ph { margin-left: auto; display: flex; gap: 4px; }
.dmg .d .ph button { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 6px; font: 600 12px Inter, sans-serif; padding: 2px 7px; cursor: pointer; }
.specs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.spec { background: var(--surface); padding: 10px 12px; min-width: 0; }
.spec .k { font-size: 12px; color: var(--muted); } .spec .v { font-weight: 600; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; } .chips span { background: var(--surface-2); border-radius: 99px; padding: 4px 10px; font-size: 13px; }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 500; margin-top: 10px; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font-size: 14px; color: var(--ink-2); }
.issue { display: flex; gap: 10px; align-items: baseline; }
.issue .pill { flex: none; }
.sources { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; font-size: 13px; }
.sources a .lg { font-weight: 700; color: var(--muted); margin-right: 3px; text-transform: uppercase; }
.hist { width: 100%; border-collapse: collapse; font-size: 14px; } .hist td { padding: 6px 0; border-bottom: 1px solid var(--line); } .hist td:last-child { text-align: right; font-weight: 600; }
.hist.timeline td:last-child { text-align: left; font-weight: 500; }
.gone-note { align-self: flex-start; }
.carask .cthread { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.carask .cmsg { padding: 8px 12px; border-radius: 10px; font-size: 14px; line-height: 1.45; }
.carask .cmsg.u { background: var(--accent-soft); align-self: flex-end; max-width: 92%; }
.carask .cmsg.a { background: var(--surface-2); }
.mapbox iframe { width: 100%; height: 240px; border: 0; border-radius: 12px; background: var(--surface-2); }
.wait { display: flex; gap: 12px; align-items: center; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: sp 1s linear infinite; flex: none; }
@keyframes sp { to { transform: rotate(360deg); } }
.disclaimer { font-size: 12px; color: var(--muted); margin-top: 12px; }

/* полноэкранный просмотр фото */
dialog#photoDlg:not([open]) { display: none; }
dialog#photoDlg[open] { position: fixed; inset: 0; width: auto; height: auto; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #07080b; color: #fff; overflow: hidden; display: flex; flex-direction: column; }
dialog#photoDlg::backdrop { background: rgba(0,0,0,.8); }
.pv-top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; }
.pv-top span { color: #c9ced8; font-weight: 600; }
.pv-stage { flex: 1; min-height: 0; overflow: hidden; display: grid; place-items: center; cursor: grab; touch-action: none; }
.pv-stage.dragging { cursor: grabbing; }
.pv-frame { position: relative; display: inline-grid; max-width: 100%; max-height: 100%; transform-origin: center center; }
.pv-frame img { grid-area: 1 / 1; max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; display: block; }
.pv-nav { position: absolute; top: 50%; z-index: 2; width: 44px; height: 44px; margin-top: -22px; border: 0; border-radius: 12px; background: rgba(255,255,255,.16); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; }
.pv-nav.prev { left: 12px; } .pv-nav.next { right: 12px; }

/* рынок */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k { font-size: 13px; color: var(--muted); } .kpi .v { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin-top: 2px; } .kpi .h { font-size: 12px; color: var(--muted); margin-top: 2px; }
.mgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 860px) { .mgrid { grid-template-columns: minmax(0, 1fr); } }
.chart h3 { font-size: 16px; margin-bottom: 4px; } .chart .cap { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.hbars { display: grid; gap: 6px; }
.hb { display: grid; grid-template-columns: minmax(70px, 120px) 1fr minmax(70px, auto); gap: 10px; align-items: center; font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.hb:hover { background: var(--surface-2); }
.hb .tr { position: relative; height: 14px; }
.hb .rg { position: absolute; top: 3px; height: 8px; background: var(--bar-soft); border-radius: 4px; }
.hb .bar { position: absolute; left: 0; top: 0; height: 14px; background: var(--bar); border-radius: 0 4px 4px 0; }
.hb .md { position: absolute; top: -1px; width: 4px; height: 16px; margin-left: -2px; background: var(--bar); border-radius: 2px; }
.hb .val { text-align: right; font-weight: 600; white-space: nowrap; } .hb .val small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 8px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 8px; border-bottom: 1px solid var(--line); }
table.tbl tr.click { cursor: pointer; } table.tbl tr.click:hover td { background: var(--surface-2); }
table.tbl td.r, table.tbl th.r { text-align: right; }
#tip { position: fixed; z-index: 60; pointer-events: none; display: none; background: var(--ink); color: var(--bg); font-size: 13px; padding: 8px 10px; border-radius: 8px; max-width: 260px; line-height: 1.4; }

/* чат: окно на всё место под шапкой, слева список разговоров */
body:has(#v-ask.on) { overflow: hidden; height: 100dvh; display: flex; flex-direction: column; }
body:has(#v-ask.on) footer { display: none; }
body:has(#v-ask.on) main.wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; width: min(1200px, 100%); align-self: center; padding-bottom: 0; }
#v-ask.on { flex: 1; min-height: 0; display: flex; flex-direction: column; height: auto; padding: 10px 0 12px; }
.chatwin { flex: 1; min-height: 0; display: flex; flex-direction: row; position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.chatside { width: 240px; flex: none; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-right: 1px solid var(--line); background: var(--surface); min-height: 0; }
.chatside .btn { width: 100%; }
#chatList { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.chatitem { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "t x" "w x"; column-gap: 6px; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 8px; cursor: pointer; color: var(--ink); font: inherit; }
.chatitem:hover { background: var(--surface-2); }
.chatitem.on { background: var(--accent-soft); }
.chatitem .tt { grid-area: t; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chatitem .when { grid-area: w; font-size: 11px; color: var(--muted); }
.chatitem .del { grid-area: x; align-self: center; color: var(--muted); font-size: 14px; padding: 2px 4px; }
.chatkept { margin: 0; }
.chatmain { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chathead { flex: none; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chathead h2 { font-size: 18px; } .chathead p { margin: 2px 0 0; color: var(--muted); font-size: 13px; max-width: 640px; }
#chatLimit { margin-left: auto; text-align: right; }
#chatListBtn { display: none; flex: none; }
@media (max-width: 800px) {
  .chatside { position: absolute; inset: 0; width: auto; z-index: 4; display: none; }
  .chatside.open { display: flex; }
  #chatListBtn { display: inline-flex; }
  .chathead p { display: none; }
}
@media (max-width: 720px) { #v-ask.on { padding: 8px 0 calc(72px + env(safe-area-inset-bottom)); } }
.chatbox { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--bg); }
.chatempty { margin: auto; max-width: 440px; text-align: center; color: var(--muted); padding: 12px; }
.msg { max-width: min(680px, 88%); padding: 10px 14px; border-radius: 16px; overflow-wrap: anywhere; line-height: 1.5; }
.msg.u { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 5px; white-space: pre-wrap; }
.msg.a { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; box-shadow: var(--shadow); }
.msg.a > :first-child { margin-top: 0; } .msg.a > :last-child { margin-bottom: 0; }
.msg.a p { margin: 0 0 8px; }
.msg.a h3 { font-size: 15px; margin: 14px 0 6px; }
.msg.a h4 { font-size: 14px; margin: 12px 0 6px; }
.msg.a ul, .msg.a ol { margin: 4px 0 8px; padding-left: 1.2em; }
.msg.a li { margin: 3px 0; }
.msg.a hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.msg.a table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 8px 0 4px; }
.msg.a th, .msg.a td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.msg.a th { color: var(--muted); font-weight: 600; font-size: 12px; }
.msg.a code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.msg.a pre { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; overflow: auto; margin: 8px 0; }
.msg.a pre code { background: none; padding: 0; }
.msg.a em { color: var(--ink-2); }
.msg.a a.car { display: inline-flex; align-items: center; font-weight: 650; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 0 8px; font-size: 13px; }
.msg.a a.car:hover { text-decoration: none; }
.chatform { flex: none; display: flex; gap: 8px; margin: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 10px; }
.chatform input { flex: 1; border: 0; outline: 0; background: var(--surface-2); border-radius: 12px; font: 15px Inter, sans-serif; color: var(--ink); padding: 10px 12px; min-width: 0; }

footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 24px 0 40px; }
#gate { display: none; position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 92%, #000); place-items: center; padding: 16px; }
#gate.on { display: grid; }
#gate form { width: min(420px, 100%); display: flex; flex-direction: column; gap: 10px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; }
.toast.on { opacity: .95; }

/* узкий экран (360–380 px): переключатель языков и логотип помещаются в шапку */
@media (max-width: 380px) {
  .hbar { gap: 6px; }
  .logo { font-size: 16px; gap: 7px; }
  .logo i { width: 26px; height: 26px; }
  .langs { gap: 1px; }
  .langs button { padding: 5px 6px; }
}
@media (max-width: 720px) {
  footer { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
