/* MAX Kitchen Mini App — современный дизайн
   Палитра: тёплый акцент (кухни/дерево) + нейтральная база.
   Тёмная тема включается атрибутом data-theme на <html>. */

:root {
  --accent: #ff6b35;
  --accent-strong: #f2541c;
  --accent-soft: #fff1ea;

  --bg: #f7f7f9;
  --surface: #ffffff;
  --surface-2: #f1f2f5;
  --border: #e6e7eb;

  --text: #14161a;
  --text-dim: #6b7280;
  --text-mute: #9aa1ac;

  --ok: #16a34a;
  --ok-soft: #eaf7ee;

  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 12px;

  --shadow-sm: 0 1px 2px rgba(16, 18, 24, .06), 0 1px 3px rgba(16, 18, 24, .04);
  --shadow: 0 6px 20px rgba(16, 18, 24, .08);
  --shadow-accent: 0 8px 24px rgba(255, 107, 53, .28);

  --safe-b: env(safe-area-inset-bottom, 0px);
  --bar-h: 64px;
}

[data-theme="dark"] {
  --accent-soft: #2a1a12;
  --bg: #0f1115;
  --surface: #171a20;
  --surface-2: #1f232b;
  --border: #2a2f39;

  --text: #f2f4f8;
  --text-dim: #a2aab8;
  --text-mute: #7b8492;

  --ok: #34d399;
  --ok-soft: #122a1f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-accent: 0 8px 24px rgba(255, 107, 53, .22);
}

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

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

body { transition: background .25s ease, color .25s ease; }

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

/* ---------- Верхняя панель ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}

.topbar.scrolled { border-bottom-color: var(--border); }

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

.topbar-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress {
  margin-top: 8px;
  height: 4px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width .35s cubic-bezier(.22, 1, .36, 1);
}

.topbar-badge {
  flex: none;
  padding: 6px 11px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
}

.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Экран ---------- */

.screen {
  flex: 1;
  padding: 4px 16px 8px;
  outline: none;
  animation: screen-in .34s cubic-bezier(.22, 1, .36, 1);
}

.screen.back { animation-name: screen-in-back; }

@keyframes screen-in {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: none; }
}

@keyframes screen-in-back {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: none; }
}

.hero { padding: 8px 2px 4px; }

.hero h1 {
  margin: 0 0 10px;
  font-size: 27px;
  line-height: 1.16;
  letter-spacing: -.025em;
  font-weight: 720;
}

.hero h1 .accent { color: var(--accent); }

.hero p {
  margin: 0;
  color: var(--text-dim);
  font-size: 15px;
}

.step-title {
  margin: 6px 0 6px;
  font-size: 23px;
  line-height: 1.2;
  letter-spacing: -.02em;
  font-weight: 690;
}

.step-hint {
  margin: 0 0 18px;
  color: var(--text-dim);
  font-size: 14.5px;
}

/* ---------- Карточки выбора ---------- */

.options { display: flex; flex-direction: column; gap: 10px; }

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .14s ease, border-color .2s ease, background .2s ease,
              box-shadow .2s ease;
}

.option:active { transform: scale(.985); }

.option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-accent);
}

[data-theme="dark"] .option.selected { background: var(--surface-2); }

.option-emoji {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 23px;
  line-height: 1;
}

.option.selected .option-emoji { background: var(--surface); }

.option-body { flex: 1; min-width: 0; }

.option-name {
  font-size: 16px;
  font-weight: 640;
  letter-spacing: -.01em;
}

.option-sub {
  margin-top: 2px;
  font-size: 13.5px;
  color: var(--text-dim);
}

.option-right { flex: none; text-align: right; }

.option-price {
  font-size: 14.5px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
}

.option.selected .option-price { color: var(--accent-strong); }

.check {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  background: var(--surface);
  transition: background .18s ease, border-color .18s ease;
}

.option.selected .check { background: var(--accent); border-color: var(--accent); }

.check svg {
  width: 15px; height: 15px;
  fill: none; stroke: #fff; stroke-width: 3.2;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: 0; transition: opacity .16s ease;
}

.option.selected .check svg { opacity: 1; }

/* Сетка-чипсы (площадь, техника) */

.chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.chip {
  padding: 16px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 640;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .14s ease, border-color .2s ease, background .2s ease;
}

.chip:active { transform: scale(.96); }

.chip.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.chip .chip-note {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
}

.chip.selected .chip-note { color: var(--accent-strong); opacity: .85; }

/* ---------- Итог ---------- */

.total-card {
  padding: 22px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(150deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: var(--shadow-accent);
}

.total-label { font-size: 14px; opacity: .92; font-weight: 550; }

.total-sum {
  margin-top: 4px;
  font-size: 34px;
  font-weight: 730;
  letter-spacing: -.03em;
  line-height: 1.1;
}

.total-per { margin-top: 6px; font-size: 14px; opacity: .9; }

.section {
  margin-top: 16px;
  padding: 4px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}

.row:last-child { border-bottom: none; }
.row-label { color: var(--text-dim); }
.row-value { font-weight: 600; text-align: right; }
.row-value.discount { color: var(--ok); }

.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.pill {
  padding: 7px 13px;
  border-radius: 99px;
  background: var(--surface-2);
  font-size: 13.5px;
  color: var(--text-dim);
}

.pill b { color: var(--text); font-weight: 620; }

.note {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
}

.note.ok {
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 560;
}

/* Просмотр стиля */

.style-hero {
  padding: 26px 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.style-hero .big-emoji { font-size: 44px; line-height: 1; }

.style-hero h2 {
  margin: 12px 0 6px;
  font-size: 24px;
  letter-spacing: -.02em;
  font-weight: 700;
}

.style-hero p { margin: 0; color: var(--text-dim); font-size: 15px; }

.feature {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 0;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}

.feature:last-child { border-bottom: none; }

.feature-dot {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

/* ---------- Нижняя панель действий ---------- */

.actionbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-size: 16.5px;
  font-weight: 650;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: transform .14s ease, opacity .2s ease, background .2s ease;
}

.btn:active { transform: scale(.98); }

.btn-primary {
  background: linear-gradient(150deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: var(--shadow-accent);
}

.btn-primary[disabled] {
  background: var(--surface-2);
  color: var(--text-mute);
  box-shadow: none;
  cursor: default;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-ghost[disabled] { opacity: .55; cursor: default; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; min-width: 0; font-size: 15px; padding: 14px 12px; }

/* Поле ввода */

.field {
  width: 100%;
  min-height: 54px;
  padding: 15px 17px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16.5px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.field::placeholder { color: var(--text-mute); }

.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

.field.error { border-color: #e5484d; }

.error-text {
  margin: 8px 2px 0;
  color: #e5484d;
  font-size: 13.5px;
  min-height: 18px;
}

/* Успех */

.done {
  padding: 34px 24px;
  text-align: center;
}

.done-icon {
  width: 76px; height: 76px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ok-soft);
  font-size: 38px;
}

.done h2 { margin: 0 0 10px; font-size: 25px; letter-spacing: -.02em; font-weight: 700; }
.done p { margin: 0; color: var(--text-dim); font-size: 15.5px; }

.skeleton {
  height: 54px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s infinite linear;
}

@keyframes shimmer { to { background-position: -220% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
