@layer utilities {
  .no-scrollbar::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none
  }

  .no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none
  }
}

html,
body {
  max-width: 100%;
  overflow-x: hidden
}

*,
*::before,
*::after {
  box-sizing: border-box
}

section,
.card,
.container {
  max-width: 100%;
  box-sizing: border-box
}

/* ---------- Чипы дней ---------- */
.day-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 9999px;
  padding: 10px 16px;
  height: 40px;
  background: rgba(30, 41, 59, .06);
  border: 1px solid rgba(148, 163, 184, .25);
  color: inherit;
  line-height: 1.1;
  transition: background .2s, border-color .2s, transform .08s;
  white-space: nowrap
}

.day-pill:hover {
  background: rgba(30, 41, 59, .12);
  border-color: rgba(148, 163, 184, .4)
}

.day-pill:active {
  transform: scale(.98)
}

.day-pill.is-active {
  background: linear-gradient(120deg, #6d5ef9 0%, #7c6dfc 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(109, 94, 249, .25)
}

.dark .day-pill {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .9)
}

.dark .day-pill:hover {
  background: rgba(255, 255, 255, .10);
  border-color: rgba(255, 255, 255, .2)
}

.dark .day-pill.is-active {
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(109, 94, 249, .35)
}

@media (prefers-color-scheme:dark) {
  .day-pill {
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .12);
    color: rgba(255, 255, 255, .9)
  }

  .day-pill:hover {
    background: rgba(255, 255, 255, .10);
    border-color: rgba(255, 255, 255, .2)
  }

  .day-pill.is-active {
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(109, 94, 249, .35)
  }
}

/* Sticky чипы на мобилках */
@media (max-width:767px) {
  #plan-days-wrap {
    position: sticky;
    top: 0;
    z-index: 10;
    background: inherit;
    padding: 6px 0
  }
}

/* ---------- Секции приёмов пищи ---------- */
.meal-section {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, .25)
}

.dark .meal-section {
  border-color: rgba(255, 255, 255, .10)
}

.meal-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, .05)
}

.dark .meal-header {
  background: rgba(255, 255, 255, .05)
}

.meal-body {
  border-top: 1px solid rgba(148, 163, 184, .25)
}

.dark .meal-body {
  border-color: rgba(255, 255, 255, .10)
}

.meal-row {
  padding: 12px 16px
}

.progress {
  height: 8px;
  border-radius: 9999px;
  overflow: hidden;
  width: 96px;
  background: rgba(15, 23, 42, .08)
}

.dark .progress {
  background: rgba(255, 255, 255, .10)
}

.progress>i {
  display: block;
  height: 100%;
  width: 0%;
  background: #10b981
}

input[type="checkbox"].js-meal-chk {
  width: 20px;
  height: 20px
}

/* Mobile compact */
@media (max-width:390px) {
  .day-pill {
    padding: 8px 12px;
    height: 38px
  }
}

#plan-days {
  max-width: 100%;
  box-sizing: border-box
}

/* =======================
   Mobile App-like Shell
   ======================= */
:root {
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px)
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: calc(10px + var(--app-safe-top));
  padding-bottom: 10px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(148, 163, 184, .25)
}

.dark .app-header {
  background: rgba(15, 23, 42, .72);
  border-bottom-color: rgba(255, 255, 255, .10)
}

.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px;
  padding-bottom: calc(60px + var(--app-safe-bottom))
}

@media (min-width:768px) {
  .app-content {
    padding: 20px;
    padding-bottom: 24px
  }
}

.app-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  padding-bottom: var(--app-safe-bottom);
  z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(148, 163, 184, .25)
}

.dark .app-tabbar {
  background: rgba(15, 23, 42, .78);
  border-top-color: rgba(255, 255, 255, .10)
}

.app-tabbar .tabbar-inner {
  max-width: 880px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 10px
}

.app-tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none
}

.app-tabbar a.is-active {
  background: rgba(2, 6, 23, .06)
}

.dark .app-tabbar a.is-active {
  background: rgba(255, 255, 255, .08)
}

.app-tabbar .t-label {
  font-size: 11px;
  line-height: 1
}

