:root {
  --am-picker-green: var(--am-catalog-green, #18743c);
  --am-picker-green-dark: var(--am-catalog-green-dark, #105c2e);
  --am-picker-ink: var(--am-catalog-ink, #17251c);
  --am-picker-muted: var(--am-catalog-muted, #66736a);
  --am-picker-line: var(--am-catalog-line, #dce7de);
  --am-picker-soft: #f5faf6;
  --am-picker-context: #edf7ef;
  --am-picker-selected: #dcefe1;
}

.am-category-picker {
  position: relative;
  min-width: 0;
  color: var(--am-picker-ink);
}

.am-category-picker *,
.am-category-picker *::before,
.am-category-picker *::after {
  box-sizing: border-box;
}

.am-category-picker__toggle {
  display: flex;
  width: 100%;
  min-width: 0;
  height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid #cbd8cd;
  border-radius: 9px;
  background: #f8faf8;
  color: var(--am-picker-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.am-category-picker__toggle:hover {
  border-color: #96ad9a;
  background: var(--am-picker-soft);
}

.am-category-picker__toggle[aria-expanded="true"] {
  border-color: var(--am-picker-green);
  box-shadow: 0 0 0 3px rgba(24, 116, 60, .14);
}

.am-category-picker__toggle > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.am-category-picker__chevron {
  flex: 0 0 auto;
  color: var(--am-picker-green-dark);
  font-size: 18px;
  line-height: 1;
  transition: transform .16s ease;
}

.am-category-picker__toggle[aria-expanded="true"] .am-category-picker__chevron {
  transform: rotate(180deg);
}

.am-category-picker__toggle:focus-visible,
.am-category-picker__panel button:focus-visible {
  outline: 3px solid rgba(24, 116, 60, .28);
  outline-offset: 2px;
}

.am-category-picker__panel {
  position: absolute;
  z-index: 950;
  top: calc(100% + 8px);
  left: 0;
  width: min(760px, calc(100vw - 32px));
  max-height: min(540px, var(--am-picker-available-height, calc(100vh - 120px)));
  overflow: hidden;
  border: 1px solid #bfd3c3;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(6, 22, 42, .2);
  transform: translateX(var(--am-picker-shift-x, 0));
}

.am-category-picker__panel[hidden],
.am-category-picker__level--two > [hidden] {
  display: none !important;
}

.am-category-picker__header {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 12px 9px 16px;
  border-bottom: 1px solid var(--am-picker-line);
  color: var(--am-picker-green-dark);
}

.am-category-picker__header strong {
  font-size: 14px;
}

.am-category-picker__header button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--am-picker-line);
  border-radius: 8px;
  background: #fff;
  color: #385044;
  font: inherit;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

.am-category-picker__header button:hover {
  border-color: #8fb498;
  background: var(--am-picker-soft);
  color: var(--am-picker-green-dark);
}

.am-category-picker__columns {
  display: grid;
  grid-template-columns: minmax(235px, .82fr) minmax(320px, 1.18fr);
  height: min(486px, calc(var(--am-picker-available-height, calc(100vh - 120px)) - 52px));
  min-height: min(300px, calc(var(--am-picker-available-height, calc(100vh - 120px)) - 52px));
}

.am-category-picker__level {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding: 14px;
}

.am-category-picker__level--one {
  border-right: 1px solid var(--am-picker-line);
  background: #fbfcfb;
}

.am-category-picker__level h3 {
  flex: 0 0 auto;
  margin: 0 0 10px;
  color: var(--am-picker-green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.am-category-picker__level ul {
  min-height: 0;
  margin: 0;
  padding: 0 3px 0 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  scrollbar-color: #a8c4ae transparent;
  scrollbar-width: thin;
}

.am-category-picker__level li + li {
  margin-top: 3px;
}

.am-category-picker__root-row {
  display: flex;
  align-items: stretch;
  gap: 2px;
  border-radius: 8px;
}

.am-category-picker__choice,
.am-category-picker__root-toggle {
  border: 1px solid transparent;
  background: transparent;
  color: #2a3f31;
  font: inherit;
  cursor: pointer;
}

.am-category-picker__choice {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 38px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.28;
  text-align: left;
}

.am-category-picker__choice span {
  overflow-wrap: anywhere;
}

.am-category-picker__root-row .am-category-picker__choice {
  flex: 1 1 auto;
}

.am-category-picker__root-toggle {
  display: grid;
  width: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 8px;
  color: var(--am-picker-green);
  font-size: 20px;
  line-height: 1;
}

.am-category-picker__choice:focus-visible,
.am-category-picker__root-toggle:focus-visible,
.am-category-picker__root.is-active .am-category-picker__root-row {
  background: var(--am-picker-soft);
}

.am-category-picker__choice:hover,
.am-category-picker__root-toggle:hover {
  background: var(--am-picker-context);
}

.am-category-picker__choice.is-context {
  border-color: #c6dfcc;
  background: var(--am-picker-context);
  color: var(--am-picker-green-dark);
  font-weight: 650;
}

.am-category-picker__choice.is-selected {
  border-color: #78aa84;
  background: var(--am-picker-selected);
  color: #0d5429;
  font-weight: 750;
  box-shadow: inset 3px 0 0 var(--am-picker-green);
}

.am-category-picker__level--two ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 5px;
}

.am-category-picker__level--two li + li {
  margin-top: 0;
}

.am-category-picker__empty {
  margin: 6px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: #f7faf7;
  color: var(--am-picker-muted);
  font-size: 13px;
  line-height: 1.45;
}

.am-catalog-search__label {
  display: block;
  margin: 0 0 5px;
  color: #425248;
  font-size: 12px;
  font-weight: 700;
}

.am-home-search .am-category-picker__toggle {
  min-height: 42px;
  height: 42px;
  border-color: #dce3de;
  border-radius: 6px;
  background: #f4f6f4;
  color: #405046;
  font-size: 12px;
}

@media (max-width: 1000px) and (min-width: 701px) {
  .am-category-picker__panel {
    right: 0;
    left: auto;
  }
}

@media (max-width: 700px) {
  .am-category-picker__panel {
    position: fixed;
    top: 69px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100dvh - 79px);
    overflow-y: auto;
    border-radius: 12px;
  }

  .am-category-picker__header {
    position: sticky;
    z-index: 2;
    top: 0;
    background: #fff;
  }

  .am-category-picker__columns {
    display: block;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .am-category-picker__level {
    padding: 13px;
  }

  .am-category-picker__level--one {
    border-right: 0;
    border-bottom: 1px solid var(--am-picker-line);
  }

  .am-category-picker__level ul {
    max-height: 34dvh;
  }

  .am-category-picker__level--two ul {
    grid-template-columns: minmax(0, 1fr);
    max-height: 36dvh;
  }

  .am-category-picker__choice {
    min-height: 42px;
  }
}

@media (max-width: 380px) {
  .am-category-picker__panel {
    right: 7px;
    left: 7px;
  }

  .am-home-search .am-category-picker__toggle {
    min-height: 36px;
    height: 36px;
    padding-inline: 7px;
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .am-category-picker__chevron {
    transition: none;
  }
}
