:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f2f5);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --card: var(--tg-theme-section-bg-color, var(--bg));
  --sep: rgba(127, 127, 127, .18);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg2); color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--sep); }
.tabs { display: flex; }
.tab { flex: 1; border: 0; background: none; padding: 12px 4px; color: var(--hint); font-weight: 600;
  border-bottom: 2px solid transparent; cursor: pointer; }
.tab.active { color: var(--btn); border-bottom-color: var(--btn); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger);
  color: #fff; font-size: 12px; line-height: 18px; text-align: center; }

.view { padding: 10px 10px 90px; }
.banner { background: #fff3cd; color: #6b4e00; padding: 10px 12px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: 92vw; z-index: 20;
  background: rgba(20, 20, 20, .92); color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 14px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--sep); background: var(--card); border-radius: 16px; padding: 6px 12px;
  cursor: pointer; white-space: nowrap; }
.chip.active { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }
.chip .n { opacity: .7; margin-left: 4px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--card); border-radius: var(--radius); padding: 10px; display: flex; gap: 10px;
  cursor: pointer; align-items: flex-start; }
.thumb { width: 72px; height: 72px; flex: none; border-radius: 8px; object-fit: cover; background: var(--bg2); }
.avatar { width: 48px; height: 48px; flex: none; border-radius: 50%; object-fit: cover; background: var(--bg2); }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.price { font-weight: 700; margin-top: 2px; }
.meta { color: var(--hint); font-size: 13px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.row { display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--btn); flex: none; }
.time { color: var(--hint); font-size: 12px; flex: none; }
.empty { text-align: center; color: var(--hint); padding: 40px 10px; }
.more { width: 100%; margin-top: 8px; }

.section { background: var(--card); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.section h3 { margin: 0 0 8px; font-size: 15px; }
.gallery { display: flex; gap: 6px; overflow-x: auto; margin: -2px -2px 10px; padding: 2px; }
.gallery img { height: 200px; border-radius: 10px; flex: none; object-fit: cover; background: var(--bg2); }
.desc { white-space: pre-wrap; word-wrap: break-word; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 14px; }
.kv .k { color: var(--hint); }

.btn { border: 0; border-radius: 10px; padding: 11px 14px; background: var(--btn); color: var(--btn-text);
  font-weight: 600; cursor: pointer; }
.btn.secondary { background: var(--bg2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { flex: 1 1 45%; }

label.f { display: block; margin: 10px 0 4px; color: var(--hint); font-size: 13px; }
.inp, textarea.inp, select.inp { width: 100%; border: 1px solid var(--sep); background: var(--bg); border-radius: 10px;
  padding: 10px; outline: none; }
textarea.inp { min-height: 110px; resize: vertical; }
.inp:focus { border-color: var(--btn); }
.counter { text-align: right; color: var(--hint); font-size: 12px; margin-top: 2px; }
.inline { display: flex; gap: 8px; }
.inline .inp { flex: 1; }
.note { color: var(--hint); font-size: 13px; margin-top: 6px; }
.warn { color: #b26a00; font-size: 13px; margin-top: 6px; }
.err { color: var(--danger); }
.problems { margin: 8px 0 0; padding-left: 18px; color: var(--danger); }

.cats { max-height: 260px; overflow-y: auto; border: 1px solid var(--sep); border-radius: 10px; margin-top: 6px; }
.cat { padding: 8px 10px; border-bottom: 1px solid var(--sep); cursor: pointer; }
.cat:last-child { border-bottom: 0; }
.cat .p { color: var(--hint); font-size: 12px; }
.picked { background: var(--bg2); border-radius: 10px; padding: 8px 10px; margin-top: 6px; }

.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.ph { position: relative; width: 84px; height: 84px; }
.ph img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.ph .x, .ph .l { position: absolute; top: 2px; width: 24px; height: 24px; border-radius: 12px; border: 0;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 14px; line-height: 24px; padding: 0; cursor: pointer; }
.ph .x { right: 2px; } .ph .l { left: 2px; }
.ph .st { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 11px; text-align: center; border-radius: 0 0 8px 8px; padding: 1px; }
.addph { width: 84px; height: 84px; border: 2px dashed var(--sep); border-radius: 8px; display: flex;
  align-items: center; justify-content: center; color: var(--hint); font-size: 28px; cursor: pointer; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 6px; padding-bottom: 70px; }
.chathead { display: flex; gap: 10px; align-items: center; }
.msg { max-width: 82%; padding: 7px 10px; border-radius: 14px; background: var(--card); white-space: pre-wrap;
  word-wrap: break-word; align-self: flex-start; }
.msg.mine { align-self: flex-end; background: var(--btn); color: var(--btn-text); }
.msg .t { font-size: 11px; opacity: .65; margin-top: 2px; text-align: right; }
.msg img { max-width: 100%; border-radius: 10px; display: block; }
.msg.sys { align-self: center; background: transparent; color: var(--hint); font-size: 13px; text-align: center; }
.composer { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 8px 10px
  calc(8px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--sep); z-index: 6; }
.composer textarea { flex: 1; min-height: 40px; max-height: 120px; resize: none; }
.spinner { text-align: center; color: var(--hint); padding: 24px; }
.noimg { background: var(--bg2); border-radius: 8px; }
.avatar.noimg { border-radius: 50%; }
.gimg.noimg { width: 150px; height: 200px; flex: none; border-radius: 10px; }
.ph .noimg { width: 100%; height: 100%; }
.msg.sys { background: transparent; }
