:root {
  --bg: var(--tg-theme-bg-color, #17212b);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #232e3c);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #8a9aa9);
  --link: var(--tg-theme-link-color, #5ea9ff);
  --button: var(--tg-theme-button-color, #3390ec);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 24px;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.brand { font-weight: 700; font-size: 18px; }
.me { font-size: 12px; color: var(--hint); }

#tabs {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
  position: sticky;
  top: 48px;
  background: var(--bg);
  z-index: 4;
}
.tab {
  flex: 1;
  padding: 9px 4px;
  border: none;
  border-radius: 10px;
  background: var(--secondary-bg);
  color: var(--hint);
  font-size: 14px;
  font-weight: 600;
}
.tab.active { background: var(--button); color: var(--button-text); }

main { padding: 4px 12px; }
.loading, .empty { text-align: center; color: var(--hint); padding: 40px 0; }

.card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.card .title { font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.card .desc { color: var(--hint); font-size: 13px; margin-bottom: 8px; white-space: pre-wrap; }
.card .price { font-weight: 700; font-size: 18px; color: var(--text); }
.card .meta { font-size: 12px; color: var(--hint); margin-top: 6px; }
.badge {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 8px;
  background: rgba(94,169,255,.15); color: var(--link); margin-left: 6px;
}
.badge.ok { background: rgba(80,200,120,.18); color: #58d68d; }
.badge.warn { background: rgba(240,180,60,.18); color: #f1b350; }

.row { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }

button.btn {
  border: none; border-radius: 10px;
  background: var(--button); color: var(--button-text);
  font-weight: 600; font-size: 15px; padding: 11px 16px; width: 100%;
}
button.btn.ghost { background: var(--secondary-bg); color: var(--text); }
button.btn.small { width: auto; padding: 8px 14px; font-size: 13px; }

label { display: block; font-size: 13px; color: var(--hint); margin: 12px 0 4px; }
input, textarea, select {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid transparent;
  background: var(--secondary-bg); color: var(--text); font-size: 15px;
}
textarea { min-height: 90px; resize: vertical; }

.search { margin-bottom: 10px; }
.cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 6px; }
.chip {
  white-space: nowrap; padding: 7px 13px; border-radius: 20px; border: none;
  background: var(--secondary-bg); color: var(--hint); font-size: 13px;
}
.chip.active { background: var(--button); color: var(--button-text); }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #000a; color: #fff; padding: 10px 18px; border-radius: 20px;
  font-size: 14px; z-index: 50;
}

/* --- v2 additions: images, sections, chat, delivery --- */
.thumb {
  width: 100%; height: 150px; border-radius: 10px; margin-bottom: 8px;
  background-size: cover; background-position: center; background-color: #0003;
}
.card.tappable { cursor: pointer; }
.section { font-weight: 700; font-size: 15px; margin: 16px 4px 8px; }
.sortrow { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; }
.chip.sort { font-size: 12px; }
a { color: var(--link); text-decoration: none; }
.delivery {
  margin-top: 8px; padding: 10px; border-radius: 10px;
  background: rgba(80,200,120,.12); color: #58d68d; font-size: 14px; word-break: break-word;
}
#msgs { display: flex; flex-direction: column; gap: 6px; }
.msg {
  max-width: 78%; padding: 8px 12px; border-radius: 14px; font-size: 14px;
}
.msg.me { align-self: flex-end; background: var(--button); color: var(--button-text); }
.msg.them { align-self: flex-start; background: var(--secondary-bg); }
.chatimg { max-width: 200px; max-height: 200px; border-radius: 10px; display: block; margin-bottom: 4px; }
#wsdot { font-size: 10px; color: var(--hint); }
.thumb { cursor: zoom-in; }