/* Dark theme polish */
input[type="checkbox"].js-meal-chk {
  accent-color: #334155
}

.dark input[type="checkbox"].js-meal-chk {
  accent-color: #94a3b8;
  filter: saturate(.85) brightness(.95)
}

/* =============================
   Dark theme polish for controls (elegant)
   ============================= */
/* 1) Checkbox */
input[type="checkbox"].js-meal-chk {
  accent-color: #475569
}

.dark input[type="checkbox"].js-meal-chk {
  accent-color: #94a3b8;
  filter: saturate(.85) brightness(.92)
}

input[type="checkbox"].js-meal-chk:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, .25);
  border-radius: 6px
}

.dark input[type="checkbox"].js-meal-chk:focus-visible {
  box-shadow: 0 0 0 3px rgba(148, 163, 184, .28)
}

/* 2) Portion +/- buttons */
.js-portion-inc,
.js-portion-dec {
  border: 1px solid rgba(15, 23, 42, .12);
  background: rgba(15, 23, 42, .02);
  color: inherit;
  border-radius: 10px;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease
}

.js-portion-inc:hover,
.js-portion-dec:hover {
  background: rgba(15, 23, 42, .05)
}

.js-portion-inc:active,
.js-portion-dec:active {
  background: rgba(15, 23, 42, .08)
}

.js-portion-inc:focus-visible,
.js-portion-dec:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .18)
}

.dark .js-portion-inc,
.dark .js-portion-dec {
  border-color: rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .92)
}

.dark .js-portion-inc:hover,
.dark .js-portion-dec:hover {
  background: rgba(255, 255, 255, .07)
}

.dark .js-portion-inc:active,
.dark .js-portion-dec:active {
  background: rgba(255, 255, 255, .10)
}

.dark .js-portion-inc:focus-visible,
.js-portion-dec:focus-visible {
  box-shadow: 0 0 0 3px rgba(148, 163, 184, .25)
}

/* 3) Portion input */
.js-portion-input {
  border: 1px solid rgba(15, 23, 42, .12);
  background: rgba(15, 23, 42, .02);
  color: inherit;
  border-radius: 10px;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease
}

.js-portion-input:hover {
  background: rgba(15, 23, 42, .05)
}

.js-portion-input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .18)
}

.dark .js-portion-input {
  border-color: rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .95)
}

.dark .js-portion-input:hover {
  background: rgba(255, 255, 255, .07)
}

.dark .js-portion-input:focus-visible {
  box-shadow: 0 0 0 3px rgba(148, 163, 184, .25)
}

/* === Navbar Search (adapted) === */
.search-group {
  position: relative;
  display: flex;
  align-items: center;
  line-height: 28px;
  max-width: 20rem
}

.search-input {
  width: 14rem;
  height: 2.75rem;
  padding-left: 2.5rem;
  padding-right: .75rem;
  border-radius: 1rem;
  border: 1px solid rgba(15, 23, 42, .12);
  background: rgba(15, 23, 42, .02);
  color: inherit;
  outline: none;
  box-shadow: 0 0 0 1.5px rgba(15, 23, 42, .14), 0 0 25px -17px #000;
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, transform .1s ease
}

.search-input::placeholder {
  color: #94a3b8
}

.search-input:hover {
  background: rgba(15, 23, 42, .05);
  box-shadow: 0 0 0 2.5px rgba(15, 23, 42, .20), 0 0 25px -15px #000
}

.search-input:focus {
  box-shadow: 0 0 0 2.5px rgba(99, 102, 241, .35);
  border-color: rgba(99, 102, 241, .45)
}

.search-input:active {
  transform: scale(.985)
}

.search-icon {
  position: absolute;
  left: 1rem;
  width: 1rem;
  height: 1rem;
  pointer-events: none;
  fill: currentColor;
  color: #94a3b8
}

.dark .search-input {
  border-color: rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .95);
  box-shadow: 0 0 0 1.5px rgba(148, 163, 184, .18), 0 0 25px -17px #000
}

.dark .search-input:hover {
  background: rgba(255, 255, 255, .08);
  box-shadow: 0 0 0 2.5px rgba(148, 163, 184, .22), 0 0 25px -15px #000
}

