:root {
  --bg: #17120e;
  --bg-card: #221a14;
  --bg-card-hi: #2c211a;
  --line: #392c22;
  --text: #f3e9df;
  --muted: #b39c8a;
  --accent: #e6a15c;
  --accent-2: #c9756b;
  --radius: 14px;
  --maxw: 720px;
  --fs: 17px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs)/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app { max-width: var(--maxw); margin: 0 auto; }
.loading, .empty { color: var(--muted); text-align: center; padding: 3rem 1rem; }
.hidden { display: none !important; }

/* --- Шапка / поиск --- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(var(--bg) 72%, transparent);
  padding: 1rem 1rem 0.6rem;
}
.brand { margin: 0 0 0.6rem; font-size: 1.7rem; letter-spacing: 0.5px; }
.search {
  width: 100%; font-size: 1.05rem; padding: 0.85rem 1rem;
  color: var(--text); background: var(--bg-card);
  border: 1px solid var(--line); border-radius: var(--radius); outline: none;
}
.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--muted); }
.searchwrap { padding: 0 1rem 0.2rem; }

/* --- Сетка плиток 2×, квадратные --- */
.grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem; padding: 0.5rem 1rem 1.5rem;
}
.tile {
  position: relative; aspect-ratio: 1 / 1; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.4rem; padding: 1rem; text-align: center;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); color: inherit; text-decoration: none;
}
.tile:active { background: var(--bg-card-hi); }
.tile-emoji { font-size: 2.8rem; line-height: 1; }
.tile-label { font-size: 1.1rem; font-weight: 650; }
.tile-sub { font-size: 0.78rem; color: var(--muted); }
.tile-en { font-size: 0.8rem; color: var(--muted); }

/* плитка-карточка с фото: фото на весь тайл, подпись снизу на градиенте */
.tile-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-tile { justify-content: center; }
.card-tile .tile-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; flex-direction: column; gap: 1px;
  padding: 0.55rem 0.7rem; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,0.82));
}

/* --- Быстрые результаты на хабе --- */
.results { padding: 0.2rem 1rem 0.4rem; display: flex; flex-direction: column; gap: 0.45rem; }
.row {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.75rem 0.9rem;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); color: inherit; text-decoration: none;
}
.row:active { background: var(--bg-card-hi); }
.row-badge { font-size: 1.35rem; flex: none; }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-ru { font-weight: 650; }
.row-meta { font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-chevron { color: var(--accent); font-size: 1.5rem; flex: none; }

.foot { color: var(--muted); font-size: 0.8rem; text-align: center; padding: 0.5rem 1rem 5rem; }

/* --- Экран карточки --- */
.detail-top { display: flex; align-items: center; gap: 0.6rem; padding-bottom: 0.6rem; }
.back {
  flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: var(--accent); text-decoration: none;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
}
.back:active { background: var(--bg-card-hi); }
.detail-title { font-size: 1.25rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.recipe { padding: 0 1.1rem 6rem; }
.recipe > h1:first-child { display: none; }
.recipe h1, .recipe h2, .recipe h3 { line-height: 1.25; margin: 1.4rem 0 0.6rem; }
.recipe h2 { font-size: 1.3rem; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 0.3rem; }
.recipe h3 { font-size: 1.1rem; color: var(--accent-2); }
.recipe p { margin: 0.6rem 0; }
.recipe strong { color: #fff; }
.recipe ul, .recipe ol { padding-left: 1.3rem; }
.recipe li { margin: 0.35rem 0; }
.recipe blockquote {
  margin: 1rem 0; padding: 0.6rem 1rem;
  background: var(--bg-card); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0; color: var(--muted);
}
.recipe code { background: var(--bg-card-hi); padding: 0.1rem 0.35rem; border-radius: 6px; font-size: 0.9em; font-family: ui-monospace, Menlo, monospace; }
.recipe img { max-width: 100%; border-radius: var(--radius); margin: 0.6rem 0; }
/* силуэт бокала (SVG-иллюстрация формы на странице стакана) */
.glass-fig {
  width: 104px; height: 136px; display: block; margin: 0.6rem 0 0.2rem;
  color: var(--accent); stroke: currentColor; fill: none;
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
}
.recipe a { color: var(--accent); }
.recipe hr { border: none; border-top: 1px solid var(--line); margin: 1.6rem 0; }
.recipe table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.95rem; display: block; overflow-x: auto; }
.recipe th, .recipe td { border: 1px solid var(--line); padding: 0.5rem 0.7rem; text-align: left; }
.recipe th { background: var(--bg-card-hi); }

/* --- Островок «степень опьянения» (ползунок) --- */
#dock {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  z-index: 50; width: min(420px, calc(100% - 1.5rem));
  margin-bottom: calc(0.7rem + env(safe-area-inset-bottom));
  padding: 0.55rem 1.1rem 0.65rem;
  background: rgba(34, 26, 20, 0.93); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.5);
}
.dock-label { text-align: center; font-weight: 650; font-size: 0.95rem; margin-bottom: 0.2rem; }
.booze { width: 100%; height: 1.7rem; accent-color: var(--accent); cursor: pointer; }
.dock-scale { display: flex; justify-content: space-between; font-size: 1.05rem; margin-top: 0.05rem; }

