/* ==========================================================================
   ЛукиЛуки — оформление Mini App.
   Всё оформление собрано в переменных ниже: можно менять цвета в одном месте.
   ========================================================================== */

/* Страховка: любой элемент с атрибутом hidden скрыт, что бы ни говорили
   классы ниже. Без этого правило вида `.overlay { display: flex }` перебивает
   служебный hidden (правила автора сильнее встроенных правил браузера),
   элемент остаётся на экране и перехватывает нажатия. */
[hidden] { display: none !important; }

:root {
  --bg: #12101a;
  --bg-soft: #1b1826;
  --card: #221e2f;
  --card-2: #2b2740;
  --text: #f4f1ff;
  --muted: #a49fb8;
  --accent: #b98cff;
  --accent-2: #7b5cff;
  --good: #4ad991;
  --warn: #ffb84d;
  --bad: #ff6b81;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="light"] {
  --bg: #f6f4fb;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-2: #f0ecfa;
  --text: #1b1726;
  --muted: #6f6980;
  --accent: #7b5cff;
  --accent-2: #5a3ce0;
  --shadow: 0 8px 24px rgba(40, 20, 90, .12);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
}

/* ---------- Верхняя панель ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(18, 16, 26, 0));
  backdrop-filter: blur(8px);
}

.logo { font-size: 19px; font-weight: 800; letter-spacing: .2px; }
.logo span { color: var(--accent); }

.logo__icon {
  width: 22px; height: 22px;
  border-radius: 7px;
  vertical-align: -4px;
  margin-right: 7px;
}
.topbar__title { flex: 1; display: flex; flex-direction: column; }
.topbar__title small { color: var(--muted); font-size: 11.5px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--card-2);
  background: var(--card);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }

/* ---------- Экраны ---------- */
main { flex: 1; padding: 4px 14px 96px; }

.screen { display: none; animation: fade .22s ease; }
.screen.is-active { display: block; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen__title { font-size: 20px; margin: 12px 0 14px; }

.hero { margin: 6px 0 16px; }
.hero h1 { font-size: 23px; margin: 0 0 6px; }
.hero p { color: var(--muted); margin: 0; }

/* ---------- Карточки-кнопки ---------- */
.mode-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--card-2);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.mode-card:active { transform: scale(.985); border-color: var(--accent); }
.mode-card__emoji { font-size: 26px; }
.mode-card__text { flex: 1; display: flex; flex-direction: column; }
.mode-card__text b { font-size: 16px; }
.mode-card__text small { color: var(--muted); }
.mode-card__arrow { color: var(--muted); font-size: 22px; }

.card {
  background: var(--card);
  border: 1px solid var(--card-2);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card--muted { background: var(--bg-soft); color: var(--muted); font-size: 13.5px; }

/* ---------- Поля ввода ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

select, input[type="text"] {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-2);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  appearance: none;
}

select:focus, input[type="text"]:focus { outline: 2px solid var(--accent-2); }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.row { display: flex; gap: 10px; }
.field--half { flex: 1; }

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--card-2);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 14.5px;
}
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

.btn {
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
}
.btn--primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn--ghost { background: var(--card); color: var(--text); border-color: var(--card-2); }
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .55; cursor: default; }

.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }
.notes { color: var(--muted); font-size: 12.5px; }
.notes div { margin-bottom: 4px; }

/* ---------- Загрузка фото ---------- */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 190px;
  margin-bottom: 14px;
  padding: 16px;
  border: 2px dashed var(--card-2);
  border-radius: var(--radius);
  background: var(--bg-soft);
  text-align: center;
  cursor: pointer;
  overflow: hidden;
}
.dropzone img { width: 100%; border-radius: var(--radius-sm); max-height: 320px; object-fit: contain; }
.dropzone__text b { display: block; }
.dropzone__text small { color: var(--muted); }

.details { margin-bottom: 14px; }
.details summary { color: var(--muted); font-size: 13.5px; cursor: pointer; padding: 8px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--card-2);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.chip.is-on { background: var(--accent-2); border-color: var(--accent); color: #fff; }

/* ---------- Товары в результате ---------- */
.item {
  background: var(--card);
  border: 1px solid var(--card-2);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.item__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--card-2);
  font-size: 12.5px;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--muted);
}
.item__images { display: flex; gap: 6px; padding: 10px; }
.item__images img {
  flex: 1;
  width: 50%;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  object-fit: cover;
  aspect-ratio: 3 / 4;
}
.item__body { padding: 0 14px 14px; }
.item__title { font-size: 15.5px; font-weight: 600; margin-bottom: 6px; }
.item__price { font-size: 17px; font-weight: 700; }
.item__price s { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 6px; }
.item__meta { color: var(--muted); font-size: 13px; margin: 6px 0 10px; }
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(74, 217, 145, .16);
  color: var(--good);
  font-size: 12px;
  font-weight: 600;
  margin-right: 6px;
}
.badge--warn { background: rgba(255, 184, 77, .16); color: var(--warn); }
.item__actions { display: flex; gap: 8px; }
.item__actions .btn { margin: 0; padding: 12px; font-size: 14px; }

.tryon-tag {
  display: inline-block;
  margin: 0 14px 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(185, 140, 255, .16);
  color: var(--accent);
  font-size: 12px;
}

/* ---------- Нижнее меню ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: var(--bg-soft);
  border-top: 1px solid var(--card-2);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.tab span { font-size: 19px; }
.tab.is-active { color: var(--accent); }

/* ---------- Оверлей загрузки и тосты ---------- */
/* ВАЖНО: display задаём только для НЕскрытого состояния.
   Раньше здесь стояло безусловное `display: flex`, и правило автора
   перебивало служебный атрибут hidden: оверлей «Подбираю образ…» висел
   поверх экрана всегда и проглатывал все нажатия — кнопки не работали. */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  background: rgba(8, 6, 14, .72);
  backdrop-filter: blur(3px);
  padding: 24px;
}
.overlay:not([hidden]) { display: flex; }
.overlay[hidden] { display: none; }
.loader-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 26px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 320px;
}
.loader-card small { display: block; color: var(--muted); margin-top: 8px; }
.spinner {
  width: 38px; height: 38px;
  margin: 0 auto 14px;
  border: 3px solid var(--card-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--card-2);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 14px;
}
.toast--bad { background: #4a2030; }

.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
