/*
 * Оформление наследует тему Telegram: клиент отдаёт цвета в CSS-переменных
 * --tg-theme-*, поэтому приложение само подстраивается под светлую и тёмную
 * тему пользователя. Запасные значения — на случай запуска вне Telegram.
 */

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --radius: 12px;
  --gap: 12px;
}

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

/*
 * Атрибут hidden скрывает через display:none из стилей браузера, и любое
 * собственное правило display его перебивает. У .sheet и .spec стоит
 * display:flex — без этой строки скрытый список остаётся на экране, а его
 * прозрачная подложка перехватывает все нажатия.
 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

.app {
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

.loader {
  padding: 48px 16px;
  text-align: center;
  color: var(--hint);
}

.title {
  font-size: 22px;
  font-weight: 700;
  margin: 4px 0 6px;
}

.lead {
  margin: 0 0 16px;
  color: var(--hint);
  font-size: 14px;
}

.head {
  margin-bottom: 14px;
}

/* ── Карточки ─────────────────────────────────────────────────────────── */

.cards {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--secondary-bg);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.card:active {
  transform: scale(0.985);
}

.card-icon {
  font-size: 26px;
  line-height: 1;
  flex: 0 0 auto;
}

.card-main {
  flex: 1 1 auto;
  min-width: 0;
}

.card-title {
  font-weight: 600;
}

.card-sub {
  color: var(--hint);
  font-size: 13px;
  margin-top: 2px;
}

.card-price {
  flex: 0 0 auto;
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}

.card-price small {
  display: block;
  font-weight: 400;
  color: var(--hint);
  font-size: 11px;
}

/* ── Строки настроек ──────────────────────────────────────────────────── */

.rows {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--secondary-bg);
  overflow: hidden;
  margin-bottom: 16px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--bg);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.row:last-child {
  border-bottom: 0;
}

.row:active {
  background: rgba(127, 127, 127, 0.12);
}

.row-label {
  color: var(--hint);
  font-size: 14px;
  flex: 0 0 auto;
}

.row-value {
  flex: 1 1 auto;
  text-align: right;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-chevron {
  color: var(--hint);
  flex: 0 0 auto;
}

.row.toggle {
  cursor: pointer;
}

.switch {
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: rgba(127, 127, 127, 0.35);
  position: relative;
  transition: background 0.15s ease;
}

.switch.on {
  background: var(--accent);
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch.on::after {
  transform: translateX(18px);
}

/* ── Железо и цена ────────────────────────────────────────────────────── */

.spec {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.spec:not([hidden]) {
  display: flex;
}

.spec span {
  background: var(--secondary-bg);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  color: var(--hint);
}

.price {
  border-radius: var(--radius);
  background: var(--secondary-bg);
  padding: 14px;
}

.price-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--hint);
}

.price-lines div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.price-lines:empty {
  display: none;
}

.price-total {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--bg);
  font-size: 20px;
  font-weight: 700;
}

.price-lines:empty + .price-total {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.price-total.solo {
  border: 0;
  padding: 0;
  margin: 0 0 16px;
}

.price-total small {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--hint);
  margin-top: 2px;
}

.note {
  color: var(--hint);
  font-size: 13px;
  margin: 12px 0 0;
}

.summary {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  font-size: 14px;
}

.summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
}

.summary span:first-child {
  color: var(--hint);
}

.access {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
}

.ghost {
  border: 0;
  background: transparent;
  color: var(--link);
  font: inherit;
  padding: 12px;
  cursor: pointer;
}

.wide {
  display: block;
  width: 100%;
  margin-top: 8px;
}

/* ── Всплывающий список ───────────────────────────────────────────────── */

.sheet {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: flex-end;
}

.sheet:not([hidden]) {
  display: flex;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.sheet-body {
  position: relative;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 12px 0 calc(8px + env(safe-area-inset-bottom));
  animation: rise 0.18s ease;
}

@keyframes rise {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 10px;
}

.sheet-close {
  border: 0;
  background: transparent;
  color: var(--hint);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.search {
  margin: 0 16px 8px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: var(--secondary-bg);
  color: inherit;
  font: inherit;
}

.sheet-list {
  overflow-y: auto;
  padding: 0 8px;
  -webkit-overflow-scrolling: touch;
}

.option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.option:active {
  background: var(--secondary-bg);
}

.option[disabled] {
  opacity: 0.35;
  cursor: default;
}

.option.selected {
  color: var(--link);
  font-weight: 600;
}

.option-main {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.option-side {
  color: var(--hint);
  font-size: 13px;
  white-space: nowrap;
}

.option-sep {
  padding: 14px 12px 6px;
  color: var(--hint);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 6px;
  font-size: 11px;
  padding: 1px 6px;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--hint);
}
