/* Final interaction refinements: recent items, fixed detail navigation/search, inline freshness. */

.recent-items {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 8px 0;
  min-width: 0;
}

.recent-items-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.recent-items-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.recent-item-chip {
  max-width: min(220px, 36vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(78, 184, 255, .18);
  border-radius: 999px;
  padding: 6px 10px;
  color: #b8dcf5;
  background: rgba(78, 184, 255, .045);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.recent-item-chip:hover,
.recent-item-chip:focus-visible {
  color: #e7f7ff;
  border-color: rgba(78, 184, 255, .46);
  background: rgba(78, 184, 255, .1);
}

.item-page-shell {
  padding-top: 104px;
}

.detail-command-bar {
  position: fixed;
  z-index: 60;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  width: min(900px, calc(100% - 32px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(88, 181, 255, .18);
  border-radius: 17px;
  background: rgba(5, 18, 31, .88);
  box-shadow: 0 18px 55px rgba(0, 6, 15, .4), inset 0 1px 0 rgba(130, 205, 255, .04);
  backdrop-filter: blur(14px);
}

.detail-back-button {
  min-height: 52px;
  border: 1px solid rgba(78, 184, 255, .26);
  border-radius: 12px;
  padding: 0 16px;
  color: #dff4ff;
  background: linear-gradient(145deg, rgba(36, 126, 190, .42), rgba(14, 70, 112, .55));
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.detail-back-button:hover,
.detail-back-button:focus-visible {
  border-color: rgba(108, 205, 255, .56);
  background: linear-gradient(145deg, rgba(45, 146, 216, .5), rgba(17, 83, 132, .62));
}

.detail-search-panel {
  position: relative;
  min-width: 0;
}

.detail-search-form {
  padding: 4px;
  border-radius: 13px;
  box-shadow: none;
}

.detail-search-row input {
  min-height: 52px;
}

.detail-search-row button {
  min-height: 52px;
}

.detail-search-message {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  margin: 0;
  min-height: 0;
  pointer-events: none;
}

.detail-search-message:empty {
  display: none;
}

.detail-search-close,
.mobile-search-toggle {
  display: none;
}

.price-label-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.price-label-row .freshness-pill {
  margin-top: 0;
  padding: .2rem .5rem;
  font-size: .72rem;
}

.price-label-row .freshness-dot {
  width: .45rem;
  height: .45rem;
}

.item-page #searchOverlayRoot .catalog-discovery {
  z-index: 75;
}

.history-chart-wrap canvas {
  cursor: crosshair;
}

@media (max-width: 720px) {
  .recent-items {
    align-items: flex-start;
    margin-left: 4px;
    margin-right: 4px;
  }

  .recent-item-chip {
    max-width: min(190px, 62vw);
    padding: 6px 9px;
  }

  .item-page-shell {
    padding-top: 76px;
  }

  .detail-command-bar {
    top: max(10px, env(safe-area-inset-top));
    left: 10px;
    width: auto;
    transform: none;
    display: block;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    pointer-events: none;
  }

  .detail-back-button {
    min-height: 46px;
    padding: 0 13px;
    border-radius: 13px;
    pointer-events: auto;
    box-shadow: 0 10px 28px rgba(0, 8, 18, .36);
  }

  .detail-search-panel {
    display: none;
  }

  .detail-search-open .detail-search-panel {
    position: fixed;
    z-index: 72;
    top: max(10px, env(safe-area-inset-top));
    left: 92px;
    right: 10px;
    display: block;
    pointer-events: auto;
  }

  .detail-search-open .detail-search-form {
    padding: 4px;
    border-color: rgba(78, 184, 255, .38);
    box-shadow: 0 12px 38px rgba(0, 7, 18, .48), 0 0 24px rgba(78, 184, 255, .07);
  }

  .detail-search-row {
    grid-template-columns: 1fr;
  }

  .detail-search-row button {
    display: none;
  }

  .detail-search-row input {
    min-height: 46px;
    padding-right: 42px;
    border-radius: 10px;
  }

  .detail-search-close {
    position: absolute;
    z-index: 2;
    top: 9px;
    right: 9px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    color: #a9c9df;
    background: rgba(7, 30, 48, .92);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }

  .mobile-search-toggle {
    position: fixed;
    z-index: 58;
    top: 44%;
    right: 0;
    display: block;
    writing-mode: vertical-rl;
    border: 1px solid rgba(78, 184, 255, .32);
    border-right: 0;
    border-radius: 14px 0 0 14px;
    padding: 13px 9px;
    color: #cdeeff;
    background: rgba(8, 38, 61, .93);
    box-shadow: 0 12px 32px rgba(0, 7, 17, .4), 0 0 22px rgba(78, 184, 255, .08);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    cursor: pointer;
  }

  .detail-search-open .mobile-search-toggle {
    display: none;
  }

  .price-label-row {
    gap: 6px;
  }

  .price-label-row .freshness-pill {
    font-size: .68rem;
  }

  .history-chart-wrap canvas {
    cursor: default;
  }
}

@media (max-width: 420px) {
  .recent-items {
    display: grid;
    gap: 7px;
  }

  .recent-items-list {
    gap: 6px;
  }

  .recent-item-chip {
    max-width: 82vw;
  }
}