/* ================= СТЕПЕНЬ ОПЬЯНЕНИЯ (4 уровня) ================= */
@keyframes wobble {
  0%, 100% { transform: translateX(-50%) rotate(-1.4deg); }
  50% { transform: translateX(-50%) rotate(1.4deg); }
}

/* Уровень 2 «Подшофе»: другой шрифт, крупнее, контрастнее, ВЕРХНИЙ РЕГИСТР */
body[data-level="2"] {
  --fs: 20px; --text: #ffffff; --muted: #d9c4ad;
  font-family: "Segoe UI", "Roboto", system-ui, sans-serif; font-weight: 500;
}
body[data-level="2"] .brand,
body[data-level="2"] .tile-label,
body[data-level="2"] .detail-title,
body[data-level="2"] .recipe,
body[data-level="2"] .row-ru { text-transform: uppercase; letter-spacing: 0.4px; }
body[data-level="2"] .tile-img { filter: contrast(1.18) saturate(1.1); }

/* Уровни 3–4: островок «пьянеет» и качается (на 4 — быстрее) */
body[data-level="3"] #dock,
body[data-level="4"] #dock { border-color: var(--accent-2); animation: wobble 2.6s ease-in-out infinite; }
body[data-level="4"] #dock { animation-duration: 1.5s; }
body[data-level="3"] .booze,
body[data-level="4"] .booze { accent-color: var(--accent-2); }

/* Уровень 3 «Пьяный»: крупнее */
body[data-level="3"] { --fs: 22px; }
body[data-level="3"] .tile-label { font-size: 1.3rem; }
body[data-level="3"] .tile-emoji { font-size: 3.2rem; }
body[data-level="3"] .brand { font-size: 2rem; }

/* Уровень 4 «Вдрызг»: ещё крупнее */
body[data-level="4"] { --fs: 24px; }
body[data-level="4"] .tile-label { font-size: 1.4rem; }
body[data-level="4"] .tile-emoji { font-size: 3.6rem; }
body[data-level="4"] .brand { font-size: 2.2rem; }

/* Баннер предостережений на хабе (уровни 3–4) */
.drunk-banner {
  margin: 0.4rem 1rem 0.8rem; padding: 0.4rem 1rem;
  background: var(--bg-card); border: 2px solid var(--accent-2); border-radius: var(--radius);
}
.drunk-banner h1 { font-size: 1.3rem; color: var(--accent-2); margin: 0.6rem 0; }
.drunk-banner ul { padding-left: 1.2rem; }
.drunk-banner li { margin: 0.5rem 0; font-size: 1.05rem; }
.drunk-banner hr, .drunk-banner h2, .drunk-banner blockquote { display: none; }

