.search {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
}

.search.active {
  display: block;
}

.search__overlay {
  position: absolute;
  inset: 0;
  background: var(--search-overlay-bg);
}

.search__modal {
  position: relative;
  z-index: 1;
  width: calc(100vw - 80px);
  max-height: calc(100vh - 40px);
  margin: 20px 40px 0;
  background: var(--search-modal-bg);
  border: 1px solid var(--search-border);
  border-radius: 15px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.search__header {
  position: relative;
  flex: 0 0 auto;
  background: var(--search-modal-bg);
  border-bottom: 1px solid var(--search-divider);
}

.search__field {
  min-width: 0;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 64px 0 18px;
  background: transparent;
  border: none;
}

.search__field-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.search__field-icon img {
  width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
}

.search__input {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  box-shadow: none;
  font-family: 'Inter', sans-serif;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--search-text);
}

.search__input::placeholder {
  color: var(--search-muted);
  opacity: 1;
}

.search__close {
  position: absolute;
  top: 50%;
  right: 18px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  border-radius: 10px;
  transition: background 0.18s ease, opacity 0.18s ease;
}

.search__close:hover {
  background: var(--search-hover);
}

.search__close img {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
  opacity: 1;
  visibility: visible;
}

.search__results {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  background: var(--search-modal-bg);
}

.search__results:empty {
  display: none;
}

.search__results::-webkit-scrollbar {
  width: 8px;
}

.search__results::-webkit-scrollbar-thumb {
  background: var(--search-divider);
  border-radius: 999px;
}

.search__results::-webkit-scrollbar-track {
  background: transparent;
}

.search__item {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1px minmax(0, 1fr) 1px 22px;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  margin: 0 0 8px;
  text-decoration: none;
  color: var(--search-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 16px;
  transition:
    background 0.18s ease,
    border-color 0.18s ease;
}

.search__item:last-child {
  margin-bottom: 0;
}

.search__item:hover {
  background: var(--search-hover);
  border-color: var(--search-border);
}

.search__item-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--search-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search__item-divider {
  width: 1px;
  height: 42px;
  background: var(--search-divider);
}

.search__item-desc {
  font-size: 15px;
  line-height: 1.35;
  color: var(--search-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search__item-arrow {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  line-height: 0;
}

.search__item-arrow img {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}

.search__empty {
  padding: 10px 8px 12px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--search-muted);
}

html[data-theme="light"] .search__field-icon img,
html[data-theme="light"] .search__close img,
html[data-theme="light"] .search__item-arrow img {
  filter: none;
}

html[data-theme="dark"] .search__field-icon img,
html[data-theme="dark"] .search__close img,
html[data-theme="dark"] .search__item-arrow img {
  filter: brightness(0) invert(1);
}

@media (max-width: 900px) and (min-width: 601px) {
  .search__modal {
    width: calc(100vw - 40px);
    max-height: calc(100vh - 24px);
    margin: 12px 20px 0;
    border-radius: 18px;
  }

  .search__field {
    height: 60px;
    padding: 0 60px 0 16px;
    gap: 12px;
  }

  .search__field-icon,
  .search__field-icon img {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
  }

  .search__input {
    font-size: 16px;
  }

  .search__close {
    right: 14px;
    width: 34px;
    height: 34px;
  }

  .search__close img {
    width: 18px;
    height: 18px;
  }

  .search__results {
    padding: 10px;
  }

  .search__item {
    grid-template-columns: minmax(0, 1fr) 22px;
    grid-template-rows: auto auto;
    column-gap: 14px;
    row-gap: 6px;
    padding: 16px 18px;
    border-radius: 14px;
  }

  .search__item-title {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    font-size: 15px;
  }

  .search__item-desc {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    font-size: 13px;
    line-height: 1.45;
    white-space: nowrap;
  }

  .search__item-arrow {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
    justify-self: end;
  }

  .search__item-divider {
    display: none;
  }

  .search__empty {
    padding: 8px 6px 10px;
    font-size: 13px;
  }
}

@media (max-width: 600px) {
  .search__modal {
    width: calc(100vw - 28px);
    max-height: calc(100vh - 12px);
    margin: 6px 14px 0;
    border-radius: 16px;
  }

  .search__field {
    height: 56px;
    padding: 0 56px 0 14px;
    gap: 12px;
  }

  .search__field-icon,
  .search__field-icon img {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
  }

  .search__input {
    font-size: 16px;
  }

  .search__close {
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .search__close img {
    width: 18px;
    height: 18px;
  }

  .search__results {
    padding: 8px;
  }

  .search__item {
    grid-template-columns: minmax(0, 1fr) 20px;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 6px;
    padding: 14px 16px;
    border-radius: 12px;
  }

  .search__item-title {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    font-size: 15px;
  }

  .search__item-desc {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    font-size: 13px;
    line-height: 1.45;
    white-space: nowrap;
  }

  .search__item-arrow {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
    justify-self: end;
  }

  .search__item-divider {
    display: none;
  }

  .search__empty {
    padding: 8px 6px 10px;
    font-size: 13px;
  }
}
