/* Shared mobile header. Desktop keeps its existing search and labelled actions. */
.mobile-search-toggle,
.mobile-search-panel {
  display: none;
}

.mobile-search-panel[hidden] {
  display: none;
}

@media (max-width: 850px) {
  .header {
    height: 76px;
    gap: 8px;
  }

  .header .brand {
    min-width: 0;
    flex: 1 1 auto;
    white-space: nowrap;
  }

  .header > .search,
  .header .phone,
  .header .catalog-button {
    display: none;
  }

  .header .account,
  .header .cart,
  .header .mobile-search-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    gap: 0;
    border: 1px solid #d9e4ed;
    border-radius: 50% !important;
    color: var(--ink);
    background: #fff;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
  }

  .header .mobile-search-toggle {
    order: 1;
  }

  .header .account::after,
  .header .cart::after {
    display: none;
  }

  .header .account svg,
  .header .cart svg,
  .mobile-search-toggle svg,
  .mobile-search-close svg,
  .mobile-search-submit svg,
  .mobile-search-panel .search svg {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .header .cart em {
    min-width: 20px;
    height: 20px;
    top: -5px;
    right: -2px;
    padding: 0 3px;
    display: grid;
    place-items: center;
    line-height: 1;
    border: 2px solid #fff;
    box-sizing: border-box;
  }

  .header .menu {
    display: grid;
    place-items: center;
    flex: 0 0 28px;
    width: 28px;
    height: 40px;
    margin: 0;
    padding: 0;
    color: var(--ink);
    font-size: 26px;
    line-height: 1;
  }

  .mobile-search-toggle[aria-expanded="true"] {
    color: var(--blue);
    background: #edf5ff;
    border-color: #9bc5f4;
  }

  .mobile-search-panel {
    position: relative;
    z-index: 3;
    display: block;
    padding: 14px 0 19px;
    border-top: 1px solid #e6edf3;
    border-bottom: 1px solid #e6edf3;
    background: #fff;
    box-shadow: 0 9px 18px rgba(9, 27, 53, .045);
    animation: mobile-search-reveal .18s ease-out;
  }

  .mobile-search-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 9px;
  }

  .mobile-search-heading p {
    margin: 0;
    color: #5c728a;
    font: 700 12px Manrope, Arial, sans-serif;
  }

  .mobile-search-close {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin-right: -5px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #6b8096;
    cursor: pointer;
  }

  .mobile-search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 8px;
  }

  .mobile-search-panel .search {
    display: flex;
    min-width: 0;
    max-width: none;
    height: 48px;
    margin: 0;
    padding: 0 12px;
    gap: 8px;
    border: 1px solid #d3dfea;
    border-radius: 6px;
    background: #f5f8fb;
    color: #839ab0;
  }

  .mobile-search-panel .search:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(22, 119, 232, .1);
  }

  .mobile-search-panel .search input {
    width: 100%;
    min-width: 0;
    padding: 0;
    color: var(--ink);
    background: transparent;
    font-size: 16px;
  }

  .mobile-search-panel .search > span {
    display: none;
  }

  .mobile-search-panel .search > svg {
    display: block;
  }

  .mobile-search-submit {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: var(--blue);
    color: #fff;
    cursor: pointer;
  }

  .mobile-search-submit:hover {
    background: #0966cf;
  }

  .mobile-search-toggle:focus-visible,
  .mobile-search-close:focus-visible,
  .mobile-search-submit:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 3px;
  }
}

/* Keep the smallest supported phone width free of flex squeezing. */
@media (max-width: 360px) {
  .header { gap: 4px; }
  .header .brand { font-size: 16px; }
  .header .brand i { width: 20px; height: 27px; margin-right: 6px; flex-shrink: 0; }
  .header .brand small { font-size: 6px; }
  .header .menu { flex-basis: 26px; width: 26px; }
}

@keyframes mobile-search-reveal {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-search-panel { animation: none; }
}