/* Упрощённая карточка (уровни 3 «Пьяный» и 4 «Вдрызг») */
.simple-card .simple-body {
  font-size: 1.6rem; line-height: 1.4; text-align: center;
  padding: 1.3rem 1rem; margin-top: 0.5rem;
  background: var(--bg-card); border: 2px solid var(--accent); border-radius: var(--radius);
}
.simple-card .simple-body strong { color: var(--accent); }
.simple-card .simple-body ul { list-style: none; padding: 0; margin: 0; }
.simple-card .simple-body li { margin: 0.6rem 0; }
.simple-card .simple-body p { margin: 0.5rem 0; }
/* Уровень 4: состав огромными буквами */
body[data-level="4"] .simple-card .simple-body { font-size: 2.1rem; line-height: 1.5; border-color: var(--accent-2); }
body[data-level="4"] .simple-card .simple-body strong { color: var(--accent-2); }

.drunk-warn {
  font-size: 1.15rem; text-align: center; color: var(--accent-2);
  font-weight: 650; margin: 1.1rem 0.5rem;
}
.morebtn {
  display: block; width: calc(100% - 2rem); margin: 0.5rem auto;
  padding: 1rem; font-size: 1.1rem; font-weight: 650;
  color: var(--text); background: var(--bg-card);
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.morebtn:active { background: var(--bg-card-hi); }

/* --- Пилюля «Три бюджета» --- */
.budget { padding: 0.2rem 1.1rem 0; }
.bseg-row { display: flex; gap: 0.4rem; }
.bseg {
  flex: 1; padding: 0.6rem 0.3rem; font-size: 0.9rem; font-weight: 650;
  color: var(--muted); background: var(--bg-card);
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.bseg.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.budget-body {
  margin-top: 0.6rem; padding: 0.3rem 1rem;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
}
.budget-body p { margin: 0.5rem 0; }
.budget-body ul { padding-left: 1.2rem; }
.budget-body li { margin: 0.3rem 0; }
.budget-body strong { color: #fff; }
.budget-body blockquote {
  margin: 0.6rem 0; padding: 0.4rem 0.8rem;
  background: var(--bg-card-hi); border-left: 3px solid var(--accent-2);
  border-radius: 0 8px 8px 0; color: var(--muted);
}

/* --- Бар-калькулятор --- */
.barcalc {
  display: block; margin: 0.2rem 1rem 0.8rem; padding: 0.95rem 1rem;
  text-align: center; font-size: 1.05rem; font-weight: 700;
  color: var(--bg); background: var(--accent); border-radius: var(--radius);
  text-decoration: none; box-shadow: 0 3px 12px rgba(0,0,0,0.35);
}
.barcalc:active { transform: translateY(1px); }
.bar-intro { color: var(--muted); padding: 0 1.1rem; margin: 0.2rem 0 0.6rem; }
.bar-toggle {
  display: flex; align-items: center; gap: 0.5rem; margin: 0 1rem 0.7rem;
  padding: 0.65rem 0.8rem; background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 10px; font-size: 0.95rem; font-weight: 650; cursor: pointer;
}
.bar-toggle input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent-2); flex: none; }
.bar-checks { padding: 0 1rem; }
.bar-group { margin-bottom: 0.9rem; }
.bar-group-t { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); margin-bottom: 0.4rem; }
.bar-chks { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.chk {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.7rem;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 10px;
  font-size: 0.95rem; cursor: pointer;
}
.chk input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); flex: none; }
.bar-h { font-size: 1.1rem; margin: 1rem 1rem 0.2rem; color: var(--text); }