.dark .search-input:focus {
  box-shadow: 0 0 0 2.5px rgba(148, 163, 184, .30);
  border-color: rgba(148, 163, 184, .40)
}

.dark .search-icon {
  color: #cbd5e1
}

@media (min-width:1024px) {
  .search-input {
    width: 20rem
  }
}

/* === Autocomplete dropdown (elegant) === */
.search-group .ac-panel {
  left: 0;
  right: 0;
  min-width: 100%
}

.ac-panel {
  padding: 6px;
  background: rgba(255, 255, 255, .98)
}

.dark .ac-panel {
  background: rgba(2, 6, 23, .96)
}

.ac-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: inherit
}

.ac-item:hover {
  background: rgba(2, 6, 23, .06)
}

.dark .ac-item:hover {
  background: rgba(255, 255, 255, .08)
}

.ac-item.is-active {
  outline: 2px solid rgba(99, 102, 241, .35);
  outline-offset: 0;
  background: rgba(99, 102, 241, .07)
}

.dark .ac-item.is-active {
  outline-color: rgba(148, 163, 184, .35);
  background: rgba(148, 163, 184, .10)
}

.ac-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.ac-item-meta {
  margin-left: 12px;
  font-size: .8rem;
  color: #64748b
}

.dark .ac-item-meta {
  color: #94a3b8
}

.ac-empty {
  padding: 12px;
  color: #64748b
}

.dark .ac-empty {
  color: #a8b2c4
}

.ac-footer {
  margin-top: 4px;
  padding: 8px 10px;
  text-align: center;
  border-top: 1px solid rgba(148, 163, 184, .20)
}

.dark .ac-footer {
  border-top-color: rgba(255, 255, 255, .10)
}

.ac-footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(99, 102, 241, .10);
  color: #4338ca
}

.ac-footer-btn:hover {
  background: rgba(99, 102, 241, .16)
}

.dark .ac-footer-btn {
  background: rgba(99, 102, 241, .15);
  color: #c7d2fe
}

.dark .ac-footer-btn:hover {
  background: rgba(99, 102, 241, .22)
}

/* =============================
   Search page specific overrides
   ============================= */
/* На /search поле шире — не ограничиваем 20rem из navbar */
.search-hero .search-group {
  max-width: 100%
}

.search-hero .search-input {
  width: 100%;
  height: 3rem
}

/* Выпадашка тянется ровно по ширине */
.search-hero .ac-panel {
  left: 0;
  right: 0;
  min-width: 100%
}

@media (min-width:640px) {
  .search-hero .search-input {
    height: 3rem
  }
}

/* Горизонтальный скролл фильтров на мобилках */
.filters-wrap {
  margin-right: -0.25rem
}

.filters-wrap>.flex {
  padding-bottom: 2px
}

/* Ensure chips don't shrink and stay on one visual row via horizontal scroll */
.filters-wrap .day-pill {
  flex: 0 0 auto
}

.filters-wrap>.flex {
  align-items: center;
  gap: .5rem
}

/* On small screens, move the sort select to the next line with proper spacing */
@media (max-width: 640px) {
  .filters-wrap>.flex {
    flex-wrap: wrap;
    row-gap: .5rem
  }

  .filters-wrap .js-sort {
    margin-left: auto
  }
}

/* Tighten hero spacing so the block looks balanced on mobile */
.search-hero .mx-auto>.flex {
  margin-bottom: .25rem
}

.search-hero form {
  margin-top: .5rem
}

/* Avoid double-outline clashing for the search submit icon button */
.search-hero button[type="submit"] {
  box-shadow: none;
  border: 1px solid rgba(148, 163, 184, .25)
}

.dark .search-hero button[type="submit"] {
  border-color: rgba(255, 255, 255, .12)
}


/* Уплотняем чипы на очень узких экранах */
@media (max-width:380px) {
  .day-pill {
    padding: 8px 12px;
    height: 36px
  }
}

/* Карточки не переполняют контейнер */
#search-results {
  width: 100%
}

#search-results>article {
  min-width: 0
}

html,
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji';
}

[x-cloak] { display: none !important; }