:root {
  --bg: #0a0a0b;
  --surface: #141417;
  --surface-2: #1c1c21;
  --border: #2a2a31;
  --text: #f2f2f4;
  --muted: #8a8a93;
  --accent: #e8e8ea;
  --accent-press: #c9c9cd;
  --green: #3ddc84;
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro", "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  overscroll-behavior-y: none;
}

#app { max-width: 720px; margin: 0 auto; min-height: 100vh; }

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Экраны ---------- */
.screen { display: none; padding: 12px; }
.screen.active { display: block; }

.hero { padding: 16px 2px 8px; }
.hero h1 { font-size: 22px; font-weight: 700; margin: 0 0 2px; letter-spacing: -0.5px; }
.hero p { margin: 0; font-size: 14px; }

/* ---------- Список маркетплейсов ---------- */
.markets { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.market-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.market-card:active { transform: scale(.985); background: var(--surface-2); }
.market-emoji {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  font-size: 22px;
  background: var(--surface-2);
  border-radius: 12px;
}
.market-card .mc-title { font-size: 17px; font-weight: 600; }
.market-card .mc-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.market-card .chev { margin-left: auto; color: var(--muted); font-size: 22px; }

/* ---------- Поиск ---------- */
.searchbar { display: flex; align-items: center; gap: 7px; padding: 4px 0 10px; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); width: 38px; height: 38px; flex: none;
  border-radius: 11px; font-size: 21px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--surface-2); }
.search-input-wrap {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 11px; padding: 3px 3px 3px 12px;
}
#search-input {
  flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 16px; padding: 7px 0;
}
#search-input::placeholder { color: var(--muted); }
.go-btn {
  background: var(--accent); color: #0a0a0b; border: none;
  border-radius: 9px; padding: 8px 13px; font-weight: 600; font-size: 14px;
  cursor: pointer; flex: none;
}
.go-btn:active { background: var(--accent-press); }

/* ---------- Выбор страны (Vinted) ---------- */
.country-bar {
  display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 8px;
  scrollbar-width: none;
}
.country-bar::-webkit-scrollbar { display: none; }
.country-chip {
  flex: none; padding: 7px 12px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-size: 14px; cursor: pointer; white-space: nowrap;
}
.country-chip.active { background: var(--accent); color: #0a0a0b; border-color: var(--accent); font-weight: 600; }

/* ---------- Фильтры ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 2px 0 8px; }
.price-inputs { display: flex; align-items: center; gap: 6px; }
.price-inputs input {
  width: 84px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 14px; padding: 9px 10px; outline: none;
}
.price-inputs input::placeholder { color: var(--muted); }
.price-inputs input:focus { border-color: var(--muted); }
.price-inputs .dash { color: var(--muted); }
.sort-group { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.sort-chip {
  padding: 8px 12px; border-radius: 20px; font-size: 13px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.sort-chip.active { background: var(--accent); color: #0a0a0b; border-color: var(--accent); font-weight: 600; }

/* ---------- Статус ---------- */
.status { color: var(--muted); font-size: 14px; padding: 8px 2px; min-height: 20px; }
.spinner {
  width: 26px; height: 26px; margin: 28px auto;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Пагинация ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 8px 0 36px; }
.pagination.hidden { display: none; }
.page-btn {
  min-width: 44px; height: 40px; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; font-size: 15px; cursor: pointer;
}
.page-btn:active { background: var(--surface-2); }
.page-btn:disabled { opacity: .35; cursor: default; }
.page-indicator { font-size: 14px; color: var(--muted); min-width: 60px; text-align: center; }

/* ---------- Дата объявления ---------- */
.card-date { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ---------- Результаты (сетка карточек) ---------- */
.results { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding-bottom: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform .12s ease;
}
.card:active { transform: scale(.98); }
.card-img {
  width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--surface-2);
  display: block;
}
.card-img.placeholder { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.card-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.card-title { font-size: 12.5px; line-height: 1.3; max-height: 2.6em; overflow: hidden; }
.card-brand { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.card-price-rub { font-size: 15px; font-weight: 700; margin-top: 1px; }
.card-price-orig { font-size: 11.5px; color: var(--muted); }

/* ---------- Модалка товара ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-card {
  background: var(--surface); width: 100%; max-width: 720px;
  max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; border: 1px solid var(--border);
  padding: 0 0 24px; position: relative;
  animation: slideup .22s ease;
}
@keyframes slideup { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff; border: none; font-size: 16px; cursor: pointer;
}
.modal-img { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--surface-2); }
.modal-content { padding: 16px 18px 0; }
.modal-content h2 { font-size: 18px; margin: 0 0 6px; line-height: 1.3; }
.modal-orig-title { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.price-row { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 16px; }
.price-rub-big { font-size: 26px; font-weight: 800; }
.price-orig-big { font-size: 15px; color: var(--muted); }
.meta-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.meta-pill { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; font-size: 13px; }
.meta-pill b { color: var(--muted); font-weight: 500; margin-right: 6px; }
.desc-block { margin: 8px 0 16px; }
.desc-block h3 { font-size: 13px; color: var(--muted); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .4px; }
.desc-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.open-orig {
  display: block; text-align: center; text-decoration: none;
  background: var(--accent); color: #0a0a0b; font-weight: 700;
  padding: 15px; border-radius: 14px; margin-top: 8px;
}
.open-orig:active { background: var(--accent-press); }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.error-box { background: #2a1416; border: 1px solid #5a2a2e; color: #ffb4b4; padding: 14px; border-radius: 12px; margin: 8px 0; font-size: 14px; }
