.category-menu {
  position: relative;
  align-self: stretch;
  flex: 0 0 auto;
  color: var(--ink);
}

.category-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 4px 9px 4px 0;
  list-style: none;
  color: var(--heading);
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.category-trigger::-webkit-details-marker { display: none; }
.category-trigger::marker { content: ''; }
.category-trigger:hover, .category-menu[open] > .category-trigger { color: var(--accent); }
.category-trigger:focus-visible { outline-offset: -2px; }
.category-trigger svg { width: 21px; height: 21px; }
.category-trigger .category-caret {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  line-height: 0;
}

.category-caret > svg { width: 100%; height: 100%; transform: rotate(90deg); }
.category-menu[open] .category-caret { transform: rotate(180deg); }

.category-panel {
  position: absolute;
  z-index: 9;
  inset-block-start: 100%;
  inset-inline-start: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(600px, calc(100vw - 2 * var(--gutter)));
  max-height: 610px;
  max-height: min(610px, max(180px, calc(100dvh - 153px)));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
  background: var(--paper, #fff);
  box-shadow: 0 18px 36px rgb(19 61 36 / .14), 0 4px 10px rgb(19 61 36 / .06);
  line-height: 1.4;
}

.category-menu:not([open]) .category-panel { display: none; }

.category-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 10px;
  padding: 5px 12px 5px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.category-panel-head :is(h2, h3) { font: inherit; }

.category-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.category-close:hover { background: #f4f5f4; color: var(--accent); }
.category-close svg { width: 19px; height: 19px; }

.category-columns {
  display: grid;
  grid-template-columns: minmax(0, 40%) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.category-groups, .category-content {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: #c4ccc7 transparent;
}

.category-groups {
  padding: 8px 0;
  border-inline-end: 1px solid var(--line);
  background: var(--paper);
}

.category-group {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 8px 14px 8px 15px;
  border: 0;
  border-inline-start: 3px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: start;
  font-size: 15px;
  font-weight: 670;
  line-height: 1.35;
}

.category-group:hover { color: var(--accent); background: #f6f7f6; }

.category-group[aria-pressed='true'] {
  border-inline-start-color: var(--accent);
  background: #f1f3f2;
  color: var(--heading);
  font-weight: 780;
}

.category-group svg { width: 21px; height: 21px; }
.category-group svg:last-child:not(:first-child) { width: 13px; height: 13px; margin-inline-start: auto; }

[data-group='food'] { --department-ink: #496c37; }
[data-group='life'] { --department-ink: #326e70; }
[data-group='fashion'] { --department-ink: #6b5491; }
[data-group='beauty'] { --department-ink: #92526b; }
[data-group='digital'] { --department-ink: #416d96; }
[data-group='interior'] { --department-ink: #8a5e3b; }
[data-group='sports'] { --department-ink: #8b681d; }
[data-group='pets'] { --department-ink: #9a5346; }

.category-group > svg:first-child,
.mobile-drawer-department > summary > svg:first-child {
  flex: 0 0 auto;
  color: var(--department-ink, var(--muted));
}

.category-content { padding: 16px 20px; }
.category-links { display: grid; align-content: start; gap: 1px; }

.category-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 7px;
  padding: 2px 6px 13px;
  border-bottom: 1px solid var(--line);
}

.category-preview img {
  display: block;
  width: 68px;
  height: 68px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: #eaf3ed;
  object-fit: cover;
}

.category-heading {
  margin: 0 1px 5px;
  padding: 4px 8px 9px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.category-preview .category-heading { margin: 0; padding: 0; border: 0; }

.category-link, .category-all {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 45px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 620;
  line-height: 1.35;
  white-space: normal;
}

.category-link:hover, .category-link[aria-current], .category-all:hover { background: #f4f5f4; color: var(--accent); }
.category-branch > summary { list-style: none; cursor: pointer; }
.category-branch > summary::-webkit-details-marker { display: none; }
.category-branch > summary svg {
  width: 15px;
  height: 15px;
  margin-inline-start: auto;
  color: var(--muted);
  transform: rotate(90deg);
}
.category-branch[open] > summary svg { transform: rotate(-90deg); }
.category-branch:is([open], :has([aria-current])) > summary { background: #f1f3f2; color: var(--accent); font-weight: 730; }
.category-branch-links { margin: 2px 0 7px 15px; padding-inline-start: 7px; border-inline-start: 1px solid var(--line); }
.category-branch-links .category-link { min-height: 42px; font-size: 14px; }
.category-branch-links .category-branch-overview { color: var(--accent); font-weight: 730; }
.category-all { margin-top: 5px; color: var(--accent); font-weight: 780; }
.category-all svg { width: 14px; height: 14px; }
.category-panel :focus-visible { outline-offset: -2px; }

@media (min-width: 721px) {
  .category-panel {
    max-height: calc(100vh - 150px);
    max-height: calc(100dvh - 150px);
  }
}

@media (min-width: 721px) and (max-height: 820px) {
  .category-content { padding-block: 12px; }
  .category-preview img { width: 58px; height: 58px; }
  .category-link, .category-all { min-height: 39px; }
}

.mobile-drawer-categories { border: 1px solid var(--line); background: var(--paper); }
.mobile-drawer-department[open] > summary { background: #f4f5f4; }
.mobile-drawer-department > .mobile-drawer-submenu { grid-template-columns: minmax(0, 1fr); }
.mobile-drawer-department .category-branch > summary { min-height: 42px; padding-inline: 8px; font-size: 14px; }
.mobile-drawer-department .category-branch-links { margin-inline-start: 13px; }

@media (max-width: 720px) {
  .category-trigger { gap: 6px; min-height: 46px; padding-inline: 0; font-size: 15px; }
  .category-trigger svg { width: 19px; height: 19px; }
  .category-trigger .category-caret { width: 12px; height: 12px; }

  .category-panel {
    width: calc(100vw - 2 * var(--gutter));
    max-height: min(595px, max(140px, calc(100vh - 212px)));
    max-height: min(595px, max(140px, calc(100dvh - 212px - env(safe-area-inset-bottom))));
    border-radius: 0 0 11px 11px;
  }

  .category-panel-head { min-height: 49px; padding-inline: 13px 7px; font-size: 16px; }
  .category-close { width: 42px; height: 42px; }
  .category-columns { grid-template-columns: minmax(0, 44%) minmax(0, 1fr); }
  .category-groups { padding-block: 6px; }
  .category-group { gap: 7px; min-height: 47px; padding-inline: 8px 6px; font-size: 14px; }
  .category-group svg { width: 17px; height: 17px; }
  .category-group svg:last-child:not(:first-child) { width: 11px; height: 11px; }
  .category-content { padding: 10px 9px 13px; }
  .category-preview { gap: 8px; padding-inline: 3px; }
  .category-preview img { width: 48px; height: 48px; border-radius: 7px; }
  .category-heading { font-size: 15px; }
  .category-link, .category-all { min-height: 43px; font-size: 14px; }
}

@media (max-width: 375px) {
  .category-trigger { gap: 5px; font-size: 14px; }
  .category-group { gap: 4px; padding-inline: 5px 4px; }
  .category-group svg { width: 16px; height: 16px; }
  .category-group svg:last-child:not(:first-child) { width: 10px; height: 10px; }
  .category-content { padding-inline: 6px; }
}
