:root {
  --tg-bg: #ffffff;
  --tg-text: #111111;
  --tg-hint: #999999;
  --tg-button: #2ea6ff;
}

* { box-sizing: border-box; }

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

.app-container { padding: 12px 14px 24px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.icon-btn {
  border: none;
  background: rgba(150,150,150,0.12);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tg-text);
  flex-shrink: 0;
}
.icon-btn svg { width: 22px; height: 22px; }

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: rgba(150,150,150,0.12);
  border-radius: 12px;
  padding: 0 10px;
  height: 42px;
}
.search-icon { width: 18px; height: 18px; color: var(--tg-hint); margin-right: 6px; flex-shrink: 0; }
#search-input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 15px;
  color: var(--tg-text);
}

.page-title { font-size: 17px; font-weight: 600; }

.list-title { font-size: 14px; color: var(--tg-hint); margin: 6px 0 8px; font-weight: 600; }

.results-list { display: flex; flex-direction: column; gap: 8px; }

.product-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(150,150,150,0.08);
}
.product-card img {
  width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: #eee; flex-shrink: 0;
}
.product-card .card-title { font-size: 15px; font-weight: 500; }
.product-card .card-sub { font-size: 13px; color: var(--tg-hint); }

.empty-state { text-align: center; color: var(--tg-hint); margin-top: 30px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #222;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  transition: all .25s;
  z-index: 999;
  pointer-events: none;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* product page */
.product-photo-wrap { display: flex; justify-content: center; margin: 10px 0; }
.product-photo { width: 160px; height: 160px; object-fit: cover; border-radius: 16px; background: #eee; }
.product-name { font-size: 19px; font-weight: 700; text-align: center; margin: 6px 0 16px; }

.gram-control { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 18px; }
.gram-input-wrap { display: flex; align-items: center; gap: 6px; background: rgba(150,150,150,0.12); border-radius: 10px; padding: 4px 10px; }
.gram-input-wrap input { width: 70px; border: none; background: transparent; font-size: 16px; text-align: right; outline: none; color: var(--tg-text); }

.calories-block { text-align: center; margin-bottom: 12px; }
.kcal-value { font-size: 40px; font-weight: 700; line-height: 1; }
.kcal-label { font-size: 15px; color: var(--tg-hint); }
.kj-subtitle { font-size: 13px; color: var(--tg-hint); margin-top: 4px; }

.macro-row { display: flex; justify-content: space-between; align-items: center; font-size: 15px; margin-top: 14px; padding: 0 4px; }
.macro-label { display: flex; align-items: center; gap: 8px; color: var(--tg-text); }
.macro-row .dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; display: inline-block; }

.primary-btn {
  display: block;
  width: 100%;
  margin-top: 24px;
  background: var(--tg-button);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
}

.secondary-btn {
  display: inline-block;
  text-align: center;
  border: 1px solid rgba(150,150,150,0.4);
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
}

.loader, .hint-text { text-align: center; color: var(--tg-hint); margin-top: 20px; }

.scanner-viewport { position: relative; width: 100%; height: 260px; background: #000; border-radius: 14px; overflow: hidden; }
.scanner-viewport video, .scanner-viewport canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.scan-actions { display: flex; gap: 10px; margin-top: 14px; }
.scan-actions .primary-btn, .scan-actions .secondary-btn { flex: 1; margin-top: 0; }