/* --- Пилюля «Размер порции» --- */
.size { padding: 0.2rem 1.1rem 0.2rem; }
.size-row { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.size-label { font-size: 0.9rem; color: var(--muted); margin-right: 0.2rem; }
.sseg {
  min-width: 2.6rem; padding: 0.45rem 0.5rem; font-size: 0.95rem; font-weight: 650;
  color: var(--muted); background: var(--bg-card);
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.sseg.on { color: var(--bg); background: var(--accent-2); border-color: var(--accent-2); }
.size-info { margin-top: 0.45rem; padding: 0.5rem 0.8rem; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); }
.size-info b { color: var(--text); }
.size-note { color: var(--muted); font-size: 0.8rem; }

/* --- Ссылки-чипы: ингредиенты, бренды, бокалы, техники как фоновые «пилюли» --- */
.recipe a[href*="/c/ingredients/"], .recipe a[href*="/c/brands/"],
.recipe a[href*="/c/glassware/"], .recipe a[href*="/c/techniques/"],
.recipe a[href*="/c/recipes/"], .recipe a[href*="/c/serving/"],
.budget-body a[href*="/c/ingredients/"], .budget-body a[href*="/c/brands/"],
.budget-body a[href*="/c/glassware/"], .budget-body a[href*="/c/techniques/"],
.budget-body a[href*="/c/recipes/"], .budget-body a[href*="/c/serving/"] {
  display: inline-block; padding: 0.02rem 0.45rem; border-radius: 999px;
  text-decoration: none; font-weight: 400; line-height: 1.5; white-space: nowrap;
}
/* ингредиент-чип: по умолчанию «крепкое» (янтарный) */
.recipe a[href*="/c/ingredients/"], .budget-body a[href*="/c/ingredients/"] {
  background: #33281b; color: var(--accent);
}
/* ликёры и биттеры — красноватый */
.recipe a[href$="/ingredients/campari"], .budget-body a[href$="/ingredients/campari"],
.recipe a[href$="/ingredients/sweet-vermouth"], .budget-body a[href$="/ingredients/sweet-vermouth"],
.recipe a[href$="/ingredients/triple-sec"], .budget-body a[href$="/ingredients/triple-sec"],
.recipe a[href$="/ingredients/maraschino"], .budget-body a[href$="/ingredients/maraschino"],
.recipe a[href$="/ingredients/kahlua"], .budget-body a[href$="/ingredients/kahlua"],
.recipe a[href$="/ingredients/blue-curacao"], .budget-body a[href$="/ingredients/blue-curacao"],
.recipe a[href$="/ingredients/angostura"], .budget-body a[href$="/ingredients/angostura"],
.recipe a[href$="/ingredients/falernum"], .budget-body a[href$="/ingredients/falernum"],
.recipe a[href$="/ingredients/creme-violette"], .budget-body a[href$="/ingredients/creme-violette"] {
  background: #34211f; color: #d98a80;
}
/* миксеры/сиропы — голубой */
.recipe a[href$="/ingredients/ginger-beer"], .budget-body a[href$="/ingredients/ginger-beer"],
.recipe a[href$="/ingredients/grenadine"], .budget-body a[href$="/ingredients/grenadine"] {
  background: #1f2a30; color: #7bb0cf;
}
/* бренд — форма «ярлычок-ценник» (срезанный левый угол) */
.recipe a[href*="/c/brands/"], .budget-body a[href*="/c/brands/"] {
  background: #4a2f2a; color: #f0c0b8; border-radius: 0 6px 6px 0;
  padding-left: 0.7em; clip-path: polygon(0.5em 0, 100% 0, 100% 100%, 0.5em 100%, 0 50%);
}
/* бокал — форма «стакан» (низ скруглён), ведёт в раздел «Стаканы» */
.recipe a[href*="/c/glassware/"], .budget-body a[href*="/c/glassware/"] {
  background: #33414d; color: #d6e7f2; border-radius: 3px 3px 9px 9px;
}
/* техника — форма «процесс/стрелка» (срез справа), ведёт в раздел «Техники» */
.recipe a[href*="/c/techniques/"], .budget-body a[href*="/c/techniques/"] {
  background: #2c4a44; color: #c7ebdc; border-radius: 6px 0 0 6px;
  padding-right: 0.7em; clip-path: polygon(0 0, calc(100% - 0.5em) 0, 100% 50%, calc(100% - 0.5em) 100%, 0 100%);
}
/* рецепт (коктейль) — мягкий прямоугольник, розовый. Ведёт на страницу рецепта */
.recipe a[href*="/c/recipes/"], .budget-body a[href*="/c/recipes/"] {
  background: #4a2a3a; color: #f2b8d6; border-radius: 5px;
}
/* тип подачи — форма «вкладка» (верх скруглён), фиолетовый. Ведёт в раздел «Подача» */
.recipe a[href*="/c/serving/"], .budget-body a[href*="/c/serving/"] {
  background: #382f50; color: #cdbcf0; border-radius: 9px 9px 3px 3px;
}

/* --- Теги-чипы (цвет = категория) --- */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0 1.1rem 0.4rem; }
.chip {
  font-size: 0.85rem; font-weight: 650; padding: 0.32rem 0.75rem;
  border-radius: 999px; text-decoration: none; color: #1a1206; white-space: nowrap;
}
.chip:active { filter: brightness(0.9); }
/* вкусовые чипы — контурные (рамка, без заливки), цвет = вкус */
.flavors { margin-top: -0.1rem; }
.flavors .chip { background: transparent; border: 1.5px solid currentColor; }
.fl-strong { color: #d98a8a; }
.fl-sour { color: #b6d96a; }
.fl-sweet { color: #e092bd; }
.fl-bitter { color: #cda06a; }
.fl-spicy { color: #e89a6a; }
.fl-fresh { color: #7fc6d6; }
.fl-other { color: var(--muted); }

/* ряд «как готовить» (метод + бокал); те же формы дублируются инлайн в тексте */
.prep { margin-top: -0.1rem; }
/* бокал — форма «стакан» (низ скруглён) */
.chip.glass {
  background: #33414d; color: #d6e7f2; border-radius: 4px 4px 11px 11px;
}
.chip.glass:active { filter: brightness(1.12); }
/* метод — форма «процесс/стрелка» (срез справа) */
.chip.method {
  background: #2c4a44; color: #c7ebdc; border-radius: 6px 0 0 6px; padding-right: 1.05em;
  clip-path: polygon(0 0, calc(100% - 0.5em) 0, 100% 50%, calc(100% - 0.5em) 100%, 0 100%);
}
.chip.method:active { filter: brightness(1.12); }

/* строка метрик: крепость и цена-бакет */
.metrics { display: flex; gap: 1.2rem; padding: 0.1rem 1.1rem 0.3rem; color: var(--muted); font-size: 0.9rem; }
.metrics .dots { letter-spacing: 1px; color: var(--accent-2); }
.metrics .bucket { color: var(--accent); font-weight: 700; }

/* плавающий островок выбора режима (правый нижний угол) */
.modedock { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; opacity: 0.88;
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.mode-fab { width: 4.5rem; height: 4.5rem; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg-card-hi); color: var(--text); font-size: 2.6rem; cursor: pointer;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; }
.mode-menu { display: flex; flex-direction: column; gap: 0.6rem; }
.mode-menu.hidden { display: none; }
.mode-opt { width: 4rem; height: 4rem; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg-card); color: var(--text); font-size: 2.4rem; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); display: flex; align-items: center; justify-content: center; }
.mode-opt.on { background: var(--accent); border-color: var(--accent); }

/* режим «Крупно»: крупно + КАПС (включая бренды/ингредиенты) */
.big-card { font-size: 1.5rem; line-height: 1.6; text-transform: uppercase; }
.big-card h2, .big-card h3 { font-size: 1.5rem; color: var(--accent); }
.big-card ul { padding-left: 1.2rem; }

/* режим «Просто»: джиггеры крупно */
.ultra-card { padding: 1.4rem 1.1rem; }
.ultra-pour { list-style: none; padding: 0; margin: 0; }
.ultra-pour li { font-size: 2rem; line-height: 1.8; }
.ultra-pour b { color: var(--accent); white-space: nowrap; }
.jig { width: 0.6em; height: 0.92em; vertical-align: -0.1em; margin-left: 0.06em; fill: currentColor; }
.ultra-how { font-size: 1.3rem; line-height: 1.5; margin-top: 1.2rem; color: var(--text); }
.ultra-jig { color: var(--muted); margin-top: 1.4rem; font-size: 0.95rem; }

/* настройки */
.settings { padding: 1rem 1.1rem; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.6rem 0; }
.set-row input, .set-row select { width: 6rem; padding: 0.45rem; font-size: 1.1rem;
  background: var(--bg-card); color: var(--text); border: 1px solid var(--line); border-radius: 0.4rem; }
.set-hint { color: var(--muted); font-size: 0.85rem; margin: 0.1rem 0 0.9rem; }
.foot a { color: var(--accent); }

.g-strong { background: #e6a15c; }
.g-liqueur { background: #d98a80; }
.g-mixer { background: #7bb0cf; }
.g-fresh { background: #97c777; }
.g-other { background: #c2ad9a; }
.detail-title .chip { font-size: 1rem; }

@media (min-width: 600px) { :root { --fs: 18px; } }
